Fix issue with PhpFpm Application Deployed on Kubernetes

Ticker

6/recent/ticker-posts

Fix issue with PhpFpm Application Deployed on Kubernetes

 Question :  We deployed an Nginx and PHPFPM based application on Kubernetes cluster last week and it had been working fine. This morning one of the team members was troubleshooting an issue with this stack and he was supposed to run Nginx welcome page for now on this stack till issue with phpfpm is fixed but he made a change somewhere which caused some issue and the application stopped working. Please look into the issue and fix the same:

The deployment name is nginx-phpfpm-dp and service name is nginx-service. Figure out the issues and fix them. FYI Nginx is configured to use default http port, node port is 30008 and copy index.php under /tmp/index.php to deployment under /var/www/html. Please do not try to delete/modify any other existing components like deployment name, service name etc.

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 that might differ. So please read the task carefully before executing it. 
All the Best 👍
Solution:  

1. Check existing running pods 

thor@jump_host ~$ kubectl get pods

NAME                               READY   STATUS    RESTARTS   AGE

nginx-phpfpm-dp-5cccd45499-57z9d   2/2     Running   0          94s

thor@jump_host ~$ 

 2. check the shared volume path in the existing config map 

thor@jump_host ~$ kubectl get configmap

NAME               DATA   AGE

kube-root-ca.crt   1      42m

nginx-config       1      5m51s

thor@jump_host ~$

thor@jump_host ~$ kubectl describe configmap nginx-config

Name:         nginx-config

Namespace:    default

Labels:       <none>

Annotations:  <none>

 

Data

====

nginx.conf:

----

events {

}

http {

  server {

    listen 80 default_server;

    listen [::]:80 default_server;

 

    # Set nginx to serve files from the shared volume!

    root /var/www/html;

    index  index.html index.htm index.php;

    server_name _;

    location / {

      try_files $uri $uri/ =404;

    }

    location ~ \.php$ {

      include fastcgi_params;

      fastcgi_param REQUEST_METHOD $request_method;

      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

      fastcgi_pass 127.0.0.1:9000;

    }

  }

}

 Events:  <none>

thor@jump_host ~$

3. Check the Services port to identify the error 

thor@jump_host ~$ kubectl get services

NAME            TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE

kubernetes      ClusterIP      10.96.0.1       <none>        443/TCP          35m

nginx-service   LoadBalancer   10.96.250.183   <pending>     8093:30008/TCP   7m48s

thor@jump_host ~$

thor@jump_host ~$ kubectl describe services

Name:              kubernetes

Namespace:         default

Labels:            component=apiserver

                   provider=kubernetes

Annotations:       <none>

Selector:          <none>

Type:              ClusterIP

IP:                10.96.0.1

Port:              https  443/TCP

TargetPort:        6443/TCP

Endpoints:         172.18.0.2:6443

Session Affinity:  None

Events:            <none>

Name:                     nginx-service

Namespace:                default

Labels:                   app=nginx-fpm

Annotations:              <none>

Selector:                 app=nginx-fpm,tier=frontend

Type:                     LoadBalancer

IP:                       10.96.250.183

Port:                     <unset>  8093/TCP

TargetPort:               8093/TCP

NodePort:                 <unset>  30008/TCP

Endpoints:                10.244.0.5:8093

Session Affinity:         None

External Traffic Policy:  Cluster

Events:                   <none>

thor@jump_host ~$

4. Kindly refer to the below video for the Configuration part

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