In this blog we will learn how we can launch pods and expose them with the help of jenkins
Prerequisites
EC2 Instance: Begin by provisioning an EC2 instance with a T2-MEDIUM instance type.
Jenkins Installation: Install Jenkins on your EC2 instance.
Docker: Ensure Docker is installed and configured on your EC2 instance.
Kubernetes Setup: Setup Kubernetes on your EC2 instance.
Step 1: We will install kubectl.
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
give the file execution permission
sudo chmod +x kubectl
and then we will MV this file in default directory
sudo mv kubectl /usr/bin
Step 2: Install and setup jenkins and java.
Step 3: create a new job with freestyle which will execute the commands to launch and expose pods.
Step 4: Write these commands on execute shell of build step.
#launch sudo kubectl create deployment myd1 --image=vimal13/apache-webserver-php #Launch the port kubectl expose deployment myd1 --type=NodePort --port=80
After that click on build now your pods will be created and exposed.