Skip to content

Commit 4e60123

Browse files
committed
First cut at standardizing the k8s labels
1 parent 10db405 commit 4e60123

22 files changed

+331
-139
lines changed

kubernetes/internal/create-weblogic-domain-job-template.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata:
77
namespace: %NAMESPACE%
88
labels:
99
weblogic.domainUID: %DOMAIN_UID%
10+
weblogic.domainName: %DOMAIN_NAME%
1011
data:
1112
utility.sh: |-
1213
#!/bin/bash
@@ -514,8 +515,9 @@ spec:
514515
template:
515516
metadata:
516517
labels:
517-
app: %DOMAIN_UID%-create-weblogic-domain-job
518518
weblogic.domainUID: %DOMAIN_UID%
519+
weblogic.domainName: %DOMAIN_NAME%
520+
app: %DOMAIN_UID%-create-weblogic-domain-job
519521
spec:
520522
restartPolicy: Never
521523
containers:

kubernetes/internal/create-weblogic-domain.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ function createYamlFiles {
406406
fi
407407

408408
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${domainPVOutput}
409+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${domainPVOutput}
409410
sed -i -e "s:%NAMESPACE%:$namespace:g" ${domainPVOutput}
410411
sed -i -e "s:%WEBLOGIC_DOMAIN_STORAGE_PATH%:${weblogicDomainStoragePath}:g" ${domainPVOutput}
411412
sed -i -e "s:%WEBLOGIC_DOMAIN_STORAGE_RECLAIM_POLICY%:${weblogicDomainStorageReclaimPolicy}:g" ${domainPVOutput}
@@ -419,6 +420,7 @@ function createYamlFiles {
419420
cp ${domainPVCInput} ${domainPVCOutput}
420421
sed -i -e "s:%NAMESPACE%:$namespace:g" ${domainPVCOutput}
421422
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${domainPVCOutput}
423+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${domainPVCOutput}
422424
sed -i -e "s:%WEBLOGIC_DOMAIN_STORAGE_SIZE%:${weblogicDomainStorageSize}:g" ${domainPVCOutput}
423425

424426
# Generate the yaml to create the kubernetes job that will create the weblogic domain
@@ -476,8 +478,9 @@ function createYamlFiles {
476478
echo Generating ${traefikOutput}
477479
sed -i -e "s:%NAMESPACE%:$namespace:g" ${traefikOutput}
478480
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${traefikOutput}
479-
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikOutput}
481+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${traefikOutput}
480482
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${traefikOutput}
483+
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikOutput}
481484
sed -i -e "s:%LOAD_BALANCER_WEB_PORT%:$loadBalancerWebPort:g" ${traefikOutput}
482485
sed -i -e "s:%LOAD_BALANCER_DASHBOARD_PORT%:$loadBalancerDashboardPort:g" ${traefikOutput}
483486

@@ -486,6 +489,8 @@ function createYamlFiles {
486489
echo Generating ${traefikSecurityOutput}
487490
sed -i -e "s:%NAMESPACE%:$namespace:g" ${traefikSecurityOutput}
488491
sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${traefikSecurityOutput}
492+
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${traefikSecurityOutput}
493+
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${traefikSecurityOutput}
489494
sed -i -e "s:%CLUSTER_NAME_LC%:${clusterNameLC}:g" ${traefikSecurityOutput}
490495

491496
# Remove any "...yaml-e" files left over from running sed

kubernetes/internal/create-weblogic-operator.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ function deployOperator {
570570
fi
571571

572572
echo Checking the operator labels
573-
LABEL=`kubectl describe deploy weblogic-operator -n ${namespace} | grep "^Labels:" | awk ' { print $2; } '`
574-
if [ "$LABEL" != "app=weblogic-operator" ]; then
573+
LABEL=`kubectl get deploy weblogic-operator -n ${namespace} -o jsonpath='{.spec.template.metadata.labels.app}'`
574+
if [ "$LABEL" != "weblogic-operator" ]; then
575575
fail "The weblogic-operator deployment should have the label app=weblogic-operator"
576576
fi
577577

kubernetes/internal/domain-custom-resource-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ metadata:
1010
namespace: %NAMESPACE%
1111
labels:
1212
weblogic.domainUID: %DOMAIN_UID%
13+
weblogic.domainName: %DOMAIN_NAME%
1314
spec:
1415
# The domainUID must be unique across the entire Kubernetes Cluster. Each WebLogic Domain must
1516
# have its own unique domainUID. This does not have to be the same as the Domain Name. It is allowed

kubernetes/internal/generate-security-policy.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ apiVersion: v1
6666
kind: Namespace
6767
metadata:
6868
name: ${NAMESPACE}
69+
labels:
70+
weblogic.operatorName: ${NAMESPACE}
6971
---
7072
#
7173
# Service Account for WebLogic Operator
@@ -75,6 +77,8 @@ kind: ServiceAccount
7577
metadata:
7678
namespace: ${NAMESPACE}
7779
name: ${ACCOUNT_NAME}
80+
labels:
81+
weblogic.operatorName: ${NAMESPACE}
7882
---
7983
EOF
8084

@@ -86,6 +90,8 @@ kind: ClusterRole
8690
apiVersion: rbac.authorization.k8s.io/v1beta1
8791
metadata:
8892
name: weblogic-operator-cluster-role
93+
labels:
94+
weblogic.operatorName: ${NAMESPACE}
8995
rules:
9096
- apiGroups: [""]
9197
resources: ["namespaces", "persistentvolumes"]
@@ -107,6 +113,8 @@ kind: ClusterRole
107113
apiVersion: rbac.authorization.k8s.io/v1beta1
108114
metadata:
109115
name: weblogic-operator-cluster-role-nonresource
116+
labels:
117+
weblogic.operatorName: ${NAMESPACE}
110118
rules:
111119
- nonResourceURLs: ["/version/*"]
112120
verbs: ["get"]
@@ -118,6 +126,8 @@ kind: ClusterRoleBinding
118126
apiVersion: rbac.authorization.k8s.io/v1beta1
119127
metadata:
120128
name: ${NAMESPACE}-operator-rolebinding
129+
labels:
130+
weblogic.operatorName: ${NAMESPACE}
121131
subjects:
122132
- kind: ServiceAccount
123133
name: ${ACCOUNT_NAME}
@@ -132,6 +142,8 @@ kind: ClusterRoleBinding
132142
apiVersion: rbac.authorization.k8s.io/v1beta1
133143
metadata:
134144
name: ${NAMESPACE}-operator-rolebinding-nonresource
145+
labels:
146+
weblogic.operatorName: ${NAMESPACE}
135147
subjects:
136148
- kind: ServiceAccount
137149
name: ${ACCOUNT_NAME}
@@ -146,6 +158,8 @@ kind: ClusterRoleBinding
146158
apiVersion: rbac.authorization.k8s.io/v1beta1
147159
metadata:
148160
name: ${NAMESPACE}-operator-rolebinding-discovery
161+
labels:
162+
weblogic.operatorName: ${NAMESPACE}
149163
subjects:
150164
- kind: ServiceAccount
151165
name: ${ACCOUNT_NAME}
@@ -160,6 +174,8 @@ kind: ClusterRoleBinding
160174
apiVersion: rbac.authorization.k8s.io/v1beta1
161175
metadata:
162176
name: ${NAMESPACE}-operator-rolebinding-auth-delegator
177+
labels:
178+
weblogic.operatorName: ${NAMESPACE}
163179
subjects:
164180
- kind: ServiceAccount
165181
name: ${ACCOUNT_NAME}
@@ -177,6 +193,8 @@ kind: ClusterRole
177193
apiVersion: rbac.authorization.k8s.io/v1beta1
178194
metadata:
179195
name: weblogic-operator-namespace-role
196+
labels:
197+
weblogic.operatorName: ${NAMESPACE}
180198
rules:
181199
- apiGroups: [""]
182200
resources: ["secrets", "persistentvolumeclaims"]
@@ -214,6 +232,8 @@ apiVersion: rbac.authorization.k8s.io/v1beta1
214232
metadata:
215233
name: weblogic-operator-rolebinding
216234
namespace: ${i}
235+
labels:
236+
weblogic.operatorName: ${NAMESPACE}
217237
subjects:
218238
- kind: ServiceAccount
219239
name: ${ACCOUNT_NAME}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata:
77
name: %DOMAIN_UID%-weblogic-domain-pv
88
labels:
99
weblogic.domainUID: %DOMAIN_UID%
10+
weblogic.domainName: %DOMAIN_NAME%
1011
spec:
1112
storageClassName: %DOMAIN_UID%-weblogic-domain-storage-class
1213
capacity:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ metadata:
88
namespace: %NAMESPACE%
99
labels:
1010
weblogic.domainUID: %DOMAIN_UID%
11+
weblogic.domainName: %DOMAIN_NAME%
1112
spec:
1213
storageClassName: %DOMAIN_UID%-weblogic-domain-storage-class
1314
accessModes:

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ metadata:
55
name: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
66
labels:
77
weblogic.domainUID: %DOMAIN_UID%
8+
weblogic.domainName: %DOMAIN_NAME%
9+
weblogic.clusterName: %CLUSTER_NAME_LC%
10+
weblogic.clusterNameLC: %CLUSTER_NAME_LC%
811
rules:
912
- apiGroups:
1013
- ""
@@ -32,7 +35,9 @@ metadata:
3235
name: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
3336
labels:
3437
weblogic.domainUID: %DOMAIN_UID%
38+
weblogic.domainName: %DOMAIN_NAME%
3539
weblogic.clusterName: %CLUSTER_NAME_LC%
40+
weblogic.clusterNameLC: %CLUSTER_NAME_LC%
3641
roleRef:
3742
apiGroup: rbac.authorization.k8s.io
3843
kind: ClusterRole

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ metadata:
66
namespace: %NAMESPACE%
77
labels:
88
weblogic.domainUID: %DOMAIN_UID%
9+
weblogic.domainName: %DOMAIN_NAME%
910
weblogic.clusterName: %CLUSTER_NAME_LC%
11+
weblogic.clusterNameLC: %CLUSTER_NAME_LC%
1012
---
1113
kind: Deployment
1214
apiVersion: extensions/v1beta1
1315
metadata:
1416
name: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
1517
namespace: %NAMESPACE%
1618
labels:
17-
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
1819
weblogic.domainUID: %DOMAIN_UID%
20+
weblogic.domainName: %DOMAIN_NAME%
1921
weblogic.clusterName: %CLUSTER_NAME_LC%
22+
weblogic.clusterNameLC: %CLUSTER_NAME_LC%
23+
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
2024
spec:
2125
replicas: 1
2226
selector:
@@ -25,9 +29,11 @@ spec:
2529
template:
2630
metadata:
2731
labels:
28-
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
2932
weblogic.domainUID: %DOMAIN_UID%
33+
weblogic.domainName: %DOMAIN_NAME%
3034
weblogic.clusterName: %CLUSTER_NAME_LC%
35+
weblogic.clusterNameLC: %CLUSTER_NAME_LC%
36+
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
3137
spec:
3238
serviceAccountName: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
3339
terminationGracePeriodSeconds: 60
@@ -80,9 +86,11 @@ metadata:
8086
name: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik-cm
8187
namespace: %NAMESPACE%
8288
labels:
83-
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
8489
weblogic.domainUID: %DOMAIN_UID%
90+
weblogic.domainName: %DOMAIN_NAME%
8591
weblogic.clusterName: %CLUSTER_NAME_LC%
92+
weblogic.clusterNameLC: %CLUSTER_NAME_LC%
93+
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
8694
data:
8795
traefik.toml: |
8896
# traefik.toml
@@ -104,7 +112,9 @@ metadata:
104112
namespace: %NAMESPACE%
105113
labels:
106114
weblogic.domainUID: %DOMAIN_UID%
115+
weblogic.domainName: %DOMAIN_NAME%
107116
weblogic.clusterName: %CLUSTER_NAME_LC%
117+
weblogic.clusterNameLC: %CLUSTER_NAME_LC%
108118
spec:
109119
selector:
110120
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
@@ -121,9 +131,11 @@ metadata:
121131
name: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik-dashboard
122132
namespace: %NAMESPACE%
123133
labels:
124-
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
125134
weblogic.domainUID: %DOMAIN_UID%
135+
weblogic.domainName: %DOMAIN_NAME%
126136
weblogic.clusterName: %CLUSTER_NAME_LC%
137+
weblogic.clusterNameLC: %CLUSTER_NAME_LC%
138+
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik
127139
spec:
128140
selector:
129141
app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik

kubernetes/internal/weblogic-operator-template.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ kind: ConfigMap
1313
metadata:
1414
name: weblogic-operator-cm
1515
namespace: %NAMESPACE%
16+
labels:
17+
weblogic.operatorName: %NAMESPACE%
1618
data:
1719
serviceaccount: %ACCOUNT_NAME%
1820
targetNamespaces: "%TARGET_NAMESPACES%"
@@ -25,6 +27,8 @@ kind: Secret
2527
metadata:
2628
name: weblogic-operator-secrets
2729
namespace: %NAMESPACE%
30+
labels:
31+
weblogic.operatorName: %NAMESPACE%
2832
type: Opaque
2933
data:
3034
externalOperatorKey: %EXTERNAL_KEY_DATA%
@@ -37,11 +41,14 @@ metadata:
3741
name: weblogic-operator
3842
# set the namespace that you want the operator deployed in here
3943
namespace: %NAMESPACE%
44+
labels:
45+
weblogic.operatorName: %NAMESPACE%
4046
spec:
4147
replicas: 1
4248
template:
4349
metadata:
44-
labels:
50+
labels:
51+
weblogic.operatorName: %NAMESPACE%
4552
app: weblogic-operator
4653
spec:
4754
serviceAccountName: %ACCOUNT_NAME%
@@ -121,6 +128,8 @@ spec:
121128
%EXTERNAL_OPERATOR_SERVICE_PREFIX%metadata:
122129
%EXTERNAL_OPERATOR_SERVICE_PREFIX% name: external-weblogic-operator-svc
123130
%EXTERNAL_OPERATOR_SERVICE_PREFIX% namespace: %NAMESPACE%
131+
%EXTERNAL_OPERATOR_SERVICE_PREFIX% labels:
132+
%EXTERNAL_OPERATOR_SERVICE_PREFIX% weblogic.operatorName: %NAMESPACE%
124133
%EXTERNAL_OPERATOR_SERVICE_PREFIX%spec:
125134
%EXTERNAL_OPERATOR_SERVICE_PREFIX% type: NodePort
126135
%EXTERNAL_OPERATOR_SERVICE_PREFIX% selector:
@@ -141,6 +150,8 @@ kind: Service
141150
metadata:
142151
name: internal-weblogic-operator-svc
143152
namespace: %NAMESPACE%
153+
labels:
154+
weblogic.operatorName: %NAMESPACE%
144155
spec:
145156
type: ClusterIP
146157
selector:

0 commit comments

Comments
 (0)