Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Basic Architecture

minikube - the cluster manager

kubectl - CLI to interact with the cluster manager

Info
titleKubernetes Cheat Sheet

https://kubernetes.io/docs/reference/kubectl/cheatsheet/


Developing a microservice

Info
titleNote

This tutorial shows you how to run a simple Hello World Node.js app on Kubernetes using Minikube and Katacoda. Katacoda provides a free, in-browser Kubernetes environment.

You ca find it at https://kubernetes.io/docs/tutorials/hello-minikube/

When you start minikube using the command minikube start, it will create a cluster of 1.

Kubernetes Deployment

A Kubernetes Pod is a group of one or more Containers, tied together for the purposes of administration and networking. The Pod in the online tutorial has only one Container.  A Kubernetes Deployment checks on the health of your Pod and restarts the Pod’s Container if it terminates. Deployments are the recommended way to manage the creation and scaling of Pods.

Use the kubectl create command to create a Deployment that manages a Pod. The Pod runs a Container based on the provided Docker image.


Code Block
languagebash
titleshell command
kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node

Use the dashboard to view the changes that have taken place.

  • gcr.io is the google container registry, it is similar to hub.docker.com.
  • hello-minikube-zero-install/hello-node is the name of the image within the register
  • hello-minikube-zero-install/hello-node is the owner of the image within the register
  • hello-world after the sub-command deployment is the name of the deployment that will be created

NOTE - if you want to work with the Docker registry see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ 

Creating a Service

By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster. To make the hello-node Container accessible from outside the Kubernetes virtual network, you have to expose the Pod as a Kubernetes Service.

Code Block
languagebash
titleshell command
kubectl expose deployment hello-node --type=LoadBalancer --port=8080

Run the command minikube service list to get a list of available services.  When you do this the hello-world service should have a valid URL you can enter into your browser.

Info
titleNote

When you use --expose switch, a Service is created at the same time as you create a Deployment


Deploying an application into Kubernetes Cluster

Info
titleWhere to go

https://kubernetes.io/docs/tutorials/kubernetes-basics/

...

  1. $Env:POD_NAME=$(kubectl get pods -o go-template --template '{{range .item}}{{.metadata.name}}{{end}}')
  2. echo $Env:POD_NAME
  3. curl http://localhost:8001/api/v1/namespaces/default/pods/$Env:POD_NAME/proxy/

Developing a microservice

Info
titleNote

This tutorial shows you how to run a simple Hello World Node.js app on Kubernetes using Minikube and Katacoda. Katacoda provides a free, in-browser Kubernetes environment.

You ca find it at https://kubernetes.io/docs/tutorials/hello-minikube/

When you start minikube using the command minikube start, it will create a cluster of 1.

Kubernetes Deployment

A Kubernetes Pod is a group of one or more Containers, tied together for the purposes of administration and networking. The Pod in the online tutorial has only one Container.  A Kubernetes Deployment checks on the health of your Pod and restarts the Pod’s Container if it terminates. Deployments are the recommended way to manage the creation and scaling of Pods.

Use the kubectl create command to create a Deployment that manages a Pod. The Pod runs a Container based on the provided Docker image.

...

languagebash
titleshell command

...

  1. /

...

Use the dashboard to view the changes that have taken place.

  • gcr.io is the google container registry, it is similar to hub.docker.com.
  • hello-minikube-zero-install/hello-node is the name of the image within the register
  • hello-minikube-zero-install/hello-node is the owner of the image within the register
  • hello-world after the sub-command deployment is the name of the deployment that will be created

NOTE - if you want to work with the Docker registry see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ 

Creating a Service

By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster. To make the hello-node Container accessible from outside the Kubernetes virtual network, you have to expose the Pod as a Kubernetes Service.

Code Block
languagebash
titleshell command
kubectl expose deployment hello-node --type=LoadBalancer --port=8080

...