Web Server with Live Updates Roll Out using Jenkins and K8s

Problem Statement :

systemctl daemon-reload
systemctl restart docker
FROM centos:latest
COPY kubernetes.repo /etc/yum.repos.d/kubernetes.repo
RUN yum install kubectl -y
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/bin/
RUN kubectl version --client
RUN mkdir /root/.kube
COPY config /root/.kube/
COPY *.crt /root/
COPY client.key /root/
RUN yum install java -y
RUN yum install openssh-server -y
RUN mkdir /root/jenkins-ws
RUN ssh-keygen -A
COPY ssh_config /etc/ssh/
RUN echo root:redhat | chpasswd
CMD ["/usr/sbin/sshd" , "-D"] && / bin/bash
RUN yum install sudo -y
RUN yum install git -y
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
yum install kubectl -y
apiVersion: v1
kind: Configclusters:
- cluster:
server: https://192.168.99.105:8443
certificate-authority: /root/ca.crt
name: pgclustercontexts:
- context:
cluster: pgcluster
user: Priyanshiusers:
- name: Priyanshi
user:
client-key: /root/client.key
client-certificate: /root/client.crt
Port 22
Protocol 2
Hostkey /etc/ssh/ssh_host_rsa_key
Hostkey /etc/ssh/ssh_host_dsa_key
Hostkey /etc/ssh/ssh_host_ecda_key
Hostkey /etc/ssh/ssh_host_ed25519_keyLoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
usePAM yes
docker build -t k8s:v1 .
FROM centos:latest
RUN yum install httpd -y
WORKDIR /root/jen-ws
COPY *.html /var/www/html
CMD /usr/sbin/httpd -DFOREGROUND && /bin/bash
EXPOSE 80

JOB 2 : ( Should be run on the dynamic slave of Jenkins configured with Kubernetes kubectl command): Launch the application on the top of Kubernetes cluster performing following operations:

apiVersion: apps/v1
kind: Deployment
metadata:
name: t4-deploy
spec:
replicas: 3
selector:
matchLabels:
env: production
template:
metadata:
name: t4-con
labels:
env: production
spec:
containers:
- name: t4-con
image: priyanshigarg/webserver:latest

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store