Skip to content

Commit

Permalink
Fix region/account for manifests generated from helm (aws#1592)
Browse files Browse the repository at this point in the history
* Yamls generated from helm was missing region/account override

* fix domains
  • Loading branch information
jayanthvn authored and haouc committed Aug 31, 2021
1 parent 9189c35 commit 953c334
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions charts/aws-vpc-cni/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
hostNetwork: true
initContainers:
- name: aws-vpc-cni-init
image: "{{- if .Values.init.image.override }}{{- .Values.init.image.override }}{{- else }}602401143452.dkr.ecr.{{- .Values.init.image.region }}.amazonaws.com/amazon-k8s-cni-init:{{- .Values.init.image.tag }}{{- end}}"
image: "{{- if .Values.init.image.override }}{{- .Values.init.image.override }}{{- else }}{{- .Values.init.image.account }}.dkr.ecr.{{- .Values.init.image.region }}.{{- .Values.init.image.domain }}/amazon-k8s-cni-init:{{- .Values.init.image.tag }}{{- end}}"
env:
{{- range $key, $value := .Values.init.env }}
- name: {{ $key }}
Expand All @@ -62,7 +62,7 @@ spec:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: aws-node
image: "{{- if .Values.image.override }}{{- .Values.image.override }}{{- else }}602401143452.dkr.ecr.{{- .Values.image.region }}.amazonaws.com/amazon-k8s-cni:{{- .Values.image.tag }}{{- end}}"
image: "{{- if .Values.image.override }}{{- .Values.image.override }}{{- else }}{{- .Values.image.account }}.dkr.ecr.{{- .Values.image.region }}.{{- .Values.image.domain }}/amazon-k8s-cni:{{- .Values.image.tag }}{{- end}}"
ports:
- containerPort: 61678
name: metrics
Expand Down
4 changes: 4 additions & 0 deletions charts/aws-vpc-cni/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ init:
image:
tag: v1.9.0
region: us-west-2
account: "602401143452"
pullPolicy: Always
domain: "amazonaws.com"
# Set to use custom image
# override: "repo/org/image:tag"
env:
Expand All @@ -21,6 +23,8 @@ init:
image:
region: us-west-2
tag: v1.9.0
account: "602401143452"
domain: "amazonaws.com"
pullPolicy: Always
# Set to use custom image
# override: "repo/org/image:tag"
Expand Down
4 changes: 2 additions & 2 deletions charts/cni-metrics-helper/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ spec:
value: {{ $value | quote }}
{{- end }}
name: cni-metrics-helper
image: "{{- if .Values.image.override }}{{- .Values.image.override }}{{- else }}602401143452.dkr.ecr.{{- .Values.image.region }}.amazonaws.com/cni-metrics-helper:{{- .Values.image.tag }}{{- end}}"
serviceAccountName: {{ template "cni-metrics-helper.serviceAccountName" . }}
image: "{{- if .Values.image.override }}{{- .Values.image.override }}{{- else }}{{- .Values.image.account }}.dkr.ecr.{{- .Values.image.region }}.{{- .Values.image.domain }}/cni-metrics-helper:{{- .Values.image.tag }}{{- end}}"
serviceAccountName: {{ template "cni-metrics-helper.serviceAccountName" . }}
6 changes: 4 additions & 2 deletions charts/cni-metrics-helper/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ nameOverride: cni-metrics-helper

image:
region: us-west-2
tag: v1.8.0
tag: v1.9.0
account: "602401143452"
domain: "amazonaws.com"
# Set to use custom image
# override: "repo/org/image:tag"

Expand All @@ -20,4 +22,4 @@ serviceAccount:
# If not set and create is true, a name is generated using the fullname template
name:
annotations: {}
# eks.amazonaws.com/role-arn: arn:aws:iam::AWS_ACCOUNT_ID:role/IAM_ROLE_NAME
# eks.amazonaws.com/role-arn: arn:aws:iam::AWS_ACCOUNT_ID:role/IAM_ROLE_NAME
26 changes: 10 additions & 16 deletions scripts/generate-cni-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ INDV_RESOURCES_DIR=$BUILD_DIR/individual-resources
CNI_TAR_RESOURCES_FILE=$BUILD_DIR/cni_individual-resources.tar
METRICS_TAR_RESOURCES_FILE=$BUILD_DIR/cni_metrics_individual-resources.tar
CALICO_TAR_RESOURCES_FILE=$BUILD_DIR/calico_individual-resources.tar
CNI_RESOURCES_YAML=$BUILD_DIR/aws-vpc-cni
CNI_RESOURCES_YAML=$BUILD_DIR/aws-k8s-cni
METRICS_RESOURCES_YAML=$BUILD_DIR/cni-metrics-helper
CALICO_OPERATOR_RESOURCES_YAML=$BUILD_DIR/calico-operator.yaml
CALICO_CRS_RESOURCES_YAML=$BUILD_DIR/calico-crs.yaml
Expand Down Expand Up @@ -59,7 +59,6 @@ jq -c '.[]' $REGIONS_FILE | while read i; do
ecrRegion=`echo $i | jq '.ecrRegion' -r`
ecrAccount=`echo $i | jq '.ecrAccount' -r`
ecrDomain=`echo $i | jq '.ecrDomain' -r`

if [ "$ecrRegion" = "us-west-2" ]; then
NEW_CNI_RESOURCES_YAML="${CNI_RESOURCES_YAML}.yaml"
NEW_METRICS_RESOURCES_YAML="${METRICS_RESOURCES_YAML}.yaml"
Expand All @@ -73,27 +72,22 @@ jq -c '.[]' $REGIONS_FILE | while read i; do

$BUILD_DIR/helm template charts/aws-vpc-cni \
--set originalMatchLabels=true,\
initContainers.image.region=$ecrRegion,\
initContainers.image.account=$ecrAccount,\
initContainers.image.domain=$ecrDomain,\
image.region=$ecrRegion,\
image.account=$ecrAccount,\
image.domain=$ecrDomain \
--set init.image.region=$ecrRegion,\
--set init.image.account=$ecrAccount,\
--set init.image.domain=$ecrDomain,\
--set image.region=$ecrRegion,\
--set image.account=$ecrAccount,\
--set image.domain=$ecrDomain \
--namespace $NAMESPACE \
--name-template aws-vpc-cni \
$SCRIPTPATH/../charts/aws-vpc-cni > $NEW_CNI_RESOURCES_YAML
cat $NEW_CNI_RESOURCES_YAML | grep -v 'helm.sh\|app.kubernetes.io/managed-by: Helm' > $BUILD_DIR/helm_annotations_removed.yaml
mv $BUILD_DIR/helm_annotations_removed.yaml $NEW_CNI_RESOURCES_YAML

$BUILD_DIR/helm template charts/cni-metrics-helper \
--set initContainers.image.region=$ecrRegion,\
initContainers.image.account=$ecrAccount,\
initContainers.image.domain=$ecrDomain,\
image.region=$ecrRegion,\
image.account=$ecrAccount,\
image.domain=$ecrDomain \
--set image.region=$ecrRegion,\
--set image.account=$ecrAccount,\
--set image.domain=$ecrDomain \
--namespace $NAMESPACE \
--name-template cni-metrics-helper \
$SCRIPTPATH/../charts/cni-metrics-helper > $NEW_METRICS_RESOURCES_YAML
cat $NEW_METRICS_RESOURCES_YAML | grep -v 'helm.sh\|app.kubernetes.io/managed-by: Helm' > $BUILD_DIR/helm_annotations_removed.yaml
mv $BUILD_DIR/helm_annotations_removed.yaml $NEW_METRICS_RESOURCES_YAML
Expand Down

0 comments on commit 953c334

Please sign in to comment.