A B C D E F G H I J K L M N O P Q R S T U V W X Z
Kn Ku

Kubernetes and Rancher and Swarm

Introduction

docker-compose is used to deploy multiple containers on the same host. Once you want to run and connect containers on multiple hosts, you will need a container orchestration tool such as Docker swarm or Kubernetes.

Kubernetes

Kubernetes is the de facto standard orchestration tool and makes it easy to deploy, maintain and scale Docker containers.

Basic concepts and objects in Kubernetes include:

  • Cluster: consists of worker machines/nodes that run containers (host Pods).
  • Pod: the smallest unit that can be deployed in Kubernetes. It consists of a single container or multiple containers that are tightly grouped and share the same resources. Each Pod has an unique IP address.
  • ReplicaSets: manage Pods. Replicas are copies of Pods and ensure high availability. ReplicaSets define the desired scale and state of a group of Pods.
  • Deployment: manage ReplicaSets. Deployments create and update ReplicaSets which, in turn, create and update Pods.
  • ConfigMap: overrides container-specific data like config files, environment variables, entire directories of data – enables customizing without modifying the original base image.
  • Services: provide stable DNS and IP address for a a group of Pods.
  • Ingresses: define how traffic outside the cluster is routed to inside the cluster; are used to expose Kubernetes Services to the world.
  • Manifests are specifications of Kubernetes objects written in YAML or JSON. To create an object such as a Pod, a Deployment etc, usekubectl apply -f path/to/manifest.yamlto apply its manifest to the cluster.

Rancher

Rancher facilitates the creation, upgrade, monitoring and management of Kubernetes clusters and simplifies automating Kubernetes-related tasks. Rancher is designed to be an authentication proxy, i.e. whoever wants to access the clusters does so through authenticating in Rancher. Rancher can be accessed through a feature-rich and easy-to-use web interface. To add Kubernetes clusters to Rancher you can either import an existing cluster or create a new cluster using RKE (Rancher Kubernetes Engine).

SWARM

https://docs.docker.com/engine/swarm/

Current versions of Docker include swarm mode for natively managing a cluster of Docker Engines called a swarm. Use the Docker CLI to create a swarm, deploy application services to a swarm, and manage swarm behavior.

Docker Swarm mode is built into the Docker Engine. Do not confuse Docker Swarm mode with Docker Classic Swarm which is no longer actively developed.

  • Cluster management integrated with Docker Engine: Use the Docker Engine CLI to create a swarm of Docker Engines where you can deploy application services. You don’t need additional orchestration software to create or manage a swarm.
  • Decentralized design: Instead of handling differentiation between node roles at deployment time, the Docker Engine handles any specialization at runtime. You can deploy both kinds of nodes, managers and workers, using the Docker Engine. This means you can build an entire swarm from a single disk image.
  • Declarative service model: Docker Engine uses a declarative approach to let you define the desired state of the various services in your application stack. For example, you might describe an application comprised of a web front end service with message queueing services and a database backend.
  • Scaling: For each service, you can declare the number of tasks you want to run. When you scale up or down, the swarm manager automatically adapts by adding or removing tasks to maintain the desired state.
  • Desired state reconciliation: The swarm manager node constantly monitors the cluster state and reconciles any differences between the actual state and your expressed desired state. For example, if you set up a service to run 10 replicas of a container, and a worker machine hosting two of those replicas crashes, the manager creates two new replicas to replace the replicas that crashed. The swarm manager assigns the new replicas to workers that are running and available.
  • Multi-host networking: You can specify an overlay network for your services. The swarm manager automatically assigns addresses to the containers on the overlay network when it initializes or updates the application.
  • Service discovery: Swarm manager nodes assign each service in the swarm a unique DNS name and load balances running containers. You can query every container running in the swarm through a DNS server embedded in the swarm.
  • Load balancing: You can expose the ports for services to an external load balancer. Internally, the swarm lets you specify how to distribute service containers between nodes.
  • Secure by default: Each node in the swarm enforces TLS mutual authentication and encryption to secure communications between itself and all other nodes. You have the option to use self-signed root certificates or certificates from a custom root CA.
  • Rolling updates: At rollout time you can apply service updates to nodes incrementally. The swarm manager lets you control the delay between service deployment to different sets of nodes. If anything goes wrong, you can roll back to a previous version of the service.

Sources

https://www.youtube.com/watch?v=5h1TCrh_hZ0  Introduction to Kubernetes and Rancher (1.5h)

Sadegh, S. (2021). Kubernetes with Rancher at the GWDG. Part 1: Basic concepts. GWDG Nachrichten, 44(3), 16-18.

Sadegh, S. (2021). Kubernetes with Rancher at the GWDG. Part 2: Setup and Deployment. GWDG Nachrichten, 44(4), 15-19.

https://kubernetes.io/docs/home/

https://rancher.com/docs/

Further reading

Sadegh, S. (2021). Kubernetes with Rancher at the GWDG. Part 3: Deploy a Workload. GWDG Nachrichten, 44(8), 6-8.

Sadegh, S. (2021). Kubernetes with Rancher at the GWDG. Part 4: Setup a PostgreSQL Cluster. GWDG Nachrichten, 44(10), 5-9.