Deploy Nginx and Phpfpm on Kubernetes

Ticker

6/recent/ticker-posts

Deploy Nginx and Phpfpm on Kubernetes

Question : The Nautilus Application team is planning to deploy one of the php-based application on Kubernetes cluster. As per discussion with DevOps team they decided to use nginx and phpfpm. Additionally, they shared some custom configuration requirements. Below you can find more details. Please complete the task as per requirements mentioned below:

1.) Create a config map nginx-config for nginx.conf as we want to add some custom settings for nginx.conf.

a) Change default port 80 to 8092 in nginx.conf.

b) Change default document root /usr/share/nginx to /var/www/html in nginx.conf.

c) Update directory index to index index.html index.htm index.php in nginx.conf.

2.) Create a pod named nginx-phpfpm .

b) Create a shared files volume shared-files that will be used by both containers (nginx and phpfpm) also it should be emptyDir: {}

c) Map the ConfigMap we declared above as a volume for the pod. Name the volume as nginx-config-volume

d) Nginx container should be named as nginx-container and it should use nginx:latest image. PhpFPM container should be named as php-fpm-container and it should use php:7.0-fpm image.

e) The shared volume shared-files should be mounted at /var/www/html location in both containers.

f) Add one more volume for nginx-container. Name it as nginx-config-volume, mount path should be /etc/nginx/nginx.conf and subPath should be nginx.conf

Before clicking on finish button always make sure to check if all pods are in running state.

You can use any labels as per your choice.

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  kubectl  utility configure and working from jump server, run below commands

    kubectl get configmap

    kubectl get pods


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 )


3.  Run below command to create pod

    kubectl create -f /tmp/nginx.yaml


4.  Wait for pod running status 

    kubectl get pods


5.  Validate the task by login on pod and run curl
    
    kubectl exec -it nginx-phpfpm -- /bin/bash



6.  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

0 Comments

Latest Posts