Deploy Iron Gallery App on Kubernetes Kodekloud



Solution:

In the Jump Host Create a namespace mentioned in the question

kubectl create ns iron-namespace-datacenter

Create the following deployments and services of app and db

vi app.yml

apiVersion: apps/v1
kind: Deployment
metadata:
name: iron-gallery-deployment-datacenter
namespace: iron-namespace-datacenter
labels:
run: iron-gallery
spec:
replicas: 1
selector:
matchLabels:
run: iron-gallery
template:
metadata:
labels:
run: iron-gallery
spec:
volumes:
- name: config
emptyDir: {}
- name: images
emptyDir: {}
containers:
- name: iron-gallery-container-datacenter
image: kodekloud/irongallery:2.0
volumeMounts:
- name: config
mountPath: /usr/share/nginx/html/data
- name: images
mountPath: /usr/share/nginx/html/uploads
resources:
limits:
memory: "100Mi"
cpu: "50m"


 

vi db.yml 


apiVersion: apps/v1
kind: Deployment
metadata:
name: iron-db-deployment-datacenter
namespace: iron-namespace-datacenter
labels:
db: mariadb
spec:
replicas: 1
selector:
matchLabels:
db: mariadb
template:
metadata:
labels:
db: mariadb
spec:
volumes:
- name: db
emptyDir: {}
containers:
- name: iron-db-container-datacenter
image: kodekloud/irondb:2.0
env:
- name: MYSQL_DATABASE
value: database_blog
- name: MYSQL_ROOT_PASSWORD
- name: MYSQL_PASSWORD
- name: MYSQL_USER
value: kodekloud
volumeMounts:
- name: db
mountPath: /var/lib/mysql


 

vi app-service.yml 

apiVersion: v1
kind: Service
metadata:
name: iron-gallery-service-datacenter
namespace: iron-namespace-datacenter
spec:
type: NodePort
selector:
run: iron-gallery
ports:
- port: 80
targetPort: 80
nodePort: 32678

 

vi db-service.yml  

apiVersion: v1
kind: Service
metadata:
name: iron-db-service-datacenter
namespace: iron-namespace-datacenter
spec:
type: ClusterIP
selector:
db: mariadb
ports:
- port: 3306
targetPort: 3306

Then apply all yml configurations

kubectl apply -f . 

Inspect the service

kubectl get svc -n iron-namespace-datacenter

curl -Ik http://IP_Address

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment