Deploy Jekyll App on Kubernetes

Ticker

6/recent/ticker-posts

Deploy Jekyll App on Kubernetes

Question: Create a namespace jekyll-namespace-datacenter for jekyll.

PersistentVolume is already created on jump_host.

Create a PersistentVolumeClaim which should be named jekyll-site-datacenter under the same namespace. accessModes should be ReadWriteMany, request 1Gi storage.

Create a pod named jekyll-pod-datacenter for jekyll. Init container should be named as jekyll-init-datacenter, image should be kodekloud/jekyll, use command as [ "jekyll", "new", "/site" ]. Its image pull policy should be IfNotPresent, volumeMount name should be site and its mountPath should be /site. The main container should be named as jekyll-container-datacenter, its image should be kodekloud/jekyll-serve, volumeMount name should be site and its mountPath should be /site. Volume name should be site and persistent volume claim's claim name should be jekyll-site-datacenter

Create a service for jekyll which should be named jekyll-service-datacenter under the same namespace. Port should be 8080, protocol should be TCP, its targetPort should be 4000 and nodePort should be 31181. Its type should be NodePort and loadbalancer status should be {}.

You can use any labels as per your choice.


Please Note :-  Perform the below commands based on your question server,  user name & other details that might differ. So please read the task carefully before executing it. All the Best 👍

Solution:  

1. At first  kubectl  utility configure and working from jump server, run below commands  

thor@jump_host /$ kubectl get namespace

NAME              STATUS   AGE

default           Active   8m20s

kube-node-lease   Active   8m21s

kube-public       Active   8m22s

kube-system       Active   8m22s

thor@jump_host /$

thor@jump_host /$ kubectl get pods

No resources found in default namespace.

thor@jump_host /$


2. create a new namespace as per the task

thor@jump_host /$ kubectl create namespace jekyll-namespace-datacenter

namespace/jekyll-namespace-datacenter created

thor@jump_host /$

thor@jump_host /$ kubectl get namespace

NAME                          STATUS   AGE

default                       Active   118s

jekyll-namespace-datacenter   Active   36s

kube-node-lease               Active   2m

kube-public                   Active   2m

kube-system                   Active   2m

thor@jump_host /$

 
3.  Create yaml  file with all the parameters , you can copy form gitlab

    https://gitlab.com/nb-tech-support/devops.git

    Refer Below Video for more clarity )

thor@jump_host /$ vi  /tmp/jekyll.yaml

thor@jump_host /$ cat /tmp/jekyll.yaml

apiVersion: v1

kind: PersistentVolumeClaim

metadata:

  name: jekyll-site-datacenter

  namespace: jekyll-namespace-datacenter

spec:

  accessModes:

    - ReadWriteMany

  resources:

    requests:

      storage: 1Gi

---

apiVersion: v1

kind: Service

metadata:

  name: jekyll-service-datacenter

  namespace: jekyll-namespace-datacenter

spec:

  type: NodePort

  selector:

    app: jekyll-pod-datacenter

  ports:

    - port: 8080

      protocol: TCP

      targetPort: 4000

      nodePort: 31181

status:

  loadBalancer: {}

---

apiVersion: v1

kind: Pod

metadata:

  name: jekyll-pod-datacenter

  namespace: jekyll-namespace-datacenter

  labels:

    app: jekyll-pod-datacenter

spec:

  volumes:

    - name: site

      persistentVolumeClaim:

        claimName: jekyll-site-datacenter

  initContainers:

    - name: jekyll-init-datacenter

      image: kodekloud/jekyll

      imagePullPolicy: IfNotPresent

      command: ["jekyll", "new", "/site"]

      volumeMounts:

        - name: site

          mountPath: /site

  containers:

    - name: jekyll-container-datacenter

      image: kodekloud/jekyll-serve

      volumeMounts:

        - name: site

          mountPath: /site

thor@jump_host /$

4.  Run below command to create a pod 

thor@jump_host /$ kubectl create -f /tmp/jekyll.yaml

persistentvolumeclaim/jekyll-site-datacenter created

service/jekyll-service-datacenter created

pod/jekyll-pod-datacenter created

thor@jump_host /$


5.  Wait for  pods to get running status
       

thor@jump_host /$ kubectl get pods -n jekyll-namespace-datacenter

NAME                    READY   STATUS    RESTARTS   AGE

jekyll-pod-datacenter     1/1     Running   0          31s

thor@jump_host /$


6.  Click on Finish & Confirm to complete the task successfully


Happy Learning!!!!


Apart from this if you need more clarity,  I have made a  tutorial video on this

please go through and share your comments. Like and share the knowledge



Post a Comment

0 Comments

Latest Posts

File Permission Correction  Level 1 Linux KodeKloud Engineer Task Success