In this example we learn how to create a Daemon Service for allowing to run infrastructure-focused Pods on specific nodes.
This examples assumes a Kubernetes installation available. In this case its best played through with Minikube as we need some support for PVs. Check the INSTALL documentation for how to install Minikube.
This example used our random-generator
application for seeding /dev/random
periodically by writing 100000 random number every time to /dev/random
.
To be honest, this a make up example which should never be used for any application as the generated random number are not really random.
Note
|
You could achieve a similar effect with a Periodic Job and and appropriate nodeSelector . However, a Daemon Service is still more safe for such kind of a task, as it also works without changes also for nodes that will be added later.
|
Nevertheless, let’s create a DaemonSet with
kubectl create -f https://k8spatterns.io/DaemonService/daemonset.yml
You can now check the generates pods with
kubectl get pods
You see one Pod per node of your cluster. So for Minikube it should be a single pod and you can check the logs as ususal.