- Here is a video tutorial; continue reading for a list of written instructions.
Exercises to complete:
- Create pods with Alpine and Ubuntu images.
- Use the watch command to watch the changes live.
- Check the architecture of machine Kubernetes runs on.
- Use multiarch image.
- Get into the container.
- Create a pod with Ubuntu image through yaml file with sleep command.
- Apply the YAML file.
- Observe changes.
- Set the Kubernetes policy.
Create pods with Alpine and Ubuntu images
1
2
|
kubectl run alpine --image=alpine
kubectl run ubuntu --image=ubuntu
|
Use the watch command to watch the changes live.
Check the architecture of machine Kubernetes runs on
Use multiarch image
1
|
kubectl run multiarch --image=nginx:alpine
|
Get into the container
1
2
|
kubectl exec --help
kubectl exec -it multiarch -- /bin/ash
|
or
1
|
kubectl exec -it multiarch -- /bin/ash
|
Create a pod with Ubuntu image through yaml file with sleep command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleep
namespace: default
spec:
containers:
- name: ubuntu
image: ubuntu
command:
- sleep
- "60"
resources:
limits:
memory: "600Mi"
requests:
memory: "100Mi"
|
Apply the YAML file.
1
|
kubectl apply -f pod.yaml
|
Use the watch command to watch the changes live.
You will observe that pod with container are restarting. This is not a solution.
Set the Kubernetes policy
1
2
|
kubectl run ubuntu-no-restart --image=ubuntu --restart=Never
kubectl run ubuntu-on-failure --image=ubuntu --restart=OnFailure
|
By default Kubernetes policy restarts always the pod.
Use the watch command to watch the changes live.
Pods have status completed, but there are no running containers inside pods.