Files
Kubernetes/Cluster_admin/nodes_update_commands.md
T

113 lines
2.9 KiB
Markdown

# OS package update runbook for Hetzner cluster nodes
Order: **master first, then workers, ONE NODE AT A TIME.**
Verify each node is `Ready` before uncordoning and before moving to the next.
Replace `<node>` with: `master-4gb-hel1-2` | `ubuntu-4gb-hel1-docker` | `woker-1-8gb-hel1-1`
## Per-node sequence
1. From your admin machine: cordon + drain the node so workloads migrate
```bash
kubectl drain <node> --ignore-daemonsets --delete-emptydir-data
```
2. Confirm drain finished (pods gone, node marked `SchedulingDisabled`)
```bash
kubectl get nodes
kubectl get pods -A --field-selector spec.nodeName=<node> --watch
```
3. SSH into the node
```bash
ssh <node>
```
4. Inside the node: update OS packages
```bash
sudo apt update && sudo apt upgrade -y
sudo apt autoremove -y
```
5. (Optional) check what needs a reboot; usually kernel/glibc upgrades do
```bash
cat /var/run/reboot-required 2>/dev/null || echo "no reboot required"
```
6. Reboot the node to apply kernel updates
```bash
sudo reboot
```
7. Wait for the node to come back, then from your admin machine verify it's `Ready`
```bash
kubectl get nodes -w
# Wait for: <node> Ready <role> <age> <version>
```
8. Uncordon the node so it accepts pods again
```bash
kubectl uncordon <node>
```
9. Verify workloads re-scheduled and healthy
```bash
kubectl get pods -A --field-selector spec.nodeName=<node>
kubectl get nodes
```
## Full sequence
### master-4gb-hel1-2
```bash
kubectl drain master-4gb-hel1-2 --ignore-daemonsets --delete-emptydir-data
# ssh master-4gb-hel1-2 -> sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
# sudo reboot
# (wait for Ready)
kubectl uncordon master-4gb-hel1-2
```
### ubuntu-4gb-hel1-docker
```bash
kubectl drain ubuntu-4gb-hel1-docker --ignore-daemonsets --delete-emptydir-data
# ssh ubuntu-4gb-hel1-docker -> sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
# sudo reboot
# (wait for Ready)
kubectl uncordon ubuntu-4gb-hel1-docker
```
### woker-1-8gb-hel1-1
```bash
kubectl drain woker-1-8gb-hel1-1 --ignore-daemonsets --delete-emptydir-data
# ssh woker-1-8gb-hel1-1 -> sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
# sudo reboot
# (wait for Ready)
kubectl uncordon woker-1-8gb-hel1-1
```
## Notes
- Do **NOT** upgrade `kubelet`/`kubeadm`/`kubectl` via apt without following the
upstream kubeadm cluster-upgrade procedure first. Pin those packages:
```bash
sudo apt-mark hold kubelet kubeadm kubectl kubernetes-cni
```
Or check the held state with: `apt-mark showhold`
- If a kernel update is **not** in the upgrade set and you want to skip the
reboot, skip step 6 and go straight to uncordon after `apt upgrade`.
- Hetzner CSI/Cilium DaemonSets stay running during drain
(`--ignore-daemonsets`); that's expected and safe.