#######Question : 14#######
We want to deploy a python based application on the cluster using a template located at /root/olive-app-cka10-str.yaml on student-node. However, before you proceed we need to make some modifications to the YAML file as per details given below:
The YAML should also contain a persistent volume claim with name olive-pvc-cka10-str to claim a 100Mi of storage from olive-pv-cka10-str PV.
Update the deployment to add a sidecar container, which can use busybox image (you might need to add a sleep command for this container to keep it running.)
Share the python-data volume with this container and mount the same at path /usr/src. Make sure this container only has read permissions on this volume.
Finally, create a pod using this YAML and make sure the POD is in Running state.
Note: Additionally, you can expose a NodePort service for the application. The service should be named olive-svc-cka10-str and expose port 5000 with a nodePort value of 32006.
However, inclusion/exclusion of this service won’t affect the validation for this task.
#####################
######## Updated Manifests file ########
#####olive-app-cka10-str.yaml#####
##################################
apiVersion: apps/v1
kind: Deployment
metadata:
name: olive-app-cka10-str
spec:
replicas: 1
template:
metadata:
labels:
app: olive-app-cka10-str
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cluster1-node01
containers:
- name: python
image: poroko/flask-demo-app
ports:
- containerPort: 5000
volumeMounts:
- name: python-data
mountPath: /usr/share/
- name: sidecontainer
image: busybox
command: ["/bin/sh"]
args: ["-c", "sleep 3600"]
volumeMounts:
- name: python-data
mountPath: /usr/src
readOnly: true
volumes:
- name: python-data
persistentVolumeClaim:
claimName: olive-pvc-cka10-str
selector:
matchLabels:
app: olive-app-cka10-str
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: olive-pvc-cka10-str
spec:
storageClassName: olive-stc-cka10-str
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
##############
#####DOUBT#######
After exam evaluvation the resources created after updaing the above provided manifest file is shown as wrong . Please check and help to figure out what was wrong in this ?
#####DOUBT#######
Hi Abhilash Mudavakkat,
I don’t see the Service resource in your YAML. Did you forget to create it or mention it in the feedback?
Hi @raymond.baoly
I did create the service for testing the app but through a seperate manifest file . But the question has not specified the service creation as a mandatory requirement .
However, inclusion/exclusion of this service won’t affect the validation for this task. ``
Hi
It looks like the YAML file is missing the PersistentVolume olive-pv-cka10-str
. You can define it using volumeName: olive-pv-cka10-str
. Here’s the requirement from the question:
The YAML should include a PersistentVolumeClaim named olive-pvc-cka10-str
that requests 100Mi
of storage from the olive-pv-cka10-str
PersistentVolume.
1 Like
Hi,
@raymond.baoly
Thank you for your response! I’ll add the missing volumeName: olive-pv-cka10-str
in the next attempt and confirm if it resolves the issue. I really appreciate your help!
Hi,
@raymond.baoly
apiVersion: apps/v1
kind: Deployment
metadata:
name: olive-app-cka10-str
spec:
replicas: 1
template:
metadata:
labels:
app: olive-app-cka10-str
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cluster1-node01
containers:
- name: python
image: poroko/flask-demo-app
ports:
- containerPort: 5000
volumeMounts:
- name: python-data
mountPath: /usr/share/
- name: sidecar
image: busybox
command: ['/bin/sh', '-c', 'sleep 1800']
volumeMounts:
- name: python-data
mountPath: /usr/src/
readOnly: true
volumes:
- name: python-data
persistentVolumeClaim:
claimName: olive-pvc-cka10-str
selector:
matchLabels:
app: olive-app-cka10-str
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: olive-pvc-cka10-str
spec:
volumeName: olive-pv-cka10-str
storageClassName: olive-stc-cka10-str
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
---
apiVersion: v1
kind: Service
metadata:
name: olive-svc-cka10-str
spec:
type: NodePort
selector:
app: olive-app-cka10-str
ports:
- port: 5000
targetPort: 5000
nodePort: 32006
In my next attempt for the same question the above provided manifest was used and still the solution is marked as failed during evaluation . Is this a problem related to the grading or is there anything else to be fixed in this manifest ? Could you please check and confirm ?
Hi,
I just checked, and it’s working properly on my end. You can see the screenshot below, and here’s the /root/olive-app-cka10-str.yaml file.
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: olive-pvc-cka10-str
spec:
accessModes:
- ReadWriteMany
storageClassName: olive-stc-cka10-str
volumeName: olive-pv-cka10-str
resources:
requests:
storage: 100Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: olive-app-cka10-str
spec:
replicas: 1
template:
metadata:
labels:
app: olive-app-cka10-str
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cluster1-node01
containers:
- name: python
image: poroko/flask-demo-app
ports:
- containerPort: 5000
volumeMounts:
- name: python-data
mountPath: /usr/share/
- name: busybox
image: busybox
command:
- "bin/sh"
- "-c"
- "sleep 10000"
volumeMounts:
- name: python-data
mountPath: "/usr/src"
readOnly: true
volumes:
- name: python-data
persistentVolumeClaim:
claimName: olive-pvc-cka10-str
selector:
matchLabels:
app: olive-app-cka10-str
---
apiVersion: v1
kind: Service
metadata:
name: olive-svc-cka10-str
spec:
type: NodePort
ports:
- port: 5000
nodePort: 32006
selector:
app: olive-app-cka10-str