I’m going to deploy a Kubernetes cluster using the Pivotal Container Service (PKS) and explore the environment.
Deploying the Kubernetes cluster
We will start by deploying the Kubernetes cluster with a single master and worker node:
pks create-cluster cluster1 –external-hostname cluster1 –plan small –num-nodes 1
Name: cluster1
Plan Name: small
UUID: 03c9960c-ece3-4cbd-b663-0770be693280
Last Action: CREATE
Last Action State: in progress
Last Action Description: Creating cluster
Kubernetes Master Host: cluster1
Kubernetes Master Port: 8443
Worker Instances: 1
Kubernetes Master IP(s): In Progress
If you look in vCenter, you’ll see the two VMs being created:
Then run bosh task immediately after to watch the progress of the deployment:
Using environment ‘192.168.30.51’ as client ‘ops_manager’
Task 365
Task 365 | 18:37:51 | Preparing deployment: Preparing deployment (00:00:03)
Task 365 | 18:37:57 | Preparing package compilation: Finding packages to compile (00:00:00)
Task 365 | 18:37:57 | Creating missing vms: master/92f6277d-1601-422f-853d-d7af9c6b2dfe (0)
Task 365 | 18:37:57 | Creating missing vms: worker/22a4dd31-6601-4323-aeeb-bfda81473769 (0) (00:01:11)
Task 365 | 18:39:19 | Creating missing vms: master/92f6277d-1601-422f-853d-d7af9c6b2dfe (0) (00:01:22)
Task 365 | 18:39:19 | Updating instance master: master/92f6277d-1601-422f-853d-d7af9c6b2dfe (0) (canary) (00:02:17)
Task 365 | 18:41:37 | Updating instance worker: worker/22a4dd31-6601-4323-aeeb-bfda81473769 (0) (canary) (00:04:19)Task 365 Started Tue Apr 17 18:37:51 UTC 2018
Task 365 Finished Tue Apr 17 18:45:56 UTC 2018
Task 365 Duration 00:08:05
Task 365 doneSucceeded
Once this task is complete we can run bosh task again to see the status of the Kubernetes addons task. At this stage we will see a new VM be deployed that will install the addons to the Kubernetes cluster.
Once the addons tasks is completed, you’ll see the addons VMs disappear.
Using environment ‘192.168.30.51’ as client ‘ops_manager’
Task 367
Task 367 | 18:46:43 | Preparing deployment: Preparing deployment
Task 367 | 18:46:45 | Preparing package compilation: Finding packages to compile (00:00:00)
Task 367 | 18:46:45 | Preparing deployment: Preparing deployment (00:00:02)
Task 367 | 18:46:45 | Creating missing vms: apply-addons/d9b81cb6-a7bf-4f28-b133-6a0b8bd97d89 (0) (00:01:10)
Task 367 | 18:47:55 | Updating instance apply-addons: apply-addons/d9b81cb6-a7bf-4f28-b133-6a0b8bd97d89 (0) (canary) (00:01:47)
Task 367 | 18:49:42 | Running errand: apply-addons/d9b81cb6-a7bf-4f28-b133-6a0b8bd97d89 (0) (00:00:01)
Task 367 | 18:49:43 | Fetching logs for apply-addons/d9b81cb6-a7bf-4f28-b133-6a0b8bd97d89 (0): Finding and packing log files (00:00:02)Task 367 Started Tue Apr 17 18:46:43 UTC 2018
Task 367 Finished Tue Apr 17 18:49:45 UTC 2018
Task 367 Duration 00:03:02
Task 367 doneSucceeded
Exploring the environment
vCenter
So we have to VMs in vCenter that make up our Kubernetes cluster. How can we identity which VM is running what role (master/worker)? We can look at the Custom Attributes of each and see their roles (job):
Master
Worker
BOSH
We can also view our VMs using the bosh command:
bosh vms
I’ve highlighted the two VMs that make up the Kubernetes cluster, but you can also see the Harbor and PKS VMs.
Now lets ssh into the worker node and take a look at the containers it’s running. To do this we will need three things:
- The BOSH environment
- The Kubernetes service UUID
- The Kubernetes worker ID
You can see how to get each of these in the screenshot below:
- Environment
- Kubernetes cluster deployment
- Worker ID
With all the necessary info, we can now ssh into the worker node with the following command:
bosh -e 192.168.30.51 -d service-instance_03c9960c-ece3-4cbd-b663-0770be693280 ssh worker/22a4dd31-6601-4323-aeeb-bfda81473769
Now you can run commands such as docker ps to look at all the running containers on the node. For space reasons I’ll just display the container ID and name:
docker ps –format ‘{{.ID}}\t{{.Names}}’