« Back to Index

Kubernetes Essentials

View original Gist on GitHub

Kubernetes Essentials.md

Components

Master

The “master” is a cluster-wide set of services (such as the API server, which kubectl interacts with) which allow Kubernetes to manage our cluster of Nodes.

Node

Nodes run pods. Nodes are also managed by the master services.

Each Node needs a Kubelet. The master sends orders to the kubelet which it uses to interact with pod containers.

Each Node also needs a proxy which provides simple load balancing (kube-proxy)

Pods

Pods are groups of containers, co-located on the same host.

Each Pod gets its own dedicated IP (these IPs change as pods are created/killed).

Pods can be assigned labels.

Replication Controllers

RCs handle the lifecycle of the pods, ensuring they match the specification.

If there are too few, it’ll create more. If there are too many, it’ll kill those over the threshold.

Services

Services are collections of pods that are exposed with a single and stable name and network address. The service provides load balancing to the underlying pods, with or without an external load balancer

Services are an abstraction. They define a way of accessing a set of pods.

In a practical sense, a ‘service’ is a REST endpoint, created by POST’ing a definition file to the Kubernetes “API server”:

{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "my-service"
    },
    "spec": {
        "selector": {
            "app": "MyApp"
        },
        "ports": [
            {
                "protocol": "TCP",
                "port": 80,
                "targetPort": 9376
            }
        ]
    }
}

The pods targeted by a service, are done so by utilising labels (in the above example our service is grouping together a set of pods that have been labelled MyApp).

If a set of pods come up and down, it doesn’t matter that their ip addresses have changed because our new ‘service’ (abstraction) hides this detail and gives us a single entry point to access the pods the service manages.

The service is given an ip address (also known as a “cluster IP”) allowing other nodes/pods to query it in order to locate other pods.

Labels

These are key-value pairs.

Replication Controllers use them for “service discovery”.

Volumes

A volume is a directory, mounted into a container for the purpose of storing state.

Kubectl

Command line tool, which allows you to: add/delete Nodes, Pods and Replication Controllers.


Local Set-up

A local set-up requires creating a “standalone cluster”