How to deploy a hello world container in Kubernetes

Install kubectl

Follow the howto here.

Setup the kubernetes client (kubectl) to point to the cluster

# create kubectl config directory if it doesn't exists

mkdir -p ~/.kube

# change permissions

chmod 600 ~/.kube

# dump kubectl config from microk8s

# this command must be executed on a node that is part of the cluster
# if you are setting up the kubectl client on a remote machine
# you must copy the generated ~/.kube/config to ~/.kube/config on your machine

sudo microk8s config > ~/.kube/config

# fix  permissions

chmod 600 ~/.kube/config


# Check that kubectl is ok

kubectl cluster-info

Make a Hello World deployment

# create a deployment with a single pod with a single running container

kubectl create deployment hello-node --image=registry.k8s.io/echoserver:1.4

# expose it as a service

kubectl expose deployment hello-node --type=NodePort --port=8080

# check what is the external port that 8080 got exposed to

kubectl get services -o wide | grep hello-node

# access the service via some node from the cluster

curl -v http://piglet.seqpipe.org:<exposed-port>/