Day 0#30daysofK8s
Making any changes to an existing pod requires recreating it, making any change to deployments can be done just by editing them deployment yaml and applying the changes.
DaemonSet — it’s like a replicaset but it ensures that all/some nodes run a certain copy of node.
If a node is added to the cluster, pods are added to the node, if the node is destroyed, the pods are garbage collected from them.
DaemonSet can be used for creating pods that do (node) monitoring or logging or work as an agent for some service or kube-proxy which is required by every node so that it can communicate with other nodes. It requires to select nodes to deploy the pods on, so it does so by using node selection or node affinity or taints & tolerations or any.
It’s config file is same as that of ReplicaSet, except the kind
field.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: elasticsearch
spec:
template:
metadata:
labels:
name: fluentd-elasticsearch
spec:
containers:
- image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
name: fluentd
selector:
matchLabels:
name: fluentd-elasticsearch
k get daemonsets -A
gets daemonsets in all the namespaces.
k describe daemonset elasticsearch --n=kube-system
gets elasticsearch daemon from the kube-system namespace, it won’t work without the -n
flag.
To do a string in the directory run grep "kind: Pod" *
where “kind: Pod” is the string and * points to all the files in the directory.
Static Pods: They run within the node and provisioned by the kubelet of the node. A mirror of the pod can be seen from outside it’s node but not be edited/deleted. It can only be deleted/edited by making change to it’s definition file that resides inside the manifest path.
To find the path Check systemctl status kubelet.service
and look for -
1) --pod-manifest-path
which will have all the static pod definition files
2) --config
which points to a config file and look for staticPodPath
in the config which will point to static pod definition files.
Create a static pod —
kubectl run — restart=Never — image=busybox:1.28.4 static-busybox — dry-run=client -o yaml — command — sleep 1000 > /etc/kubernetes/manifests/static-busybox.yaml
Or create a pod-def.yaml inside the manifest folder.
These static pods can be used by the k8s control plane(node) to keep a definitional file for all it’s component such as etcd, kube-apiserver, kube-scheduler inside the manifest folder so that it does not need to rely on services or binaries in case they crash, it can simply restart the service.
etcd, kube-apiserver, kube-controller are pods in the kube-system namespace by default.(?)