In this blog, Deploy Keptn in Kubernetes(K8s) using ReplicaSet, we will quickly go through the steps to deploy Keptn in Kubernetes(K8s) using Replica Set!! So lets dive in 🙂
What is Keptn?
Keptn is an open source control plane to build cloud-native, industry-driven continous delivery systems. According to Dynatrace, Keptn augments any standard Kubernetes cluster to support delivery based on automated quality gates and self-healing operations workflows.
Pre-requisites
For deploying Keptn in kubernetes we require the following :-
- Basic Knowledge about Kubernetes and replica set.
- Basic knowledge about yaml files.
- Difference between replicaset and replication controllers.
Code Block
Copy the code for the replica set in your yaml file and save it as keptn-rs.yaml.
apiVersion: apps/v1
kind: ReplicaSet
metadata:
#contains 2 things object name and label
name: keptn-rs
spec:
#contains no. of replicas and pods spec
replicas: 3
selector:
matchLabels:
app: keptn-app
template:
#pods spec
metadata:
name: keptn-pod
labels:
app: keptn-app
spec:
containers:
- name: keptn-container
image: gardnera/thekindkeptn:0.0.15
ports:
- containerPort: 80
Here we are creating a replication controller with the following specs:
- Metadata of replica set: keptn-rs
- Replica of keptn pods: 3
- Container name: keptn-container
- Keptn image: gardnera/thekindkeptn:0.0.15
- Port for running: 80
By default only 3 pods of Keptn will be running on nodes. To scale up or down the pods use the following command.
Code Implementation
- Deploy keptn rs with (default 3 replicas) following command.
kubectl create -f keptn-rs.yaml
- Get output of running pods using this command.
kubectl get po -o wide
- Scale Up / Scale Down the pods using this command.
kubectl scale rs keptn-rs --replicas=5
kubectl scale rs keptn-rs --replicas=1
- Delete keptn-rs after deployment
kubectl delete -f keptn-rs.yaml
FUN PART 🙂
If you don’t want to execute the above steps, I have a script made for you that does that 🙂
echo "Please enter the number of pods you want to deploy for Keptn"
read count
echo $count
#Start keptn: with 3 nodes
kubectl create -f keptn-rs.yaml && kubectl scale rs keptn-rs --
replicas=$count
#Check output:
kubectl get po -o wide
echo
while true; do
read -p "Do you want to scalup Pods? [y for Yes ; n for No ; q for
Quit] " yn
echo ""
case $yn in
[Yy]* ) echo "Enter number of pods to scale up"
read scale_count
echo "Pods scaled up to $scale_count" && kubectl scale rs keptn-rs --
replicas=$scale_count ; break;;
[Nn]* ) break ;;
[Qq]* ) exit 0;;
* ) echo "Please provide a yes or no answer."
esac
done
echo
while true; do
read -p "Do you want to scaldown Pods? [y for Yes ; n for No ; q for
Quit] " yn
echo ""
case $yn in
[Yy]* ) echo "Enter number of pods to scale down"
read scale_count
echo "Pods scaled down to $scale_count" && kubectl scale rs keptn-rs
--replicas=$scale_count ; break;;
[Nn]* ) break ;;
[Qq]* ) exit 0;;
* ) echo "Please provide a yes or no answer."
esac
done
echo
while true; do
read -p "Do you want to delete this Deployment? [y for Yes ; n for No
; q for Quit] " yn
echo ""
case $yn in
[Yy]* ) kubectl delete -f keptn-rs.yaml ; break;;
[Nn]* ) break ;;
[Qq]* ) exit 0;;
* ) echo "Please provide a yes or no answer."
esac
done
Output
Running and scaling up Keptn pods with the above command.

Running and scaling down Keptn pods with the above command.

Conclusion
In this blog I have tried to cover Keptn deployment using Kubernetes(K8s). I have tried my best to provide you with the source code as well as a script that does all that steps for you.
Please like and subscribe the blog to get more informative blogs like this !!
References
Keptn Docs: https://keptn.sh/docs/quickstart/
For more fresh content, click here