Skip to content

Commit f19a864

Browse files
committed
Merge branch 'owls-120737' into 'main'
Correct Helm chart usage of enableClusterRoleBinding See merge request weblogic-cloud/weblogic-kubernetes-operator!4868 (cherry picked from commit f88e424) 382bed5 Correct usage of cluster roles 4be70c7 Work in progress 582b921 Merge remote-tracking branch 'origin/main' into owls-120737 e27d172 Merge remote-tracking branch 'origin/main' into owls-120737 6e51178 Merge remote-tracking branch 'origin/main' into owls-120737 422280c Work in progress 03e4fc6 Work in progress 35027b8 Test passing dbd928f Merge remote-tracking branch 'origin/main' into owls-120737 217b81d Corrections
1 parent 089332f commit f19a864

12 files changed

+32
-31
lines changed

kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-domain-admin.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.operatorClusterRoleDomainAdmin" }}

kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-general.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.operatorClusterRoleGeneral" }}

kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-namespace.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.operatorClusterRoleNamespace" }}

kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-operator-admin.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.operatorClusterRoleOperatorAdmin" }}

kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-general.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.clusterRoleBindingGeneral" }}

kubernetes/charts/weblogic-operator/templates/_operator-rolebinding-namespace.tpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.operatorRoleBindingNamespace" }}
55
---
6-
{{- if and (or .enableClusterRoleBinding (not (hasKey . "enableClusterRoleBinding"))) (ne .domainNamespaceSelectionStrategy "Dedicated") }}
6+
{{- $useClusterRole := and (or .enableClusterRoleBinding (not (hasKey . "enableClusterRoleBinding"))) (not (eq .domainNamespaceSelectionStrategy "Dedicated")) }}
7+
{{- if $useClusterRole }}
78
kind: "ClusterRoleBinding"
89
{{- else }}
910
kind: "RoleBinding"
1011
{{- end }}
1112
apiVersion: "rbac.authorization.k8s.io/v1"
1213
metadata:
13-
{{- if and (or .enableClusterRoleBinding (not (hasKey . "enableClusterRoleBinding"))) (ne .domainNamespaceSelectionStrategy "Dedicated") }}
14+
{{- if $useClusterRole }}
1415
name: {{ list .Release.Namespace "weblogic-operator-clusterrolebinding-namespace" | join "-" | quote }}
1516
{{- else }}
1617
name: "weblogic-operator-rolebinding-namespace"

kubernetes/charts/weblogic-operator/templates/_operator.tpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- if and (not (empty .Capabilities.APIVersions)) (not (.Capabilities.APIVersions.Has "policy/v1")) }}
@@ -28,9 +28,10 @@
2828
{{- include "operator.operatorInternalService" . }}
2929
{{- include "operator.operatorExternalService" . }}
3030
{{- include "operator.operatorWebhookExternalService" . }}
31-
{{- if or (not .enableClusterRoleBinding) (eq .domainNamespaceSelectionStrategy "Dedicated") }}
32-
{{- include "operator.domainNamespaces" . }}
33-
{{- else }}
31+
{{- $useClusterRole := and (or .enableClusterRoleBinding (not (hasKey . "enableClusterRoleBinding"))) (not (eq .domainNamespaceSelectionStrategy "Dedicated")) }}
32+
{{- if $useClusterRole }}
3433
{{- include "operator.operatorRoleBindingNamespace" . }}
34+
{{- else }}
35+
{{- include "operator.domainNamespaces" . }}
3536
{{- end }}
3637
{{- end }}

kubernetes/charts/weblogic-operator/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ domainNamespaceSelectionStrategy: LabelSelector
4848

4949
# enableClusterRoleBinding specifies whether the roles necessary for the operator to manage domains
5050
# will be granted using a ClusterRoleBinding rather than using RoleBindings in each managed namespace.
51-
# If not specified, the default is true unless 'domainNamespaceSelectionStrategy' is 'Dedicated, in which
51+
# If not specified, the default is true unless 'domainNamespaceSelectionStrategy' is 'Dedicated', in which
5252
# case this value is ignored as all resources will be created in the namespace where the operator is deployed.
53+
# If `enableClusterRoleBinding` is false but `domainNamespaceSelectionStrategy` is not `Dedicated` then
54+
# ClusterRoleBindings will still be created to allow the operator to manage the CRDs and to list namespaces.
55+
# No ClusterRoles or ClusterRoleBindings will be created when `enableClusterRoleBinding` is false and
56+
# `domainNamespaceSelectionStrategy` is `Dedicated`.
5357
#
5458
enableClusterRoleBinding: true
5559

kubernetes/src/test/java/oracle/kubernetes/operator/create/CreateOperatorGeneratedFilesTestBase.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -651,20 +651,16 @@ private V1ClusterRole getExpectedWeblogicOperatorNamespaceRole() {
651651

652652
@Test
653653
void generatesCorrect_domainNamespaces_weblogicOperatorRoleBindings() {
654-
for (String domainNamespace : getInputs().getDomainNamespaces().split(",")) {
655-
String namespace = domainNamespace.trim();
656-
assertThat(
657-
getGeneratedFiles().getWeblogicOperatorRoleBinding(namespace),
658-
equalTo(getExpectedWeblogicOperatorRoleBinding(namespace)));
659-
}
654+
assertThat(
655+
getGeneratedFiles().getWeblogicOperatorClusterRoleBinding(),
656+
equalTo(getExpectedWeblogicOperatorClusterRoleBinding()));
660657
}
661658

662-
private V1RoleBinding getExpectedWeblogicOperatorRoleBinding(String namespace) {
663-
return newRoleBinding()
659+
private V1ClusterRoleBinding getExpectedWeblogicOperatorClusterRoleBinding() {
660+
return newClusterRoleBinding()
664661
.metadata(
665662
newObjectMeta()
666-
.name("weblogic-operator-rolebinding-namespace")
667-
.namespace(namespace)
663+
.name(getInputs().getNamespace() + "-weblogic-operator-clusterrolebinding-namespace")
668664
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
669665
.addSubjectsItem(
670666
newSubject()

kubernetes/src/test/java/oracle/kubernetes/operator/helm/HelmOperatorValues.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.helm;
@@ -103,8 +103,6 @@ private void loadImagePullSecretsFromMap(Map<String, Object> map) {
103103
Map<String, Object> createMap() {
104104
HashMap<String, Object> map = new HashMap<>();
105105

106-
map.put("enableClusterRoleBinding", Boolean.FALSE);
107-
108106
addStringMapEntry(map, this::getServiceAccount, "serviceAccount");
109107
addStringMapEntry(map, this::getWeblogicOperatorImage, "image");
110108
addStringMapEntry(map, this::getJavaLoggingLevel, "javaLoggingLevel");

0 commit comments

Comments
 (0)