Skip to content

Lab1 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
spec:
containers:
- name: www
image: nginx:1.21-alpine
Terminal window
kubectl apply -f web.yml

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.17
command: ["sleep","3600"]
Terminal window
kubectl apply -f debug.yml

Se connecter sur le pod debug et faire un curl sur l’IP du pod web

Terminal window
kubectl exec -it debug -- sh
apk add curl
curl <IP WEB>

Troisième Pod

Créer un pod nommé all basé sur 2 conteneurs (nginx et alpine)

Terminal window
vi all.yml
apiVersion: v1
kind: Pod
metadata:
name: all
spec:
containers:
- name: www
image: nginx:1.21-alpine
- name: debug
image: alpine:3.17
command: ["sleep","3600"]
Terminal window
kubectl apply -f all.yml

Se connecter sur le pod all dans le conteneur alpine et faire un curl sur l’IP localhost

Terminal window
kubectl exec -it all -c debug -- sh
apk add curl
curl 127.0.0.1