First payload

Now when you have all infrastructure in place, move to the Kubernetes side. To mange your cluster you need kubectl. You can get it automatically by (you might need to add it to PATH):

az acs kubernetes install-cli

Next you need to authenticate `kubectl` with your cluster.

az acs kubernetes get-credentials -n my-very-own-k8s-cluster \

-g my-very-own-k8s-cluster

And check if all is good. This command will give you versions for both client and server side.

kubectl version

By this time you actually have everything you need to run your first payload. So let’s create fist definition and try to run it. Definitions in Kubernetes could use many file formats, I will use YAML, so let’s create hello.yml file with content:

apiVersion: extensions/v1beta1

kind: Deployment

metadata:

name: hello # Name of the deployment, just for reference purposes

spec:

replicas: 1 # Number of instances for the given application

template:

metadata:

labels:

app: hello

spec:

containers:

- name: ner-uk-ms # Name of container, could be anything you like

image: chaliy/ner-ms:uk # Docker image to run

ports:

- containerPort: 8080

For the moment it is important to understand some Kubernetes terminology.

Pod — instance of the container — http://kubernetes.io/docs/user-guide/pods/

Deployment — something that will ensure your pods run, supervisors — http://kubernetes.io/docs/user-guide/deployments/

Service — something that makes your pods to be an a system — http://kubernetes.io/docs/user-guide/services/

So definition that we just created is actually deployment for single pod defined in template. The command bellow, will pull Docker image `chaliy/ner-ms:uk`, start instance of it and setup supervisor:

kubectl create -f ./hello.yml

Now few commands to play with it:

# Retrieve logs associated with deployment

kubectl logs hello # List Pods

kubectl get pods # List deployments

kubectl get deployments # Details about concrete pod, for example in case of errors

kubectl describe pods/podid # Delete something

kubectl describe pods/podid

If you want reconfigure your application, just change it (for example set `replicas:10`) in definition file and run:

kubectl apply -f ./hello.yml

Technically you already run your payload. So let’s see how it is going on. Kubernetes provides UI to observe your cluster. It runs in cluster the same way your applications will run. Of course, you do not want such UI appear outside of your cluster, so by default you will be able to run it only inside a cluster.. But wait.. How then to access to it? It turns out to be quite simple. Kubernetes implements Basteon Pattern and provides a simple way to proxy it to your local computer. So you need to run proxy first:

kubectl proxy --port=8000

And then you will have Kubernetes Dashboard right on your computer. Navigate to http://localhost:8000/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard and walk though it.