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 several dependencies in the cluster nodes:

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

Once done, the next step is to istall 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
k8s-master                    Ready    master   291d   v1.15.5
virtual_machine_name-node-1   Ready    worker   291d   v1.15.5
virtual_machine_name-node-2   Ready    worker   291d   v1.15.5

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:

  • First set registryServer as registry.quobis.com, uncomment the dockerPassword related to this registry, and run:

$ ansible-playbook -i inventory/<inventory name> main.yml --tags "create-old-registry-secret"
  • Secondly, set registryServer as registry.gitlab.com, uncomment the dockerPassword related to this registry and run:

$ 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
regcred                              kubernetes.io/dockerconfigjson        1      263d
registry-credential                  kubernetes.io/dockerconfigjson        1      32d

For on-prem deployments, you need now to install NFS service:

$ ansible-playbook -i inventory/<inventory name> main.yml --tags "nfs-install"
$ ansible-playbook -i inventory/<inventory name> main.yml --tags "nfs-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

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