Kubernetes Introduction
Theory
Why do we need Kubernetes
Kubernetes is a container orchestrator, but what is container orchestration?
- Provisioning and deployment
- Configuration and scheduling
- Resource allocation
- Container availability
- Scaling or removing containers based on balancing workloads across your infrastructure
- Load balancing and traffic routing
- Monitoring container health
- Configuring applications based on the container in which they will run
- Keeping interactions between containers secure
for in-depth analysis of kubernetes orchestartion please check this medium blog post
Resources
- Kubernetes Documentation
- CKAD - Certified Kubernetes Application Developer curriculum: what developers should know about Kubernetes
- Really good introduction to Kubernetes with interactive exercises
Practice
We will create cluster based on our IAC session using this repo
Cluster will be already deployed for the exercises. We are doing to focus on what developer's point of view and will skip Operations and Infrastructure concerns You will have access to the cluster running in azure-k8stest resource group. Cluster name is k8stest in azure-k8stest resource group
Accessing cluster
In order to access the running cluster and be able to follow along you need to install kubectl
(CLI to interact with Kubernetes clusters).
- follow this guide to install
kubectl
- once
kubectl
is installed run this commandaz aks get-credentials -g azure-k8stest -n k8stest
, it will append auth info to your Kubernetes config file so you can interact with the cluster - run
kubectl get nodes
to verify that you have access to the cluster (you should see 3 nodes)
AKS Specific
Development Loop
https://itnext.io/best-practices-for-developing-on-kubernetes-8fbdbba12538
Monitoring
Exercise 1 - Deployments
Exercise 2 - Persistent Storage
Exercise 3 - Configuration
Exercise 5 - Services
Exercise 6 - Putting it all together
Clone the repository and deploy sample app to AKS cluster
Bonus Exercise
I don't want to hand craft all those yaml files, I've already learned docker and docker compose!! Why do I have to learn new syntax again?!
Well, good news, you don't have to. If you have an existing docker-compose.yaml file, you can use kompose
CLI to convert them to native Kubernetes resources.
Try it out yourself:
- clone sample repository: https://github.com/ilearnazuretoday/docker-compose.git
- install kompose
- run
kompose convert
- create resources on the cluster
kubectl create -f .
Bonus Material
Here is list of free services and programs to play around with Kubernetes and Docker
-
Local installation with Kind Kubernetes IN Docker
-
Local installation with Vagrant and VirtualBox
-
Local installation with Docker Desktop on Windows, Mac or Linux
-
Local installation with k3s on an old laptop/pc
-
Remote cluster with Katakoda
-
Remote cluster or local installation with LXC Containers
-
Remote cluster PWK — Play With Kubernetes
-
Remote docker Interactive online docker environments on demand: docker