-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Private Registry Authentication #24
Comments
+1 |
2 similar comments
👍 |
+1 |
Hi All( @2opremio @vultron81 @abest0 @alvarowolfx @samuelkarp ), I patched the source code for PoC: add “User Data” entries into CloudFormation settings to put credentials into I am creating a Pull-Request on this issue to make authentication easy, but wondering how would we put credentials for DockerHub.
I think that the option 2 is most appropriate in this situation from the viewpoint of security. Of course it’s only my opinion and I want to know how other people think. Any comments are welcomed. |
@miw0129 I would expect a more generic solution (i.e. not specific to private registry credentials), in which you can append whatever User Data you want during instance creation, specified when invoking This should ultimately be approved by the maintainers, of course (@samuelkarp I think). In the meantime and in case it's useful for anybody else, I use this workaround to configure Private Registry Authentication after creating a cluster with the ECS CLI. I use the AWS CLI to add credentials to all the container instances in the cluster. In the example below
Tweak The example assumes that you have created a key pair named bar and the #!/bin/bash
set -e
EXTRA_ECS_CONFIG='ECS_ENGINE_AUTH_TYPE=dockercfg\nECS_ENGINE_AUTH_DATA={"quay.io":{"auth":"SECRET=","email":""}}'
CLUSTER_NAME=foo
CLUSTER_SIZE=3
INSTANCE_TYPE=t2.micro
REGION=us-east-1
KEY_NAME=bar
KEY_FILE=bar.pem
print_instance_ips() {
INSTANCE_ARNS=$(aws --region $REGION ecs list-container-instances --cluster $CLUSTER_NAME --query 'containerInstanceArns[*]' --output text)
INSTANCE_IDS=$(aws --region $REGION ecs describe-container-instances --cluster $CLUSTER_NAME --container-instances $INSTANCE_ARNS --query 'containerInstances[*].ec2InstanceId' --output text)
aws --region $REGION ec2 describe-instances --instance-ids $INSTANCE_IDS --query 'Reservations[*].Instances[*].PublicIpAddress' --output text
}
ecs-cli configure --region $REGION --cluster $CLUSTER_NAME
ecs-cli up --port 22 --keypair $KEY_NAME --capability-iam --size $CLUSTER_SIZE --instance-type $INSTANCE_TYPE
echo -n "Waiting for instances to be up to add auth credentials (this may take a while) ..."
while ! INSTANCE_IPS=$(print_instance_ips 2> /dev/null) ||
[ "$(echo $INSTANCE_IPS | wc -w)" -ne $CLUSTER_SIZE ] ; do
sleep 5
done
echo "done"
SSH_ARGS="-i $KEY_FILE -o StrictHostKeyChecking=no ec2-user@"
for IP in $INSTANCE_IPS; do
ssh $SSH_ARGS$IP -t sudo bash -c "'echo -e $(printf %q $EXTRA_ECS_CONFIG) >> /etc/ecs/ecs.config'"
ssh $SSH_ARGS$IP -t sudo stop ecs
ssh $SSH_ARGS$IP -t sudo start ecs
done |
@2opremio 🍔 for you. Fantastic script that should satisfy most people's needs for now. |
@2opremio
About (1), I want to discuss about how About (2), in my opinion,
By the way, thanks for your workaround shell script. It looks useful 🍣. |
I agree that there should be a more general solution for this, however I imagine they are holding off until amazon's own private registry service is available. Then they don't have to worry about creds. You will just have to push your images to the amazon hosted private registry and reference the image there inside your docker-compose.yml. This is similar to the way tutum and google container services work. |
Right, that's why it's just a workaround :)
Maybe, but the ECS CLI should support other registries, not just Amazon's just like ECS already does. |
+1 |
1 similar comment
👍 |
@2opremio for some reason the script is hanging at "Waiting for instances to be up to add auth credentials (this may take a while) ..." on me |
@pleerock i.e. Change the above condition to [ "$(echo $INSTANCE_IPS | wc -w)" -ne $CLUSTER_SIZE ] -ne is for numeric "not equal", and != is for string comparison. And again, thanks @2opremio for the script!! |
@aidanbon thanks, thats worked |
@aidanbon Thanks! I have edited the original script with your improvement. |
+1 |
2 similar comments
+1 |
+1 |
@2opremio thanks for sharing your script. You forgot to replace us-east-1 with $REGION in the last line of print_instance_ips |
@jesucarr Thanks for spotting it, I've corrected the script. |
Related to #16 |
Hi all, We released support for private registry authentication using AWS Secrets Manager secrets in 1.8.0. (see #573). A more generic solution re: adding extra user data is being tracked in #16. |
Hi all - FYI, enhanced support for private registry credentials was added in 1.10.0. Now the ecs-cli can store your creds with AWS Secrets Manager via the new |
@allisaurus how are you auto adding them to the tasks with the registry-creds up? Followed the steps but, I still have to manually add the secrets after every deploy for private repos. |
@j-mendez Here are a couple examples to show how that would work with different inputs. If you already have an output file, Or if you already have your secrets in SSM parameters, you can also just pass them in directly via the |
ECS has an easy way to set up Private Registry Authentication through User Data but the ECS CLI still doesn't support it (see #16 )
The text was updated successfully, but these errors were encountered: