Kubernetes

Kubernetes - Assigning Pod to Nodes

Learn how to use Kubernetes nodeSelector to assign pod to particular nodes

ta-ching chen

2 minute read

Intro

Currently Kubernetes support nodeSelector, affinity and anti-affinity to constraint pod to run on paritcular nodes. In this post, you will learn how to assign pod to specifc nodes by nodeSelector.

Hands-On

Show Labels

$ kubectl get nodes --show-labels
NAME            STATUS    AGE       LABELS
192.168.1.1    Ready     4d        beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=192.168.1.1
192.168.1.2    Ready     4d        beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=192.168.1.2
192.168.1.3    Ready     4d        beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=192.168.1.3

Kubernetes - Pod

Intro to smallest deployable unit in Kubernetes

ta-ching chen

3 minute read

Pod

A Pod is a group of one or more containers and it is the smallest deployable unit in Kubernetes. Pod and VM (virtual machine) are similar in many ways:

  • Containers in pod share the same IP address and port space
  • Shared storage (volumes)
  • Relatively tightly coupled applications in one pod

Shared IP address and port space

Kubernetes applies IP at Pod scope. Containers within a pod share an IP address and port space, and can find each other via localhost. Its just like what we do in VM: one prcoess find others with localhost:port.

Also pod can be accessed by other pod in Kubernetes cluster, it helps developer no need to worry about how to access other containers cross hosts. However, normally we don’t access other Pod directly but using service instead and we will discuss it in later article.

Kubernetes - High Availability

Learn how to create high availability Kubernetes cluster

ta-ching chen

5 minute read

Prerequisites

Create Reliable Storage Layer

Kubernetes use etcd as backend storage to keep cluster information. If we want to have a high availability of Kubernetes cluster, we need to set up etcd cluster as our reliable distributed key-value storage. Once we setup the etcd cluster, it will help us to populate data to whole etcd cluster.

Stop Single Node etcd

service etcd stop

Create etcd Cluster by Running Etcd on Multiple Nodes

sudo /opt/bin/etcd --name <node name> -data-dir <path to etcd data dir> \
--initial-advertise-peer-urls http://<node ip>:4000 \
--listen-peer-urls http://<node ip>:4000 \
--listen-client-urls http://127.0.0.1:4001,http://<node ip>:4001 \
--advertise-client-urls http://<node ip>:4001 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster <node1 name>=http://<node1 ip>:4000,<node2 name>=http://<node2 ip>:4000,<node3 name>=http://<node3 ip>:4000 \
--initial-cluster-state new
ta-ching chen

5 minute read

NOTE

If your OS is Ubuntu 16.04+, please visit Kubernetes - Two Steps Installation instead.

Introduction

Docker is getting popular among cloud provider and developers, because it helps people to package their own application(service) into one Docker image and delivery it without worried any external dependencies. Also, Docker is a kind of lightweight virtual machine(compare to full virtualization), operation engineer can launch hundred of docker instances on the same host.

However, it becomes a great challenge for the engineers to maintain, upgrade and monitoring all containers in an elegant way. At this point, we definitely need a tool that helps us to solve such problem, and fortunately, right now we have different tools to meet the problem such as Docker Swarm, Nomad, Mesos, DC/OS and our topic today - Kubernetes !

Kubernetes