charts icon indicating copy to clipboard operation
charts copied to clipboard

[stable/spinnaker] Doesn't support DockerRegistry password-command req for ECR

Open darkn3rd opened this issue 7 years ago • 7 comments

dDESCRIPTION

The spinnaker chart allows you to specify a number of Docker Registries, which requires a password, and does not support a password-command that is required for solutions that need to refresh tokens, such as Amazon's ECR.

SOLUTION

The solution would be to support a password-command as an alternative to password:

dockerRegistries:
- name: ecr
  username: AWS
  address: XXXXXXXXXXXX.dkr.ecr.us-west-2.amazonaws.com
  password-command: >
    aws ecr get-authorization-token
    --region us-west-2
    --output text
    --query 'authorizationData[].authorizationToken' |
    base64 -d | sed 's/^AWS://'

ALTERNATIVES

Currently exploring possibility of using a shell script to configure DockerRegistry outside of the limited mechanism supported by the Helm chart, e.g.

additionalScripts:
    create: true
    data:
      configure_ecr.sh: > 
        # script goes here

Another alternative would be to simply pass the token (but this will expire eventually) and adding a side car container to refresh the stored secret.

darkn3rd avatar Nov 17 '19 21:11 darkn3rd

@darkn3rd Do you think the pr https://github.com/helm/charts/pull/15564 will fit your use case ?

mced avatar Nov 18 '19 15:11 mced

@darkn3rd since you mentioned AWS ECR, this would work for your use-case

  • add kube2iam to your cluster
  • create a role that clouddriver can assume
    • attach respective policies
  • add an annotation to clouddriver (noted in the yaml file) that specifies above role

no keys or secrets to handle ever

camilosantana avatar Nov 19 '19 01:11 camilosantana

@camilosantana I don't think your approach works. I tried it but even though the IAM role that's been assumed has ECR read privileges, it's still necessary to get login token from ECR hence the need for passwordcommand

yhware avatar Nov 28 '19 10:11 yhware

@mced I think it might indeed. I have not tried it. Some test cases would be (1) only password file config, (2) only password-command config, (3) mixed. The AWS CLI shouldn't be required on halyard.

My current workaround is with using halyard.additionalSecrets, halyard.additionalConfigMaps, and halyard.additionalScripts, and running the commands in the shell script.

darkn3rd avatar Dec 02 '19 21:12 darkn3rd

@camilosantana FYI. The eks cluster worker nodes (ec2) already policy of AmazonEC2ContainerRegistryPowerUser, so all pods on the cluster have access to ECR. There's no access problems in that scope.

The issues has to do with the [Docker Registry HTTP API V2](Docker Registry HTTP API V2) that requires an access token. Unlike other Docker registries (e.g. docker hub, quay), ECR rotates the access token, so Clouddriver needs a way to use a new access token. This was solved with a sidecar container that updates a shared passwordfile, but later Spinnaker contributor added support of password-command option, and another PR added aws cli to Clouddriver docker image, both needed to support ECR. The problem is that the helm chart was also not updated to support this new feature.

darkn3rd avatar Dec 03 '19 21:12 darkn3rd

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Jan 02 '20 22:01 stale[bot]

This issue is being automatically closed due to inactivity.

stale[bot] avatar Jan 16 '20 22:01 stale[bot]