Deploy Apache Web Server on Kubernetes Cluster

Ticker

6/recent/ticker-posts

Deploy Apache Web Server on Kubernetes Cluster

Question : There is an application that needs to be deployed on Kubernetes cluster under Apache web server. The Nautilus application development team has asked the DevOps team to deploy it. We need to develop a template as per requirements mentioned below:

Create a namespace named as httpd-namespace-nautilus.

Create a service named as httpd-service-nautilus under same namespace, targetPort should be 80 and nodePort should be 30004.

Create a deployment named as httpd-deployment-nautilus under the same namespace as mentioned above. Use image httpd with latest tag only and remember to mention tag i.e httpd:latest, and container name should be httpd-container-nautilus. And make sure replicas counts are 4.

Set labels app to httpd_app_nautilus.

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.



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

Solution:  

1. At first  create a namespace as per the task 

    kubectl create namespace httpd-namespace-nautilus

    kubectl get namespace 



2. 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 )


apiVersion: v1
kind: Service
metadata:
  name: httpd-service-nautilus
  namespace: httpd-namespace-nautilus
spec:
  type: NodePort
  selector:
    app: httpd_app_nautilus
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30004
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpd-deployment-nautilus
  namespace: httpd-namespace-nautilus
  labels:
    app: httpd_app_nautilus
spec:
  replicas: 4
  selector:
    matchLabels:
      app: httpd_app_nautilus
  template:
    metadata:
      labels:
        app: httpd_app_nautilus
    spec:
      containers:
        - name: httpd-container-nautilus
          image: httpd:latest
          ports:
            - containerPort: 80


3.  Run below command to create pod

    kubectl create -f /tmp/http.yaml



4.  Wait for  pods to get running status

        kubectl get pods


5.  Click on Finish & Confirm to complete the task successful

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

7 Comments

  1. Congrats on setting up a kubernetes web server that serves no content.

    ReplyDelete
  2. Nice article. I appreciate it. Simple easy to understand!!

    ReplyDelete
    Replies
    1. Thanks @wahaj4311 for your kind words. Keep Learning

      Delete
  3. what if I want my custom html pages with apache server ?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. yes you can do by adding in configmap html files path or post pod deploy

      Delete

Latest Posts