Skip to content

Lab2 Scheduler solution

Premier Pod

Créer un pod nommé web basé sur une image nginx

Terminal window
vi web.yml
apiVersion: v1
kind: Pod
metadata:
name: web
labels:
app: web
spec:
containers:
- name: www
image: nginx:1.19-alpine
nodeSelector:
disktype: ssd

Appliquer les spécifications

Terminal window
kubectl apply -f web.yml

Visualiser le résultat

Terminal window
kubectl get pods -o wide --show-labels

Deuxième PoD

Créer un pod nommé debug basé sur une image alpine

Terminal window
vi debug.yml
apiVersion: v1
kind: Pod
metadata:
name: debug
spec:
containers:
- name: debug
image: alpine:3.12
command: ["sleep","3600"]
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- web
topologyKey: kubernetes.io/hostname

Appliquer les spécifications

Terminal window
kubectl apply -f debug.yml

Visualiser le résultat

Terminal window
kubectl get pods -o wide --show-labels

Worker

Créer sur un worker un Label disktype=ssd

Terminal window
vi host13.yml
apiVersion: v1
kind: Node
metadata:
labels:
disktype: ssd
name: host13

Appliquer la spécification

Terminal window
kubectl apply -f host13.yml

Remarquer que le status des pods nginx et alpine est Running

Terminal window
kubectl get pods -o wide --show-labels