Skip to content

Commit ce936de

Browse files
committed
seamless upgrades cli flag + kubeletplugin yaml accounts for updateStrategy values
1 parent 9bd686f commit ce936de

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

cmd/dra-example-kubeletplugin/driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func NewDriver(ctx context.Context, config *Config) (*driver, error) {
6161
kubeletplugin.PluginDataDirectoryPath(config.DriverPluginPath()),
6262
}
6363

64-
// Enable seamless upgrades when POD_UID is available (which gets set by Helm when seamlessUpgrades.enabled=true)
65-
if config.flags.podUID != "" {
64+
// Enable seamless upgrades when both seamless upgrades are enabled and POD_UID is available
65+
if config.flags.seamlessUpgrades && config.flags.podUID != "" {
6666
kubeletPluginOptions = append(kubeletPluginOptions,
6767
kubeletplugin.RollingUpdate(types.UID(config.flags.podUID)),
6868
)

cmd/dra-example-kubeletplugin/health.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func startHealthcheck(ctx context.Context, config *Config) (*healthcheck, error)
6464
regSockPath := (&url.URL{
6565
Scheme: "unix",
6666
Path: func() string {
67-
if config.flags.podUID != "" {
67+
if config.flags.seamlessUpgrades && config.flags.podUID != "" {
6868
return path.Join(config.flags.kubeletRegistrarDirectoryPath, consts.DriverName+"-"+config.flags.podUID+"-reg.sock")
6969
}
7070
return path.Join(config.flags.kubeletRegistrarDirectoryPath, consts.DriverName+"-reg.sock")
@@ -82,7 +82,7 @@ func startHealthcheck(ctx context.Context, config *Config) (*healthcheck, error)
8282
draSockPath := (&url.URL{
8383
Scheme: "unix",
8484
Path: func() string {
85-
if config.flags.podUID != "" {
85+
if config.flags.seamlessUpgrades && config.flags.podUID != "" {
8686
return path.Join(config.DriverPluginPath(), "dra-"+config.flags.podUID+".sock")
8787
}
8888
return path.Join(config.DriverPluginPath(), "dra.sock")

cmd/dra-example-kubeletplugin/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Flags struct {
5050
kubeletPluginsDirectoryPath string
5151
healthcheckPort int
5252
podUID string
53+
seamlessUpgrades bool
5354
}
5455

5556
type Config struct {
@@ -122,6 +123,12 @@ func newApp() *cli.App {
122123
Destination: &flags.podUID,
123124
EnvVars: []string{"POD_UID"},
124125
},
126+
&cli.BoolFlag{
127+
Name: "seamless-upgrades",
128+
Usage: "Enable seamless upgrades support. When enabled, the driver will use rolling update mode if pod-uid is available.",
129+
Destination: &flags.seamlessUpgrades,
130+
EnvVars: []string{"SEAMLESS_UPGRADES"},
131+
},
125132
}
126133
cliFlags = append(cliFlags, flags.kubeClientConfig.Flags()...)
127134
cliFlags = append(cliFlags, flags.loggingConfig.Flags()...)

deployments/helm/dra-example-driver/templates/kubeletplugin.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ spec:
1212
matchLabels:
1313
{{- include "dra-example-driver.selectorLabels" . | nindent 6 }}
1414
app.kubernetes.io/component: kubeletplugin
15+
{{- with .Values.kubeletPlugin.updateStrategy }}
16+
updateStrategy:
17+
{{- toYaml . | nindent 4 }}
18+
{{- else }}
1519
{{- if .Values.kubeletPlugin.seamlessUpgrades.enabled }}
1620
updateStrategy:
1721
type: RollingUpdate
1822
rollingUpdate:
1923
maxSurge: 1
2024
maxUnavailable: 0
21-
{{- else }}
22-
{{- with .Values.kubeletPlugin.updateStrategy }}
23-
updateStrategy:
24-
{{- toYaml . | nindent 4 }}
2525
{{- end }}
2626
{{- end }}
2727
template:
@@ -88,11 +88,13 @@ spec:
8888
- name: HEALTHCHECK_PORT
8989
value: {{ .Values.kubeletPlugin.containers.plugin.healthcheckPort | quote }}
9090
{{- end }}
91-
{{- if .Values.kubeletPlugin.seamlessUpgrades.enabled }}
9291
- name: POD_UID
9392
valueFrom:
9493
fieldRef:
9594
fieldPath: metadata.uid
95+
{{- if .Values.kubeletPlugin.seamlessUpgrades.enabled }}
96+
- name: SEAMLESS_UPGRADES
97+
value: "true"
9698
{{- end }}
9799
volumeMounts:
98100
- name: plugins-registry

0 commit comments

Comments
 (0)