#阿里云 deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
[kubelet-start] Starting the kubelet [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...
This node has joined the cluster: * Certificate signing request was sent to apiserver and a response was received. * The Kubelet was informed of the new secure connection details.
Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
1 2 3 4 5
root@h9:~# kubectl get nodes NAME STATUS ROLES AGE VERSION h7 NotReady <none> 2m23s v1.22.15 h9 NotReady control-plane,master 8m36s v1.22.15
wget https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml root@h9:~# kubectl apply -f kube-flannel.yml namespace/kube-flannel created clusterrole.rbac.authorization.k8s.io/flannel created clusterrolebinding.rbac.authorization.k8s.io/flannel created serviceaccount/flannel created configmap/kube-flannel-cfg created daemonset.apps/kube-flannel-ds created
稍等一下,就都变成ready状态了
1 2 3 4
root@h9:~# kubectl get nodes NAME STATUS ROLES AGE VERSION h7 Ready <none> 17m v1.22.15 h9 Ready control-plane,master 23m v1.22.15
2.6 环境测试
1 2 3 4 5 6 7 8 9 10 11
root@h9:~# kubectl create deployment nginx --image=nginx:1.14-alpine deployment.apps/nginx created root@h9:~# kubectl expose deployment nginx --port=80 --type=NodePort service/nginx exposed root@h9:~# kubectl get pods,svc NAME READY STATUS RESTARTS AGE pod/nginx-65c4bffcb6-d7dgf 1/1 Running 0 100s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 27m service/nginx NodePort 10.104.66.35 <none> 80:31934/TCP 49s