3. Kubernetes Cluster
In the previous exercise, you put the Go app into a Docker container and pushed it to the Docker Hub repository. So now you need to deploy this application from your Docker Hub repository to your local Kubernetes cluster.
Note
This exercise is slightly different from the original one - it was modified according to more practical use cases and connect student progress from the previous lessons.
Preparation
Install VirtualBox and Vagrant
Install VirtualBox:
sudo apt install virtualbox
Install Vagrant:
sudo apt-get update && sudo apt-get install vagrant
Up Virtual Machine
Change directory to exercises:
cd exercises
Init virtual machine:
vagrant init
Up the virtual machine:
vagrant up
Check the status of virtual machine:
vagrant status
Useful Vagrant Commands
Shut down virtual machine forcefully:
vagrant halt
Suspend the virtual machine:
vagrant suspend
Restart virtual machine:
vagrant up
Find out more in Vagrant Cheat Sheet
Exercise 3.1 - Create Kubernetes Cluster
Create k3s Kubernetes cluster on the local machine using Virtual Box and Vagrant.
Exercise 3.2 - Deploy Application to the Kubernetes Cluster
Run go-helloworld app at the Kunernetes cluster from the Docker Hub.
Deploy go-helloworld to the Kubernetes cluster from the Docker Hub.
Exercise 3.3 - Define and Deploy Kubernetes Resources
Deploy the following resources using the kubectl command:
- a namespace:
name:
demo
label:
tier: test
- a deployment:
image:
nginx:alpine
name:
nginx-apline
namespace:
demo
replicas: 3
labels:
app: nginx
,tag: alpine
- a service:
expose the above deployment on port
8111
namespace:
demo
- a configmap:
name:
nginx-version
containing key-value pair:
version=alpine
namespace:
demo
Note
Nginx is one of the public Docker images, that you can access and use for your exercises or testing purposes.
Make sure the following tasks are completed:
You have created a Namespace
You have created a Deployment
You have created a Service
You have created a Configmap