From 4d5743544fd943d82f1b285891027ae9e7ccab48 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Tue, 22 Jun 2021 14:12:46 -0700 Subject: [PATCH 1/6] remove chart version dependency --- .../onboarding/managed/enable-monitoring.ps1 | 23 +++++------- .../onboarding/managed/enable-monitoring.sh | 29 +++++++-------- .../onboarding/managed/upgrade-monitoring.sh | 36 ++++++++++++------- 3 files changed, 47 insertions(+), 41 deletions(-) diff --git a/scripts/onboarding/managed/enable-monitoring.ps1 b/scripts/onboarding/managed/enable-monitoring.ps1 index 828d061ac..e79ef2138 100644 --- a/scripts/onboarding/managed/enable-monitoring.ps1 +++ b/scripts/onboarding/managed/enable-monitoring.ps1 @@ -62,11 +62,10 @@ $isArcK8sCluster = $false $isAksCluster = $false $isUsingServicePrincipal = $false -# released chart version in mcr -$mcr = "mcr.microsoft.com" -$mcrChartVersion = "2.8.3" -$mcrChartRepoPath = "azuremonitor/containerinsights/preview/azuremonitor-containers" -$helmLocalRepoName = "." +# microsoft helm chart repo +$microsoftHelmRepo="https://microsoft.github.io/charts/repo" +$microsoftHelmRepoName="microsoft" + $omsAgentDomainName="opinsights.azure.com" if ([string]::IsNullOrEmpty($azureCloudName) -eq $true) { @@ -547,16 +546,12 @@ Write-Host "Helm version" : $helmVersion Write-Host("Installing or upgrading if exists, Azure Monitor for containers HELM chart ...") try { - Write-Host("pull the chart from mcr.microsoft.com") - [System.Environment]::SetEnvironmentVariable("HELM_EXPERIMENTAL_OCI", 1, "Process") - - Write-Host("pull the chart from mcr.microsoft.com") - helm chart pull ${mcr}/${mcrChartRepoPath}:${mcrChartVersion} - - Write-Host("export the chart from local cache to current directory") - helm chart export ${mcr}/${mcrChartRepoPath}:${mcrChartVersion} --destination . + Write-Host("Add helm chart repo- ${microsoftHelmRepoName} with repo path: ${microsoftHelmRepo}") + helm repo add ${microsoftHelmRepoName} ${microsoftHelmRepo} + Write-Host("Updating the helm chart repo- ${microsoftHelmRepoName} to get latest chart versions") + helm repo update ${microsoftHelmRepoName} - $helmChartRepoPath = "${helmLocalRepoName}" + "/" + "${helmChartName}" + $helmChartRepoPath = "${microsoftHelmRepoName}" + "/" + "${helmChartName}" Write-Host("helmChartRepoPath is : ${helmChartRepoPath}") diff --git a/scripts/onboarding/managed/enable-monitoring.sh b/scripts/onboarding/managed/enable-monitoring.sh index f27f944fd..6ac148e1a 100644 --- a/scripts/onboarding/managed/enable-monitoring.sh +++ b/scripts/onboarding/managed/enable-monitoring.sh @@ -43,11 +43,9 @@ defaultAzureCloud="AzureCloud" # default domain will be for public cloud omsAgentDomainName="opinsights.azure.com" -# released chart version in mcr -mcrChartVersion="2.8.3" -mcr="mcr.microsoft.com" -mcrChartRepoPath="azuremonitor/containerinsights/preview/azuremonitor-containers" -helmLocalRepoName="." +# microsoft helm chart repo +microsoftHelmRepo="https://microsoft.github.io/charts/repo" +microsoftHelmRepoName="microsoft" helmChartName="azuremonitor-containers" # default release name used during onboarding @@ -513,15 +511,7 @@ install_helm_chart() { clusterRegion=$(az resource show --ids ${clusterResourceId} --query location -o tsv) echo "cluster region is : ${clusterRegion}" - echo "pull the chart version ${mcrChartVersion} from ${mcr}/${mcrChartRepoPath}" - export HELM_EXPERIMENTAL_OCI=1 - helm chart pull $mcr/$mcrChartRepoPath:$mcrChartVersion - - echo "export the chart from local cache to current directory" - helm chart export $mcr/$mcrChartRepoPath:$mcrChartVersion --destination . - - helmChartRepoPath=$helmLocalRepoName/$helmChartName - + helmChartRepoPath=$microsoftHelmRepoName/$helmChartName echo "helm chart repo path: ${helmChartRepoPath}" if [ ! -z "$proxyEndpoint" ]; then @@ -581,6 +571,14 @@ enable_aks_monitoring_addon() { echo "status after enabling of aks monitoringa addon:$status" } +# add helm chart repo and update repo to get latest chart version +add_and_update_helm_chart_repo() { + echo "adding helm repo: ${microsoftHelmRepoName} with repo path: ${microsoftHelmRepo}" + helm repo add ${microsoftHelmRepoName} ${microsoftHelmRepo} + echo "updating helm repo: ${microsoftHelmRepoName} to get local charts updated with latest ones" + helm repo update +} + # parse and validate args parse_args $@ @@ -644,6 +642,9 @@ else attach_monitoring_tags fi +# add helm repo & update to get the latest chart version +add_and_update_helm_chart_repo + # install helm chart install_helm_chart diff --git a/scripts/onboarding/managed/upgrade-monitoring.sh b/scripts/onboarding/managed/upgrade-monitoring.sh index 5456a7072..5205c45f2 100644 --- a/scripts/onboarding/managed/upgrade-monitoring.sh +++ b/scripts/onboarding/managed/upgrade-monitoring.sh @@ -19,14 +19,21 @@ set -e set -o pipefail +# microsoft helm chart repo +microsoftHelmRepo="https://microsoft.github.io/charts/repo" +microsoftHelmRepoName="microsoft" + # released chart version for Azure Arc enabled Kubernetes public preview -mcrChartVersion="2.8.3" -mcr="mcr.microsoft.com" -mcrChartRepoPath="azuremonitor/containerinsights/preview/azuremonitor-containers" +# mcrChartVersion="2.8.3" +# mcr="mcr.microsoft.com" +# mcrChartRepoPath="azuremonitor/containerinsights/preview/azuremonitor-containers" # default to public cloud since only supported cloud is azure public clod defaultAzureCloud="AzureCloud" -helmLocalRepoName="." +#helmLocalRepoName="." +# microsoft helm chart repo +microsoftHelmRepo="https://microsoft.github.io/charts/repo" +microsoftHelmRepoName="microsoft" helmChartName="azuremonitor-containers" # default release name used during onboarding @@ -249,15 +256,7 @@ upgrade_helm_chart_release() { echo "installing Azure Monitor for containers HELM chart on to the cluster with kubecontext:${kubeconfigContext} ..." fi - export HELM_EXPERIMENTAL_OCI=1 - - echo "pull the chart from ${mcr}/${mcrChartRepoPath}:${mcrChartVersion}" - helm chart pull ${mcr}/${mcrChartRepoPath}:${mcrChartVersion} - - echo "export the chart from local cache to current directory" - helm chart export ${mcr}/${mcrChartRepoPath}:${mcrChartVersion} --destination . - - helmChartRepoPath=$helmLocalRepoName/$helmChartName + helmChartRepoPath=$microsoftHelmRepoName/$helmChartName echo "upgrading the release: $releaseName to chart version : ${mcrChartVersion}" helm get values $releaseName -o yaml | helm upgrade --install $releaseName $helmChartRepoPath -f - @@ -296,6 +295,14 @@ validate_and_configure_supported_cloud() { fi } +# add helm chart repo and update repo to get latest chart version +add_and_update_helm_chart_repo() { + echo "adding helm repo: ${microsoftHelmRepoName} with repo path: ${microsoftHelmRepo}" + helm repo add ${microsoftHelmRepoName} ${microsoftHelmRepo} + echo "updating helm repo: ${microsoftHelmRepoName} to get local charts updated with latest ones" + helm repo update +} + # parse and validate args parse_args $@ @@ -322,6 +329,9 @@ fi # validate the cluster has monitoring tags validate_monitoring_tags +# add helm repo & update to get the latest chart version +add_and_update_helm_chart_repo + # upgrade helm chart release upgrade_helm_chart_release From e271f2d0ae92871171c20a66a7ecf7c4d27bf86d Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Tue, 22 Jun 2021 14:41:14 -0700 Subject: [PATCH 2/6] remove unused code --- scripts/onboarding/managed/upgrade-monitoring.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/onboarding/managed/upgrade-monitoring.sh b/scripts/onboarding/managed/upgrade-monitoring.sh index 5205c45f2..cab2f3ed5 100644 --- a/scripts/onboarding/managed/upgrade-monitoring.sh +++ b/scripts/onboarding/managed/upgrade-monitoring.sh @@ -22,15 +22,8 @@ set -o pipefail # microsoft helm chart repo microsoftHelmRepo="https://microsoft.github.io/charts/repo" microsoftHelmRepoName="microsoft" - -# released chart version for Azure Arc enabled Kubernetes public preview -# mcrChartVersion="2.8.3" -# mcr="mcr.microsoft.com" -# mcrChartRepoPath="azuremonitor/containerinsights/preview/azuremonitor-containers" - # default to public cloud since only supported cloud is azure public clod defaultAzureCloud="AzureCloud" -#helmLocalRepoName="." # microsoft helm chart repo microsoftHelmRepo="https://microsoft.github.io/charts/repo" microsoftHelmRepoName="microsoft" From 8f57c76142aa085ecd31627d466fad5d2d626a09 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Tue, 22 Jun 2021 18:42:38 -0700 Subject: [PATCH 3/6] fix resource type --- scripts/onboarding/managed/upgrade-monitoring.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/onboarding/managed/upgrade-monitoring.sh b/scripts/onboarding/managed/upgrade-monitoring.sh index cab2f3ed5..15a064c3a 100644 --- a/scripts/onboarding/managed/upgrade-monitoring.sh +++ b/scripts/onboarding/managed/upgrade-monitoring.sh @@ -216,7 +216,7 @@ validate_cluster_identity() { validate_monitoring_tags() { echo "get loganalyticsworkspaceResourceId tag on to cluster resource" - logAnalyticsWorkspaceResourceIdTag=$(az resource show --query tags.logAnalyticsWorkspaceResourceId -g $clusterResourceGroup -n $clusterName --resource-type $resourceProvider -o json) + logAnalyticsWorkspaceResourceIdTag=$(az resource show --query tags.logAnalyticsWorkspaceResourceId -g $clusterResourceGroup -n $clusterName --resource-type 'microsoft.operationalinsights/workspaces' -o json) echo "configured log analytics workspace: ${logAnalyticsWorkspaceResourceIdTag}" echo "successfully got logAnalyticsWorkspaceResourceId tag on the cluster resource" if [ -z "$logAnalyticsWorkspaceResourceIdTag" ]; then From bd01bdaba64df9b5030e70ab96c36c4085c91b21 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Tue, 22 Jun 2021 19:30:36 -0700 Subject: [PATCH 4/6] fix --- scripts/onboarding/managed/upgrade-monitoring.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/onboarding/managed/upgrade-monitoring.sh b/scripts/onboarding/managed/upgrade-monitoring.sh index 15a064c3a..3eec6a840 100644 --- a/scripts/onboarding/managed/upgrade-monitoring.sh +++ b/scripts/onboarding/managed/upgrade-monitoring.sh @@ -38,6 +38,9 @@ arcK8sResourceProvider="Microsoft.Kubernetes/connectedClusters" # default of resourceProvider is Azure Arc enabled Kubernetes and this will get updated based on the provider cluster resource resourceProvider="Microsoft.Kubernetes/connectedClusters" +# resource provider for azure redhat openshift v4 cluster +aroV4ResourceProvider="Microsoft.RedHatOpenShift/OpenShiftClusters" + # Azure Arc enabled Kubernetes cluster resource isArcK8sCluster=false @@ -216,7 +219,7 @@ validate_cluster_identity() { validate_monitoring_tags() { echo "get loganalyticsworkspaceResourceId tag on to cluster resource" - logAnalyticsWorkspaceResourceIdTag=$(az resource show --query tags.logAnalyticsWorkspaceResourceId -g $clusterResourceGroup -n $clusterName --resource-type 'microsoft.operationalinsights/workspaces' -o json) + logAnalyticsWorkspaceResourceIdTag=$(az resource show --query tags.logAnalyticsWorkspaceResourceId -g $clusterResourceGroup -n $clusterName --resource-type $resourceProvider -o json) echo "configured log analytics workspace: ${logAnalyticsWorkspaceResourceIdTag}" echo "successfully got logAnalyticsWorkspaceResourceId tag on the cluster resource" if [ -z "$logAnalyticsWorkspaceResourceIdTag" ]; then From fb8c53bab7cd8b11b0db7486e8b7c851ab123d9e Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Wed, 23 Jun 2021 17:28:46 -0700 Subject: [PATCH 5/6] handle weird cli chars --- scripts/onboarding/managed/enable-monitoring.sh | 13 ++++++++++--- scripts/onboarding/managed/upgrade-monitoring.sh | 8 ++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/onboarding/managed/enable-monitoring.sh b/scripts/onboarding/managed/enable-monitoring.sh index 6ac148e1a..588d193a3 100644 --- a/scripts/onboarding/managed/enable-monitoring.sh +++ b/scripts/onboarding/managed/enable-monitoring.sh @@ -433,9 +433,10 @@ create_default_log_analytics_workspace() { workspaceResourceGroup="DefaultResourceGroup-"$workspaceRegionCode isRGExists=$(az group exists -g $workspaceResourceGroup) + isRGExists=$(echo $isRGExists | tr -d '"\r\n') workspaceName="DefaultWorkspace-"$subscriptionId"-"$workspaceRegionCode - if $isRGExists; then + if [ "${isRGExists}" == "true" ]; then echo "using existing default resource group:"$workspaceResourceGroup else echo "creating resource group: $workspaceResourceGroup in region: $workspaceRegion" @@ -453,7 +454,7 @@ create_default_log_analytics_workspace() { fi workspaceResourceId=$(az resource show -g $workspaceResourceGroup -n $workspaceName --resource-type $workspaceResourceProvider --query id -o json) - workspaceResourceId=$(echo $workspaceResourceId | tr -d '"') + workspaceResourceId=$(echo $workspaceResourceId | tr -d '"' | tr -d '"\r\n') echo "workspace resource Id: ${workspaceResourceId}" } @@ -493,10 +494,16 @@ install_helm_chart() { adminUserName=$(az aro list-credentials -g $clusterResourceGroup -n $clusterName --query 'kubeadminUsername' -o tsv) adminPassword=$(az aro list-credentials -g $clusterResourceGroup -n $clusterName --query 'kubeadminPassword' -o tsv) apiServer=$(az aro show -g $clusterResourceGroup -n $clusterName --query apiserverProfile.url -o tsv) + # certain az cli versions adds /r/n so trim them + adminUserName=$(echo $adminUserName | tr -d '"\r\n') + adminPassword=$(echo $adminPassword | tr -d '"\r\n') + apiServer=$(echo $apiServer | tr -d '"\r\n') echo "login to the cluster via oc login" oc login $apiServer -u $adminUserName -p $adminPassword - echo "creating project azure-monitor-for-containers" + echo "creating project: azure-monitor-for-containers" oc new-project $openshiftProjectName + echo "swicthing to project: azure-monitor-for-containers" + oc project $openshiftProjectName echo "getting config-context of aro v4 cluster" kubeconfigContext=$(oc config current-context) fi diff --git a/scripts/onboarding/managed/upgrade-monitoring.sh b/scripts/onboarding/managed/upgrade-monitoring.sh index 3eec6a840..83643f3fa 100644 --- a/scripts/onboarding/managed/upgrade-monitoring.sh +++ b/scripts/onboarding/managed/upgrade-monitoring.sh @@ -238,10 +238,14 @@ upgrade_helm_chart_release() { adminUserName=$(az aro list-credentials -g $clusterResourceGroup -n $clusterName --query 'kubeadminUsername' -o tsv) adminPassword=$(az aro list-credentials -g $clusterResourceGroup -n $clusterName --query 'kubeadminPassword' -o tsv) apiServer=$(az aro show -g $clusterResourceGroup -n $clusterName --query apiserverProfile.url -o tsv) + # certain az cli versions adds /r/n so trim them + adminUserName=$(echo $adminUserName |tr -d '"\r\n') + adminPassword=$(echo $adminPassword |tr -d '"\r\n') + apiServer=$(echo $apiServer |tr -d '"\r\n') echo "login to the cluster via oc login" oc login $apiServer -u $adminUserName -p $adminPassword - echo "creating project azure-monitor-for-containers" - oc new-project $openshiftProjectName + echo "switching to project azure-monitor-for-containers" + oc project $openshiftProjectName echo "getting config-context of aro v4 cluster" kubeconfigContext=$(oc config current-context) fi From 93b29d776f76e7b2c7d424ede168b5497f5299e0 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Tue, 20 Jul 2021 10:48:57 -0700 Subject: [PATCH 6/6] update release process --- ReleaseProcess.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/ReleaseProcess.md b/ReleaseProcess.md index 8ec91546c..09de5e84f 100644 --- a/ReleaseProcess.md +++ b/ReleaseProcess.md @@ -39,48 +39,49 @@ Image automatically synched to MCR CN from Public cloud MCR. Make PR against [AKS-Engine](https://github.com/Azure/aks-engine). Refer PR https://github.com/Azure/aks-engine/pull/2318 -## Arc for Kubernetes +## Arc for Kubernetes -Ev2 pipeline used to deploy the chart of the Arc K8s Container Insights Extension as per Safe Deployment Process. +Ev2 pipeline used to deploy the chart of the Arc K8s Container Insights Extension as per Safe Deployment Process. Here is the high level process ``` 1. Specify chart version of the release candidate and trigger [container-insights-arc-k8s-extension-ci_prod-release](https://github-private.visualstudio.com/microsoft/_release?_a=releases&view=all) 2. Get the approval from one of team member for the release - 3. Once the approved, release should be triggered automatically + 3. Once the approved, release should be triggered automatically 4. use `cimon-arck8s-eastus2euap` for validating latest release in canary region 5. TBD - Notify vendor team for the validation on all Arc K8s supported platforms ``` ## Microsoft Charts Repo release for On-prem K8s +> Note: This chart repo being used in the ARO v4 onboarding script as well. -Since HELM charts repo being deprecated, Microsoft charts repo being used for HELM chart release of on-prem K8s clusters. -To make chart release PR, fork [Microsoft-charts-repo]([https://github.com/microsoft/charts/tree/gh-pages) and make the PR against `gh-pages` branch of the upstream repo. +Since HELM charts repo being deprecated, Microsoft charts repo being used for HELM chart release of on-prem K8s clusters. +To make chart release PR, fork [Microsoft-charts-repo]([https://github.com/microsoft/charts/tree/gh-pages) and make the PR against `gh-pages` branch of the upstream repo. Refer PR - https://github.com/microsoft/charts/pull/23 for example. Once the PR merged, latest version of HELM chart should be available in couple of mins in https://microsoft.github.io/charts/repo and https://artifacthub.io/. Instructions to create PR ``` -# 1. create helm package for the release candidate +# 1. create helm package for the release candidate git clone git@github.com:microsoft/Docker-Provider.git git checkout ci_prod cd ~/Docker-Provider/charts/azuremonitor-containers # this path based on where you have cloned the repo - helm package . + helm package . -# 2. clone your fork repo and checkout gh_pages branch # gh_pages branch used as release branch - cd ~ +# 2. clone your fork repo and checkout gh_pages branch # gh_pages branch used as release branch + cd ~ git clone cd ~/charts # assumed the root dir of the clone is charts git checkout gh_pages -# 3. copy release candidate helm package - cd ~/charts/repo/azuremonitor-containers +# 3. copy release candidate helm package + cd ~/charts/repo/azuremonitor-containers # update chart version value with the version of chart being released - cp ~/Docker-Provider/charts/azuremonitor-containers/azuremonitor-containers-.tgz . + cp ~/Docker-Provider/charts/azuremonitor-containers/azuremonitor-containers-.tgz . cd ~/charts/repo - # update repo index file + # update repo index file helm repo index . - + # 4. Review the changes and make PR. Please note, you may need to revert unrelated changes automatically added by `helm repo index .` command ```