|
| 1 | +# Updating self-managed worker nodes using autopilot for HCP |
| 2 | + |
| 3 | +In hybrid control plane (HCP) setups, the Kubernetes control plane runs inside pods, while worker nodes are self-managed and connect remotely. Keeping both the control plane and worker nodes up to date is essential for security and compatibility. |
| 4 | + |
| 5 | + |
| 6 | +This guide demonstrates how to use the autopilot feature to update self-managed worker nodes after the control plane has been upgraded. |
| 7 | + |
| 8 | +!!! note |
| 9 | + Everything described in this article is applicable to and all commands are run in the workload cluster. |
| 10 | + |
| 11 | +## Update the control plane |
| 12 | + |
| 13 | +First, update the control plane to the desired k0s version by modifying the `Cluster` resource: |
| 14 | + |
| 15 | +```yaml |
| 16 | +apiVersion: k0smotron.io/v1beta1 |
| 17 | +kind: Cluster |
| 18 | +metadata: |
| 19 | + name: k0smotron-test |
| 20 | +spec: |
| 21 | + replicas: 1 |
| 22 | + k0sImage: quay.io/k0sproject/k0s |
| 23 | + version: v1.33.1-k0s.0 # new k0s version |
| 24 | +``` |
| 25 | +
|
| 26 | +!!! warning |
| 27 | + Always update the control plane components first before updating the worker nodes. |
| 28 | + Refer to the [Kubernetes version skew policy](https://kubernetes.io/releases/version-skew-policy/). |
| 29 | +
|
| 30 | +## Update self-managed worker nodes using autopilot |
| 31 | +
|
| 32 | +Autopilot is the easiest way to update self-managed worker nodes. |
| 33 | +
|
| 34 | +Read more about [k0s autopilot configuration](https://docs.k0sproject.io/stable/autopilot/#configuration). |
| 35 | +
|
| 36 | +!!! warning |
| 37 | + The Plan name should always be "autopilot" and the Plan resource is immutable. To make changes, remove old Plan and create a new one with a different `spec.id`. |
| 38 | + |
| 39 | +!!! note |
| 40 | + The `selector` field in the `discovery` section can be adjusted to target specific nodes based on labels. An empty selector `{}` targets all worker nodes. |
| 41 | + To target specific nodes, use a `static` discovery like `discovery: { "static": ["node-name1", "node-name2"] }`. |
| 42 | + |
| 43 | +!!! note |
| 44 | + `get.k0sproject.io` is a simple proxy service to the GitHub release assets. GitHub CDN may answer with a 403 error for automated downloads, so using `get.k0sproject.io` helps avoid this issue. |
| 45 | + `https://get.k0sproject.io/v1.33.1+k0s.0/k0s-v1.33.1+k0s.0-amd64` will proxy to `https://github.com/k0sproject/k0s/releases/download/v1.33.1+k0s.0/k0s-v1.33.1+k0s.0-amd64`. |
| 46 | + |
| 47 | +Create a `Plan` resource that specifies the desired k0s version and targets the worker nodes: |
| 48 | + |
| 49 | +```yaml |
| 50 | +apiVersion: autopilot.k0sproject.io/v1beta2 |
| 51 | +kind: Plan |
| 52 | +metadata: |
| 53 | + name: autopilot |
| 54 | +spec: |
| 55 | + id: id123 # Unique ID for the plan |
| 56 | + timestamp: now |
| 57 | + commands: |
| 58 | + - k0supdate: |
| 59 | + version: v1.33.1+k0s.0 # Target k0s version |
| 60 | + platforms: |
| 61 | + linux-amd64: |
| 62 | + url: https://get.k0sproject.io/v1.33.1+k0s.0/k0s-v1.33.1+k0s.0-amd64 |
| 63 | + linux-arm64: |
| 64 | + url: https://get.k0sproject.io/v1.33.1+k0s.0/k0s-v1.33.1+k0s.0-arm64 |
| 65 | + targets: |
| 66 | + # We target only workers, since we updated control planes using the Cluster object |
| 67 | + workers: |
| 68 | + discovery: |
| 69 | + selector: {} # Select all worker nodes |
| 70 | +``` |
| 71 | + |
| 72 | +Autopilot will automatically apply the update to the selected worker nodes. |
0 commit comments