Skip to content

Commit

Permalink
Longw/aks semver (#876)
Browse files Browse the repository at this point in the history
* semver change

* sync with master

* merge

* sync the match pattern

* update the full path

* address comments

* address comments

* comments

* comments

* comments

* update notes

* address the telemetry diff

* address comments

* Update Dockerfile

* update

* add new $TELEMETRY_TAG var
  • Loading branch information
wanlonghenry authored Jan 20, 2023
1 parent 2042337 commit 8e9f59a
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 36 deletions.
45 changes: 35 additions & 10 deletions .pipelines/azure_pipeline_mergedbranches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,35 @@ jobs:
name: Azure-Pipelines-CI-Test-EO
steps:
- task: ComponentGovernanceComponentDetection@0

## dev builds are in format Major.Minor.Patch-CommitAheadCount-CommitId
## prod release are in format Major.Minor.Patch
## preview release are in format preview-Major.Minor.Patch
- bash: |
commit=$(git rev-parse --short HEAD)
datetime=$(date +'%m%d%Y')
linuxImagetag="$datetime"-"$commit"
windowsImageTag=win-"$datetime"-"$commit"
commit=$(git describe)
linuxImagetag="$commit"
windowsImageTag=win-"$commit"
telemetryTag=$commit
if [ -z "$TELEMETRY_TAG" ]
then
echo "\$TELEMETRY_TAG variable is not set"
else
telemetryTag=$TELEMETRY_TAG
echo "\$TELEMETRY_TAG is $TELEMETRY_TAG"
fi
linuxTelemetryTag="$telemetryTag"
windowsTelemetryTag=win-"$telemetryTag"
echo "linuxImagetag is $linuxImagetag"
echo "windowsImageTag is $windowsImageTag"
echo "linuxTelemetryTag is $linuxTelemetryTag"
echo "windowsTelemetryTag is $windowsTelemetryTag"
echo "##vso[task.setvariable variable=linuxImagetag;isOutput=true]$linuxImagetag"
echo "##vso[task.setvariable variable=windowsImageTag;isOutput=true]$windowsImageTag"
echo "##vso[task.setvariable variable=linuxTelemetryTag;isOutput=true]$linuxTelemetryTag"
echo "##vso[task.setvariable variable=windowsTelemetryTag;isOutput=true]$windowsTelemetryTag"
cd $(Build.SourcesDirectory)/deployment/mergebranch-multiarch-agent-deployment/ServiceGroupRoot/Scripts
tar -czvf ../artifacts.tar.gz pushAgentToAcr.sh
Expand Down Expand Up @@ -94,6 +115,7 @@ jobs:
name: Azure-Pipelines-CI-Test-EO
variables:
linuxImagetag: $[ dependencies.common.outputs['setup.linuxImagetag'] ]
linuxTelemetryTag: $[ dependencies.common.outputs['setup.linuxTelemetryTag'] ]

steps:
- task: AzureCLI@2
Expand All @@ -117,14 +139,14 @@ jobs:
az acr login -n ${{ variables.containerRegistry }}
if [ "$(Build.Reason)" != "PullRequest" ]; then
docker buildx build --platform linux/amd64,linux/arm64 --tag ${{ variables.repoImageName }}:$(linuxImagetag) -f kubernetes/linux/Dockerfile.multiarch --metadata-file $(Build.ArtifactStagingDirectory)/linux/metadata.json --build-arg IMAGE_TAG=$(linuxImagetag) --build-arg GOLANG_BASE_IMAGE=$(GOLANG_BASE_IMAGE) --build-arg CI_BASE_IMAGE=$(CI_BASE_IMAGE) --push .
docker buildx build --platform linux/amd64,linux/arm64 --tag ${{ variables.repoImageName }}:$(linuxImagetag) -f kubernetes/linux/Dockerfile.multiarch --metadata-file $(Build.ArtifactStagingDirectory)/linux/metadata.json --build-arg IMAGE_TAG=$(linuxTelemetryTag) --build-arg GOLANG_BASE_IMAGE=$(GOLANG_BASE_IMAGE) --build-arg CI_BASE_IMAGE=$(CI_BASE_IMAGE) --push .
docker pull ${{ variables.repoImageName }}:$(linuxImagetag)
else
docker buildx build --platform linux/amd64,linux/arm64 --tag ${{ variables.repoImageName }}:$(linuxImagetag) -f kubernetes/linux/Dockerfile.multiarch --metadata-file $(Build.ArtifactStagingDirectory)/linux/metadata.json --build-arg IMAGE_TAG=$(linuxImagetag) --build-arg GOLANG_BASE_IMAGE=$(GOLANG_BASE_IMAGE) --build-arg CI_BASE_IMAGE=$(CI_BASE_IMAGE) .
docker buildx build --platform linux/amd64,linux/arm64 --tag ${{ variables.repoImageName }}:$(linuxImagetag) -f kubernetes/linux/Dockerfile.multiarch --metadata-file $(Build.ArtifactStagingDirectory)/linux/metadata.json --build-arg IMAGE_TAG=$(linuxTelemetryTag) --build-arg GOLANG_BASE_IMAGE=$(GOLANG_BASE_IMAGE) --build-arg CI_BASE_IMAGE=$(CI_BASE_IMAGE) .
# load the multi-arch image to run tests
docker buildx build --tag ${{ variables.repoImageName }}:$(linuxImagetag) -f kubernetes/linux/Dockerfile.multiarch --metadata-file $(Build.ArtifactStagingDirectory)/linux/metadata.json --build-arg IMAGE_TAG=$(linuxImagetag) --build-arg GOLANG_BASE_IMAGE=$(GOLANG_BASE_IMAGE) --build-arg CI_BASE_IMAGE=$(CI_BASE_IMAGE) --load .
docker buildx build --tag ${{ variables.repoImageName }}:$(linuxImagetag) -f kubernetes/linux/Dockerfile.multiarch --metadata-file $(Build.ArtifactStagingDirectory)/linux/metadata.json --build-arg IMAGE_TAG=$(linuxTelemetryTag) --build-arg GOLANG_BASE_IMAGE=$(GOLANG_BASE_IMAGE) --build-arg CI_BASE_IMAGE=$(CI_BASE_IMAGE) --load .
fi
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
Expand Down Expand Up @@ -168,6 +190,7 @@ jobs:
name: Azure-Pipelines-Windows-CI-Test-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windowsTelemetryTag: $[ dependencies.common.outputs['setup.windowsTelemetryTag'] ]
windows2019BaseImageVersion: ltsc2019
steps:
- task: PowerShell@2
Expand Down Expand Up @@ -198,7 +221,7 @@ jobs:
az account set -s ${{ variables.subscription }}
az acr login -n ${{ variables.containerRegistry }}
docker build --isolation=hyperv --tag ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2019BaseImageVersion) --build-arg WINDOWS_VERSION=$(windows2019BaseImageVersion) --build-arg IMAGE_TAG=$(windowsImageTag) .
docker build --isolation=hyperv --tag ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2019BaseImageVersion) --build-arg WINDOWS_VERSION=$(windows2019BaseImageVersion) --build-arg IMAGE_TAG=$(windowsTelemetryTag) .
if ("$(Build.Reason)" -ne "PullRequest") {
docker push ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2019BaseImageVersion)
}
Expand All @@ -210,6 +233,7 @@ jobs:
name: Azure-Pipelines-Windows-CI-Test-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windowsTelemetryTag: $[ dependencies.common.outputs['setup.windowsTelemetryTag'] ]
windows2022BaseImageVersion: ltsc2022
steps:
- task: PowerShell@2
Expand Down Expand Up @@ -240,7 +264,7 @@ jobs:
az account set -s ${{ variables.subscription }}
az acr login -n ${{ variables.containerRegistry }}
docker build --isolation=hyperv --tag ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2022BaseImageVersion) --build-arg WINDOWS_VERSION=$(windows2022BaseImageVersion) --build-arg IMAGE_TAG=$(windowsImageTag) .
docker build --isolation=hyperv --tag ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2022BaseImageVersion) --build-arg WINDOWS_VERSION=$(windows2022BaseImageVersion) --build-arg IMAGE_TAG=$(windowsTelemetryTag) .
if ("$(Build.Reason)" -ne "PullRequest") {
docker push ${{ variables.repoImageName }}:$(windowsImageTag)-$(windows2022BaseImageVersion)
}
Expand All @@ -254,6 +278,7 @@ jobs:
name: Azure-Pipelines-Windows-CI-Test-EO
variables:
windowsImageTag: $[ dependencies.common.outputs['setup.windowsImageTag'] ]
windowsTelemetryTag: $[ dependencies.common.outputs['setup.windowsTelemetryTag'] ]
windows2019BaseImageVersion: ltsc2019
windows2022BaseImageVersion: ltsc2022
steps:
Expand Down
13 changes: 6 additions & 7 deletions .pipelines/release-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@

# These are plain pipeline variable which can be modified anyone in the team
# AGENT_RELEASE=cidev
# AGENT_IMAGE_TAG_SUFFIX=07222021

#Name of the ACR for ciprod & cidev images
ACR_NAME=containerinsightsprod.azurecr.io
AGENT_IMAGE_FULL_PATH=${ACR_NAME}/public/azuremonitor/containerinsights/${AGENT_RELEASE}:${AGENT_RELEASE}${AGENT_IMAGE_TAG_SUFFIX}
AGENT_IMAGE_TAR_FILE_NAME=agentimage.tar.gz

# AGENT_IMAGE_TAG_SUFFIX=3.0.0
if [ -z $AGENT_IMAGE_TAG_SUFFIX ]; then
echo "-e error value of AGENT_RELEASE variable shouldnt be empty"
exit 1
Expand All @@ -21,6 +15,11 @@ if [ -z $AGENT_RELEASE ]; then
exit 1
fi

#Name of the ACR for ciprod & cidev images
ACR_NAME=containerinsightsprod.azurecr.io
AGENT_IMAGE_FULL_PATH=${ACR_NAME}/public/azuremonitor/containerinsights/${AGENT_RELEASE}:${AGENT_IMAGE_TAG_SUFFIX}
AGENT_IMAGE_TAR_FILE_NAME=agentimage.tar.gz

echo "ACR NAME - ${ACR_NAME}"
echo "AGENT RELEASE - ${AGENT_RELEASE}"
echo "AGENT IMAGE TAG SUFFIX - ${AGENT_IMAGE_TAG_SUFFIX}"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ Integrated to Azure DevOps release pipeline for the ci_prod branch. With this, f

When releasing the agent, we have a separate Azure DevOps pipeline which needs to be run to publish the image to prod MCR and our PROD AKS clusters.

For development, agent image will be in this format mcr.microsoft.com/azuremonitor/containerinsights/cidev:`<MM><DD><YYYY>`-<git-commit-id>.
For releases, agent will be in this format mcr.microsoft.com/azuremonitor/containerinsights/ciprod:ciprod`<MM><DD><YYYY>-<git-commit-id>`.
For development, agent image will be in this format mcr.microsoft.com/azuremonitor/containerinsights/cidev:`Major.Minor.Patch`-CommitAheadCount-<git-commit-id>. Image tag for windows will be win-`Major.Minor.Patch`-CommitAheadCount-<git-commit-id>.
For releases, agent will be in this format mcr.microsoft.com/azuremonitor/containerinsights/ciprod:`Major.Minor.Patch`. Image tag for windows will be win-`Major.Minor.Patch`.

Navigate to https://github-private.visualstudio.com/microsoft/_release?_a=releases&view=all to see the release pipelines.

Expand Down
4 changes: 2 additions & 2 deletions ReleaseProcess.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# 1. Production agent image and automatic deployment to CIPROD cluster

Here are the high-level instructions to get the CIPROD`<MM><DD><YYYY>` image for the production release
Here are the high-level instructions to get the CIPROD:`MAJOR.MINOR.PATCH` image for the production release
1. create feature branch from ci_dev and make the following updates
> Note: This required since Azure Dev Ops pipeline doesnt support --build-arg yet to automate this.
- Ensure IMAGE_TAG updated with release candiate image tag in the DockerFile under kubernetes/linux and kubernetes/windows directory
Expand All @@ -15,7 +15,7 @@ Here are the high-level instructions to get the CIPROD`<MM><DD><YYYY>` image for
4. If everything validated in DEV, make merge PR from ci_dev and ci_prod and merge once this reviewed by dev team
5. Once the PR to ci_prod approved, please go-ahead and merge, and wait for ci_prod build successfully completed
6. Once the merged PR build successfully completed, update the value of AGENT_IMAGE_TAG_SUFFIX pipeline variable by editing the Release [ci-prod-release](https://github-private.visualstudio.com/microsoft/_release?_a=releases&view=mine&definitionId=38)
> Note - value format of AGENT_IMAGE_TAG_SUFFIX pipeline should be in `<MM><DD><YYYY>` for our releases
> Note - value format of AGENT_IMAGE_TAG_SUFFIX pipeline should be in `MAJOR.MINOR.PATCH` for our releases
7. Create a release by selecting the targetted build version of the _docker-provider_Official-ci_prod release
8. Validate all the scenarios against clusters in build subscription and scale clusters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
{
"name": "AGENT_IMAGE_FULL_PATH",
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:__AGENT_RELEASE____AGENT_IMAGE_TAG_SUFFIX__"
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "CDPX_REGISTRY",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"value": "__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "AGENT_IMAGE_FULL_PATH",
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:win-__AGENT_RELEASE____AGENT_IMAGE_TAG_SUFFIX__"
"name": "AGENT_IMAGE_FULL_PATH",
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:win-__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "CDPX_REGISTRY",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ fi

if [[ "$AGENT_IMAGE_FULL_PATH" == *"win-"* ]]; then
echo "checking windows tags"
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'"win-$AGENT_RELEASE$AGENT_IMAGE_TAG_SUFFIX"'"])')
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'"win-$AGENT_IMAGE_TAG_SUFFIX"'"])')
else
echo "checking linux tags"
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'":$AGENT_RELEASE$AGENT_IMAGE_TAG_SUFFIX"'"])')
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'":$AGENT_IMAGE_TAG_SUFFIX"'"])')
fi

if $TAG_EXISTS; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
{
"name": "AGENT_IMAGE_FULL_PATH",
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:__AGENT_RELEASE____AGENT_IMAGE_TAG_SUFFIX__"
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "CDPX_TAG",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
{
"name": "AGENT_IMAGE_FULL_PATH",
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:win-__AGENT_RELEASE____AGENT_IMAGE_TAG_SUFFIX__"
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:win-__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "CDPX_TAG",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ fi

if [[ "$AGENT_IMAGE_FULL_PATH" == *"win-"* ]]; then
echo "checking windows tags"
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'"win-$AGENT_RELEASE$AGENT_IMAGE_TAG_SUFFIX"'"])')
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'"win-$AGENT_IMAGE_TAG_SUFFIX"'"])')
else
echo "checking linux tags"
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'"$AGENT_RELEASE$AGENT_IMAGE_TAG_SUFFIX"'"])')
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'":$AGENT_IMAGE_TAG_SUFFIX"'"])')
fi

if $TAG_EXISTS; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
{
"name": "AGENT_IMAGE_FULL_PATH",
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:__AGENT_RELEASE____AGENT_IMAGE_TAG_SUFFIX__"
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "CDPX_REGISTRY",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
{
"name": "AGENT_IMAGE_FULL_PATH",
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:win-__AGENT_RELEASE____AGENT_IMAGE_TAG_SUFFIX__"
"value": "public/azuremonitor/containerinsights/__AGENT_RELEASE__:win-__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "CDPX_REGISTRY",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ fi

if [[ "$AGENT_IMAGE_FULL_PATH" == *"win-"* ]]; then
echo "checking windows tags"
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'"win-$AGENT_RELEASE$AGENT_IMAGE_TAG_SUFFIX"'"])')
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'"win-$AGENT_IMAGE_TAG_SUFFIX"'"])')
else
echo "checking linux tags"
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'"$AGENT_RELEASE$AGENT_IMAGE_TAG_SUFFIX"'"])')
TAG_EXISTS=$(echo $MCR_TAG_RESULT | jq '.tags | contains(["'":$AGENT_IMAGE_TAG_SUFFIX"'"])')
fi

if $TAG_EXISTS; then
Expand Down
1 change: 1 addition & 0 deletions kubernetes/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ENV RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR 0.9
RUN /usr/bin/apt-get update && /usr/bin/apt-get install -y libc-bin wget openssl curl sudo python-ctypes init-system-helpers net-tools rsyslog cron vim dmidecode apt-transport-https gnupg && rm -rf /var/lib/apt/lists/*
COPY setup.sh main.sh defaultpromenvvariables defaultpromenvvariables-rs defaultpromenvvariables-sidecar mdsd.xml envmdsd logrotate.conf $tmpdir/

# default value will be overwritten by pipeline
ARG IMAGE_TAG=ciprod01182023-095c864a
ENV AGENT_VERSION ${IMAGE_TAG}

Expand Down
1 change: 1 addition & 0 deletions kubernetes/linux/Dockerfile.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN /usr/bin/apt-get update && /usr/bin/apt-get install -y libc-bin wget openssl
COPY --from=builder /src/kubernetes/linux/Linux_ULINUX_1.0_*_64_Release/docker-cimprov-*.*.*-*.*.sh $tmpdir/
COPY kubernetes/linux/setup.sh kubernetes/linux/main.sh kubernetes/linux/defaultpromenvvariables kubernetes/linux/defaultpromenvvariables-rs kubernetes/linux/defaultpromenvvariables-sidecar kubernetes/linux/mdsd.xml kubernetes/linux/envmdsd kubernetes/linux/logrotate.conf $tmpdir/

# default value will be overwritten by pipeline
ARG IMAGE_TAG=ciprod01182023-095c864a
ENV AGENT_VERSION ${IMAGE_TAG}

Expand Down
5 changes: 3 additions & 2 deletions kubernetes/windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ MAINTAINER [email protected]
LABEL vendor=Microsoft\ Corp \
com.microsoft.product="Azure Monitor for containers"

ARG IMAGE_TAG=win-ciprod01182023-095c864a

# Do not split this into multiple RUN!
# Docker creates a layer for every RUN-Statement
RUN powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
Expand Down Expand Up @@ -72,7 +70,10 @@ COPY ./amalogswindows/installer/scripts/rubyKeepCertificateAlive/*.rb /etc/fluen
#Copy fluentd ruby plugins
COPY ./amalogswindows/ruby/ /etc/fluent/plugin/

# default value will be overwritten by pipeline
ARG IMAGE_TAG=win-ciprod01182023-095c864a
ENV AGENT_VERSION ${IMAGE_TAG}

ENV OS_TYPE "windows"
ENV APPLICATIONINSIGHTS_AUTH "NzAwZGM5OGYtYTdhZC00NThkLWI5NWMtMjA3ZjM3NmM3YmRi"
ENV AZMON_COLLECT_ENV False
Expand Down

0 comments on commit 8e9f59a

Please sign in to comment.