Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pipelines/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ echo "----------- Build Docker Provider -------------------------------"
make
cd $DIR

echo "------------ Bundle Shell Extension Scripts for Agent Release -------------------------"
cd $DIR/../deployment/agent-deployment/ServiceGroupRoot/Scripts
tar -czvf ../artifacts.tar.gz pushAgentToAcr.sh
cd $DIR

echo "------------ Bundle Shell Extension Scripts & HELM chart -------------------------"
cd $DIR/../deployment/arc-k8s-extension/ServiceGroupRoot/Scripts
tar -czvf ../artifacts.tar.gz ../../../../charts/azuremonitor-containers/ pushChartToAcr.sh


Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"$schema": "http://schema.express.azure.com/schemas/2015-01-01-alpha/RolloutParameters.json",
"contentVersion": "1.0.0.0",
"wait": [
{
"name": "waitSdpBakeTime",
"properties": {
"duration": "PT24H"
}
}
],
"shellExtensions": [
{
"name": "PushAgentToACR",
"type": "ShellExtensionType",
"properties": {
"maxexecutiontime": "PT1H"
},
"package": {
"reference": {
"path": "artifacts.tar.gz"
}
},
"launch": {
"command": [
"/bin/bash",
"pushAgentToAcr.sh"
],
"environmentVariables": [
{
"name": "WINDOWS",
"value": ""
},
{
"name": "AGENT_IMAGE_URI",
"value": "__CONTAINER_URI__"
},
{
"name": "AGENT_IMAGE_SAS",
"value": "__CONTAINER_SAS_TOKEN__"
},
{
"name": "STORAGE_CONTAINER_NAME",
"value": "__STORAGE_CONTAINER_NAME__"
},
{
"name": "STORAGE_ACCOUNT_NAME",
"value": "__STORAGE_ACCOUNT_NAME__"
},
{
"name": "AGENT_IMAGE_TAR_FILE_NAME",
"value": "agentimage.tar.gz"
},
{
"name": "RELEASE_ID",
"value": "__RELEASE_ID__"
},
{
"name": "ACR_NAME",
"value": "__ACR_NAME__"
},
{
"name": "AGENT_RELEASE",
"value": "__AGENT_RELEASE__"
},
{
"name": "AGENT_IMAGE_TAG_SUFFIX",
"value": "__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "AGENT_IMAGE_FULL_PATH",
"value": "__ACR_NAME__/public/azuremonitor/containerinsights/__AGENT_RELEASE__:__AGENT_RELEASE____AGENT_IMAGE_TAG_SUFFIX__"
}
],
"identity": {
"type": "userAssigned",
"userAssignedIdentities": [
"__MANAGED_IDENTITY__"
]
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"$schema": "http://schema.express.azure.com/schemas/2015-01-01-alpha/RolloutParameters.json",
"contentVersion": "1.0.0.0",
"wait": [
{
"name": "waitSdpBakeTime",
"properties": {
"duration": "PT24H"
}
}
],
"shellExtensions": [
{
"name": "PushAgentToACR",
"type": "ShellExtensionType",
"properties": {
"maxexecutiontime": "PT1H"
},
"package": {
"reference": {
"path": "artifacts.tar.gz"
}
},
"launch": {
"command": [
"/bin/bash",
"pushAgentToAcr.sh"
],
"environmentVariables": [
{
"name": "WINDOWS",
"value": "win-"
},
{
"name": "AGENT_IMAGE_URI",
"value": "__CONTAINER_URI__"
},
{
"name": "AGENT_IMAGE_SAS",
"value": "__CONTAINER_SAS_TOKEN__"
},
{
"name": "STORAGE_CONTAINER_NAME",
"value": "__STORAGE_CONTAINER_NAME__"
},
{
"name": "STORAGE_ACCOUNT_NAME",
"value": "__STORAGE_ACCOUNT_NAME__"
},
{
"name": "AGENT_IMAGE_TAR_FILE_NAME",
"value": "agentimage.tar.zip"
},
{
"name": "RELEASE_ID",
"value": "__RELEASE_ID__"
},
{
"name": "ACR_NAME",
"value": "__ACR_NAME__"
},
{
"name": "AGENT_RELEASE",
"value": "__AGENT_RELEASE__"
},
{
"name": "AGENT_IMAGE_TAG_SUFFIX",
"value": "__AGENT_IMAGE_TAG_SUFFIX__"
},
{
"name": "AGENT_IMAGE_FULL_PATH",
"value": "__ACR_NAME__/public/azuremonitor/containerinsights/__AGENT_RELEASE__:win-__AGENT_RELEASE____AGENT_IMAGE_TAG_SUFFIX__"
}
],
"identity": {
"type": "userAssigned",
"userAssignedIdentities": [
"__MANAGED_IDENTITY__"
]
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "https://ev2schema.azure.net/schemas/2020-01-01/rolloutSpecification.json",
"ContentVersion": "1.0.0.0",
"RolloutMetadata": {
"ServiceModelPath": "ServiceModels//Public.ServiceModel.json",
"ScopeBindingsPath": "ScopeBindings//Public.ScopeBindings.json",
"Name": "ContainerInsightsAgent",
"RolloutType": "Major",
"BuildSource": {
"Parameters": {
"VersionFile": "buildver.txt"
}
},
"Notification": {
"Email": {
"To": "omscontainers@microsoft.com"
}
}
},
"OrchestratedSteps": [
{
"name": "PushLinuxAgent",
"targetType": "ServiceResource",
"targetName": "PushLinuxAgent",
"actions": [ "Shell/PushAgentToACR" ],
"dependsOn": [ ]
},
{
"name": "PushWindowsAgent",
"targetType": "ServiceResource",
"targetName": "PushWindowsAgent",
"actions": [ "Shell/PushAgentToACR" ],
"dependsOn": [ ]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$schema": "https://ev2schema.azure.net/schemas/2020-01-01/scopeBindings.json",
"contentVersion": "0.0.0.1",
"scopeBindings": [
{
"scopeTagName": "Global",
"bindings": [
{
"find": "__ACR_NAME__",
"replaceWith": "$(ACRName)"
},
{
"find": "__AGENT_RELEASE__",
"replaceWith": "$(AgentRelease)"
},
{
"find": "__AGENT_IMAGE_TAG_SUFFIX__",
"replaceWith": "$(AgentImageTagSuffix)"
},
{
"find": "__RELEASE_ID__",
"replaceWith": "$(Release.ReleaseId)"
},
{
"find": "__MANAGED_IDENTITY__",
"replaceWith": "$(ManagedIdentity)"
},
{
"find": "__CONTAINER_URI__",
"replaceWith": "$(Storage.StorageContainerUri)"
},
{
"find": "__CONTAINER_SAS_TOKEN__",
"replaceWith": "$(Storage.StorageContainerSasToken)"
},
{
"find": "__STORAGE_CONTAINER_NAME__",
"replaceWith": "$(StorageContainerName)"
},
{
"find": "__STORAGE_ACCOUNT_NAME__",
"replaceWith": "$(StorageAccountName)"
}

]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash
set -e

# Note - This script used in the pipeline as inline script

if [ -z $AGENT_IMAGE_TAG_SUFFIX ]; then
echo "-e error value of AGENT_IMAGE_TAG_SUFFIX variable shouldnt be empty. check release variables"
exit 1
fi

if [ -z $AGENT_RELEASE ]; then
echo "-e error AGENT_RELEASE shouldnt be empty. check release variables"
exit 1
fi

if [ -z $AGENT_IMAGE_URI ]; then
echo "-e error value of AGENT_IMAGE_URI shouldn't be empty. check output from file copy release task"
exit 1
fi

if [ -z $AGENT_IMAGE_SAS ]; then
echo "-e error value of AGENT_IMAGE_SAS shouldn't be empty. check output from file copy release task"
exit 1
fi

if [ -z $STORAGE_CONTAINER_NAME ]; then
echo "-e error value of STORAGE_CONTAINER_NAME shouldn't be empty. check release variables"
exit 1
fi

if [ -z $STORAGE_ACCOUNT_NAME ]; then
echo "-e error value of STORAGE_ACCOUNT_NAME shouldn't be empty. check release variables"
exit 1
fi

if [ -z $ACR_NAME ]; then
echo "-e error value of ACR_NAME shouldn't be empty. check release variables"
exit 1
fi

#Download agentimage tarball from blob storage account
echo "Downloading tarball image from $WINDOWS $AGENT_IMAGE_URI"
wget -O $AGENT_IMAGE_TAR_FILE_NAME "${AGENT_IMAGE_URI}${WINDOWS}${RELEASE_ID}${AGENT_IMAGE_SAS}"


if [ ! -f $AGENT_IMAGE_TAR_FILE_NAME ]; then
echo "Agent tarfile: ${AGENT_IMAGE_TAR_FILE_NAME} does not exist, unable to continue"
exit 1
fi

#Install crane
echo "Installing crane"
wget -O crane.tar.gz https://github.com/google/go-containerregistry/releases/download/v0.4.0/go-containerregistry_Linux_x86_64.tar.gz
if [ $? -eq 0 ]; then
echo "crane downloaded successfully"
else
echo "-e error crane download failed"
exit 1
fi
tar xzvf crane.tar.gz
echo "Installed crane"


#Login to az cli and authenticate to acr
echo "Login cli using managed identity"
az login --identity

echo "Getting acr credentials"
TOKEN_QUERY_RES=$(az acr login -n "$ACR_NAME" -t)
TOKEN=$(echo "$TOKEN_QUERY_RES" | jq -r '.accessToken')
if [ -z $TOKEN ]; then
echo "-e error failed to get az acr login token"
exit 1
fi

DESTINATION_ACR=$(echo "$TOKEN_QUERY_RES" | jq -r '.loginServer')
if [ -z $DESTINATION_ACR ]; then
echo "-e error value of DESTINATION_ACR shouldnt be empty"
exit 1
fi

./crane auth login "$DESTINATION_ACR" -u "00000000-0000-0000-0000-000000000000" -p "$TOKEN"

#Prepare tarball and push to acr
if [[ "$AGENT_IMAGE_TAR_FILE_NAME" == *"tar.gz"* ]]; then
gunzip $AGENT_IMAGE_TAR_FILE_NAME
fi

if [[ "$AGENT_IMAGE_TAR_FILE_NAME" == *"tar.zip"* ]]; then
unzip $AGENT_IMAGE_TAR_FILE_NAME
fi

echo "Pushing file $TARBALL_IMAGE_FILE to $AGENT_IMAGE_FULL_PATH"
./crane push *.tar "$AGENT_IMAGE_FULL_PATH"


#Delete agentimage tarball from blob storage to prevent future conflicts
echo "Deleting agentimage copy from blob storage"

BLOB_EXIST_RESULT=$(az storage blob exists --container-name $STORAGE_CONTAINER_NAME --name $WINDOWS$RELEASE_ID --account-name $STORAGE_ACCOUNT_NAME --sas-token $AGENT_IMAGE_SAS)
BLOB_EXIST=$(echo "$BLOB_EXIST_RESULT" | jq -r '.exists')
echo $BLOB_EXIST_RESULT
echo $BLOB_EXIST

if $BLOB_EXIST; then
az storage blob delete --container-name "${STORAGE_CONTAINER_NAME}" --name "${WINDOWS}${RELEASE_ID}" --account-name "${STORAGE_ACCOUNT_NAME}" --sas-token "${AGENT_IMAGE_SAS}"
echo "Deleted agentimate copy from blob storage"
else
echo "Agentimage has already been deleted from blob storage"
fi
Loading