Updating and Scaling DaemonSet Workloads
Kubernetes DaemonSet provides built-in support for updating and scaling your system-level workloads. In this section, we'll explore the processes involved in updating and scaling DaemonSet applications.
Updating DaemonSet Workloads
DaemonSet supports rolling updates, which allow you to update the container image or configuration of the pods without disrupting the running workloads. To update a DaemonSet, you can modify the YAML manifest and apply the changes using the kubectl apply
command:
kubectl apply -f updated-daemonset.yaml
Kubernetes will then perform a rolling update, ensuring that new pods are deployed and old pods are gradually terminated, maintaining the desired state of the DaemonSet.
You can monitor the progress of the rolling update using the following command:
kubectl rollout status daemonset example-daemonset
This command will display the status of the rolling update, including any errors or warnings that may occur during the update process.
Scaling DaemonSet Workloads
Unlike Deployments or ReplicaSets, DaemonSets do not have a replicas
field, as they are designed to run one pod per eligible node. However, you can control the nodes on which the DaemonSet pods are scheduled by using node selectors.
To scale a DaemonSet, you can modify the node selector in the YAML manifest and apply the changes:
spec:
selector:
matchLabels:
app: example-daemonset
template:
metadata:
labels:
app: example-daemonset
spec:
nodeSelector:
node-type: worker
containers:
- name: example-container
image: example/image:latest
In this example, the DaemonSet is configured to run on nodes with the node-type=worker
label. You can add or remove labels from nodes to control the scheduling of DaemonSet pods.
After updating the YAML manifest, apply the changes using kubectl apply
:
kubectl apply -f updated-daemonset.yaml
Kubernetes will then ensure that the DaemonSet pods are scheduled on the appropriate nodes based on the updated node selector.
By understanding the processes for updating and scaling DaemonSet workloads, you can effectively manage and maintain your system-level services in your Kubernetes environment.