lib/resourcemerge: sync daemonset container env vars
Sync env var changes in the daemonset definition, so injected proxy
env var updates will get applied upon an upgrade.
@@ -99,6 +99,23 @@ func ensureContainer(modified *bool, existing *corev1.Container, required corev1
setStringIfSet(modified, &existing.WorkingDir, required.WorkingDir)
+ // also sync the env vars here, added to handle proxy
+ for _, required := range required.Env {
+ var existingCurr *corev1.EnvVar
+ for j, curr := range existing.Env {
+ if curr.Name == required.Name {
+ existingCurr = &existing.Env[j]
+ break
+ }
+ }
+ if existingCurr == nil {
+ *modified = true
+ existing.Env = append(existing.Env, corev1.EnvVar{})
+ existingCurr = &existing.Env[len(existing.Env)-1]
+ }
+ ensureEnvVar(modified, existingCurr, required)
+ }
+
// any port we specify, we require
for _, required := range required.Ports {
var existingCurr *corev1.ContainerPort
@@ -177,6 +194,13 @@ func ensureContainerPort(modified *bool, existing *corev1.ContainerPort, require
}
}
+func ensureEnvVar(modified *bool, existing *corev1.EnvVar, required corev1.EnvVar) {
+ if !equality.Semantic.DeepEqual(required, *existing) {
+ *modified = true
+ *existing = required
+ }
+}
+
func ensureVolumeMount(modified *bool, existing *corev1.VolumeMount, required corev1.VolumeMount) {
if !equality.Semantic.DeepEqual(required, *existing) {
*modified = true
