Skip to content

Commit

Permalink
fix: preserve existing flags when applying metrics patch
Browse files Browse the repository at this point in the history
Ensure that enabling the manager_metrics_patch.yaml in config/default/kustomization.yaml does not overwrite existing arguments in config/manager/manager.yaml. The patch now appends the --metrics-bind-address argument without replacing other arguments.

More info: #3934
  • Loading branch information
camilamacedo86 committed May 20, 2024
1 parent 4f0e2c3 commit 1855c9e
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ spec:
containers:
- name: manager
args:
- "--metrics-bind-address=0.0.0.0:8080"
- --metrics-bind-address=0.0.0.0:8080
# We need to keep the same args
# provided in the manager.
# More info: https://github.com/kubernetes-sigs/kubebuilder/issues/3934
- --leader-elect
- --health-probe-bind-address=:8081"
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ spec:
containers:
- name: manager
args:
- "--metrics-bind-address=0.0.0.0:8080"
- --metrics-bind-address=0.0.0.0:8080
# We need to keep the same args
# provided in the manager.
# More info: https://github.com/kubernetes-sigs/kubebuilder/issues/3934
- --leader-elect
- --health-probe-bind-address=:8081"
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@ spec:
containers:
- name: manager
args:
- "--metrics-bind-address=0.0.0.0:8080"
- --metrics-bind-address=0.0.0.0:8080
# We need to keep the same args
# provided in the manager.
# More info: https://github.com/kubernetes-sigs/kubebuilder/issues/3934
- --leader-elect
- --health-probe-bind-address=:8081"
`
14 changes: 14 additions & 0 deletions test/e2e/v4/plugin_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ func Run(kbc *utils.TestContext, hasWebhook, isToUseInstaller, hasMetrics bool)
}()
EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed())

By("Checking if all flags are applied to the manager pod")

// Get the manager pod details
podOutput, err := kbc.Kubectl.Get(
true,
"pod", controllerPodName,
"-o", "jsonpath={.spec.containers[0].args}",
)
ExpectWithOffset(1, err).NotTo(HaveOccurred())
ExpectWithOffset(1, podOutput).To(ContainSubstring("--leader-elect"),
"Expected manager pod to have --leader-elect flag")
ExpectWithOffset(1, podOutput).To(ContainSubstring("--health-probe-bind-address=:8081"),
"Expected manager pod to have --health-probe-bind-address flag")

By("validating the metrics endpoint")
_ = curlMetrics(kbc, hasMetrics)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ spec:
containers:
- name: manager
args:
- "--metrics-bind-address=0.0.0.0:8080"
- --metrics-bind-address=0.0.0.0:8080
# We need to keep the same args
# provided in the manager.
# More info: https://github.com/kubernetes-sigs/kubebuilder/issues/3934
- --leader-elect
- --health-probe-bind-address=:8081"
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ spec:
containers:
- name: manager
args:
- "--metrics-bind-address=0.0.0.0:8080"
- --metrics-bind-address=0.0.0.0:8080
# We need to keep the same args
# provided in the manager.
# More info: https://github.com/kubernetes-sigs/kubebuilder/issues/3934
- --leader-elect
- --health-probe-bind-address=:8081"
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ spec:
containers:
- name: manager
args:
- "--metrics-bind-address=0.0.0.0:8080"
- --metrics-bind-address=0.0.0.0:8080
# We need to keep the same args
# provided in the manager.
# More info: https://github.com/kubernetes-sigs/kubebuilder/issues/3934
- --leader-elect
- --health-probe-bind-address=:8081"
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ spec:
containers:
- name: manager
args:
- "--metrics-bind-address=0.0.0.0:8080"
- --metrics-bind-address=0.0.0.0:8080
# We need to keep the same args
# provided in the manager.
# More info: https://github.com/kubernetes-sigs/kubebuilder/issues/3934
- --leader-elect
- --health-probe-bind-address=:8081"
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ spec:
containers:
- name: manager
args:
- "--metrics-bind-address=0.0.0.0:8080"
- --metrics-bind-address=0.0.0.0:8080
# We need to keep the same args
# provided in the manager.
# More info: https://github.com/kubernetes-sigs/kubebuilder/issues/3934
- --leader-elect
- --health-probe-bind-address=:8081"

0 comments on commit 1855c9e

Please sign in to comment.