Skip to content

Commit e96042e

Browse files
committed
Manage the addon namespace for OpenShift monitoring configuration
Previously, only non-default namespace would get the openshift.io/cluster-monitoring label if Prometheus was enabled and it was OpenShift. Now this also gets set on the default namespace name. Relates: https://issues.redhat.com/browse/ACM-7675 https://issues.redhat.com/browse/ACM-7633 Signed-off-by: mprahl <[email protected]>
1 parent 21c01f0 commit e96042e

File tree

4 files changed

+15
-26
lines changed

4 files changed

+15
-26
lines changed
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# Copyright Contributors to the Open Cluster Management project
2-
3-
{{- if ne .Release.Namespace "open-cluster-management-agent-addon" }}
42
apiVersion: v1
53
kind: Namespace
64
metadata:
75
name: {{ .Release.Namespace }}
86
labels:
7+
{{- if ne .Release.Namespace "open-cluster-management-agent-addon" }}
98
addon.open-cluster-management.io/namespace: "true"
109
addon.open-cluster-management.io/hosted-manifest-location: hosting
10+
{{- end }}
1111
{{- if and .Values.prometheus.enabled (eq .Values.kubernetesDistribution "OpenShift") }}
1212
openshift.io/cluster-monitoring: "true"
1313
{{- end }}
14-
{{- if eq (.Release.Namespace | trimPrefix "klusterlet-") .Values.clusterName }}
14+
{{- if or (eq .Release.Namespace "open-cluster-management-agent-addon") (eq (.Release.Namespace | trimPrefix "klusterlet-") .Values.clusterName) }}
1515
annotations:
1616
"addon.open-cluster-management.io/deletion-orphan": ""
1717
{{- end }}
18-
{{- end }}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# Copyright Contributors to the Open Cluster Management project
2-
3-
{{- if ne .Release.Namespace "open-cluster-management-agent-addon" }}
42
apiVersion: v1
53
kind: Namespace
64
metadata:
75
name: {{ .Release.Namespace }}
86
labels:
7+
{{- if ne .Release.Namespace "open-cluster-management-agent-addon" }}
98
addon.open-cluster-management.io/namespace: "true"
109
addon.open-cluster-management.io/hosted-manifest-location: hosting
10+
{{- end }}
1111
{{- if and .Values.prometheus.enabled (eq .Values.kubernetesDistribution "OpenShift") }}
1212
openshift.io/cluster-monitoring: "true"
1313
{{- end }}
14-
{{- if eq (.Release.Namespace | trimPrefix "klusterlet-") .Values.clusterName }}
14+
{{- if or (eq .Release.Namespace "open-cluster-management-agent-addon") (eq (.Release.Namespace | trimPrefix "klusterlet-") .Values.clusterName) }}
1515
annotations:
1616
"addon.open-cluster-management.io/deletion-orphan": ""
1717
{{- end }}
18-
{{- end }}

test/e2e/case2_config_deployment_test.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ import (
1616
)
1717

1818
const (
19-
case2ManagedClusterAddOnName string = "config-policy-controller"
20-
case2ManagedClusterAddOnCR string = "../resources/config_policy_addon_cr.yaml"
21-
case2ManagedClusterCustomNsAddOnCR string = "../resources/config_policy_addon_custom_ns.yaml"
22-
case2ClusterManagementAddOnCR string = "../resources/config_policy_clustermanagementaddon.yaml"
23-
case2DeploymentName string = "config-policy-controller"
24-
case2PodSelector string = "app=config-policy-controller"
25-
case2OpenShiftClusterClaim string = "../resources/openshift_cluster_claim.yaml"
26-
policyCrdName string = "policies.policy.open-cluster-management.io"
27-
deletionOrphanAnnotationKey string = "addon.open-cluster-management.io/deletion-orphan"
19+
case2ManagedClusterAddOnName string = "config-policy-controller"
20+
case2ManagedClusterAddOnCR string = "../resources/config_policy_addon_cr.yaml"
21+
case2ClusterManagementAddOnCR string = "../resources/config_policy_clustermanagementaddon.yaml"
22+
case2DeploymentName string = "config-policy-controller"
23+
case2PodSelector string = "app=config-policy-controller"
24+
case2OpenShiftClusterClaim string = "../resources/openshift_cluster_claim.yaml"
25+
policyCrdName string = "policies.policy.open-cluster-management.io"
26+
deletionOrphanAnnotationKey string = "addon.open-cluster-management.io/deletion-orphan"
2827
)
2928

3029
func verifyConfigPolicyDeployment(
@@ -406,8 +405,6 @@ var _ = Describe("Test config-policy-controller deployment", func() {
406405
It("should create a config-policy-controller deployment with metrics monitoring on OpenShift clusters", func() {
407406
Expect(managedClusterList).ToNot(BeEmpty())
408407
hubClient := managedClusterList[0].clusterClient
409-
// A custom namespace is used to see if the openshift.io/cluster-monitoring label is set.
410-
addonNamespace := "e2e-test-config-policy-controller"
411408

412409
for i, cluster := range managedClusterList {
413410
logPrefix := cluster.clusterType + " " + cluster.clusterName + ": "
@@ -446,7 +443,7 @@ var _ = Describe("Test config-policy-controller deployment", func() {
446443
// The status doesn't need to be checked on the deployment because the deployment requires a cert that
447444
// is auto-generated by OpenShift, which won't be present.
448445
By(logPrefix + "deploying the default config-policy-controller managedclusteraddon")
449-
Kubectl("apply", "-n", cluster.clusterName, "-f", case2ManagedClusterCustomNsAddOnCR)
446+
Kubectl("apply", "-n", cluster.clusterName, "-f", case2ManagedClusterAddOnCR)
450447
deploy := GetWithTimeout(
451448
cluster.clusterClient, gvrDeployment, case2DeploymentName, addonNamespace, true, 30,
452449
)

test/resources/config_policy_addon_custom_ns.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)