Validation issue Deploy Lemp Stack on Kubernetes Cluster

@rahul456 @Inderpreet @Tej-Singh-Rana @mmumshad @vijin.palazhi

There is an issue with the validation of this task. I have given it for review also.

I got the below:-

wordpress website is not working properly

@nilesh.b.jamale @Inderpreet @rahul456

I was able to successfully complete the task, I was able access the WordPress website but the task was marked failed. Please check and advise.

The website

NGINX on port 80 - Configmap

NGINX service

Thank you.

@Salim As per the question your nginx-service port should be 80, but you have given 9007 which is why it failed the validation error.

Hi @sathish2032, the task asked for the “Nginx Server” to be configured with TCP port 80 and therefore the server will be the Nginx/php-fpm pod and its configuration (Configmap).

The service is exposes the pod to the internet and it is configured with the target port of TCP 80 (targetting the Nginx/php-fpm pod) and the 9007 is the port of the nginx-service for itself to connect and forward the traffics to the Nginx pod.

That’s the way I understood the question.

Thanks for the reply.

@rahul456 can Is it possible you reset this task me? It did not mentioned the service port to be 80. I was able to fix the issues and access the website my friend. :sweat_smile:

@Salim, you will be re-assigned failed/expired tasks in near future.

Okay, thanks @rahul456

when i do the task of fixing issue with lemp stack, the deployment has an pull limit error. can you check?

Failed to pull image “wordpress:php7.2-fpm”: rpc error: code = Unknown desc = Error response from daemon: toomanyrequests: You have reached your pull rate limit. You mayincrease the limit by authenticating and upgrading: Understanding Your Docker Hub Rate Limit | Docker

@rahul456 @Tej-Singh-Rana

FastCGI sent in stderr: “fastcgi://127.0.0.1:9000” nginx-wp-dp-6fd799f7cb-mlk6z

I received the above message today for this task after 10 tries, which means I can ping mysql container from nginx, but I can’t ping nginx from mysql. This means that nginx-service is unreachable. After consulting google, the issue lies in file permissions!!! I wonder how fellow engineers pass this task without facing this issue.

Please advice.

@rahul456 @Tej-Singh-Rana

I’m sure that is something wrong with this task

kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-config
data:
  nginx.conf: |

    events {
    }

    http {
      server {
        listen 80 default_server;
        listen [::]:80 default_server;
        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_index index.php;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        fastcgi_param REQUEST_METHOD \$request_method;
        }
      }
    }

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nginx-pv
  labels:
    app: nginx-volume
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: standard
  hostPath:
    path: "/mnt/data"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nginx-pv-claim
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: standard
  resources:
    requests:
      storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-wp-dp 
  labels:
    app: app
spec:
  selector:
    matchLabels:
      app: app
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
      - name: nginx-container
        image: nginx:latest
        env:
        - name: MYSQL_DATABASE
          valueFrom:
            secretKeyRef:
              name: mysql-db-url
              key: database
        - name: MYSQL_USER
          valueFrom:
            secretKeyRef:
              name: mysql-user-pass
              key: username
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-root-pass
              key: password
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-user-pass
              key: password
        - name: MYSQL_HOST
          valueFrom:
            secretKeyRef:
              name: mysql-host
              key: host
        volumeMounts:
        - name: shared-files
          mountPath: /var/www/html
        - name: nginx-config-volume
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
      - name: php-fpm-container
        image: wordpress:php7.2-fpm
        env:
        - name: MYSQL_DATABASE
          valueFrom:
            secretKeyRef:
              name: mysql-db-url
              key: database
        - name: MYSQL_USER
          valueFrom:
            secretKeyRef:
              name: mysql-user-pass
              key: username
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-root-pass
              key: password
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-user-pass
              key: password
        - name: MYSQL_HOST
          valueFrom:
            secretKeyRef:
              name: mysql-host
              key: host
        volumeMounts:
        - name: shared-files
          mountPath: /var/www/html
      volumes:
      - name: nginx-persistent-storage
        persistentVolumeClaim:
          claimName: nginx-pv-claim
      - name: shared-files
        emptyDir: {}
      - name: nginx-config-volume
        configMap:
          name: nginx-config
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
    app: app
spec:
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30008
  type: LoadBalancer
  selector:
    app: app
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-pv
  labels:
    app: mysql-volume
spec:
  capacity:
    storage: 5Gi
  accessModes:
  - ReadWriteOnce
  storageClassName: standard
  hostPath:
    path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: standard
  resources:
    requests:
      storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-deployment
  labels:
    app: mysql-server
spec:
  selector:
    matchLabels:
      app: mysql-server
  strategy:
    type: Recreate
  template:
    metadata:
    labels:
      app: mysql-server
  spec:
    containers:
    - name: mysql-container
      image: mysql:5.6
      env:
      - name: MYSQL_DATABASE
        valueFrom:
          secretKeyRef:
            name: mysql-db-url
            key: database
      - name: MYSQL_USER
        valueFrom:
          secretKeyRef:
            name: mysql-user-pass
            key: username
      - name: MYSQL_ROOT_PASSWORD
        valueFrom:
          secretKeyRef:
            name: mysql-root-pass
            key: password
      - name: MYSQL_PASSWORD
        valueFrom:
          secretKeyRef:
            name: mysql-user-pass
            key: password
      - name: MYSQL_HOST
        valueFrom:
           secretKeyRef:
             name: mysql-host
             key: host
      ports:
      - containerPort: 3306
        name: mysql
      volumeMounts:
      - name: mysql-persistent-storage
        mountPath: /var/lib/mysql
    volumes:
    - name: mysql-persistent-storage
      persistentVolumeClaim:
        claimName: mysql-pv-claim
---
apiVersion: v1
kind: Service
metadata:
  name: mysql-service
  labels:
    app: mysql
spec:
  ports:
  - port: 3306
    targetPort: 3306
  clusterIP: None
  selector:
    app: mysql-server

@Devops, can you please share your KKE user details ?

@rahul456

KKE: ismail
[email protected]

@Devops, this is marked success for you.

1 Like

hello@rahul456
I had a similar issue which i raised but there was no resolution with review and community also.

@rahul456
This task has a validation issue which was raised many times.

@nilesh.b.jamale, sorry for the issue, this is marked success for you.

@rahul456 Thanks for the response

Hi I also got the same problem.
I managed to deploy the wordpress but task was marked as failed.

Please see the confirmation screenshot that illustrates
that the wordpress was properly deployed:
a) top of the wordpress page

b) bottom of the wordpress page

I stored the source code for this
task in the repository if you need to check it:

I tried to repeat the lab but the validation is still wrong. Could you please help me?

Please find the confirmation related to the incorrect behaviour below:

  1. related to the image
    Screenshot by Lightshot

  2. related to the environment variables:
    Screenshot by Lightshot

  3. related to the service name:
    task: Create a node port type service for nginx deployment which should be named as nginx-service [NGINX-SERVICE]

validation error (lemp-service)

  1. Website is available on the requested port
    Screenshot by Lightshot

  2. Values are not hardcoded to the php file
    Screenshot by Lightshot

THIS SOLUTION IS WRONGGGGGGGGGGGGGGGGGGGGGGGG!!!

WHOEVER SET THIS TASK UP, CHECK YOUR WORK|!!!

Uh! Oh! Looks like you might have missed something. The details are below. Don’t worry. No pressure! You will get another attempt at this task in the future.

webdevops/php-nginx:alpine-3-php7 image is not used

Service ‘lemp-service’ doesn’t exist

Mysql database is hardcoded in ‘index.php’

Mysql user is hard coded in ‘index.php’

Mysql password is hard coded in ‘index.php’

Mysql HOST is hard coded in ‘index.php’

website is not up and accessible

If you think you did it right and we checked it wrong, please post your comments at community.kodekloud.com