after the playbook run successfully, you will kubeconfig file in ansible/playbooks/.kube/config
scale the nodes
we treat the hosts.yaml as the source of truth to our resources, so to scale up or down the nodes, it will be enough to modify the follow the hosts.yaml file
ok: [master-node-1] => {
"msg": [
"Nodes to remove: '[]'.",
"Nodes to add '['worker-node-3']'."
]
}
TASK [master : pause] ****************************************************************************************************************************************************************************************************************************************
[master : pause]
Do you want to apply the above changes? (Y/n):
after you accept changes the kubernetes cluster will scale up/down depends on your desired state, also it will update the loadbalancer haproxyconfig file to the desired workloads
to install kubernetes
run the following things need to be added before
inventory/groups_vars
certificate_key: random_token:
export ANSIBLE_ROLES_PATH=$PWD/rolesexport ANSIBLE_HOST_KEY_CHECKING=Falsecreate a folder keys that contains ssh_keys and replace public_key for each host with your public_key
first add taints and labels to your nodes, for each node you need to have the following format:
Now to setup the cluster run:
ansible-playbook -i inventory/hosts.yaml playbooks/setup-cluster.yamlafter the playbook run successfully, you will kubeconfig file in
ansible/playbooks/.kube/configscale the nodes
we treat the hosts.yaml as the source of truth to our resources, so to scale up or down the nodes, it will be enough to modify the follow the hosts.yaml file
example, the current hosts.yaml is:
If we need to scale it up, we can just add another worker node
or to scale down we remove the desired worker node
Note: you can both scale up and down at the same time, but if you do it, we will run the scale up first then scale down
Note: the number of control-plane nodes need to be odd number
Now to run the syncing process, use the following command:
ansible-playbook -i inventory/hosts.yaml playbooks/sync-resources.yamlyou will prompted with following message:
after you accept changes the kubernetes cluster will scale up/down depends on your desired state, also it will update the loadbalancer haproxyconfig file to the desired workloads
to verify, run
kubectl get nodesupgrade cluster
rotate certs
ansible-playbook -i inventory/hosts.yaml playbooks/upgrade-cluster.yaml –tags rotate-certs
upgrade versions
this will update the whole cluster versions
ansible-playbook -i inventory/hosts.yaml playbooks/upgrade-cluster.yaml –tags upgrade
OS security patch
to patch os with the security patches run :
ansible-playbook -i inventory/hosts.yaml playbooks/os-patch.yamlupdates