Install the Kubernetes cluster

Note

This step is not required if you already have a Kubernetes cluster up and running. In such a case, skip to the next step: <install_deployment>.

Once all the required configuration variables are set in the playbook, it’s time to let Ansible install the software into the target machines according with our configuration. This is achieved by using the ansible-playbook command, which runs the Ansible playbooks, executing the defined tasks on the targeted hosts according to a set of tags.

The first step is to install a Kubernetes cluster in the target machines. It involves the use of tags in the ansible-playbook. A tag is an attribute that you can set to an Ansible structure (plays, roles, tasks), and then when you run a playbook you can use –tags or –skip-tags to execute a subset of tasks. In other words, tags are a way of telling Ansible which tasks it should perform and which not.

The first step is to install the Kubernetes software and launch the cluster:

$ ansible-playbook -i inventory/<inventory name> --vault-id <inventory name>@prompt main.yml --tags "deploy-cluster"

At this point, you should be able to connect to the machines where the cluster is deployed and test that the cluster has been correctly installed. In order to do so, you can enter the following command in the remote master node. If the cluster has been correctly installed, you should see the following result (please note that the node name might be different according to the name of the virtual machines where the deployment has been made)

$ kubectl get node
NAME                 STATUS   ROLES                  AGE     VERSION
quobis-master        Ready    control-plane,master   1d      v1.21.14
quobis-node-1        Ready    <none>                 1d      v1.21.14
quobis-node-2        Ready    <none>                 1d      v1.21.14
quobis-node-3        Ready    <none>                 1d      v1.21.14

Once the cluster is up and running, you need to upload the kubernetes folder to the remote master node:

$ ansible-playbook -i inventory/<inventory name> main.yml --tags "upload-files"

Now it’s time to install the Docker registry credentials in order to be able to download the software images:

$ ansible-playbook -i inventory/<inventory name> main.yml --tags "create-registry-secret"

In order to check that the token has been correctly installed, you can issue the following command and check that the result looks like this:

$ kubectl get secrets
NAME                                 TYPE                                  DATA   AGE
registry-credential                  kubernetes.io/dockerconfigjson        1      1d

For on-prem deployments, you need to choose between NFS or Lonhorn:

$ ansible-playbook -i inventory/<inventory name> main.yml --tags "nfs-deploy"
$ ansible-playbook -i inventory/<inventory name> main.yml --tags "nfs-client-provisioner-deploy"
$ ansible-playbook -i inventory/<inventory name> main.yml --tags "longhorn-deploy"

For AWS deployments, install the EFS services instead:

$ ansible-playbook -i inventory/<inventory name> main.yml --tags "efs-deploy"

In order to check that the EFS deployment has been correctly installed, you can issue a “kubectl get pods” command and check that you see the following pod:

$ kubectl get pods
NAME                                          READY   STATUS    RESTARTS   AGE
(... other pods ...)∫
nfs-client-provisioner-7c7bd78d56-q998g       1/1     Running   0          116d

For on-prem deployments without a Load Balancer, you may want to install MetalLB:

$ ansible-playbook -i inventory/<inventory name> main.yml --tags "metallb-deploy"

Now that the K8S cluster is ready, you can move to the next step to deploy the Quobis wac software into the cluster.