This project is a small proof of concept for any beginners in Kubernetes (commonly call k8s and pronounced Kates).
You will need to have an instance of kubernetes available. We will be using microk8s from canonical for that. You will need Ubuntu or a linux distro with snapcraft installed
# microk8 installation
$ sudo snap install microk8s --classic
# adds you to the correct group on linux. You will need to log off and log back in.
$ sudo usermod -aG microk8s <your username>
# makes you owner of the kube folder
$ sudo chown -f -R <your username> ~/.kube
# checks if microk8 is up
$ microk8s status --wait-ready
# installs basic services you will need in order to run k8s locally
$ microk8s enable dashboard dns registry istio
Kubectl is usable with the following command
$ kubectl ...
If you want to avoid using microk8s as a prefix you can also add the following line in your ~/.bashrc
or ~/.zshrc
file
alias kubectl="microk8s kubectl"
Run the following command once the modification is done.
# For Bash
$ source ~/.bashrc
# For zsh
$ source ~/.zshrc
$ microk8s start
$ microk8s stop
$ microk8s config > Kubeconfig
$ kubectl create deployment <Deployment-name> --image=DOCKER-IMAGE
$ kubectl delete deployment <Deployment-name>
$ kubectl expose deployment <Deployment-name> --type=LoadBalancer --port=<Port>
$ kubectl get deployments
$ kubectl get pods
$ microk8s dashboard-proxy
$ kubectl get all --all-namespaces
This is like a workspace but you will be putting all the resources and services your app will need.
$ kubectl create namespace nginx-deployment
$ kubectl create -f nginx_resourcequota.yml
$ kubectl create -f nginx_deployment.yml
$ kubectl apply -f nginx_deployment.yml
$ kubectl create -f nginx_service.yml
I strongly recommend using the following VSCode extension: Kubernetes for VSCode