This post demonstrate some Kubernetes basic commends.
Server Overview
We have setup 3 virtual machines,each has 1 cpu and 1GB memory. Details:
Server OS | IP Address | Node Type | CPU | Memory | Hostname |
---|---|---|---|---|---|
ubuntu16.04 | 192.168.56.103 | master | 1 | 1G | server01 |
ubuntu16.04 | 192.168.56.104 | slave1 | 1 | 1G | server02 |
ubuntu16.04 | 192.168.56.105 | slave2 | 1 | 1G | server03 |
To follow this demo, root privilege is required, ask system admin (Todd) for root access.
Startup all nodes
Login to the system then start virtualBox and each virtual machine.
Launch VirtualBox
1 | # get root privilege |
Login to each node
1 | $ Login as: main |
Check system information on each node
1 | # check ip address |
On master node, one should see services and their port numbers: kube-apiserver : 6443/8080, etcd : 2379/2380, kube-scheduler : 10251, kube-controller : 10252, calico-felix : 9099
On worker nodes, one should see services and their port numbers: kubelet : 4194/10248/10250/10255, kube-proxy:10249/10256, calico-felix : 9099
Commonly used commands
Use calico to check the network status on each node
1 | $ calicoctl node status |
At each node, it should be able to see the other two nodes’ ip addresses in the cluster.
Use kubectl on master node to verify the cluster resources (deloyment, nodes, pods, services, etc.)
1 | # check server/client version |
More kubectl commands
1 | $ kubectl run kubernetes-bootcamp --image=jocatalin/kubernetes-bootcamp:v1 --port=8080 |
The “secret” are mounted to each created pod as files located in /var/run/secrets/… so that each pod can connect with api-server with https requests.
Use ‘apply’ or ‘create’ with yaml files
Kubectl ‘apply’ command is similar to ‘create’ command, but has rich properties.
1 | $ cd services |
Recommended references
Following YouTube links also provide some examples worth trying out:
[1] https://www.youtube.com/watch?v=K1HuOLzPSpU
[2] https://www.youtube.com/watch?v=yu3HlOXoEKk
[3] https://www.youtube.com/watch?v=kvQ3VT_wH98