/hello-node

Primary LanguageJavaScript

Getting Started with Kubernates on macOS

What is Kubernetes?

Kubernetes serves two purposes: It scales and starts containers across multiple Docker hosts, balancing the containers across them. It also adds a higher level API to define how containers are logically grouped, allowing defining pools of containers, loading balancing, and affinity. Kubernetes is defined by states, not processes.

Source

Main concepts

Pods

A Pod represents a running process on your cluster.

Services

A Service defines a logical set of Pods and a policy by which to access them.

Deployments

A Deployment provides declarative updates for Pods. You only need to describe the desired state in a Deployment object, and the Deployment controller will change the actual state to the desired state for you.

Learn more

Prerequisites

Minikube is the recommended method to create a single node Kubernetes cluster locally for purposes of development and testing.

Installing Minikube (along with Docker and VirtualBox) via Homebrew:

brew update && brew install kubectl && brew cask install docker minikube virtualbox

Verifying:

docker --version                
docker-compose --version        
docker-machine --version        
minikube version                
kubectl version --client

Starting Minikube:

minikube start

Great! Minikube started a virtual machine for you, and a Kubernetes cluster is now running in that VM.

Setting Docker environment variables:

eval $(minikube docker-env)

Learn more

1. Building Docker image

docker build -t hello-node:v1 .

2. Creating or updating configuration

kubectl apply -f service.yaml 

3. Accessing service

curl $(minikube service hello-node --url)

4. Accessing Minikube dashboard

minikube dashboard

Cleanup

Deleting deployment and service:

kubectl delete service,deployment hello-node

Stopping Minikube:

minikube stop

To be continued...