kubeadm install the Cluster Series -3. Adding nodes work

Add Work node

worker to join the cluster by kubeadm join, add the required default cluster token expires 24 hours

 

View Token

1  kubeadm token List
 2  # If you fail to create a new
 3  kubeadm the Create token
 4  # ca obtain a certificate sha256 hash value encoded
 5 OpenSSL X509 -pubkey - in /etc/kubernetes/pki/ca.crt | OpenSSL rsa -pubin der -outform 2 > / dev / null | OpenSSL dgst -sha256 -hex | Sed  ' S /^.* // ' 
. 6 ## ffd76aed49c8f52dea15d16132897376176aea4c3ee50370e9369ca6c6c5a6b0

 

Join the cluster

1 kubeadm join 10.8.28.200:6443 --token k60p22.go0fadibgqm2xcx8 \
2     --discovery-token-ca-cert-hash sha256:ffd76aed49c8f52dea15d16132897376176aea4c3ee50370e9369ca6c6c5a6b0 \
3     --node-name k8s-test-node-1

The following is the output

[preflight] Running pre-flight checks
    [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.15" ConfigMap in the kube-system namespace
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Activating the kubelet service
[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.

 

Check the node node

1 [root@k8s-test-master-1 .kube]# kubectl get nodes
2 NAME                STATUS   ROLES    AGE     VERSION
3 k8s-test-master-1   Ready    master   146m    v1.15.1
4 k8s-test-master-2   Ready    master   121m    v1.15.1
5 k8s-test-master-3   Ready    master   116m    v1.15.1
6 k8s-test-node-1     Ready    <none>   3m47s   v1.15.1

 

test

Test pod

 1 # !!!待添加一个工作节点后运行
 2 kubectl run nginx --image=nginx:1.14 --replicas=2
 3 ## kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
 4 ## deployment.apps/nginx created
 5 kubectl get pods -o wide
 6 ## NAME                     READY   STATUS    RESTARTS   AGE   IP             NODE              NOMINATED NODE   READINESS GATES
 7 ## nginx-7b4d6c6559-4j78l   1/1     Running   0          22s   192.168.49.2   k8s-test-node-1   <none>           <none>
 8 ## nginx-7b4d6c6559-nvlgg   1/1     Running   0          22s   192.168.49.1   k8s-test-node-1   <none>           <none>
 9 curl 192.168.49.2
10 ...
11 <title>Welcome to nginx!</title>
12 ...

Dns test

[root@k8s-test-master-1 ~]# kubectl run curl --image=radial/busyboxplus:curl -it
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
If you don't see a command prompt, try pressing enter.
[ root@curl-6bf6db5c4f-d5lv9:/ ]$ nslookup kubernetes.default
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

Name:      kubernetes.default
Address 1: 10.96.0.1 kubernetes.default.svc.cluster.local

 

Guess you like

Origin www.cnblogs.com/dolphintwo/p/11310874.html