Skip to main content

Pregunta 11 - DaemonSet en Todos los Nodos

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 no tiene plantilla, pero podemos usar la del deployment. No es posible pasar las labels a un deploy, es necesario colocarlas 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 # cambiar de Deployment a Daemonset
metadata:
creationTimestamp: null
labels:
# app: ds-important # remover
id: ds-important # agregar
uuid: 18426a0b-5f59-4e10-923f-c0e078e82462 # agregar
name: ds-important
namespace: project-tiger # importante
spec:
#replicas: 1 # remover
selector:
matchLabels:
# app: ds-important # remover
id: ds-important # agregar
uuid: 18426a0b-5f59-4e10-923f-c0e078e82462 # agregar
#strategy: {} # remover
template:
metadata:
creationTimestamp: null
labels:
# app: ds-important # remover
id: ds-important # agregar
uuid: 18426a0b-5f59-4e10-923f-c0e078e82462 # agregar
spec:
containers:
- image: httpd:2.4-alpine
name: ds-important
resources:
requests: # agregar
cpu: 10m # agregar
memory: 10Mi # agregar
# Si va a incluir en el control-plane necesita la toleration para el taint que tiene
tolerations: # agregar
- effect: NoSchedule # agregar
key: node-role.kubernetes.io/control-plane # agregar
status: {} # remover
kubectl apply -f /opt/course/11/daemonset.yaml

# Para verificar si fue a todos los nodos
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

# o
k get pod -n project-tiger -o wide | grep ds-important