Questão 11 - DaemonSet em Todos os Nós
Question 11 | DaemonSet on all Nodes
Use context: kubectl config use-context k8s-c1-H
Use Namespace project-tiger for the following. Create a DaemonSet named ds-important with image httpd:2.4-alpine and labels id=ds-important and uuid=18426a0b-5f59-4e10-923f-c0e078e82462. The Pods it creates should request 10 millicore cpu and 10 mebibyte memory. The Pods of that DaemonSet should run on all nodes, also controlplanes.
# Daemonset não tem template, mas podemos usar do deployment. Não é possível passar as labels para um deploy, é necessário colocar manualmente.
k create deployment -n project-tiger --image=httpd:2.4-alpine ds-important --dry-run=client -o yaml > /opt/course/11/daemonset.yaml
vim /opt/course/11/daemonset.yaml
#/opt/course/11/daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet # change from Deployment to Daemonset
metadata:
creationTimestamp: null
labels:
# app: ds-important # remove
id: ds-important # add
uuid: 18426a0b-5f59-4e10-923f-c0e078e82462 # add
name: ds-important
namespace: project-tiger # important
spec:
#replicas: 1 # remove
selector:
matchLabels:
# app: ds-important # remove
id: ds-important # add
uuid: 18426a0b-5f59-4e10-923f-c0e078e82462 # add
#strategy: {} # remove
template:
metadata:
creationTimestamp: null
labels:
# app: ds-important # remove
id: ds-important # add
uuid: 18426a0b-5f59-4e10-923f-c0e078e82462 # add
spec:
containers:
- image: httpd:2.4-alpine
name: ds-important
resources:
requests: # add
cpu: 10m # add
memory: 10Mi # add
#Se irá incluir no control-plane precisa da toleration para a taint que ele tem
tolerations: # add
- effect: NoSchedule # add
key: node-role.kubernetes.io/control-plane # add
status: {} # remove
kubectl apply -f /opt/course/11/daemonset.yaml
# Para conferir se foi para todos os nodes
k get pod -n project-tiger -l id=ds-important -o wide
NAME READY STATUS NODE
ds-important-6pvgm 1/1 Running ... cluster1-node1
ds-important-lh5ts 1/1 Running ... cluster1-controlplane1
ds-important-qhjcq 1/1 Running ... cluster1-node2
#ou
k get pod -n project-tiger -o wide | grep ds-important