Skip to content

Commit ef1ef1e

Browse files
committed
Merge branch 'OWLS-108164' into 'release/4.0'
OWLS-108164 - Changes to convert cluster name to legal DNS 1123 name in Domain on PV and other samples. See merge request weblogic-cloud/weblogic-kubernetes-operator!4249
2 parents a25f82c + 482212b commit ef1ef1e

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

kubernetes/samples/scripts/common/domain-template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ spec:
9090
# must describe a cluster that already exists in the WebLogic domain
9191
# configuration.
9292
clusters:
93-
- name: %DOMAIN_UID%-%CLUSTER_NAME%
93+
- name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME%
9494

9595
# The number of managed servers to start for unlisted clusters
9696
# replicas: 1
@@ -100,7 +100,7 @@ spec:
100100
apiVersion: weblogic.oracle/v1
101101
kind: Cluster
102102
metadata:
103-
name: %DOMAIN_UID%-%CLUSTER_NAME%
103+
name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME%
104104
namespace: %NAMESPACE%
105105
spec:
106106
clusterName: %CLUSTER_NAME%

kubernetes/samples/scripts/common/jrf-domain-template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ spec:
9494
# must describe a cluster that already exists in the WebLogic domain
9595
# configuration.
9696
clusters:
97-
- name: %DOMAIN_UID%-%CLUSTER_NAME%
97+
- name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME%
9898

9999
# The number of managed servers to start for unlisted clusters
100100
# replicas: 1
@@ -104,7 +104,7 @@ spec:
104104
apiVersion: weblogic.oracle/v1
105105
kind: Cluster
106106
metadata:
107-
name: %DOMAIN_UID%-%CLUSTER_NAME%
107+
name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME%
108108
namespace: %NAMESPACE%
109109
spec:
110110
clusterName: %CLUSTER_NAME%

kubernetes/samples/scripts/common/utility.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ toDNS1123Legal() {
166166
echo "$val"
167167
}
168168

169+
#
170+
# Function to lowercase a value and make it a legal DNS1123 name
171+
# $1 - value to convert to lowercase
172+
# $2 - converted retrun value.
173+
convertToDNS1123Legal() {
174+
local name=$1
175+
local __result=$2
176+
val=$(echo -n $name | tr -c '[:alnum:]._-' '-' | \
177+
tr [:upper:] [:lower:] | tr '_' '-' | tr -s "-")
178+
eval $__result="'$val'"
179+
}
180+
169181
#
170182
# Check the state of a persistent volume.
171183
# $1 - name of volume
@@ -431,6 +443,8 @@ createFiles() {
431443
# Generate the properties file that will be used when creating the weblogic domain
432444
echo Generating ${domainPropertiesOutput} from ${domainPropertiesInput}
433445

446+
# convert the cluster name to a legal DNS subdomain name.
447+
convertToDNS1123Legal "${clusterName}" legalDNS1123ClusterName
434448
cp ${domainPropertiesInput} ${domainPropertiesOutput}
435449
sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${domainPropertiesOutput}
436450
sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${domainPropertiesOutput}
@@ -442,6 +456,7 @@ createFiles() {
442456
sed -i -e "s:%MANAGED_SERVER_NAME_BASE%:${managedServerNameBase}:g" ${domainPropertiesOutput}
443457
sed -i -e "s:%CONFIGURED_MANAGED_SERVER_COUNT%:${configuredManagedServerCount}:g" ${domainPropertiesOutput}
444458
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${domainPropertiesOutput}
459+
sed -i -e "s:%LEGAL_DNS_CLUSTER_NAME%:${legalDNS1123ClusterName}:g" ${domainPropertiesOutput}
445460
sed -i -e "s:%SSL_ENABLED%:${sslEnabled}:g" ${domainPropertiesOutput}
446461
sed -i -e "s:%PRODUCTION_MODE_ENABLED%:${productionModeEnabled}:g" ${domainPropertiesOutput}
447462
sed -i -e "s:%CLUSTER_TYPE%:${clusterType}:g" ${domainPropertiesOutput}
@@ -500,6 +515,8 @@ createFiles() {
500515
echo Generating ${createJobOutput}
501516

502517
cp ${createJobInput} ${createJobOutput}
518+
# convert the cluster name to a legal DNS subdomain name.
519+
convertToDNS1123Legal "${clusterName}" legalDNS1123ClusterName
503520
sed -i -e "s:%NAMESPACE%:$namespace:g" ${createJobOutput}
504521
sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${createJobOutput}
505522
sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${createJobOutput}
@@ -523,6 +540,7 @@ createFiles() {
523540
sed -i -e "s:%T3_CHANNEL_PORT%:${t3ChannelPort}:g" ${createJobOutput}
524541
sed -i -e "s:%T3_PUBLIC_ADDRESS%:${t3PublicAddress}:g" ${createJobOutput}
525542
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${createJobOutput}
543+
sed -i -e "s:%LEGAL_DNS_CLUSTER_NAME%:${legalDNS1123ClusterName}:g" ${createJobOutput}
526544
sed -i -e "s:%CLUSTER_TYPE%:${clusterType}:g" ${createJobOutput}
527545
sed -i -e "s:%DOMAIN_PVC_NAME%:${persistentVolumeClaimName}:g" ${createJobOutput}
528546
sed -i -e "s:%DOMAIN_ROOT_DIR%:${domainPVMountPath}:g" ${createJobOutput}
@@ -610,11 +628,14 @@ createFiles() {
610628
exposeAdminNodePortPrefix="${disabledPrefix}"
611629
fi
612630

631+
# convert the cluster name to a legal DNS subdomain name.
632+
convertToDNS1123Legal "${clusterName}" legalDNS1123ClusterName
613633
sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3ChannelPrefix}:g" ${dcrOutput}
614634
sed -i -e "s:%EXPOSE_ANY_CHANNEL_PREFIX%:${exposeAnyChannelPrefix}:g" ${dcrOutput}
615635
sed -i -e "s:%EXPOSE_ADMIN_PORT_PREFIX%:${exposeAdminNodePortPrefix}:g" ${dcrOutput}
616636
sed -i -e "s:%ADMIN_NODE_PORT%:${adminNodePort}:g" ${dcrOutput}
617637
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${dcrOutput}
638+
sed -i -e "s:%LEGAL_DNS_CLUSTER_NAME%:${legalDNS1123ClusterName}:g" ${dcrOutput}
618639
sed -i -e "s:%INITIAL_MANAGED_SERVER_REPLICAS%:${initialManagedServerReplicas}:g" ${dcrOutput}
619640
# MII settings are used for model-in-image integration testing
620641
sed -i -e "s:%MII_PREFIX%:${miiPrefix}:g" ${dcrOutput}
@@ -688,12 +709,17 @@ updateModelFile() {
688709
exposeAdminNodePortPrefix="${disabledPrefix}"
689710
fi
690711

712+
# convert the cluster name to a legal DNS subdomain name.
713+
convertToDNS1123Legal "${clusterName}" legalDNS1123ClusterName
714+
convertToDNS1123Legal "${clusterName2}" legalDNS1123ClusterName2
691715
sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3ChannelPrefix}:g" ${modelFile}
692716
sed -i -e "s:%EXPOSE_ANY_CHANNEL_PREFIX%:${exposeAnyChannelPrefix}:g" ${modelFile}
693717
sed -i -e "s:%EXPOSE_ADMIN_PORT_PREFIX%:${exposeAdminNodePortPrefix}:g" ${modelFile}
694718
sed -i -e "s:%ADMIN_NODE_PORT%:${adminNodePort}:g" ${modelFile}
695719
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${modelFile}
720+
sed -i -e "s:%LEGAL_DNS_CLUSTER_NAME%:${legalDNS1123ClusterName}:g" ${modelFile}
696721
sed -i -e "s:%CLUSTER_NAME2%:${clusterName2}:g" ${modelFile}
722+
sed -i -e "s:%LEGAL_DNS_CLUSTER_NAME2%:${legalDNS1123ClusterName2}:g" ${modelFile}
697723
sed -i -e "s:%INITIAL_MANAGED_SERVER_REPLICAS%:${initialManagedServerReplicas}:g" ${modelFile}
698724
# MII settings are used for model-in-image integration testing
699725
sed -i -e "s:%MII_PREFIX%:${miiPrefix}:g" ${modelFile}

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/wdt_k8s_model_template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ kubernetes:
8989
# must describe a cluster that already exists in the WebLogic domain
9090
# configuration.
9191
clusters:
92-
- name: %DOMAIN_UID%-%CLUSTER_NAME%
92+
- name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME%
9393

9494
# Used by WDT's extractDomainResource script to generate a Cluster resource.
9595
clusters:
9696
- metadata:
97-
name: %DOMAIN_UID%-%CLUSTER_NAME%
97+
name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME%
9898
namespace: "%NAMESPACE%"
9999
spec:
100100
clusterName: %CLUSTER_NAME%

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/wdt_k8s_model_template_updated.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ kubernetes:
8989
# must describe a cluster that already exists in the WebLogic domain
9090
# configuration.
9191
clusters:
92-
- name: %DOMAIN_UID%-%CLUSTER_NAME%
93-
- name: %DOMAIN_UID%-%CLUSTER_NAME2%
92+
- name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME%
93+
- name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME2%
9494

9595
# Used by WDT's extractDomainResource script to generate Cluster resources.
9696
clusters:
9797
- metadata:
98-
name: %DOMAIN_UID%-%CLUSTER_NAME%
98+
name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME%
9999
namespace: "%NAMESPACE%"
100100
spec:
101101
clusterName: %CLUSTER_NAME%
102102
replicas: %INITIAL_MANAGED_SERVER_REPLICAS%
103103
- metadata:
104-
name: %DOMAIN_UID%-%CLUSTER_NAME2%
104+
name: %DOMAIN_UID%-%LEGAL_DNS_CLUSTER_NAME2%
105105
namespace: "%NAMESPACE%"
106106
spec:
107107
clusterName: %CLUSTER_NAME2%

0 commit comments

Comments
 (0)