Skip to content

Commit 7b9e00a

Browse files
committed
Version the operator related resources, also version the deployment templates so that the pods get versioned too
1 parent f8a3965 commit 7b9e00a

File tree

6 files changed

+38
-1
lines changed

6 files changed

+38
-1
lines changed

kubernetes/internal/generate-security-policy.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ kind: Namespace
6767
metadata:
6868
name: ${NAMESPACE}
6969
labels:
70+
weblogic.resourceVersion: operator/v1
7071
weblogic.operatorName: ${NAMESPACE}
7172
---
7273
#
@@ -78,6 +79,7 @@ metadata:
7879
namespace: ${NAMESPACE}
7980
name: ${ACCOUNT_NAME}
8081
labels:
82+
weblogic.resourceVersion: operator/v1
8183
weblogic.operatorName: ${NAMESPACE}
8284
---
8385
EOF
@@ -91,6 +93,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
9193
metadata:
9294
name: weblogic-operator-cluster-role
9395
labels:
96+
weblogic.resourceVersion: operator/v1
9497
weblogic.operatorName: ${NAMESPACE}
9598
rules:
9699
- apiGroups: [""]
@@ -123,6 +126,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
123126
metadata:
124127
name: weblogic-operator-cluster-role-nonresource
125128
labels:
129+
weblogic.resourceVersion: operator/v1
126130
weblogic.operatorName: ${NAMESPACE}
127131
rules:
128132
- nonResourceURLs: ["/version/*"]
@@ -136,6 +140,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
136140
metadata:
137141
name: ${NAMESPACE}-operator-rolebinding
138142
labels:
143+
weblogic.resourceVersion: operator/v1
139144
weblogic.operatorName: ${NAMESPACE}
140145
subjects:
141146
- kind: ServiceAccount
@@ -152,6 +157,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
152157
metadata:
153158
name: ${NAMESPACE}-operator-rolebinding-nonresource
154159
labels:
160+
weblogic.resourceVersion: operator/v1
155161
weblogic.operatorName: ${NAMESPACE}
156162
subjects:
157163
- kind: ServiceAccount
@@ -168,6 +174,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
168174
metadata:
169175
name: ${NAMESPACE}-operator-rolebinding-discovery
170176
labels:
177+
weblogic.resourceVersion: operator/v1
171178
weblogic.operatorName: ${NAMESPACE}
172179
subjects:
173180
- kind: ServiceAccount
@@ -184,6 +191,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
184191
metadata:
185192
name: ${NAMESPACE}-operator-rolebinding-auth-delegator
186193
labels:
194+
weblogic.resourceVersion: operator/v1
187195
weblogic.operatorName: ${NAMESPACE}
188196
subjects:
189197
- kind: ServiceAccount
@@ -203,6 +211,7 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
203211
metadata:
204212
name: weblogic-operator-namespace-role
205213
labels:
214+
weblogic.resourceVersion: operator/v1
206215
weblogic.operatorName: ${NAMESPACE}
207216
rules:
208217
- apiGroups: [""]
@@ -245,6 +254,7 @@ metadata:
245254
name: weblogic-operator-rolebinding
246255
namespace: ${i}
247256
labels:
257+
weblogic.resourceVersion: operator/v1
248258
weblogic.operatorName: ${NAMESPACE}
249259
subjects:
250260
- kind: ServiceAccount

kubernetes/internal/weblogic-domain-apache-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ spec:
3030
template:
3131
metadata:
3232
labels:
33+
weblogic.resourceVersion: apache-load-balancer/v1
3334
weblogic.domainUID: %DOMAIN_UID%
3435
weblogic.domainName: %DOMAIN_NAME%
3536
app: apache-webtier

kubernetes/internal/weblogic-domain-traefik-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ spec:
2929
template:
3030
metadata:
3131
labels:
32+
weblogic.resourceVersion: traefik-load-balancer/v1
3233
weblogic.domainUID: %DOMAIN_UID%
3334
weblogic.domainName: %DOMAIN_NAME%
3435
weblogic.clusterName: %CLUSTER_NAME%

kubernetes/internal/weblogic-operator-template.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ metadata:
1414
name: weblogic-operator-cm
1515
namespace: %NAMESPACE%
1616
labels:
17+
weblogic.resourceVersion: operator/v1
1718
weblogic.operatorName: %NAMESPACE%
1819
data:
1920
serviceaccount: %ACCOUNT_NAME%
@@ -28,6 +29,7 @@ metadata:
2829
name: weblogic-operator-secrets
2930
namespace: %NAMESPACE%
3031
labels:
32+
weblogic.resourceVersion: operator/v1
3133
weblogic.operatorName: %NAMESPACE%
3234
type: Opaque
3335
data:
@@ -42,12 +44,14 @@ metadata:
4244
# set the namespace that you want the operator deployed in here
4345
namespace: %NAMESPACE%
4446
labels:
47+
weblogic.resourceVersion: operator/v1
4548
weblogic.operatorName: %NAMESPACE%
4649
spec:
4750
replicas: 1
4851
template:
4952
metadata:
5053
labels:
54+
weblogic.resourceVersion: operator/v1
5155
weblogic.operatorName: %NAMESPACE%
5256
app: weblogic-operator
5357
spec:
@@ -129,6 +133,7 @@ spec:
129133
%EXTERNAL_OPERATOR_SERVICE_PREFIX% name: external-weblogic-operator-svc
130134
%EXTERNAL_OPERATOR_SERVICE_PREFIX% namespace: %NAMESPACE%
131135
%EXTERNAL_OPERATOR_SERVICE_PREFIX% labels:
136+
%EXTERNAL_OPERATOR_SERVICE_PREFIX% weblogic.resourceVersion: operator/v1
132137
%EXTERNAL_OPERATOR_SERVICE_PREFIX% weblogic.operatorName: %NAMESPACE%
133138
%EXTERNAL_OPERATOR_SERVICE_PREFIX%spec:
134139
%EXTERNAL_OPERATOR_SERVICE_PREFIX% type: NodePort
@@ -151,6 +156,7 @@ metadata:
151156
name: internal-weblogic-operator-svc
152157
namespace: %NAMESPACE%
153158
labels:
159+
weblogic.resourceVersion: operator/v1
154160
weblogic.operatorName: %NAMESPACE%
155161
spec:
156162
type: ClusterIP
@@ -159,4 +165,3 @@ spec:
159165
ports:
160166
- port: 8082
161167
name: rest
162-

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ protected ExtensionsV1beta1Deployment getExpectedApacheDeployment() {
466466
.putMatchLabelsItem(APP_LABEL, getApacheAppName()))
467467
.template(newPodTemplateSpec()
468468
.metadata(newObjectMeta()
469+
.putLabelsItem(RESOURCE_VERSION_LABEL, APACHE_LOAD_BALANCER_V1)
469470
.putLabelsItem(DOMAINUID_LABEL, getInputs().getDomainUID())
470471
.putLabelsItem(DOMAINNAME_LABEL, getInputs().getDomainName())
471472
.putLabelsItem(APP_LABEL, getApacheAppName()))
@@ -532,6 +533,7 @@ protected ExtensionsV1beta1Deployment getExpectedTraefikDeployment() {
532533
.putMatchLabelsItem(CLUSTERNAME_LABEL, getInputs().getClusterName()))
533534
.template(newPodTemplateSpec()
534535
.metadata(newObjectMeta()
536+
.putLabelsItem(RESOURCE_VERSION_LABEL, TRAEFIK_LOAD_BALANCER_V1)
535537
.putLabelsItem(DOMAINUID_LABEL, getInputs().getDomainUID())
536538
.putLabelsItem(DOMAINNAME_LABEL, getInputs().getDomainName())
537539
.putLabelsItem(CLUSTERNAME_LABEL, getInputs().getClusterName()))

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import static java.util.Arrays.asList;
1212
import static oracle.kubernetes.operator.LabelConstants.*;
13+
import static oracle.kubernetes.operator.VersionConstants.*;
1314
import static oracle.kubernetes.operator.create.CreateOperatorInputs.readInputsYamlFile;
1415
import static oracle.kubernetes.operator.create.KubernetesArtifactUtils.*;
1516
import static oracle.kubernetes.operator.create.YamlUtils.yamlEqualTo;
@@ -92,6 +93,7 @@ protected V1ConfigMap getExpectedWeblogicOperatorConfigMap() {
9293
.metadata(newObjectMeta()
9394
.name("weblogic-operator-cm")
9495
.namespace(getInputs().getNamespace())
96+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
9597
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
9698
.putDataItem("serviceaccount", getInputs().getServiceAccount())
9799
.putDataItem("targetNamespaces", getInputs().getTargetNamespaces())
@@ -118,6 +120,7 @@ protected V1Secret getExpectedWeblogicOperatorSecrets() {
118120
.metadata(newObjectMeta()
119121
.name("weblogic-operator-secrets")
120122
.namespace(getInputs().getNamespace())
123+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
121124
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
122125
.type("Opaque")
123126
.putDataItem("externalOperatorKey", getExpectedExternalWeblogicOperatorKey().getBytes())
@@ -143,11 +146,13 @@ protected ExtensionsV1beta1Deployment getExpectedWeblogicOperatorDeployment() {
143146
.metadata(newObjectMeta()
144147
.name("weblogic-operator")
145148
.namespace(getInputs().getNamespace())
149+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
146150
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
147151
.spec(newDeploymentSpec()
148152
.replicas(1)
149153
.template(newPodTemplateSpec()
150154
.metadata(newObjectMeta()
155+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
151156
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace())
152157
.putLabelsItem(APP_LABEL, "weblogic-operator"))
153158
.spec(newPodSpec()
@@ -233,6 +238,7 @@ protected V1Service getExpectedExternalWeblogicOperatorService(boolean debugging
233238
.metadata(newObjectMeta()
234239
.name("external-weblogic-operator-svc")
235240
.namespace(getInputs().getNamespace())
241+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
236242
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
237243
.spec(spec);
238244
}
@@ -254,6 +260,7 @@ protected V1Service getExpectedInternalWeblogicOperatorService() {
254260
.metadata(newObjectMeta()
255261
.name("internal-weblogic-operator-svc")
256262
.namespace(getInputs().getNamespace())
263+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
257264
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
258265
.spec(newServiceSpec()
259266
.type("ClusterIP")
@@ -279,6 +286,7 @@ protected V1Namespace getExpectedWeblogicOperatorNamespace() {
279286
newNamespace()
280287
.metadata(newObjectMeta()
281288
.name(getInputs().getNamespace())
289+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
282290
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()));
283291
}
284292

@@ -299,6 +307,7 @@ protected V1ServiceAccount getExpectedWeblogicOperatorServiceAccount() {
299307
.metadata(newObjectMeta()
300308
.name(getInputs().getServiceAccount())
301309
.namespace(getInputs().getNamespace())
310+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
302311
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()));
303312
}
304313

@@ -318,6 +327,7 @@ protected V1beta1ClusterRole getExpectedWeblogicOperatorClusterRole() {
318327
newClusterRole()
319328
.metadata(newObjectMeta()
320329
.name("weblogic-operator-cluster-role")
330+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
321331
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
322332
.addRulesItem(newPolicyRule()
323333
.addApiGroupsItem("")
@@ -369,6 +379,7 @@ protected V1beta1ClusterRole getExpectedWeblogicOperatorClusterRoleNonResource()
369379
newClusterRole()
370380
.metadata(newObjectMeta()
371381
.name("weblogic-operator-cluster-role-nonresource")
382+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
372383
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
373384
.addRulesItem(newPolicyRule()
374385
.addNonResourceURLsItem("/version/*")
@@ -383,6 +394,7 @@ public void generatesCorrect_operatorRoleBinding() throws Exception {
383394
newClusterRoleBinding()
384395
.metadata(newObjectMeta()
385396
.name(getInputs().getNamespace() + "-operator-rolebinding")
397+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
386398
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
387399
.addSubjectsItem(newSubject()
388400
.kind("ServiceAccount")
@@ -410,6 +422,7 @@ protected V1beta1ClusterRoleBinding getExpectedOperatorRoleBindingNonResource()
410422
newClusterRoleBinding()
411423
.metadata(newObjectMeta()
412424
.name(getInputs().getNamespace() + "-operator-rolebinding-nonresource")
425+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
413426
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
414427
.addSubjectsItem(newSubject()
415428
.kind("ServiceAccount")
@@ -437,6 +450,7 @@ protected V1beta1ClusterRoleBinding getExpectedOperatorRoleBindingDiscovery() {
437450
newClusterRoleBinding()
438451
.metadata(newObjectMeta()
439452
.name(getInputs().getNamespace() + "-operator-rolebinding-discovery")
453+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
440454
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
441455
.addSubjectsItem(newSubject()
442456
.kind("ServiceAccount")
@@ -464,6 +478,7 @@ protected V1beta1ClusterRoleBinding getExpectedOperatorRoleBindingAuthDelegator(
464478
newClusterRoleBinding()
465479
.metadata(newObjectMeta()
466480
.name(getInputs().getNamespace() + "-operator-rolebinding-auth-delegator")
481+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
467482
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
468483
.addSubjectsItem(newSubject()
469484
.kind("ServiceAccount")
@@ -491,6 +506,7 @@ protected V1beta1ClusterRole getExpectedWeblogicOperatorNamespaceRole() {
491506
newClusterRole()
492507
.metadata(newObjectMeta()
493508
.name("weblogic-operator-namespace-role")
509+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
494510
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
495511
.addRulesItem(newPolicyRule()
496512
.addApiGroupsItem("")
@@ -546,6 +562,7 @@ protected V1beta1RoleBinding getExpectedWeblogicOperatorRoleBinding(String names
546562
.metadata(newObjectMeta()
547563
.name("weblogic-operator-rolebinding")
548564
.namespace(namespace)
565+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
549566
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
550567
.addSubjectsItem(newSubject()
551568
.kind("ServiceAccount")
@@ -578,6 +595,7 @@ protected V1Service getExpectedExternalOperatorService(boolean debuggingEnabled,
578595
.metadata(newObjectMeta()
579596
.name("external-weblogic-operator-svc")
580597
.namespace(inputs.getNamespace())
598+
.putLabelsItem(RESOURCE_VERSION_LABEL, OPERATOR_V1)
581599
.putLabelsItem(OPERATORNAME_LABEL, getInputs().getNamespace()))
582600
.spec(spec);
583601
}

0 commit comments

Comments
 (0)