master 节点与 node 节点上的 Pods 通过 Pod 网络通讯。
1、ingress
2、通过 apiserver 这种方式结合 kube-proxy kubectl proxy --address='10.64.3.7' --port=8086 --accept-hosts='^*$' 可以做一些内部 URL 的限制
浏览器访问 URL:http://10.64.3.7:8086/ui 自动跳转到:http://10.64.3.7:8086/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/#/workload?namespace=default。如果不做kubectl proxy 则意味着外界访问 api 没任何限制,加上后可以做一些限制。
[root@master]# kubectl clusterinfo Command "clusterinfo" is deprecated, use "cluster-info" instead Kubernetes master is running at http://localhost:8080 Heapster is running at http://localhost:8080/api/v1/namespaces/kube-system/services/heapster/proxy KubeDNS is running at http://localhost:8080/api/v1/namespaces/kube-system/services/kube-dns/proxy kubernetes-dashboard is running at http://localhost:8080/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy |
yum install epel-release yum install bash-completion |
kubectl completion bash > /etc/bash_completion.d/kubectl |
kubectl get node |
kubectl cordon $node_name |
kubectl drain $node_name --ignore-daemonsets |
kubectl delete node $node_name |
在 master 集群上操作
token 有效期时间 24 小时,过期重新获取
kubeadm token create \W0309 13:43:06.911180 5909 validation.go:28] Cannot validate kube-proxy config - no validator is available W0309 13:43:06.911213 5909 validation.go:28] Cannot validate kubelet config - no validator is available 59rsca.iurwxqloz74ja08z |
[root@Node-01 ~]# kubeadm token list TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS 59rsca.iurwxqloz74ja08z 23h 2020-03-05T16:02:16+08:00 authentication,signing <none> system:bootstrappers:kubeadm:default-node-token |
[root@Node-01 ~]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //' 0045405de500a0462c418774fda659fe4093c3c0fbb834ea65745d4cadc4535d |
在需要添加的节点上操作
kubeadm join 192.168.6.251:6443 --token 59rsca.iurwxqloz74ja08z \ --discovery-token-ca-cert-hash sha256:0045405de500a0462c418774fda659fe4093c3c0fbb834ea65745d4cadc4535d |