In question 11, my answer is as follows:
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"]
args: ["-c", "sleep 100000"]
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
This is pretty identical to the answer give as the solution:
---
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
I also checked the the pods were running, pvcs were bound, etc… after applying. However my answer was marked wrong. Any ideas as to why? Thanks!