10000 Support tagging resource in WLS AKS offer (#328) · azure-javaee/weblogic-azure@2abb4e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2abb4e5

Browse files
authored
Support tagging resource in WLS AKS offer (oracle#328)
* modify aks offer to support tag * debug template * specify download path * add identifier.workspaces * tag vm and vm extension that are created with cli * test bicep 0.26.54 * fix empty vm tags * fix file share name * apply tags to agent pool * Tag for Microsoft.Monitor/accounts * doc for aks tag * clean up source code for tagging resources in aks offer. * increase pom version * add comment for bicep user defined function.
1 parent 73b9519 commit 2abb4e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+295
-33
lines changed

.github/workflows/testWlsAksWithDependencyCreation.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ jobs:
229229
uses: actions/download-artifact@v4
230230
with:
231231
name: ${{needs.preflight.outputs.artifactName}}
232+
path: ${{needs.preflight.outputs.artifactName}}
232233
- uses: azure/login@v1
233234
id: azure-login
234235
with:
@@ -289,9 +290,8 @@ jobs:
289290
uses: azure/CLI@v1
290291
with:
291292
azcliversion: ${{ env.azCliVersion }}
292-
inlineScript: |
293-
artifactName=${{ needs.preflight.outputs.artifactName }}
294-
293+
inlineScript: |
294+
artifactName=${{ needs.preflight.outputs.artifactName }}
295295
az deployment group create \
296296
--verbose \
297297
--resource-group ${{ env.resourceGroupForWlsAks }} \

.github/workflows/testWlsAksWithoutDependencyCreation.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
dbName:
2828
description: 'Name of the database. Get from another pipeline run'
2929
required: true
30+
vmSize:
31+
description: 'The VM size for the AKS pool'
32+
required: true
33+
default: Standard_D2s_v3
3034
# sample cURL
3135
# curl --verbose -X POST https://api.github.com/repos/<github_user>/weblogic-azure/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -H 'Authorization: token <personal_access_token>' --data '<request_data>'
3236
# sample <request_data>
@@ -40,6 +44,7 @@ env:
4044
location: eastus
4145
dbAdminUser: weblogic
4246
dbPassword: ${{ secrets.DB_PASSWORD }}
47+
dbServerName: weblogicdb
4348
ocrSSOPSW: ${{ secrets.ORC_SSOPSW }}
4449
ocrSSOUser: ${{ secrets.ORC_SSOUSER }}
4550
wdtRuntimePassword: ${{ secrets.WDT_RUNTIMEPSW}}
@@ -192,6 +197,7 @@ jobs:
192197
uses: actions/download-artifact@v4
193198
with:
194199
name: ${{needs.preflight.outputs.artifactName}}
200+
path: ${{needs.preflight.outputs.artifactName}}
195201
- uses: azure/login@v1
196202
id: azure-login
197203
with:
@@ -238,7 +244,7 @@ jobs:
238244
"${cargoTrackerBlobUrl}" \
239245
${dbPassword} \
240246
${dbAdminUser} \
241-
jdbc:postgresql:\/\/${{ needs.preflight.outputs.dbName }}.postgres.database.azure.com:5432\/postgres \
247+
jdbc:postgresql:\/\/${{ needs.preflight.outputs.dbName }}.postgres.database.azure.com:5432\/${{ env.dbServerName }} \
242248
${location} \
243249
${ocrSSOPSW} \
244250
${ocrSSOUser} \

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<properties>
4141
<!-- versions start -->
4242
<!-- weblogic azure aks versions -->
43-
<version.wls-on-aks-azure-marketplace>1.0.81</version.wls-on-aks-azure-marketplace>
43+
<version.wls-on-aks-azure-marketplace>1.0.82</version.wls-on-aks-azure-marketplace>
4444
<!-- weblogic azure vm versions -->
4545
<version.arm-oraclelinux-wls>1.0.29</version.arm-oraclelinux-wls>
4646
<version.arm-oraclelinux-wls-admin>1.0.54</version.arm-oraclelinux-wls-admin>

resources/azure-common.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,22 @@ azure.powershell.version=11.5
5252

5353
# These filters are used to implement tags for resources. Other occurrences of these resource type identifiers
5454
# are intentionally not filtered because doing so would unnecessarily complicate the code.
55+
identifier.accounts=Microsoft.Monitor/accounts
5556
identifier.applicationGateways=Microsoft.Network/applicationGateways
5657
identifier.availabilitySets=Microsoft.Compute/availabilitySets
5758
identifier.dnszones=Microsoft.Network/dnszones
59+
identifier.managedClusters=Microsoft.ContainerService/managedClusters
5860
identifier.networkInterfaces=Microsoft.Network/networkInterfaces
5961
identifier.networkSecurityGroups=Microsoft.Network/networkSecurityGroups
6062
identifier.publicIPAddresses=Microsoft.Network/publicIPAddresses
6163
identifier.privateEndpoints=Microsoft.Network/privateEndpoints
64+
identifier.registries=Microsoft.ContainerRegistry/registries
6265
identifier.storageAccounts=Microsoft.Storage/storageAccounts
6366
identifier.vaults=Microsoft.KeyVault/vaults
6467
identifier.virtualNetworks=Microsoft.Network/virtualNetworks
6568
identifier.virtualMachines=Microsoft.Compute/virtualMachines
6669
identifier.virtualMachinesExtensions=Virtual machine extension
70+
identifier.workspaces=Microsoft.OperationalInsights/workspaces
6771
identifier.deploymentScripts=Microsoft.Resources/deploymentScripts
6872
identifier.userAssignedIdentities=Microsoft.ManagedIdentity/userAssignedIdentities
6973
identifier.resourcesDeployment=Microsoft resources deployment

resources/doc/guidance-for-tagging-resource.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,36 @@ Incorporate the [Microsoft.Common.TagsByResource UI element](https://learn.micro
7777

7878
Refer to this [pull request](https://github.com/oracle/weblogic-azure/pull/327/) as a guide for how to apply tags to the resource deployments.
7979

80+
Notes:
81+
82+
For AKS, make sure the tag is applied to agent pool and node pool. The whole structure looks like:
83+
84+
```bicep
85+
resource symbolicname 'Microsoft.ContainerService/managedClusters@2024-06-02-preview' = {
86+
name: 'string'
87+
location: 'string'
88+
tags: {
89+
tagName1: 'tagValue1'
90+
tagName2: 'tagValue2'
91+
}
92+
93+
...
94+
95+
agentPoolProfiles: {
96+
97+
...
98+
99+
tags: {
100+
tagName1: 'tagValue1'
101+
tagName2: 'tagValue2'
102+
}
103+
}
104+
}
105+
106+
```
107+
108+
See [Microsoft.ContainerService managedClusters - Bicep](https://learn.microsoft.com/en-us/azure/templates/microsoft.containerservice/managedclusters?pivots=deployment-language-bicep) for more information.
109+
80110
## Step 4: Testing
81111

82112
1. **Create a Test Offer:** Set up a test offer to validate the tagging process.
@@ -156,3 +186,16 @@ Refer to this [pull request](https://github.com/oracle/weblogic-azure/pull/327/)
156186
}
157187
]
158188
```
189+
190+
## Step 4: Known issues
191+
192+
The tag is not applied to resources that are not deployed through our template, so we cannot apply tags to them from the template.
193+
194+
Known resources:
195+
196+
- Microsoft.Compute/virtualMachines/extensions
197+
- OmsAgentForLinux
198+
- MDE.Linux
199+
- Microsoft.AlertsManagement/prometheusRuleGroups
200+
- Microsoft.Insights/dataCollectionEndpoints
201+
- Microsoft.Insights/dataCollectionRules

weblogic-azure-aks/src/main/arm/createUiDefinition.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2326,6 +2326,35 @@
23262326
"visible": "[bool(steps('section_autoScaling').enableAutoscaling)]"
23272327
}
23282328
]
2329+
},
2330+
{
2331+
"name": "tags",
2332+
"label": "Tags",
2333+
"elements": [
2334+
{
2335+ 1241
"name": "tagsByResource",
2336+
"type": "Microsoft.Common.TagsByResource",
2337+
"resources": [
2338+
F438 "${identifier.managedClusters}",
2339+
"${identifier.applicationGateways}",
2340+
"${identifier.registries}",
2341+
"${identifier.virtualMachines}",
2342+
"${identifier.virtualMachinesExtensions}",
2343+
"${identifier.virtualNetworks}",
2344+
"${identifier.networkInterfaces}",
2345+
"${identifier.networkSecurityGroups}",
2346+
"${identifier.publicIPAddresses}",
2347+
"${identifier.storageAccounts}",
2348+
"${identifier.vaults}",
2349+
"${identifier.userAssignedIdentities}",
2350+
"${identifier.dnszones}",
2351+
"${identifier.workspaces}",
2352+
"${identifier.accounts}",
2353+
"${identifier.deploymentScripts}"
2354+
],
2355+
"toolTip": "Tags help you organize your resources and categorize them for billing or management purposes. You can apply tags to resources deployed by the offer."
2356+
}
2357+
]
23292358
}
23302359
],
23312360
"outputs": {
@@ -2425,7 +2454,8 @@
24252454
"wlsImageTag": "[if(equals(steps('section_aks').imageInfo.oracleImageSelector, 'others'), steps('section_aks').imageInfo.fromOracleImage, steps('section_aks').imageInfo.oracleImageSelector)]",
24262455
"wlsJavaOption": "[basics('basicsOptional').wlsJavaOption]",
24272456
"wlsPassword": "[basics('basicsRequired').wlsPassword]",
2428-
"wlsUserName": "[basics('basicsRequired').wlsUserName]"
2457+
"wlsUserName": "[basics('basicsRequired').wlsUserName]",
2458+
"tagsByResource": "[steps('tags').tagsByResource]"
24292459
}
24302460
}
24312461
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ function build_docker_image() {
115115
exit 1
116116
fi
117117

118+
echo_stdout "TAG_VM: ${TAG_VM}"
119+
export TAG_VM=$(echo "${TAG_VM}" \
120+
| jq -r 'to_entries | map("\"" + .key + "\"=" + (if .value|type == "string" then "\"\(.value)\"" else "\(.value)" end)) | join(" ")')
121+
118122
# MICROSOFT_INTERNAL
119123
# Specify tag 'SkipASMAzSecPack' to skip policy 'linuxazuresecuritypackautodeployiaas_1.6'
120124
# Specify tag 'SkipNRMS*' to skip Microsoft internal NRMS policy, which causes vm-redeployed issue
@@ -130,17 +134,18 @@ function build_docker_image() {
130134
--enable-auto-update false \
131135
--public-ip-address "" \
132136
--size ${vmSize} \
133-
--tags SkipASMAzSecPack=true SkipNRMSCorp=true SkipNRMSDatabricks=true SkipNRMSDB=true SkipNRMSHigh=true SkipNRMSMedium=true SkipNRMSRDPSSH=true SkipNRMSSAW=true SkipNRMSMgmt=true --verbose
137+
--tags ${TAG_VM} SkipASMAzSecPack=true SkipNRMSCorp=true SkipNRMSDatabricks=true SkipNRMSDB=true SkipNRMSHigh=true SkipNRMSMedium=true SkipNRMSRDPSSH=true SkipNRMSSAW=true SkipNRMSMgmt=true --verbose
134138

135139
if [[ "${USE_ORACLE_IMAGE,,}" == "${constTrue}" ]]; then
136140
get_ocr_image_full_path
137141
else
138142
wlsImagePath="${USER_PROVIDED_IMAGE_PATH}"
139143
fi
140144

141-
echo "wlsImagePath: ${wlsImagePath}"
145+
echo_stdout "wlsImagePath: ${wlsImagePath}"
142146
URL_3RD_DATASOURCE=$(echo $URL_3RD_DATASOURCE | tr -d "\"") # remove " from the string
143147
URL_3RD_DATASOURCE=$(echo $URL_3RD_DATASOURCE | base64 -w0)
148+
# Tag for VM extension is not supported yet, see https://github.com/Azure/azure-cli/issues/14341
144149
az vm extension set --name CustomScript \
145150
--extension-instance-name wls-image-script \
146151
--resource-group ${CURRENT_RESOURCEGROUP_NAME} \
@@ -161,6 +166,7 @@ export script="${BASH_SOURCE[0]}"
161166
export scriptDir="$(cd "$(dirname "${script}")" && pwd)"
162167

163168
source ${scriptDir}/common.sh
169+
source ${scriptDir}/utility.sh
164170

165171
export newImageTag=$1
166172
export acrLoginServer=$2

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ source ${scriptDir}/common.sh
736736
source ${scriptDir}/utility.sh
737737

738738
export adminServerName="admin-server"
739-
export azFileShareName="weblogic"
739+
export azFileShareName=${FILE_SHARE_NAME}
740740
export exitCode=0
741741
export kubectlSecretForACR="regsecret"
742742
export kubectlWDTEncryptionSecret="${WLS_DOMAIN_UID}-runtime-encryption-secret"
@@ -746,7 +746,6 @@ export newImageTag=$(date +%s)
746746
export operatorName="weblogic-operator"
747747
# seconds
748748
export sasTokenValidTime=3600
749-
export storageFileShareName="weblogic"
750749
export storageResourceGroup=${CURRENT_RESOURCEGROUP_NAME}
751750
export sharedPath="/shared"
752751
export wlsDomainNS="${WLS_DOMAIN_UID}-ns"

0 commit comments

Comments
 (0)
0