CentOS 7.6安装Kubernetes v1.15.1(6)

# kubectl get node
NAME    STATUS  ROLES    AGE  VERSION
node1  Ready    master  57m  v1.15.0
node2  Ready    <none>  11s  v1.15.0

如何从集群中移除Node
如果需要从集群中移除node2这个Node执行下面的命令:
在master节点上执行:
# kubectl drain node2 –delete-local-data –force –ignore-daemonsets
# kubectl delete node node2

在node2上执行:
# kubeadm reset
# ifconfig cni0 down
# ip link delete cni0
# ifconfig flannel.1 down
# ip link delete flannel.1
# rm -rf /var/lib/cni/

报错:
error execution phase preflight: couldn’t validate the identity of the API Server: abort connecting to API servers after timeout of 5m0s
# kubeadm join ……
error execution phase preflight: couldn’t validate the identity of the API Server: abort connecting to API servers after timeout of 5m0

原因:master节点的token过期了

解决:重新生成新token
在master重新生成token
# kubeadm token create
424mp7.nkxx07p940mkl2nd
# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed ‘s/^.* //’
d88fb55cb1bd659023b11e61052b39bbfe99842b0636574a16c76df186fd5e0d

Node节点重新join就可以了
kubeadm join 192.168.169.21:6443 –token 424mp7.nkxx07p940mkl2nd \
--discovery-token-ca-cert-hash sha256:d88fb55cb1bd659023b11e61052b39bbfe99842b0636574a16c76df186fd5e0d
四、kube-proxy开启ipvs

修改ConfigMap的kube-system/kube-proxy中的config.conf,mode: “ipvs”

# kubectl edit cm kube-proxy -n kube-system
 minSyncPeriod: 0s
      scheduler: ""
      syncPeriod: 30s
    kind: KubeProxyConfiguration
    metricsBindAddress: 127.0.0.1:10249
    mode: "ipvs"                          # 加上这个
    nodePortAddresses: null

其中mode原来是空,默认为iptables模式,改为ipvs
scheduler默认是空,默认负载均衡算法为轮训
编辑完,保存退出

删除所有kube-proxy的pod
# kubectl delete pod xxx -n kube-system
之后重启各个节点上的kube-proxy pod:

# kubectl get pod -n kube-system | grep kube-proxy | awk '{system("kubectl delete pod "$1" -n kube-system")}'

# kubectl get pod -n kube-system | grep kube-proxy
kube-proxy-7fsrg                1/1    Running  0          3s
kube-proxy-k8vhm                1/1    Running  0          9s

# kubectl logs kube-proxy-7fsrg  -n kube-system
I0703 04:42:33.308289      1 server_others.go:170] Using ipvs Proxier.
W0703 04:42:33.309074      1 proxier.go:401] IPVS scheduler not specified, use rr by default
I0703 04:42:33.309831      1 server.go:534] Version: v1.15.0
I0703 04:42:33.320088      1 conntrack.go:52] Setting nf_conntrack_max to 131072
I0703 04:42:33.320365      1 config.go:96] Starting endpoints config controller
I0703 04:42:33.320393      1 controller_utils.go:1029] Waiting for caches to sync for endpoints config controller
I0703 04:42:33.320455      1 config.go:187] Starting service config controller
I0703 04:42:33.320470      1 controller_utils.go:1029] Waiting for caches to sync for service config controller
I0703 04:42:33.420899      1 controller_utils.go:1036] Caches are synced for endpoints config controller
I0703 04:42:33.420969      1 controller_utils.go:1036] Caches are synced for service config controller

日志中打印出了Using ipvs Proxier,说明ipvs模式已经开启。

五、Kubernetes常用组件部署

越来越多的公司和团队开始使用Helm这个Kubernetes的包管理器,这里也将使用Helm安装Kubernetes的常用组件。

5.1、Helm的安装

Helm由客户端命helm令行工具和服务端tiller组成,Helm的安装十分简单。 下载helm命令行工具到master节点node1的/usr/local/bin下,这里下载的2.14.1版本

# curl -O https://get.helm.sh/helm-v2.14.1-linux-amd64.tar.gz
# tar -zxvf helm-v2.14.1-linux-amd64.tar.gz
# cd linux-amd64/
# cp helm /usr/local/bin/

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4fa3b2c91310e50f22a02fd2a08049ce.html