diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/default/manager_metrics_patch.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/default/manager_metrics_patch.yaml index ee197d3f718..4cc88a79951 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/default/manager_metrics_patch.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/default/manager_metrics_patch.yaml @@ -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" diff --git a/docs/book/src/getting-started/testdata/project/config/default/manager_metrics_patch.yaml b/docs/book/src/getting-started/testdata/project/config/default/manager_metrics_patch.yaml index ee197d3f718..4cc88a79951 100644 --- a/docs/book/src/getting-started/testdata/project/config/default/manager_metrics_patch.yaml +++ b/docs/book/src/getting-started/testdata/project/config/default/manager_metrics_patch.yaml @@ -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" diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/enable_matrics_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/enable_matrics_patch.go index 768950bbf04..a7cb55ef602 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/enable_matrics_patch.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/enable_matrics_patch.go @@ -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" ` diff --git a/test/e2e/v4/plugin_cluster_test.go b/test/e2e/v4/plugin_cluster_test.go index 6c3fcddda18..cd2520eb671 100644 --- a/test/e2e/v4/plugin_cluster_test.go +++ b/test/e2e/v4/plugin_cluster_test.go @@ -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) diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/default/manager_metrics_patch.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/default/manager_metrics_patch.yaml index ee197d3f718..4cc88a79951 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/default/manager_metrics_patch.yaml +++ b/testdata/project-v4-multigroup-with-deploy-image/config/default/manager_metrics_patch.yaml @@ -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" diff --git a/testdata/project-v4-multigroup/config/default/manager_metrics_patch.yaml b/testdata/project-v4-multigroup/config/default/manager_metrics_patch.yaml index ee197d3f718..4cc88a79951 100644 --- a/testdata/project-v4-multigroup/config/default/manager_metrics_patch.yaml +++ b/testdata/project-v4-multigroup/config/default/manager_metrics_patch.yaml @@ -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" diff --git a/testdata/project-v4-with-deploy-image/config/default/manager_metrics_patch.yaml b/testdata/project-v4-with-deploy-image/config/default/manager_metrics_patch.yaml index ee197d3f718..4cc88a79951 100644 --- a/testdata/project-v4-with-deploy-image/config/default/manager_metrics_patch.yaml +++ b/testdata/project-v4-with-deploy-image/config/default/manager_metrics_patch.yaml @@ -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" diff --git a/testdata/project-v4-with-grafana/config/default/manager_metrics_patch.yaml b/testdata/project-v4-with-grafana/config/default/manager_metrics_patch.yaml index ee197d3f718..4cc88a79951 100644 --- a/testdata/project-v4-with-grafana/config/default/manager_metrics_patch.yaml +++ b/testdata/project-v4-with-grafana/config/default/manager_metrics_patch.yaml @@ -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" diff --git a/testdata/project-v4/config/default/manager_metrics_patch.yaml b/testdata/project-v4/config/default/manager_metrics_patch.yaml index ee197d3f718..4cc88a79951 100644 --- a/testdata/project-v4/config/default/manager_metrics_patch.yaml +++ b/testdata/project-v4/config/default/manager_metrics_patch.yaml @@ -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"