The safest and most secure with AWS CLI 2 is to pipe the token returned by aws get-login-password to helm registry login, this way the token is not stored anywhere ever. You may also need to set HELM_EXPERIMENTAL_OCI=1
in your environment to use this feature:
$ aws --version
aws-cli/2.0.41 Python/3.7.3 ...
$ ECR_HOST="<ACCOUNT>.dkr.ecr.<REGION>.amazonaws.com"
$ export HELM_EXPERIMENTAL_OCI=1
$ aws ecr get-login-password | helm registry login --username AWS --password-stdin $ECR_HOST
Login succeeded
Now you can push a chart from local registry. First save it to local:
$ helm chart save path/to/your-chart $ECR_HOST/your-chart:VERSION
ref: <ECR_HOST>/your-chart:1.0
digest: 466005961...
size: 2.1 KiB
name: your-chart
version: <Chart.yml "version">
1.0: saved
$ helm chart list
REF NAME VERSION DIGEST SIZE CREATED
<ECR_HOST>/your-cha... your-chart 2020.1.1-abc1234 4660059 2.1 KiB 40 seconds
Then push it to ECR:
$ helm chart push $ECR_HOST/your-chart:VERSION
The push refers to repository [<ECR_HOST>/your-chart]
ref: <ECR_HOST>/your-chart:VERSION
digest: 46600596...
size: 2.1 KiB
name: your-chart
version: 2020.1.1-abc1234
1.0: pushed to remote (1 layer, 2.1 KiB total)
Proof that it is there:
$ helm chart list
REF NAME VERSION DIGEST SIZE CREATED
<ECR_HOST>/your-char... your-chart 2020.1.1-abc1234 4660059 2.1 KiB 11 minutes
$ helm chart remove <ECR_HOST>/your-chart:1.0
1.0: removed
$ helm chart list
REF NAME VERSION DIGEST SIZE CREATED
$ helm chart pull $ECR_HOST/your-chart:1.0
1.0: Pulling from <ECR_HOST>/your-chart
ref: <ECR_HOST>/your-chart:1.0
digest: 4660059618c...
size: 2.1 KiB
name: your-chart
version: 2020.1.1-abc1234
Status: Downloaded newer chart for <ECR_HOST>/your-chart:1.0
$ helm chart list
REF NAME VERSION DIGEST SIZE CREATED
<ECR_HOST>/your-char... your-chart 2020.1.1-abc1234 4660059 2.1 KiB 13 minutes
However there are several things that will delay us adopting the ECR as a helm charts repo:
helm chart list
clips chart ref with ellipses when past a certain length and there doesn't seem to be a way to change this (helm 3.2.1), very annoying because it clips the VERSION portion which you need for other operations
- if you look in the ECR repo for your-chart, you will see an image with tag VERSION and there is no indication whatever that it is not a docker image but a chart; it looks like TAG is arbitrary so you could have TAG be "chart-VERSION" but this feels like a hack
- the correspondence between the chart version (from the Chart.yml) and the VERSION when you save the chart is unclear; in fact when you look in the ECR repo for your-chart, you do not see the
version
string that is inside the Chart.yml, you just see the tag you used when you saved the chart
All these make ECR-repo-as-helm-chart-repo feel unintuitive and early stage and not in fact ready for mainstream use in a team.