CI/CD Setup On SDC
Steps to setup CI/CD on SDC
Topics covered:
Overview
Kubespray is a composition of Ansible playbooks, inventory, provisioning tools, and domain knowledge for generic OS/Kubernetes cluster configuration management tasks. Kubespray provides:
a highly available cluster
composable attributes
support for most popular Linux distributions
continuous-integration tests
Pre-requisites
Fork the repos below to your GitHub Organization account
Go lang (version 1.13.X)
Install kubectl on your local machine to interact with the Kubernetes cluster.
Install Helm to help package the services along with the configurations, environment, secrets, etc into Kubernetes manifests.
Hardware
One Bastion machine to run Kubespray
HA-PROXY machine which acts as a load balancer with Public IP. (CPU: 2Core , Memory: 4Gb)
one machine which acts as a master node. (CPU: 2Core , Memory: 4Gb)
one machine which acts as a worker node. (CPU: 8Core , Memory: 16Gb)
ISCSI volumes for persistence volume. (number of quantity: 2 )
kaniko-cache-claim:- 10Gb
Jenkins home:- 100Gb
Software
Kubernetes nodes
Ubuntu 18.04
SSH
Privileged user
Python
Bastion machine
Ansible
git
Python
Preparing The Nodes
Run and follow instructions on all nodes.
Install Python
Ansible needs Python to be installed on all the machines.
apt-get update && apt-get install python3-pip -y
Disable Swap
Setup SSH using key-based authentication
All the machines should be in the same network with ubuntu or centos installed.
ssh key should be generated from the Bastion machine and must be copied to all the servers part of your inventory.
Generate the ssh key
ssh-keygen -t rsa
Copy over the public key to all nodes.
Setup Ansible Controller machine Setup kubespray
Clone the official repository
Install dependencies from
requirements.txt
Create Inventory
where mycluster is the custom configuration name. Replace with whatever name you would like to assign to the current cluster.
Create inventory using an inventory generator.
Once it runs, you can see an inventory file that looks like the below:
Review and change parameters under
inventory/mycluster/group_vars
Deploy Kubespray with Ansible Playbook - run the playbook as Ubuntu
The option
--become
is required, for example writing SSL keys in /etc/, installing packages and interacting with various system daemons.Note: Without
--become
- the playbook will fail to run!
Kubernetes cluster will be created with three masters and four nodes with the above process.
Kube config will be generated in a .Kubefolder. The cluster can be accessible via kubeconfig.
HA-Proxy
Install haproxy package in a haproxy machine that will be allocated for proxy
sudo apt-get install haproxy -y
IPs need to be whitelisted as per the requirements in the config.
sudo vim /etc/haproxy/haproxy.cfg
Volumes
Iscsi volumes will be provided by the SDC team as per the requisition and the same can be used for statefulsets.
CI/CD Build Job Pipeline Setup
Refer to the doc here.
Last updated