# 这里配置监听 VIP 192.168.137.100 的 16443 端口,并将请求转发到后端三台master的6443端口 cat > /etc/haproxy/haproxy.cfg << EOF global # to have these messages end up in /var/log/haproxy.log you will # need to: # # 1) configure syslog to accept network log events. This is done # by adding the '-r' option to the SYSLOGD_OPTIONS in # /etc/sysconfig/syslog # # 2) configure local2 events to go to the /var/log/haproxy.log # file. A line like the following can be added to # /etc/sysconfig/syslog # # local2.* /var/log/haproxy.log # log 127.0.0.1 local2
chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon
# turn on stats unix socket stats socket /var/lib/haproxy/stats
defaults mode tcp log global option redispatch retries 3
listen https-apiserver bind 192.168.137.100:16443 mode tcp balance roundrobin timeout server 15s timeout connect 15s server node-1 192.168.137.101:6443 check port 6443 inter 5000 fall 5 server node-2 192.168.137.102:6443 check port 6443 inter 5000 fall 5 server node-3 192.168.137.103:6443 check port 6443 inter 5000 fall 5
server node-1 192.168.137.101:8080 check port 6443 inter 5000 fall 5 server node-2 192.168.137.102:8080 check port 6443 inter 5000 fall 5 server node-3 192.168.137.103:8080 check port 6443 inter 5000 fall 5
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
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/
You can now join any number of the control-plane node running the following command on each as root:
kubeadm join cluster.kube.local:16443 --token 1qjsgg.6s83tvxoo3wma1ps \
--discovery-token-ca-cert-hash sha256:b454bece5e0292c52794a35aa41b60184d1aad64a3519786e80966fee498d0f5 \
--control-plane --certificate-key 73b5c18b703b93fde588fece41f1eef7f6ddd693a6ca01067f762f35992afd13
Please note that the certificate-key gives access to cluster sensitive data, keep it secret!
As a safeguard, uploaded-certs will be deleted in two hours; If necessary, you can use
"kubeadm init phase upload-certs --upload-certs" to reload certs afterward.
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join cluster.kube.local:16443 --token 1qjsgg.6s83tvxoo3wma1ps \
--discovery-token-ca-cert-hash sha256:b454bece5e0292c52794a35aa41b60184d1aad64a3519786e80966fee498d0f5