Skip to content

Commit

Permalink
Set OperatorPolicy default namespace option
Browse files Browse the repository at this point in the history
This sets the command-line flag added by the companion PR
open-cluster-management-io/config-policy-controller#204

This only sets that flag when the managed cluster is using OpenShift v4.
It should be noted that this flag is *not* currently configurable by the
user (it is not for example exposed through an annotation).

Refs:
 - https://issues.redhat.com/browse/ACM-9896

Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
  • Loading branch information
JustinKuli committed Feb 15, 2024
1 parent 3699932 commit ac67b97
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/addon/configpolicy/agent_addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ func getValues(cluster *clusterv1.ManagedCluster,
// Disable OperatorPolicy if the cluster is not on OpenShift version 4.y
userValues.OperatorPolicy["disabled"] = cluster.Labels["openshiftVersion-major"] != "4"

// Set the default namespace for OperatorPolicy for OpenShift 4
if cluster.Labels["openshiftVersion-major"] == "4" {
userValues.OperatorPolicy["default-namespace"] = "openshift-operators"
}

annotations := addon.GetAnnotations()

if val, ok := annotations[policyaddon.PolicyLogLevelAnnotation]; ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ spec:
{{- end }}
{{- if not .Values.operatorPolicy.disabled }}
- --enable-operator-policy=true
- --operator-policy-default-namespace={{ .Values.operatorPolicy.defaultNamespace }}
{{- end }}
env:
- name: WATCH_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ spec:
type: string
type: object
type: array
required:
- relatedObjects
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ hubKubeConfigSecret: config-policy-controller-hub-kubeconfig

operatorPolicy:
disabled: false
defaultNamespace: ""

resources:
requests:
Expand Down
1 change: 1 addition & 0 deletions test/e2e/case2_config_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ var _ = Describe("Test config-policy-controller deployment", Ordered, func() {
g.Expect(args).To(ContainElement("--client-max-qps=50"))
g.Expect(args).To(ContainElement("--leader-elect=false"))
g.Expect(args).To(ContainElement("--enable-operator-policy=true"))
g.Expect(args).To(ContainElement("--operator-policy-default-namespace=openshift-operators"))
}
}
}, 180, 10).Should(Succeed())
Expand Down

0 comments on commit ac67b97

Please sign in to comment.