Skip to content

degemenc/kubernetes-101

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Introduction to Kubernetes

This project is my attempt at creating a tutorial for all those who get lost learning Kubernetes. Unfortunately I'm too lazy to create a Medium article from it, but I will comment on all commits and you can follow the improvements. In fact, this is the way I would suggest. Don't even look at the final code, instead start from commit 1 all the way up to the latest commit and experience how to build a Kubernetes project from ground up. Please consider that while creating this project I was an absolute Kubernetes newbie. So if you know better, feel free to comment on commits and open PRs. However, I will try to keep the commit history as simple as possible for the newcomers.

This project gets you from zero to hero in Kubernetes! Well, sort of... In this project you will:

  • Create a NodeJS app.
  • Dockerize and publish it.
  • Set up a Kubernetes deployment for your app and scale it up/down.
  • Expose your deployment publicly (still in localhost but in Kubernetes terms at least you are going outside of the cluster) - with a load balancer service ;)
  • Create another NodeJS app that uses MySQL database and provide a service for your main app (kind of like a microservice).
    • Create ClusterIP type services for your apps and communicate inside your cluster between pods.

This is only kubernetes-101. I'm thinking of doing the same thing for a possible kuberenetes-102 project built upon this one. It would cover ConfigMaps, Secrets, Ingress, StatefulSets using real-world services for a (truly) publicly exposed NodeJS app!

Pre-Requisites

  • You should have at least some idea about what Docker containers and Kubernetes clusters, nodes, pods are. I highly suggest doing the Official "Learn Kubernetes Basics" Tutorial to get familiar with these terms. It takes max. 20-30 minutes and they made it incredibly easy (REALLY INCREDIBLY EASY) to follow.
  • Install Docker and set up a Kubernetes cluster with minikube.

References / Where I Learned From

The following references are the official sources listed from the high-level (easy to understand) to the low-level (hard to understand):

The following references are the unofficial ones:

Some commands - a little cheat sheet that you can use during/after the tutorial

  • Docker build: docker build -t degemenc/kubegreeter .

  • Docker run: docker run -p 49160:8080 -d degemenc/kubegreeter

  • Curl your deployment: run kubectl proxy on another terminal & run curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/ on main terminal

  • Update image: kubectl set image deployments/kubegreeter-deployment kubegreeter=degemenc/kubegreeter:latest

  • Set up LoadBalancer: run minikube tunnel on another terminal to activate local LoadBalancer. It somewhat imitates an online service's (Amazon, Azure etc.) load balancing algorithms.

  • Open a bash console in pod: kubectl exec -ti $POD_NAME bash

  • Start mysql in bash: mysql -u root -p

  • Scale up/down a deployment: kubectl scale deployments/kubegreeter-deployment --replicas=5

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published