Versions Compared

Key

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

...

A quick-start guide can be found here: httphttps://kubernetes.io/docs/setup/gettingpick-startedright-guidessolution/docker/

This will set up a Kubernetes cluster running locally on your VM.

Deploy a Kubernetes Cluster

Starting a Single-Node (Local Development) Cluster

Provided in the source code for NDS Labs is a script called kube-up.sh which will launch a local kubernetes cluster on your machine.

It will also download kubectl for you, as described above, and place it into the ~/bin/ folder.

Code Block
languagebash
#!/bin/sh
docker run \
    --volume=/:/rootfs:ro \
    --volume=/sys:/sys:ro \
    --volume=/var/lib/docker/:/var/lib/docker:rw \
    --volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
    --volume=/var/run:/var/run:rw \
    --volume=`pwd`/manifests/etcd.json:/etc/kubernetes/manifests/etcd.json \
    --net=host \
    --pid=host \
    --privileged=true \
    -d \
    gcr.io/google_containers/hyperkube-amd64:v{K8S_VERSION} \
    /hyperkube kubelet \
        --containerized \
        --hostname-override="127.0.0.1" \
        --address="0.0.0.0" \
        --api-servers=http://localhost:8080 \
        --config=/etc/kubernetes/manifests \
        --allow-privileged=true --v=2
mkdir -p ~/bin
if [ ! -e ~/bin/kubectl ]; then
	curl http://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl -o ~/bin/kubectl
	chmod +x ~/bin/kubectl
fi

 

NOTE: The first time you start your cluster, Kubernetes will tell docker to download several images.

This happens in the background and can take several minutes, so please be patient.

Downloading kubectl

The following set of commands can be used to install kubectl on your machine. You may need to change the version number below:

...

.

...

Deploying a Multi-Node (Production) Cluster

...

More information is needed on what would be involved in this process

kubectl create / delete

Pods

A Kubernetes Pod consists of one or more Docker containers running on the same local network.

This allows related or tightly-coupled services to run together with ease, communicating via localhost.

The Kubernetes Pod Spec

Pods can be configured to run with any number of custom configuration options, such as:

...

See http://kubernetes.io/docs/user-guide/pods/multi-container/#the-spec-schema for more details on the Kubernetes spec.

Replication Controllers

Pods are mortal, and can crash when things go wrong.

...

This is immensely powerful in keeping production system running long-term. 

Services

A Kubernetes Service allows a set of pods to receive traffic from within the cluster, which is accomplished by sharing the IPs and Ports of the services is through injected environment variables:

...

You can then reference these environment variable in the RC / Pod spec to use the injected values.

NodePort

Setting up a service with a NodePort will allow the service to receive traffic through the node's public (external) IP as well.

The alternative to NodePort is using a LoadBalancer , which is not yet supported on OpenStack.(see below).

Ingress Loadbalancer

If you're running on GCE, you will need to run a GLBC to handle routing your ingress traffic.

For all other platforms, an nginx instance running within your cluster can serve as the Ingress Loadbalancer

In addition to routing traffic to your running services, these loadbalancers can also handle things like TLS-termination, authentication via basic-auth (working) or OAuth2 (still in ongoing development), and providing unified custom error messages for all services.

Caveats:

  • The pod must run on a node with a Public IP
  • Your server must have a real DNS OR you must run your own bind DNS server within the cluster

Labels and Selectors

You can choose which pods a service affects by applying labels to the Pod(s) in question.

...

Namespaces are synonymous with "users" in NDS Labs, and allow you to encapsulate services from one another even further - Services cannot communicate between namespaces.