Because we generate our own CA and certificates for the cluster,
You MUST put every hostnames and IPs of the Kubernetes cluster (master & workers) in the certs/kubernetes-csr.json (hosts field).
You can also modify the certs/*json files to match your cluster-name / country. (optional)
You can use either public or private names, but they must be registered somewhere (DNS provider, internal DNS server, /etc/hosts file) or use IP records instead of names.
cd /srv/salt/k8s-certs
cfssl gencert -initca ca-csr.json | cfssljson -bare ca
# !!!!!!!!!# Don't forget to edit kubernetes-csr.json before this point !# !!!!!!!!!
cfssl gencert \
-ca=ca.pem \
-ca-key=ca-key.pem \
-config=ca-config.json \
-profile=kubernetes \
kubernetes-csr.json | cfssljson -bare kubernetes
chown salt: /srv/salt/k8s-certs/ -R
After that, edit the pillar/cluster_config.sls to tweak your future Kubernetes cluster :
If you want add a node on your Kubernetes cluster, just add the new Hostname and IPs on kubernetes-csr.json and run theses commands to regenerate your cluster certificates :
cd /srv/salt/k8s-certs
cfssl gencert \
-ca=ca.pem \
-ca-key=ca-key.pem \
-config=ca-config.json \
-profile=kubernetes \
kubernetes-csr.json | cfssljson -bare kubernetes
# Reload k8s components on Master and Workers.
salt -G 'role:k8s-master' state.highstate
salt -G 'role:k8s-worker' state.highstate
The highstate configure automatically new workers (if it match the k8s-worker role in Grains).
Tested on Debian, Ubuntu and Fedora.
You can easily upgrade software version on your cluster by changing values in pillar/cluster_config.sls and apply a highstate.
This configuration use ECDSA certificates (you can switch to rsa in certs/*.json).
You can change IPv4 IPPool, enable IPv6, change IPv6 IPPool, enable IPv6 NAT (for no-public networks), change BGP AS number, Enable IPinIP (to allow routes sharing between subnets).
If you use salt-ssh or salt-cloud you can quickly scale new workers.
请发表评论