@@ -29,8 +29,8 @@ case "${LOCAL_ARCH}" in
29
29
esac
30
30
31
31
32
- ISTIO_URL=" ${ISTIOCTL_URL} /${ISTIOCTL_VERSION} /istio-${ISTIOCTL_VERSION} -${OSEXT} -${ISTIO_ARCH} .tar.gz"
33
- SHA256_URL=" ${ISTIOCTL_URL} /${ISTIOCTL_VERSION} /istio-${ISTIOCTL_VERSION} -${OSEXT} -${ISTIO_ARCH} .tar.gz.sha256"
32
+ ISTIO_URL=" https://github.com/istio/istio/releases/download /${ISTIOCTL_VERSION} /istio-${ISTIOCTL_VERSION} -${OSEXT} -${ISTIO_ARCH} .tar.gz"
33
+ SHA256_URL=" https://github.com/istio/istio/releases/download /${ISTIOCTL_VERSION} /istio-${ISTIOCTL_VERSION} -${OSEXT} -${ISTIO_ARCH} .tar.gz.sha256"
34
34
# Download the Istioctl binary
35
35
wget -q " $ISTIO_URL " -O istio-" ${ISTIOCTL_VERSION} " -${OSEXT} -${ISTIO_ARCH} .tar.gz
36
36
@@ -58,12 +58,12 @@ echo "==========================================================================
58
58
#
59
59
60
60
ISTIO_NAMESPACE=" aks-istio-system"
61
- CURRENT_TAG_REVISION=$( istioctl tag list --istioNamespace ${ISTIO_NAMESPACE} -o json | jq --arg tag ${TAG} ' .[] | select(.tag == $tag).revision' -r)
61
+ CURRENT_TAG_REVISION=$( istioctl tag list --istioNamespace " ${ISTIO_NAMESPACE} " -o json | jq --arg tag " ${TAG} " ' .[] | select(.tag == $tag).revision' -r)
62
62
63
63
echo " ********** Ensure tag ${TAG} exists **************"
64
64
if [ -z " $CURRENT_TAG_REVISION " ]; then
65
65
echo " Tag ${TAG} does not exist yet. Creating it with version ${CURRENT_VERSION} "
66
- istioctl tag set ${TAG} --revision ${CURRENT_VERSION} --istioNamespace ${ISTIO_NAMESPACE}
66
+ istioctl tag set " ${TAG} " --revision " ${CURRENT_VERSION} " --istioNamespace " ${ISTIO_NAMESPACE} "
67
67
else
68
68
echo " Tag ${TAG} already exists and refers to version ${CURRENT_TAG_REVISION} "
69
69
fi
@@ -73,37 +73,35 @@ echo "********** ISTIO Upgrade **************"
73
73
# To upgrade or rollback, change the targetVersion to the desire version, and version to the current version.
74
74
if [[ -z " $TARGET_VERSION " ]]; then
75
75
echo " Istio is using Target Version. Exiting script."
76
- exit 0
76
+ exit 1
77
77
fi
78
78
79
79
NEWVERSION=" $TARGET_VERSION "
80
80
echo " ********** Istio Upgrade Started with version ${NEWVERSION} **************"
81
81
82
82
istioctl tag set " $TAG " --revision " ${NEWVERSION} " --istioNamespace ${ISTIO_NAMESPACE} --overwrite
83
- # Get the namespaces with the label istio.io/rev=$TAG
84
- namespaces=$( kubectl get namespaces --selector=istio.io/rev=" $TAG " -o jsonpath=' {.items[*].metadata.name}' | xargs -n1 echo)
85
83
86
- for ns in $ namespaces; do
87
- pods= $( kubectl get pods -n " $ns " -o jsonpath=' {.items[*].metadata.name}' | xargs -n1 echo )
88
- for pod_name in $pods ; do
89
- istio_version=$( kubectl get pod " $pod_name " -n " $ns " -o jsonpath=' {.metadata.annotations.sidecar\.istio\.io/status}' | grep -oP ' (?<="revision":")[^"]*' )
84
+ # Get the namespaces with the label istio.io/rev=$TAG
85
+ for namespace in $( kubectl get namespaces --selector=istio.io/rev= " $TAG " -o jsonpath=' {.items[*].metadata.name}' ) ; do
86
+ for pod in $( kubectl get pods -n " $namespace " -o jsonpath= ' {.items[*].metadata.name} ' ) ; do
87
+ istio_version=$( kubectl get pod " $pod " -n " $namespace " -o jsonpath=' {.metadata.annotations.sidecar\.istio\.io/status}' | grep -oP ' (?<="revision":")[^"]*' )
90
88
if [[ " $istio_version " != " $NEWVERSION " ]]; then
91
- owner_kind=$( kubectl get pod " $pod_name " -n " $ns " -o jsonpath=' {.metadata.ownerReferences[0].kind}' )
92
- owner_name=$( kubectl get pod " $pod_name " -n " $ns " -o jsonpath=' {.metadata.ownerReferences[0].name}' )
89
+ owner_kind=$( kubectl get pod " $pod " -n " $namespace " -o jsonpath=' {.metadata.ownerReferences[0].kind}' )
90
+ owner_name=$( kubectl get pod " $pod " -n " $namespace " -o jsonpath=' {.metadata.ownerReferences[0].name}' )
93
91
94
92
case " $owner_kind " in
95
93
" ReplicaSet" )
96
- deployment=$( kubectl get replicaset " $owner_name " -n " $ns " -o jsonpath=' {.metadata.ownerReferences[0].name}' )
94
+ deployment=$( kubectl get replicaset " $owner_name " -n " $namespace " -o jsonpath=' {.metadata.ownerReferences[0].name}' )
97
95
if [[ -n " $deployment " ]]; then
98
- kubectl rollout restart deployment " $deployment " -n " $ns "
96
+ kubectl rollout restart deployment " $deployment " -n " $namespace "
99
97
continue 2
100
98
else
101
- kubectl delete pod " $pod_name " -n " $ns "
99
+ kubectl delete pod " $pod " -n " $namespace "
102
100
fi
103
101
;;
104
102
" StatefulSet" )
105
- deployment=$( kubectl get replicaset " $owner_name " -n " $ns " -o jsonpath=' {.metadata.ownerReferences[0].name}' )
106
- kubectl rollout restart deployment " $deployment " -n " $ns "
103
+ deployment=$( kubectl get replicaset " $owner_name " -n " $namespace " -o jsonpath=' {.metadata.ownerReferences[0].name}' )
104
+ kubectl rollout restart deployment " $deployment " -n " $namespace "
107
105
continue 2
108
106
;;
109
107
* )
0 commit comments