Ques:
Create a namespace iron-namespace-datacenter
Create a deployment iron-gallery-deployment-datacenter 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-datacenter, 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-datacenter 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-datacenter, use kodekloud/irondb:2.0 image ( use exact image name / tag ).
:- Define environment, set MYSQL_DATABASE its value should be database_blog, 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-datacenter 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-datacenter 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.
The kubectl on jump_host has been configured to work with the kubernetes cluster.
Answer:
thor@jumphost ~$ cat iron-gallery-deployment-xfusion.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: iron-gallery
name: iron-gallery-deployment-xfusion
namespace: iron-namespace-xfusion
spec:
replicas: 1
selector:
matchLabels:
run: iron-gallery
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
run: iron-gallery
spec:
containers:
- image: kodekloud/irongallery:2.0
name: iron-gallery-container-xfusion
resources:
limits:
memory: “100Mi”
cpu: “50m”
volumeMounts:
- name: config
mountPath: “/usr/share/nginx/html/data”
volumeMounts:
- name: images
mountPath: “/usr/share/nginx/html/uploads”
volumes:
- name: config
emptyDir:
volumes:
- name: images
emptyDir:
#################################################################
thor@jumphost ~$ cat iron-db-deployment-xfusion.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
db: mariadb
name: iron-db-deployment-xfusion
namespace: iron-namespace-xfusion
spec:
replicas: 1
selector:
matchLabels:
db: mariadb
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
db: mariadb
spec:
containers:
- image: kodekloud/irondb:2.0
name: iron-db-container-xfusion
env:
- name: MYSQL_DATABASE
value: database_web
- name: MYSQL_ROOT_PASSWORD
value: Algeria@321
- name: MYSQL_PASSWORD
value: Algeria@321
- name: MYSQL_USER
value: udhaya
volumeMounts:
- name: db
mountPath: /var/lib/mysql
volumes:
- name: db
emptyDir: {}
#################################################################
thor@jumphost ~$ cat iron-db-service-xfusion.yaml
apiVersion: v1
kind: Service
metadata:
name: iron-db-service-xfusion
namespace: iron-namespace-xfusion
spec:
ports:
- name: iron-db-service-xfusion
port: 3306
protocol: TCP
targetPort: 3306
selector:
db: mariadb
type: ClusterIP
status:
loadBalancer: {}
#################################################################
thor@jumphost ~$ cat iron-gallery-service-xfusion.yaml
apiVersion: v1
kind: Service
metadata:
name: iron-gallery-service-xfusion
namespace: iron-namespace-xfusion
spec:
ports:
- name: iron-gallery-service-xfusion
port: 80
protocol: TCP
targetPort: 80
nodePort: 32678
selector:
run: iron-gallery
type: NodePort
status:
loadBalancer: {}