Building Kubernetes High Availability Clusters: Easy Guide 101

on DevOps, Kubernetes • April 22nd, 2022 • Write for Hevo

DevOps teams must deal with problems like bursting workloads, traffic spikes, architecting high availability across multiple regions/multiple availability zones, and much more to deploy cloud-native applications in production environments.

Kubernetes clusters provide a higher level of abstraction for deploying and managing a set of containers that make up a cloud-native application’s microservices. In this article, you will discuss Kubernetes High Availability and how to create a highly available Kubernetes cluster.

Table of Contents

Prerequisites

  • Knowledge of Containerization

What is Kubernetes?

Kubernetes High Availability - Kubernetes Logo
Image Source

Kubernetes is a platform for running highly available distributed systems. It manages your application’s scalability and provides deployment functionalities. 

Kubernetes is an open-source platform for managing containerized services, including declarative setup and automation. Kubernetes Nodes are worker machines that run containerized programs. They make up a Kubernetes Cluster, where every cluster has at least one worker node. The worker node hosts the Pods that make up the application workload(s). The control plane is in charge of the cluster’s worker nodes and Pods. In production, the control plane is commonly distributed across many computers, and a cluster often runs multiple nodes, providing fault tolerance and high availability.

What is Kubernetes High Availability & Why is it Needed?

If you run numerous apps on a single container, it’s can be prone to numerous failures. We can run many clones of containers in Kubernetes, much like virtual machines, for high availability. To handle numerous clones in Kubernetes, we employ deployment.

Crucial components like the API server and controller manager are replicated on several masters (typically two or more masters) in a Kubernetes High Availability system. If one of the masters fails, the remaining masters keep the cluster functioning. Kubernetes High Availability ensures that Kubernetes and its supporting components have no single point of failure. A single master cluster is vulnerable to failure, but a multi-master cluster uses many master nodes, each having access to the same worker nodes.

You have different master node components in Kubernetes, such as Kube API-server, etcd, and Kube-scheduler, and if one of these master nodes fails, it has a significant impact on the company. As a result, organizations install additional master nodes to ensure high availability and boost performance for a single cluster.

Understanding Scalability

Scalability is the capacity of a system to scale up or down in performance and cost in response to changes in application and system processing demands. Kubernetes is a complicated system, a variety of factors govern its scalability number of nodes in a node pool, the types, and quantities of node pools, etc.

Scalability refers to how well a hardware system performs as the number of users increases, how effectively a database handles rising queries, and how well an operating system works on different types of hardware. Businesses that are rapidly expanding should pay extra attention to scalability when selecting hardware and software.

However, companies frequently emphasize cost above scalability or even reject it outright. Unfortunately, this is a regular occurrence in Big Data ventures, where scaling concerns often derail otherwise promising projects. Scalability is a must-have feature; prioritizing it from the beginning reduces maintenance costs, improves the user experience, and increases agility. Software design is a delicate balancing act in which programmers strive to build the most refined product possible while staying within a client’s schedule and financial limits.

Build Scalable ETL Pipelines Using Hevo’s No-Code Data Pipeline

Hevo Data, an Automated No Code Data Pipeline, can help you automate, simplify & enrich your ETL process in a few clicks. With Hevo’s out-of-the-box connectors and blazing-fast scalable Data Pipelines, you can extract data from 100+ Data Sources straight into your Data Warehouse, Database, or any destination & run different pipelines in parallel. To further streamline and prepare your data for analysis, you can process and enrich Raw Granular Data using Hevo’s robust & built-in Transformation Layer!

GET STARTED WITH HEVO FOR FREE

Hevo is the fastest, easiest, and most reliable data replication platform that will save your engineering bandwidth and time multifold. Try our 14-day full access free trial to experience an entirely automated hassle-free Data Replication!

How to Set Up Kubernetes High Availability? 

Choosing a regional or zonal control plane

Regional clusters are more suited for high availability due to architectural variations. Regional clusters have numerous control planes spread throughout many compute zones in an area, whereas zonal clusters only have one control plane.

When a zonal cluster is upgraded, the control plane VM goes down, and the Kubernetes API is unavailable until the upgrade is finished.

During cluster maintenance, such as rotating IPs, upgrading control plane VMs, or resizing clusters or node pools, the control plane remains available in regional clusters. However, the Kubernetes API is still available while updating a regional cluster since two out of three control plane VMs are always operational throughout the rolling update. Meanwhile, a single-zone outage will not result in any downtime on the regional control plane.

Choosing multi-zonal or single-zone node pools

The Kubernetes control plane and its nodes must be distributed over many zones to provide high availability. Single-zone and multi-zonal node pools are available in GKE. Distribute your workload over many compute zones in a region using multi-zonal node pools, distributing nodes equally across zones to create a highly available application.

How to Create Kubernetes High Availability Scalable Clusters?

Kubernetes High Availability - Kubernetes High Availability Architecture
Image Source

In this section you will cover the following points:

What are Container Images?

Each server should be able to read and download images from the k8s.gcr.io Kubernetes container image registry. This is viable if you wish to construct a highly available cluster where the hosts do not have access to pull images. You must verify that the necessary container images are already accessible on the required hosts through some other method.

How to Use the Command-Line Interface?

Install kubectl on your PC to administer Kubernetes after your cluster is up and running. The Since kubectl lets you control, maintain, analyze, and troubleshoot Kubernetes clusters. Installing the tool on each control plane node is a good idea because it can be of great help. 

We will cover two distinct ways to use kubeadm to build up a highly available Kubernetes cluster:

  1. With Stacked Control Plane Nodes: This method needs minimal infrastructure. etcd members and control plane nodes are both in the exact location.
  2. With the help of an External etcd Cluster: This strategy needs greater infrastructure. The nodes of the control plane and the members of etcd are separated.

The first step for both methods is to create a load balancer for kube-apiserver.

  1. Make a kube-apiserver load balancer with a DNS-resolvable name.
  • In a cloud environment, your control plane nodes should be placed behind a TCP forwarding load balancer. This load balancer sends traffic to all healthy control plane nodes in its target list. An apiserver’s health check is a TCP check on the port that the kube-apiserver listens on (default value:6443).
  • In a cloud context, using an IP address directly is not advised.
  • The API server port and the load balancer must be able to connect with all control plane nodes. On its listening port, it must also enable incoming traffic.
  • Make sure that the load balancer’s IP is always the same as kubeadm’s ControlPlaneEndpoint.
  1. Test the connection by adding the first control plane node to the load balancer:
	nc -v <LOAD_BALANCER_IP> <PORT>

A connection rejected error is expected because the API server is not yet up and operating. On the other hand, a timeout indicates that the load balancer cannot interact with the control plane node. Reconfigure the load balancer to interact with the control plane node if a timeout occurs.

      3. To the load balancer target group, add the remaining control plane nodes.

Next, we will talk about the way kubeadm can help build up a Kubernetes High Availability cluster.

What Makes Hevo’s Data Pipelines Unique & Scalable?

Banner-image-for-Hevo

Extracting and loading data from a number of sources can be a mammoth task without the right set of tools. Hevo’s automated platform empowers you with everything you need to have a smooth Data Collection, Processing, and Transforming experience. Our platform has the following in store for you! 

  • Built to Scale: Exceptional Horizontal Scalability with Minimal Latency for Modern-data Needs.
  • Data Transformations: Best-in-class & Native Support for Complex Data Transformation at fingertips. Code & No-code Fexibilty designed for everyone.
  • Built-in Connectors: Support for 100+ Data Sources, including Databases, SaaS Platforms, Files & More. Native Webhooks & REST API Connector available for Custom Sources.
  • Blazing-fast Setup: Straightforward interface for new customers to work on, with minimal setup time.
  • Exceptional Security: A Fault-tolerant Architecture that ensures Zero Data Loss.
  • Live Support: The Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
SIGN UP HERE FOR A 14-DAY FREE TRIAL!

Method 1: Create Kubernetes High Availability Cluster With Stacked Control Plane Nodes

Let us discuss the steps for the first control plane node.

  1. Initialize the control plane:
sudo kubeadm init --control-plane-endpoint "LOAD_BALANCER_DNS:LOAD_BALANCER_PORT" --upload-certs
  1. Apply the CNI plugin 
  2. Type the following to get the control plane components’ pods to start:
kubectl get pod -n kube-system -w

Steps for the remaining Control Plane Nodes

You need to do the following for each extra control plane node:

  1. On the first node, run the join command that was previously supplied to you by the kubeadm init output. This is what it should look like:
sudo kubeadm join 192.168.0.200:6443 --token 9vr73a.a8uxyaju799qwdjv --discovery-token-ca-cert-hash sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866 --control-plane --certificate-key f8902e114ef118304e561c3ecd4d0b543adc226b7a07f675f56564185ffe0c07

You can connect numerous control-plane nodes parallelly.

Method 2: Create Kubernetes High Availability Cluster With External etcd Nodes 

Setting up a cluster with external etcd nodes is identical to setting up a stacked etcd cluster, with the distinction that you should first set up etcd and then send the etcd information to the kubeadm config file.

  1. Setting up the etcd cluster
  • To set up the etcd cluster, follow these steps.
  • Set up SSH according to the instructions given.
  • Copy the following files to the first control plane node from an etcd node in the cluster:
export CONTROL_PLANE="ubuntu@10.0.0.7"
scp /etc/kubernetes/pki/etcd/ca.crt "${CONTROL_PLANE}":
scp /etc/kubernetes/pki/apiserver-etcd-client.crt "${CONTROL_PLANE}":
scp /etc/kubernetes/pki/apiserver-etcd-client.key "${CONTROL_PLANE}":

Replace the value of CONTROL PLANE with the first control-plane node’s user@host.

Set up the First Control Plane Node

  1. Make a kubeadm-config. YAML file with the following contents:
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
kubernetesVersion: stable
controlPlaneEndpoint: "LOAD_BALANCER_DNS:LOAD_BALANCER_PORT" # change this (see below)
etcd:
  external:
    endpoints:
      - https://ETCD_0_IP:2379 # change ETCD_0_IP appropriately
      - https://ETCD_1_IP:2379 # change ETCD_1_IP appropriately
      - https://ETCD_2_IP:2379 # change ETCD_2_IP appropriately
    caFile: /etc/kubernetes/pki/etcd/ca.crt
    certFile: /etc/kubernetes/pki/apiserver-etcd-client.crt
    keyFile: /etc/kubernetes/pki/apiserver-etcd-client.key
  1. Replace the variables in the config template with the relevant values for your cluster:
  • LOAD_BALANCER_DNS
  • LOAD_BALANCER_PORT
  • ETCD_0_IP
  • ETCD_1_IP
  • ETCD_2_IP

The steps are identical to those in the stacked etcd setup:

  • On this node, Run sudo kubeadm init —config kubeadm-config.yaml —upload-certs
  • Write the output join instructions to a text file so they can be used later.
  • Select the CNI plugin you want to use.

Advantages of High Availability in Kubernetes

Kubernetes High Availability is not just about Kubernetes stability. It’s about configuring Kubernetes and supporting components like etcd, so that there’s no single point of failure. A single point of failure is a component in a system that, if it fails, makes the whole system stop working. Such events can lead to huge operational disruption as well as revenue losses for any company.

Application Use Cases of Kubernetes High Availability

Suppose you have an e-commerce website that must handle a large amount of traffic from all around the world. To improve the efficiency of deploying, scaling, and managing applications, you can shift to Kubernetes. With Kubernetes High Availability, you can take the data offline if any critical maintenance operations such as backups or hardware installations are to be made without having any impact on your business.

The biggest shoe manufacturer, Adidas, also operates a big e-commerce operation that needs a quick and dependable infrastructure. The Adidas website load time was slashed in half thanks to a combination of Kubernetes on AWS and Prometheus, which allowed the team to release enhancements 10,000 times faster—from once every 4-6 weeks to 3-4 times per day. Adidas utilizes Kubernetes to run roughly half of its most significant systems, with 4,000 pods and 200 nodes.

Conclusion

It is clear that Kubernetes High Availability is an essential element of reliability engineering, which focuses on making systems dependable and preventing single points of failure across the system. Although its deployment may appear complicated at first, Kubernetes High Availability provides significant benefits to systems that demand enhanced stability and dependability.

Hevo Data is a No-Code Data Pipeline that offers a faster way to move data from 100+ Data Sources including 40+ Free Sources, into your Data Warehouse to be visualized in a BI tool. Hevo is fully automated and hence does not require you to code.

VISIT OUR WEBSITE TO EXPLORE HEVO

Want to take Hevo for a spin?

SIGN UP and experience the feature-rich Hevo suite first hand. You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.

Share your experience with Kubernetes High Availability in the comments section below!

No-Code Data Pipeline For Your Data Warehouse