Deploy Iron Gallery App on Kubernetes

Shubham K. Sawant
5 min readMar 18, 2024

There is an iron gallery app that the DevOps team was developing. They have recently customized the app and are going to deploy the same on the Kubernetes cluster. Below you can find more details:
Create a namespace iron-namespace-nautilus
Create a deployment iron-gallery-deployment-nautilus for iron gallery under the same namespace you created.
:- Labels run should be iron-gallery.
:- Replicas count should be 1.
:- Selector’s matchLabels run should be iron-gallery.
:- Template labels run should be iron-gallery under metadata.
:- The container should be named as iron-gallery-container-nautilus, use kodekloud/irongallery:2.0 image ( use exact image name / tag ).
:- Resources limits for memory should be 100Mi and for CPU should be 50m.
:- First volumeMount name should be config, its mountPath should be /usr/share/nginx/html/data.
:- Second volumeMount name should be images, its mountPath should be /usr/share/nginx/html/uploads.
:- First volume name should be config and give it emptyDir and second volume name should be images, also give it emptyDir.
Create a deployment iron-db-deployment-nautilus for iron db under the same namespace.
:- Labels db should be mariadb.
:- Replicas count should be 1.
:- Selector’s matchLabels db should be mariadb.
:- Template labels db should be mariadb under metadata.
:- The container name should be iron-db-container-nautilus, use kodekloud/irondb:2.0 image ( use exact image name / tag ).
:- Define environment, set MYSQL_DATABASE its value should be database_host, set MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD value should be with some complex passwords for DB connections, and MYSQL_USER value should be any custom user ( except root ).
:- Volume mount name should be db and its mountPath should be /var/lib/mysql. Volume name should be db and give it an emptyDir.
Create a service for iron db which should be named iron-db-service-nautilus under the same namespace. Configure spec as selector’s db should be mariadb. Protocol should be TCP, port and targetPort should be 3306 and its type should be ClusterIP.
Create a service for iron gallery which should be named iron-gallery-service-nautilus under the same namespace. Configure spec as selector’s run should be iron-gallery. Protocol should be TCP, port and targetPort should be 80, nodePort should be 32678 and its type should be NodePort.
Note:We don’t need to make connection b/w database and front-end now, if the installation page is coming up it should be enough for now.

  1. lets check if we have namespace with command “k get ns” created else we can create the same with command “k create ns iron-namespace-nautilus”

2. At first kubectl utility configure and working on server, run commands “kubectl get all” to check all existing running pods and service , deployment, replicaset details in default namespace.

3. Create yaml file with all the parameters “cat svc.yaml”

---
apiVersion: v1
kind: Service
metadata:
name: iron-gallery-service-nautilus
namespace: iron-namespace-nautilus
spec:
selector:
run: iron-gallery
type: NodePort
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 32678
---
apiVersion: v1
kind: Service
metadata:
name: iron-db-service-nautilus
namespace: iron-namespace-nautilus
spec:
selector:
db: mariadb
type: ClusterIP
ports:
- protocol: TCP
port: 3306
targetPort: 3306

4. Run command to create service “kubectl create -f svc.yaml “

5. lets check the service status “k get all -n iron-namespace-nautilus”

6. Create yaml file with all the parameters “cat deploy-iron-gallery.yaml”

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: iron-gallery-deployment-nautilus
labels:
run : iron-gallery
namespace: iron-namespace-nautilus
spec:
replicas: 1
selector:
matchLabels:
run : iron-gallery
template:
metadata:
labels:
run : iron-gallery
spec:
containers:
- name: iron-gallery-container-nautilus
image: kodekloud/irongallery:2.0
ports:
- containerPort: 80
resources:
limits:
memory: "100Mi"
cpu: "50m"
volumeMounts:
- name: config
mountPath: /usr/share/nginx/html/data
- name: images
mountPath: /usr/share/nginx/html/uploads
volumes:
- name: config
emptyDir: {}
- name: images
emptyDir: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: iron-db-deployment-nautilus
labels:
db: mariadb
namespace: iron-namespace-nautilus
spec:
replicas: 1
selector:
matchLabels:
db: mariadb
template:
metadata:
labels:
db: mariadb
spec:
containers:
- name: iron-db-container-nautilus
image: kodekloud/irondb:2.0
ports:
- containerPort: 3306
env:
- name: MYSQL_DATABASE
value: database_host
- name: MYSQL_ROOT_PASSWORD
value: MYSQL_PASSWORD@123
- name: MYSQL_PASSWORD
value: MYSQL_PASSWORD@123
- name: MYSQL_USER
value: shubhamksawant
volumeMounts:
- name: db
mountPath: /var/lib/mysql
volumes:
- name: db
emptyDir: {}

7. Run command to create deployment using file “kubectl create -f deploy-iron-gallery.yaml “ and check the deployment “k get all -n iron-namespace-nautilus”

8. access check the webpage by adding url in browser “https://nodeip:nodeport”

9. we can check the logs by using command “k logs pod/iron-gallery-deployment-nautilus-656db68668–9xz7j(pod name) -n iron-namespace-nautilus” and “k logs pod/iron-db-deployment-nautilus-5778cd857c-k26px(pod name) -n iron-namespace-nautilus”

Join our DevOps knowledge sharing community with DevOps Knowledge Junction linked group :-
https://www.linkedin.com/groups/9501755/

Reachout to me on linkedin :-https://www.linkedin.com/in/shubhamsawant/

Checkout my work on GitHub :-https://github.com/shubhamksawant/shubhamksawant

--

--

Shubham K. Sawant

Tech enthusiasts #DevOps engineer (newblogpost/week) #KnowledgeSimplified