DeamonSets
Desarrollo del tema
La presente guía aborda la creacion y uso del componente DeamonSet de Kubernetes.
Laboratorio: DeamonSets
Descripción
La presente guía aborda la creacion y uso del componente DeamonSet de Kubernetes.
Objetivos
- Crear un DeamonSet a partir de un archivo YAML
- Administrar un DeamonSet con sus diferentes operaciones
Antes de comenzar
- Contar con el acceso al ambiente de laboratorio
Conexión hacia cluster
-
Ingrese al cluster asignado con las credenciales proporcionadas
-
Obtenga el archivo kubeconfig posicionando sobre la carpeta a trabajar y cambiando su nombre a config
mv /path/to/kubeconfig ~/.kube/config -
Configure la variable
KUBECONFIGexport KUBECONFIG=~/.kube/config -
Verifique el acceso mediante comandos
kubectl get namespaces kubectl config set-context --current --namespace=userx
Inicio de laboratorio
-
Cree un archivo llamado
daemonset.yamlcon el siguiente contenido:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
apiVersion: apps/v1 kind: DaemonSet metadata: name: prometheus-daemonset namespace: userx labels: app: prometheus-daemonset spec: selector: matchLabels: app: prometheus-daemonset template: metadata: labels: app: prometheus-daemonset -
Agregue el bloque de
specenspec.templatecon un bloque decontainers1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
apiVersion: apps/v1 kind: DaemonSet metadata: name: prometheus-daemonset namespace: userx labels: app: prometheus-daemonset spec: selector: matchLabels: app: prometheus-daemonset template: metadata: labels: app: prometheus-daemonset spec: containers: -
Agregue al bloque de
containersuna lista de un contenedor de nombreprometheusy la imagenprom/node-exporter1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
apiVersion: apps/v1 kind: DaemonSet metadata: name: prometheus-daemonset namespace: userx labels: app: prometheus-daemonset spec: selector: matchLabels: app: prometheus-daemonset template: metadata: labels: app: prometheus-daemonset spec: containers: - name: prometheus image: prom/node-exporter ports: - containerPort: 80 -
Valide la sintaxis
yq e daemonset.yaml -
Levante el recurso
kubectl apply -f daemonset.yaml -
Revise los daemonsets en el namespace
kubectl get daemonsets -
Obtenga información del daemonset
prometheus-daemonsetkubectl describe daemonset prometheus-daemonset -
Revise los pods en el namespace
kubectl get pods -
Revise la inforamción del pod
# Cambiar nombre-pod por el nombre real del Pod kubectl describe pod nombre-pod -
Limpie el ambiente
kubectl delete -f daemonset.yaml