Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Chang committed Dec 18, 2024
1 parent 0175e72 commit ccedcf5
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 42 deletions.
2 changes: 1 addition & 1 deletion config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ detect-change: materialize
echo "Please review the diffs below:\n\n"; \
echo "$$diff_output"; \
echo "\n\n===================================================="; \
echo "\n\nOnce you reviewed the changes and consider them meaningful, commit them by running "make -C config/ materialize" and commit your changes."; \
echo "\n\nOnce you reviewed the changes and consider them meaningful, update them by running "make -C config/ materialize" and commit your changes."; \
echo "\n\n===================================================="; \
exit 1; \
else \
Expand Down
7 changes: 3 additions & 4 deletions config/config.msft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ defaults:
kvName: arohcp-etcd-{{ .ctx.regionShort }}
kvSoftDelete: true
istio:
url: "https://github.com/istio/istio/releases/download"
istioctlVersion: "1.23.1"
istioctlVersion: "1.24.1"
tag: "prod-stable"
targetVersion: ""
version: "asm-1-22"
targetVersion: "asm-1-23"
versions: ["asm-1-22", "asm-1-23"]

# MGMT cluster specifics
mgmt:
Expand Down
8 changes: 2 additions & 6 deletions config/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,6 @@
"istio": {
"type": "object",
"properties": {
"url": {
"description": "The download Url for istioctl",
"type": "string"
},
"istioctlVersion": {
"description": "Latest version of istioctl. This is used to download the istioctl",
"type": "string"
Expand All @@ -677,9 +673,9 @@
"description": "The revision tag used in istioctl",
"type": "string"
},
"version": {
"versions": {
"description": "The current istio version in the AKS cluster",
"type": "string"
"type": "array"
},
"targetVersion": {
"description": "The target istio version that will be updated to",
Expand Down
3 changes: 1 addition & 2 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ defaults:
kvName: arohcp-etcd-{{ .ctx.regionShort }}
kvSoftDelete: true
istio:
url: "https://github.com/istio/istio/releases/download"
istioctlVersion: "1.23.1"
tag: "prod-stable"
targetVersion: ""
version: "asm-1-22"
versions: ["asm-1-22"]

# MGMT cluster specifics
mgmt:
Expand Down
7 changes: 5 additions & 2 deletions config/public-cloud-cs-pr.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@
"istioctlVersion": "1.23.1",
"tag": "prod-stable",
"targetVersion": "",
"url": "https://istio.io/downloadIstio",
"version": "asm-1-22"
"url": "https://github.com/istio/istio/releases/download",
"version": "asm-1-22",
"versions": [
"asm-1-22"
]
},
"rg": "hcp-underlay-cspr-svc",
"subscription": "ARO Hosted Control Planes (EA Subscription 1)",
Expand Down
7 changes: 5 additions & 2 deletions config/public-cloud-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@
"istioctlVersion": "1.23.1",
"tag": "prod-stable",
"targetVersion": "",
"url": "https://istio.io/downloadIstio",
"version": "asm-1-22"
"url": "https://github.com/istio/istio/releases/download",
"version": "asm-1-22",
"versions": [
"asm-1-22"
]
},
"rg": "hcp-underlay-dev-svc",
"subscription": "ARO Hosted Control Planes (EA Subscription 1)",
Expand Down
6 changes: 4 additions & 2 deletions config/public-cloud-msft-int.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@
"istioctlVersion": "1.24.1",
"tag": "prod-stable",
"targetVersion": "asm-1-23",
"url": "https://istio.io/downloadIstio",
"version": "asm-1-22"
"versions": [
"asm-1-22",
"asm-1-23"
]
},
"rg": "hcp-underlay-westus3-svc",
"subscription": "hcp-westus3",
Expand Down
7 changes: 5 additions & 2 deletions config/public-cloud-personal-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@
"istioctlVersion": "1.23.1",
"tag": "prod-stable",
"targetVersion": "",
"url": "https://istio.io/downloadIstio",
"version": "asm-1-22"
"url": "https://github.com/istio/istio/releases/download",
"version": "asm-1-22",
"versions": [
"asm-1-22"
]
},
"rg": "hcp-underlay-usw3tst-svc",
"subscription": "ARO Hosted Control Planes (EA Subscription 1)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using '../templates/svc-cluster.bicep'

param kubernetesVersion = '{{ .kubernetesVersion }}'
param istioVersion = ['{{ .svc.istio.version }}', '{{ .svc.istio.targetVersion }}']
param istioVersion = ['{{ .svc.istio.version }}']
param vnetAddressPrefix = '{{ .vnetAddressPrefix }}'
param subnetPrefix = '{{ .subnetPrefix }}'
param podSubnetPrefix = '{{ .podSubnetPrefix }}'
Expand Down
34 changes: 16 additions & 18 deletions dev-infrastructure/scripts/istio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ case "${LOCAL_ARCH}" in
esac


ISTIO_URL="${ISTIOCTL_URL}/${ISTIOCTL_VERSION}/istio-${ISTIOCTL_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz"
SHA256_URL="${ISTIOCTL_URL}/${ISTIOCTL_VERSION}/istio-${ISTIOCTL_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz.sha256"
ISTIO_URL="https://github.com/istio/istio/releases/download/${ISTIOCTL_VERSION}/istio-${ISTIOCTL_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz"
SHA256_URL="https://github.com/istio/istio/releases/download/${ISTIOCTL_VERSION}/istio-${ISTIOCTL_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz.sha256"
# Download the Istioctl binary
wget -q "$ISTIO_URL" -O istio-"${ISTIOCTL_VERSION}"-${OSEXT}-${ISTIO_ARCH}.tar.gz

Expand Down Expand Up @@ -58,12 +58,12 @@ echo "==========================================================================
#

ISTIO_NAMESPACE="aks-istio-system"
CURRENT_TAG_REVISION=$(istioctl tag list --istioNamespace ${ISTIO_NAMESPACE} -o json | jq --arg tag ${TAG} '.[] | select(.tag == $tag).revision' -r)
CURRENT_TAG_REVISION=$(istioctl tag list --istioNamespace "${ISTIO_NAMESPACE}" -o json | jq --arg tag "${TAG}" '.[] | select(.tag == $tag).revision' -r)

echo "********** Ensure tag ${TAG} exists **************"
if [ -z "$CURRENT_TAG_REVISION" ]; then
echo "Tag ${TAG} does not exist yet. Creating it with version ${CURRENT_VERSION}"
istioctl tag set ${TAG} --revision ${CURRENT_VERSION} --istioNamespace ${ISTIO_NAMESPACE}
istioctl tag set "${TAG}" --revision "${CURRENT_VERSION}" --istioNamespace "${ISTIO_NAMESPACE}"
else
echo "Tag ${TAG} already exists and refers to version ${CURRENT_TAG_REVISION}"
fi
Expand All @@ -73,37 +73,35 @@ echo "********** ISTIO Upgrade **************"
# To upgrade or rollback, change the targetVersion to the desire version, and version to the current version.
if [[ -z "$TARGET_VERSION" ]]; then
echo "Istio is using Target Version. Exiting script."
exit 0
exit 1
fi

NEWVERSION="$TARGET_VERSION"
echo "********** Istio Upgrade Started with version ${NEWVERSION} **************"

istioctl tag set "$TAG" --revision "${NEWVERSION}" --istioNamespace ${ISTIO_NAMESPACE} --overwrite
# Get the namespaces with the label istio.io/rev=$TAG
namespaces=$(kubectl get namespaces --selector=istio.io/rev="$TAG" -o jsonpath='{.items[*].metadata.name}' | xargs -n1 echo)

for ns in $namespaces; do
pods=$(kubectl get pods -n "$ns" -o jsonpath='{.items[*].metadata.name}'| xargs -n1 echo)
for pod_name in $pods; do
istio_version=$(kubectl get pod "$pod_name" -n "$ns" -o jsonpath='{.metadata.annotations.sidecar\.istio\.io/status}' | grep -oP '(?<="revision":")[^"]*')
# Get the namespaces with the label istio.io/rev=$TAG
for namespace in $( kubectl get namespaces --selector=istio.io/rev="$TAG" -o jsonpath='{.items[*].metadata.name}' ); do
for pod in $( kubectl get pods -n "$namespace" -o jsonpath='{.items[*].metadata.name}' ); do
istio_version=$(kubectl get pod "$pod" -n "$namespace" -o jsonpath='{.metadata.annotations.sidecar\.istio\.io/status}' | grep -oP '(?<="revision":")[^"]*')
if [[ "$istio_version" != "$NEWVERSION" ]]; then
owner_kind=$(kubectl get pod "$pod_name" -n "$ns" -o jsonpath='{.metadata.ownerReferences[0].kind}')
owner_name=$(kubectl get pod "$pod_name" -n "$ns" -o jsonpath='{.metadata.ownerReferences[0].name}')
owner_kind=$(kubectl get pod "$pod" -n "$namespace" -o jsonpath='{.metadata.ownerReferences[0].kind}')
owner_name=$(kubectl get pod "$pod" -n "$namespace" -o jsonpath='{.metadata.ownerReferences[0].name}')

case "$owner_kind" in
"ReplicaSet")
deployment=$(kubectl get replicaset "$owner_name" -n "$ns" -o jsonpath='{.metadata.ownerReferences[0].name}')
deployment=$(kubectl get replicaset "$owner_name" -n "$namespace" -o jsonpath='{.metadata.ownerReferences[0].name}')
if [[ -n "$deployment" ]]; then
kubectl rollout restart deployment "$deployment" -n "$ns"
kubectl rollout restart deployment "$deployment" -n "$namespace"
continue 2
else
kubectl delete pod "$pod_name" -n "$ns"
kubectl delete pod "$pod" -n "$namespace"
fi
;;
"StatefulSet")
deployment=$(kubectl get replicaset "$owner_name" -n "$ns" -o jsonpath='{.metadata.ownerReferences[0].name}')
kubectl rollout restart deployment "$deployment" -n "$ns"
deployment=$(kubectl get replicaset "$owner_name" -n "$namespace" -o jsonpath='{.metadata.ownerReferences[0].name}')
kubectl rollout restart deployment "$deployment" -n "$namespace"
continue 2
;;
*)
Expand Down
3 changes: 1 addition & 2 deletions dev-infrastructure/templates/svc-cluster.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ param aroDevopsMsiId string
param regionalDNSZoneName string

var clusterServiceMIName = 'clusters-service'
var istio = empty(istioVersion[1]) ? [istioVersion[0]] : istioVersion

resource serviceKeyVault 'Microsoft.KeyVault/vaults@2024-04-01-preview' existing = {
name: serviceKeyVaultName
Expand Down Expand Up @@ -167,7 +166,7 @@ module svcCluster '../modules/aks-cluster-base.bicep' = {
aksEtcdKVEnableSoftDelete: aksEtcdKVEnableSoftDelete
kubernetesVersion: kubernetesVersion
deployIstio: true
istioVersion: istio
istioVersion: istioVersion
vnetAddressPrefix: vnetAddressPrefix
subnetPrefix: subnetPrefix
podSubnetPrefix: podSubnetPrefix
Expand Down

0 comments on commit ccedcf5

Please sign in to comment.