This is a two-part blog:
- Series-1 blog highlights how to make a single-node Kubernetes cluster for your Spinnaker deployment. This part-1 blog is beneficial for engineers or DevOps folks to execute any experiment or run a POC on the K8S cluster.
- Series-2 blog highlights how to install Spinnaker into the K8S cluster.
Container orchestration platform, Kubernetes, has always been the love of the DevOps team for obvious reasons; It is open source, helps the infrastructure team scale infra quickly, and enables the DevOps team to deploy changes easily. Kubernetes is the backbone of all microservices and containerized applications.
However, when an organization tries to scale software delivery with Kubernetes, specific challenges emerge, such as
- Dependence on scripts (kubectl apply for the deployment of apps into dev, test, and production environments
- Lack of knowledge for deploying into various managed Kubernetes such as EKS, AKE, GKE, or on-prem Kubernetes
- Lack of safe deployment strategies like canary or blue-green or rollback
- Time-consuming process such as manual verification data gathering for release approvals
- Unable to track deployment status in a central plane.
Most of the organizations we talk to today want to overcome the above challenges and speed up their software delivery process. And since Spinnaker is open source and API based, the DevOps team wants to automate deployments using pipelines. But before deploying Spinnaker straightaway into the production environment, DevOps folks would like to perform a POC first, primarily to check if Spinnaker’s solution will be compatible with the Kubernetes version used in an organization.
In this blog, I would like to highlight setting up a single-node Kubernetes cluster for the POC of Spinnaker. Yes, single node, because multiple nodes for POC will waste resources.
Single node clusters for POC: We can test simple features with a single node k8s cluster that we can quickly set up in our VM’s standalone systems.
After POC tests are done, one can tear down the nodes and free resources. For the installation of Kubernetes, I have considered two environments- Ubuntu and RedHat Linux.
Let us start with setting up Kubernetes on Ubuntu.
Steps to Set up Kubernetes in Ubuntu
Step-1: Update existing packages before Docker installation.
Docker is a prerequisite for k8s installation. Listing out the steps for the same:
We need to update our existing packages:
We will also install a few prerequisite packages which will be apt packages over HTTPS:
We will add GPG key for official docker repository to our system:
Then, we will add docker repository to APT sources:
Next, We will update the package database from the newly added repo:
Note: Please make sure you do the installation from the Docker repo and not default Ubuntu repo:
You will see output like below, it will list all the versions of Docker that are available.
Step-2: Install Docker
To check whether docker is installed or not, you can run the below command:
Step-3: Install single node K8s cluster
We will update and upgrade the package list as usual:
We will add k8s package key by using the following command.
Note: We will need to run the below command as the root user, we will add the k8s repository by creating k8s repository source list file:
We will add the below line in the above file using vi editor or any preferred editor that can be used:
And add the below line:
We will update the package list and install the packages to run k8s:
Next we will require to initiate a pod network, this is because for k8s pod to communicate they require a pod network. There are several pod networks that can be used, you can read more about pod networks here. For our example, we are using Flannel.
Step-4: Initiate Pod Network using Flannel
We will need to pass bridged Ipv4 traffic to the iptables chain, this is a requirement for some CNI plugins to work. Run the below command:
We will have to pass pod network and initialize the same using kubeadm, by running the below command:
Once you run the above command as root you will see the below output:
In case, you run the command as a non-root user, you will see the below output:
We will run the commands in the screenshot as a non-root user:
Finally we will apply the flannel cluster, by running the below command:
We will see below output:
The warnings in the above screenshot can be avoided by making the suggested changes. These warnings are related to my system, you may not even get these warnings. Also note, warnings will not restrict the pods to come up and running.
We will check pods by running the below command:
We will see output somewhat like below:
We will also confirm if the node is a single node k8s cluster. The node in this case will be a master node by default. Use the below command to check the details of the node:
** At times the status in the above screenshot may show as not Ready because by default cluster will not schedule pods in the master node for security reasons. In that case, we have to run the below command and taint the nodes which usually fixes the issue:
Let’s move onto our next chapter wrt RedHat Linux.
Steps to Set up Kubernetes on RedHat:
The prerequisite needed are:
- Docker has to be installed.
- Sestatus set to disabled.
- Configure firewalld and IP tables.
After installing docker follow the below steps:
Step-1: Disable Sestatus
Step-2: Configure Firewall and IP tables
Step-3: Configure IP tables
Once the above mentioned step is done next we create a repo.
Step-3: Create a repo
You can use the above method or use vi to create the repo.
The next step is to install kubeadm.
Step-4: Install and Initialize Kubeadm
Once the above step is complete we will restart docker and kubelet and enable them as well:
We will initialize kubeadm next:
Once the initialization is successful we will get similar prompt that we saw during our installation in Ubuntu asking to run below commands as a regular user:
Now if we check k8s node we might find it in pending state, this we can fix initiating pod network, also after initiating pod network if we see our master in pending state we can taint the nodes, steps shared above for k8s installation in Ubuntu
Step-5: Initiate Pod Network using Weave
To deploy pod network run the below command (in this case I have used weave):
This will get your node up and running.
If you notice, once kubeadm is initialized for both the environments (Ubuntu and Red Hat), the steps are almost the same. It is only the prerequisites that have some significant differences. Also, the links shared for pod initialization keep upgrading in case you all face issues using flannel or weave, use a different pod network tool or use the latest versions of flannel/weave.
A quick point to remember is if you are starting from scratch, the Docker and Kubernetes version that will be installed will always be the latest by default.
However, if you have Docker already installed, you are starting to establish your Kubernetes cluster directly. Depending on the Docker version installed, you will start getting warnings or errors informing you that the Docker version needs updating or a compatible version of Kubernetes with your current docker version that you should install.
Even though it’s a single node cluster, we can still deploy microservices for our application and test the same unless the requirement to deploy such apps isn’t too heavy. In the next blog, we will see a test case where we will deploy Spinnaker in a single node k8s cluster.