Home > Archives > Kubernetes线下实战培训

Kubernetes线下实战培训

Publish:

前提条件

  1. 准备好3台电脑
  2. 准备好相关素材文件
  3. 关闭系统防火墙

IP地址配置信息

关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service
yum install iptables-services 
service iptables start
service iptables stop

挂载硬盘

echo /dev/vdb1 /mnt ext3 defaults 0 0 >> /etc/fstab
mount /dev/vdb1 /mnt
df -hl

安装步骤

yum install jq

./install-docker.sh docker-18.06.1-ce.tgz

docker run -it hello-world
docker ps

./install-etcd.sh etcd-v3.3.9-linux-amd64.tar.gz 01 172.17.116.249 172.17.116.249 172.17.116.250 172.17.116.251
./install-etcd.sh etcd-v3.3.9-linux-amd64.tar.gz 02 172.17.116.250 172.17.116.249 172.17.116.250 172.17.116.251
./install-etcd.sh etcd-v3.3.9-linux-amd64.tar.gz 03 172.17.116.251 172.17.116.249 172.17.116.250 172.17.116.251

./start-etcd.sh
systemctl start etcd
source /etc/profile
etcdctl cluster-health

docker load -i k8s-images.tar.gz

./install-k8s.sh kubernetes-server-linux-amd64.tar.gz 172.17.116.249 172.17.116.249
./install-k8s.sh kubernetes-server-linux-amd64.tar.gz 172.17.116.250 172.17.116.249
./install-k8s.sh kubernetes-server-linux-amd64.tar.gz 172.17.116.251 172.17.116.249

kubectl get nodes
cat /root/.kube/config 

ifconfig

./install-flannel.sh flannel-v0.7.1-linux-amd64.tar.gz 172.17.116.249 172.17.116.249 eth0
./install-flannel.sh flannel-v0.7.1-linux-amd64.tar.gz 172.17.116.250 172.17.116.249 eth0
./install-flannel.sh flannel-v0.7.1-linux-amd64.tar.gz 172.17.116.251 172.17.116.249 eth0
ifconfig

etcdctl ls
etcdctl ls /atomic.io/network
etcdctl ls /atomic.io/network/subnets
etcdctl get /atomic.io/network/subnets/192.168.3.0-24


yum -y install nfs-utils
./setUpNFS.sh

cat /etc/exports
./setUpNFS.sh /var/vols/test

kubectl get svc
watch kubectl get pods --all-namespaces -o wide

kubectl create ns core
kubectl get ns

kubectl create -f kube-dns.yaml
kubectl get pod -n core
kubectl get svc -n core

kubectl create -f pv-pvc.yaml
kubectl get pv -o json | jq -r '.items[].spec.nfs.server'
kubectl get pvc -n core
kubectl get svc -n core

kubectl create -f kube-registry-proxy.yaml
kubectl get ep -n core

kubectl label node 172.17.116.249 nodetype=master
kubectl create -f registry-with-volume.yaml

kubectl get node
kubectl get node 172.17.116.249 -o json | jq

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -L -n

kubectl exec -it kube-registry-proxy-lnthx -n core sh
ping kube-dns.cluster.local

kubectl describe pod kube-registry-ccc98dc-tljxz -n core

docker images
docker push localhost:5000/centos

---day3

curl -v http://localhost:5000/v2/_catalog
curl http://localhost:5000/v2/_catalog

kubectl log 

http://16.187.191.76:8080/api/v1/namespaces/core/services/https:kubernetes-dashboard:/proxy

http://16.187.191.76:8080/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

从aliyun配置链接串, ./kube/config

kubectl get pods --all-namespaces

hostname -i

kubectl create ns core

kubectl create -f pv-pvc.yaml

kubectl create -f kube-registry.yaml

watch kubectl get pods -n core -o wide

kubectl create -f kube-registry-proxy.yaml

kubectl crate secret docker -registry regsecret 
-- docker-server=registry.cn-shanghai.aliyuncs.com -- docker-username=username

systemctl daemon-reload
systemctl restart kubelet

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: Ding Bao Guo