@@ -38,22 +38,67 @@ Below is example Plan in development for [k3OS](https://github.com/rancher/k3os)
38
38
---
39
39
apiVersion: upgrade.cattle.io/v1
40
40
kind: Plan
41
+
41
42
metadata:
43
+ # This `name` should be short but descriptive.
42
44
name: k3os-latest
45
+
46
+ # The same `namespace` as is used for the system-upgrade-controller Deployment.
43
47
namespace: k3os-system
48
+
44
49
spec:
50
+ # The maximum number of concurrent nodes to apply this update on.
45
51
concurrency: 1
52
+
53
+ # The value for `channel` is assumed to be a URL that returns HTTP 302 with the last path element of the value
54
+ # returned in the Location header assumed to be an image tag.
55
+ # SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/upgrade/plan/plan.go#L177
46
56
channel: https://github.com/rancher/k3os/releases/latest
47
- version: v0.9.0-dev
57
+
58
+ # Providing a value for `version` will prevent polling/resolution of the `channel` if specified.
59
+ # version: v0.9.0-dev
60
+
61
+ # Select which nodes this plan can be applied to.
48
62
nodeSelector:
49
63
matchExpressions:
64
+ # This limits application of this upgrade only to nodes that have opted in by applying this label.
65
+ # Additionally, a value of `disabled` for this label on a node will cause the controller to skip over the node.
66
+ # SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/upgrade/plan/plan.go#L216
67
+ # NOTICE THAT THE NAME PORTION OF THIS LABEL MATCHES THE PLAN NAME. This is related to the fact that the
68
+ # system-upgrade-controller will tag the node with this very label having the value of the applied version.
69
+ # SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/upgrade/plan/plan.go#L112-L115
50
70
- {key: plan.upgrade.cattle.io/k3os-latest, operator: Exists}
71
+ # This label is set by k3OS, therefore a node without it should not apply this upgrade.
72
+ - {key: k3os.io/mode, operator: Exists}
73
+ # Additionally, do not attempt to upgrade nodes booted from "live" CDROM.
51
74
- {key: k3os.io/mode, operator: NotIn, values: ["live"]}
75
+
76
+ # The service account for the pod to use. As with normal pods, if not specified the `default` service account from the namespace will be assigned.
77
+ # See https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
78
+ serviceAccountName: k3os-upgrade
79
+
80
+ # The prepare init container is run before cordon/drain which is run before the upgrade container.
81
+ # Shares the same format as the `upgrade` container
82
+ # prepare:
83
+ # image: alpine:3.11
84
+ # command: [sh, -c]
85
+ # args: [" echo '### ENV ###'; env | sort; echo '### RUN ###'; find /run/system-upgrade | sort"]
86
+ # SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/apis/upgrade.cattle.io/v1/types.go#L58
87
+
88
+ # See https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/#use-kubectl-drain-to-remove-a-node-from-service
52
89
drain:
90
+ # deleteLocalData: true
91
+ # ignoreDaemonSets: true
53
92
force: true
93
+
94
+ # SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/apis/upgrade.cattle.io/v1/types.go#L51
54
95
upgrade:
96
+ # The tag portion of the image will be overridden with the value from `.status.latestVersion` a.k.a. the resolved version.
97
+ # SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/apis/upgrade.cattle.io/v1/types.go#L47
55
98
image: rancher/k3os
56
99
command: [k3os, --debug]
100
+ # It is safe to specify `--kernel` on overlay installations as the destination path will not exist and so the
101
+ # upgrade of the kernel component will be skipped (with a warning in the log).
57
102
args:
58
103
- upgrade
59
104
- --kernel
@@ -66,22 +111,6 @@ spec:
66
111
- --destination=/host/k3os/system
67
112
```
68
113
69
- This plan specifies via ` concurrency ` that only one node at a time in the cluster can be applying this plan.
70
- It specifies a ` channel ` URL that should adhere to the simple contract exhibited by Github latest release browser URLs
71
- which is to simply return an HTTP 302 with Location header pointing to the latest release tag. The controller will attempt to
72
- resolve ` channel ` URL redirects every 15 minutes by default. If, as in this example, the ` version ` is specified then
73
- ` channel ` resolution is skipped and only the specified ` version ` is honored.
74
- To specify which nodes in the cluster are eligible for application of this Plan a ` nodeSelector ` entry must be provided.
75
- The format of ` nodeSelector ` is the same as ` nodeSelectorTerms ` in the ` nodeAffinity ` section of the ` affinity ` spec for
76
- Pods.
77
- Not shown in this example is a ` cordon ` boolean, default ` false ` , that would indicate that ` kubectl cordon ` should be
78
- run against the node prior to invoking the upgrade.
79
- Instead we have a non-nil ` drain ` (which will set the same unscheduleable taint as ` cordon ` ) with parameters
80
- corresponding to those used for ` kubectl drain ` minus the selectors. Additionally, the ` deleteLocalData ` and
81
- ` ignoreDaemonSets ` parameters both default to ` true ` if, as in this example, ` drain ` is specified.
82
- Both the ` drain ` and ` cordon ` ` kubectl ` invocations are run in init containers for the Pod.
83
- Finally, to specify the ` upgrade ` , we have a very truncated container template: ` image ` , ` command ` , and ` args ` .
84
-
85
114
## Building
86
115
` make `
87
116
0 commit comments