Requirements
- Colima
- Docker
- Kubernetes
- Minikube
Understanding Kubernetes or K8s
What we more often call containterize + orchestration
container + orchestration
The name Kubernetes comes from Greek, meaning helmsman or pilot, and is the origin of the words governor and cybernetic. K8s is an abbreviation obtained by replacing the 8 letters “ubernete” with “8”.
Why do we need containers
?
- Capability/dependency
- Long setup time
- Different Dev/Test/Prod environments
What do we need to do?
- Apps need to be containerized
- Run each service with independent or separate dependencies for each container
Differences between Containers vs Virtual Machines
Advantages of Containers
Old Principle of deployments
Deployments containerize
Principles of Container Orchstration
Some Orchestration Technologies:
- Docker Swarm
- Kubernetes
- MESOS
Example of Orchestration Container
Install Kubernetes on Local
When installing Kubernetes we need several things to be installed. Make sure the requirements above are met, such as installing docker with colima (MacOS M1)
Install Set Up Kubectl
Next, install kubectl for our tools needs here
https://kubernetes.io/docs/tasks/tools/
Once finished, try confirming it again with the command below
➜ kubectl version --client
Client Version: v1.29.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Install minikube
To install Minikube, you can also see here
https://minikube.sigs.k8s.io/docs/start/
If you have followed the instructions in the link above to install Miniku, then we will try running Minikube by making sure that Docker is running.
minikube start --driver=docker
To ensure that minikube
is running, we can run the command below
➜ minikube status
minicube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
Error when running minikube
Still having an error? Try doing it
sudo chown -R $USER $HOME/.minikube; chmod -R u+wrx $HOME/.minikube
then run this
minikube start --force-systemd=true
Running Services on Kubernetes via Minikube
We will try to create a Kubernetes Deployment using an existing image with a simple HTTP Server exposed 8080.
➜ kubectl create deployment hello-node --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- /agnhost netexec --http-port=8080
deployment.apps/hello-node created
And let’s try to see the deployment with commands
➜ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
hello-node 1/1 1 1 35m
then to see the activity log from the server that we have running
➜ kubectl logs hello-node-ccf4b9788-bv9wd
I0303 11:31:13.581880 1 log.go:195] Started HTTP server on port 8080
I0303 11:31:13.583262 1 log.go:195] Started UDP server on port 8081
We create a service from the pod that was created earlier with the command below
➜ kubectl expose deployment hello-node --type=LoadBalancer --port=8080
service/hello-node exposed
then you will see the 8080
port running under ports
➜ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-node LoadBalancer 10.98.200.124 <pending> 8080:30890/TCP 110s
To get the deployment URL that we ran earlier, you can use the command
➜ minikube service hello-node --url
http://127.0.0.1:60493/