Deploy Lemp Stack on Kubernetes Cluster task failed

There is something completely screwed up with this task evaluation. It has also been marked as incorrect (failed) but all the errors given are wrong!!!

Error output is as follows:

Uh oh! Looks like the task was not completed successfully. But it’s Ok. You can try again next time this task is assigned to you.

Check
Complete
Incomplete

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

You may check your work again to see what went wrong.
The environment expires in 5 minutes.
If you think you did your work correctly and is marked failed,
you may request for a review from your task dashboard.
Or alternatively please take outputs/screenshot of your work
and post in community.kodekloud.com.

You can also view your result in your dashboard under tasks.
You will be assigned your next task within the next few days.


  1. It says webdevops/php-nginx:alpine-3-php7 image is not used, but the task specifies that any nginx image and an image like wordpress:php7.2-fpm can be used

  2. It says that lemp-service doesn’t exist but the task specifies nginx-service

  3. It says that the credentials are hardcoded in the database but this is not correct.
    wp-config.php gets its credentials as follows:

<?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * wp-config.php file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://wordpress.org/support/article/editing-wp-config-php/ * * @package WordPress */ $dbname = $_ENV["MYSQL_DATABASE"]; $dbuser = $_ENV["MYSQL_USER"]; $dbpass = $_ENV["MYSQL_PASSWORD"]; $dbhost = $_ENV["MYSQL_HOST"]; // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', $dbname); /** MySQL database username */ define( 'DB_USER', $dbuser); /** MySQL database password */ define( 'DB_PASSWORD', $dbpass); /** MySQL hostname */ define( 'DB_HOST', $dbhost); <?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * This file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://wordpress.org/support/article/editing-wp-config-php/ * * @package WordPress */ $dbname = $_ENV["MYSQL_DATABASE"]; $dbuser = $_ENV["MYSQL_USER"]; $dbpass = $_ENV["MYSQL_PASSWORD"]; $dbhost = $_ENV["MYSQL_HOST"]; // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', $dbname); /** MySQL database username */ define( 'DB_USER', $dbuser); /** MySQL database password */ define( 'DB_PASSWORD', $dbpass); /** MySQL hostname */ define( 'DB_HOST', $dbhost); .... 4. It says the websit is not up and accessible, but it was.

@ulihorn , Hi. all my objects are created properly, Although the page that loads is just index.php the default on the wordpress. What am I missin for the wordpress db to load?
Can you help me? I tried a lot, but not sure where I am going wrong. @Inderpreet Can you help please as well?

Cant attach the file here. Pasting the whole thing.
I created a .env file in the /var/www/html/ location and referenced it in the wp-config file.

kubectl create secret generic mysql-root-pass --from-literal=password=R00t
kubectl create secret generic mysql-user-pass --from-literal=username=kodekloud_tim, --from-literal=password=BruCStnMT5
kubectl create secret generic mysql-db-url --from-literal=database=kodekloud_db4
kubectl create secret generic mysql-host --from-literal=host=mysql-service

DB_NAME=kodekloud_db4
DB_USER=root
DB_PASSWORD=R00t
DB_HOST=mysql-service
WP_DEBUG=true

apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
nginx.conf: |
events {}
http {
server {
listen 80;
server_name localhost;
root /var/www/html/;

      # Point index to the Laravel front controller.
      index index.html index.htm index.php;

      location / {
      # URLs to attempt, including pretty ones.
       try_files   $uri $uri/ /index.php?$query_string;
      }
    }
  }

apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx:latest
name: nginx
ports:
- containerPort: 80
volumeMounts:
- name: html
mountPath: /var/www/html
- name: nginx-config
mountPath: /etc/nginx/
- image: wordpress:php7.2-fpm
name: phpfpm
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_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-user-pass
key: password
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-root-pass
key: password
- name: MYSQL_HOST
valueFrom:
secretKeyRef:
name: mysql-host
key: host
volumeMounts:
- name: html
mountPath: /var/www/html
volumes:
- name: html
emptyDir: {}
- name: nginx-config
configMap:
name: nginx-config
items:
- key: nginx.conf
path: nginx.conf


apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
ports:

  • targetPort: 80
    port: 80
    nodePort: 30008
    type: NodePort
    selector:
    app: nginx

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
labels:
app: mysql-deployment
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi

apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /home/thor/

apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: mysql-deployment
name: mysql-deployment
spec:
replicas: 1
selector:
matchLabels:
app: mysql-deployment
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: mysql-deployment
spec:
containers:
- image: mysql:5.6
name: mysql
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-pv
mountPath: /var/lib/mysql
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_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-user-pass
key: password
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-root-pass
key: password
- name: MYSQL_HOST
valueFrom:
secretKeyRef:
name: mysql-host
key: host
volumes:
- name: mysql-pv
persistentVolumeClaim:
claimName: mysql-pv-claim

apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
ports:

  • targetPort: 3306
    port: 3306
    selector:
    app: mysql-deployment

did you load the db.sql file inside your mysql container with mysql -u root -p kodekloud_db4 < db.sql?

Yes I did @ulihorn . still getting the same thing

I have same problem.

My yml

Website button worked correctly.