Use kubectl
to
daemonset
called dset
quay.io/fluentd_elasticsearch/fluentd:v2.5.2
# create a deployment
kubectl create deployment dset --image=quay.io/fluentd_elasticsearch/fluentd:v2.5.2 --dry-run=client -o yaml > dset.yaml
# edit the yaml to change it from a deployment to daemonset make the below changes
kind: Deployment
change to --> kind: DaemonSet
remove creationTimestamp: null
remove replicas: 1
remove strategy
remove resources
remove status
# so it now looks like this
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: dset
name: dset
spec:
selector:
matchLabels:
app: dset
template:
metadata:
labels:
app: dset
spec:
containers:
- image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
name: fluentd
# apply the file
kubectl apply -f dset.yaml
# check the results - this should show the number of pods = number of nodes and node column shows different nodes
kubectl get pods -o wide -l=app=dset
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
dset-pmrn5 1/1 Running 0 34m 192.168.106.6 k8s-worker2 <none> <none>
dset-tpltj 1/1 Running 0 34m 192.168.104.68 k8s-worker1 <none> <none>
Add a new node to your cluster
what happens with the daemonset?
The daemonset will automatically deploy a pod to the new node, see the doc reference which has the following quote
A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. Deleting a DaemonSet will clean up the Pods it created.