Skip to content

Commit 005fb8d

Browse files
galiachengedburns
authored andcommitted
create connect_aks as common function. (#3)
1 parent d05bba8 commit 005fb8d

13 files changed

+36
-83
lines changed

weblogic-azure-aks/src/main/arm/scripts/inline-scripts/enableHpa.sh

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

4-
function connect_aks(){
5-
az aks get-credentials \
6-
--resource-group ${AKS_CLUSTER_RG_NAME} \
7-
--name ${AKS_CLUSTER_NAME} \
8-
--overwrite-existing
9-
}
10-
114
function get_cluster_uid(){
125
local clusterUid=$(kubectl get clusters -n ${WLS_NAMESPACE} -o=jsonpath='{.items[].metadata.name}')
136
utility_validate_status "Obtain cluster UID."
@@ -62,7 +55,7 @@ set -Eo pipefail
6255

6356
install_kubectl
6457

65-
connect_aks
58+
connect_aks $AKS_CLUSTER_NAME $AKS_CLUSTER_RG_NAME
6659

6760
get_cluster_uid
6861

weblogic-azure-aks/src/main/arm/scripts/inline-scripts/enablePrometheusMetrics.sh

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

4-
function connect_aks(){
5-
az aks get-credentials \
6-
-n $AKS_CLUSTER_NAME \
7-
-g $AKS_CLUSTER_RG_NAME \
8-
--overwrite-existing \
9-
--only-show-errors
10-
}
4+
#!/bin/bash
115

126
function enable_promethues_metrics(){
137
# See https://learn.microsoft.com/en-us/azure/azure-monitor/containers/kubernetes-monitoring-enable?tabs=cli#enable-prometheus-and-grafana
@@ -396,7 +390,7 @@ install_kubectl
396390

397391
install_helm
398392

399-
connect_aks
393+
connect_aks $AKS_CLUSTER_NAME $AKS_CLUSTER_RG_NAME
400394

401395
get_wls_monitoring_exporter_image_url
402396

weblogic-azure-aks/src/main/arm/scripts/inline-scripts/queryDomainConfigurations.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2021, 2024 Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
# This script runs on Azure Container Instance with Alpine Linux that Azure Deployment script creates.
44
#
@@ -15,10 +15,7 @@ echo "install kubectl"
1515
az aks install-cli
1616

1717
echo "Connect AKS"
18-
az aks get-credentials \
19-
--resource-group ${AKS_CLUSTER_RESOURCEGROUP_NAME} \
20-
--name ${AKS_CLUSTER_NAME} \
21-
--overwrite-existing
18+
connect_aks $AKS_CLUSTER_NAME $AKS_CLUSTER_RESOURCEGROUP_NAME
2219

2320
wlsDomainNS="${WLS_DOMAIN_UID}-ns"
2421

weblogic-azure-aks/src/main/arm/scripts/inline-scripts/validateAgic.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
function wait_for_azure_ingress_ready() {
5-
az aks get-credentials \
6-
--resource-group ${AKS_CLUSTER_RG_NAME} \
7-
--name ${AKS_CLUSTER_NAME} \
8-
--overwrite-existing
9-
105
local ready=false
116
local attempt=0
127

@@ -36,4 +31,6 @@ set -Eo pipefail
3631

3732
install_kubectl
3833

34+
connect_aks $AKS_CLUSTER_NAME $AKS_CLUSTER_RG_NAME
35+
3936
wait_for_azure_ingress_ready

weblogic-azure-aks/src/main/arm/scripts/queryStorageAccount.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2021, 2024 Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
# Inputs:
44
# AKS_CLUSTER_RESOURCEGROUP_NAME
@@ -8,14 +8,6 @@ echo "Script ${0} starts"
88

99
export currentStorageAccount="null"
1010

11-
# Connect to AKS cluster
12-
function connect_aks_cluster() {
13-
az aks get-credentials \
14-
--resource-group ${AKS_CLUSTER_RESOURCEGROUP_NAME} \
15-
--name ${AKS_CLUSTER_NAME} \
16-
--overwrite-existing
17-
}
18-
1911
function query_storage_account() {
2012
echo "install kubectl"
2113
az aks install-cli
@@ -42,7 +34,7 @@ function output_result() {
4234
echo $result >$AZ_SCRIPTS_OUTPUT_PATH
4335
}
4436

45-
connect_aks_cluster
37+
connect_aks $AKS_CLUSTER_NAME $AKS_CLUSTER_RESOURCEGROUP_NAME
4638

4739
query_storage_account
4840

weblogic-azure-aks/src/main/arm/scripts/setupDBConnections.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2021, 2024 Oracle Corporation 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
echo "Script ${0} starts"
@@ -80,14 +80,6 @@ function validate_input() {
8080
fi
8181
}
8282

83-
# Connect to AKS cluster
84-
function connect_aks_cluster() {
85-
az aks get-credentials \
86-
--resource-group ${AKS_RESOURCE_GROUP_NAME} \
87-
--name ${AKS_NAME} \
88-
--overwrite-existing
89-
}
90-
9183
function create_datasource_model_configmap_and_secret() {
9284
echo "get data source secret name"
9385
jndiLabel=${JDBC_DATASOURCE_NAME//\//\_}
@@ -289,7 +281,7 @@ export wlsDomainNS="${WLS_DOMAIN_UID}-ns"
289281

290282
validate_input
291283

292-
connect_aks_cluster
284+
connect_aks $AKS_NAME $AKS_RESOURCE_GROUP_NAME
293285

294286
install_kubectl
295287

weblogic-azure-aks/src/main/arm/scripts/setupNetworking.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2021, 2024 Oracle Corporation 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
echo "Script ${0} starts"
@@ -114,11 +114,6 @@ function validate_input() {
114114
fi
115115
}
116116

117-
# Connect to AKS cluster
118-
function connect_aks_cluster() {
119-
az aks get-credentials --resource-group ${AKS_CLUSTER_RG_NAME} --name ${AKS_CLUSTER_NAME} --overwrite-existing
120-
}
121-
122117
function create_svc_lb() {
123118
# No lb svc inputs
124119
if [[ "${LB_SVC_VALUES}" != "[]" ]]; then
@@ -147,7 +142,7 @@ validate_input
147142

148143
install_utilities
149144

150-
connect_aks_cluster
145+
connect_aks $AKS_CLUSTER_NAME $AKS_CLUSTER_RG_NAME
151146

152147
create_svc_lb
153148

weblogic-azure-aks/src/main/arm/scripts/setupWLSDomain.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,6 @@ function install_utilities() {
285285
validate_status ${ret}
286286
}
287287

288-
# Connect to AKS cluster
289-
function connect_aks_cluster() {
290-
az aks get-credentials --resource-group ${AKS_CLUSTER_RESOURCEGROUP_NAME} --name ${AKS_CLUSTER_NAME} --overwrite-existing
291-
}
292-
293288
# remove the operator if it is not running.
294289
function uninstall_operator() {
295290
echo "remove operator"
@@ -772,7 +767,7 @@ query_acr_credentials
772767

773768
build_docker_image
774769

775-
connect_aks_cluster
770+
connect_aks $AKS_CLUSTER_NAME $AKS_CLUSTER_RESOURCEGROUP_NAME
776771

777772
install_wls_operator
778773

weblogic-azure-aks/src/main/arm/scripts/updateApplications.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ function validate_input() {
9898
fi
9999
}
100100

101-
# Connect to AKS cluster
102-
function connect_aks_cluster() {
103-
az aks get-credentials \
104-
--resource-group ${AKS_CLUSTER_RESOURCEGROUP_NAME} \
105-
--name ${AKS_CLUSTER_NAME} \
106-
--overwrite-existing
107-
}
108-
109101
function query_wls_cluster_info(){
110102
WLS_CLUSTER_SIZE=$(kubectl -n ${wlsDomainNS} get domain ${WLS_DOMAIN_UID} -o json \
111103
| jq '. | .status.clusters[] | select(.clusterName == "'${constClusterName}'") | .maximumReplicas')
@@ -291,7 +283,7 @@ validate_input
291283

292284
install_kubectl
293285

294-
connect_aks_cluster
286+
connect_aks $AKS_CLUSTER_NAME $AKS_CLUSTER_RESOURCEGROUP_NAME
295287

296288
query_wls_cluster_info
297289

weblogic-azure-aks/src/main/arm/scripts/utility.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2021, 2024 Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
# This script runs on Azure Container Instance with Alpine Linux that Azure Deployment script creates.
44

@@ -27,6 +27,16 @@ function utility_validate_status() {
2727
fi
2828
}
2929

30+
function connect_aks(){
31+
az aks get-credentials \
32+
-n $1 \
33+
-g $2 \
34+
--overwrite-existing \
35+
--only-show-errors
36+
37+
utility_validate_status "Finished connecting to AKS cluster."
38+
}
39+
3040
# JAVA_HOME=/usr/lib/jvm/java-11-openjdk
3141
function install_jdk() {
3242
local ready=false

0 commit comments

Comments
 (0)