Has anybody done “Deploy Lamp Stack on Kubernetes Cluster” task. its a 1200 point task and has very confusing instructions. The thing that is not clear to me in the statement “Please do not hardcode DB Credentials in any configuration file”. In this case it is wp-config.php file. When you setup the wordpress pod/container and setup a few env variables such as WORDPRESS_DB_HOST, WORDPRESS_DB_PASSWORD, those values are store in the wp-config.php when the container spins ups. Any ideas how the connection to the mysql-service be achieved without placing DB credentials in the wp-config.phi file
The Nautilus DevOps team want to deploy a WordPress website on Kubernetes cluster. They are going to use Apache as a web server and Mysql for database. The team had already gathered the requirements and now they want to make this website live. Below you can find more details:
Create a persistent volume named lamp-pv, storage class must be standard, storage capacity must be 750Mi, access mode must be ReadWriteOnce, it must be of type hostPath, path must be /mnt/data and persistentVolumeReclaimPolicy must be Retain.
Create a persistent volume claim named lamp-pv-claim , storage class name must be standard, access mode must be ReadWriteOnce and resources requests storage must be 550Mi
Create a deployment named lamp-wp, use labels for the deployment app must be lamp, tier should be frontend. Further strategy type must be Recreate.
Create two containers under it. httpd-php-wp-container from image wordpress:php7.4-apache and mysql-container from image mysql:5.6.
Volume must be mounted on both containers name: lamp-persistent-storage mountPath: /var/www/html.
Create some secrets for mysql.
a) Create secret for mysql-root-pass
name: password and value: R00t
b) Create secret for mysql-user-pass
name: username, value: kodekloud_rin and name: password, value: TmPcZjtRQx
c) Create secret for mysql-db-url
name: database and value: kodekloud_db5
d) Create secret for mysql-host
name: host and value: mysql-service
Add some environment variables for both containers:
a) name: MYSQL_ROOT_PASSWORD and take it value from secret key reference name: mysql-root-pass and key: password
b) name: MYSQL_DATABASE and take it value from secret key reference name: mysql-db-url and key: database
c) name: MYSQL_USER, and take it value from secret key reference name: mysql-user-pass and key: username
d) name: MYSQL_PASSWORD and take it value from secret key reference name: mysql-user-pass and key: password
e ) name: MYSQL_HOST and take it value from secret key reference name: mysql-host and key: host
Create a service for lamp named lamp-service, port must be 80, nodePort must be 30008 and its type must be LoadBalancer
Create a service for mysql named mysql-service and its port must be 3306.
We already have a sql dump under /tmp/db.sql on jump_host server.
a) import the db.sql dump to the database which you are created in mysql-container.
b) Configure wordpress to make it work with the mysql db.
c) You must be able to run pre-configured WordPress website on node port 30008 at the end.
Please do not hardcode DB credentials in any configuration file.
The kubectl utility on jump_host has been configured to work with the kubernetes cluster.