Created
June 7, 2016 22:10
-
-
Save mtbdeano/60a4517088a4428a62f8e263d3565fe6 to your computer and use it in GitHub Desktop.
simple script to translate an `aws ecr get-login` into a Kubernetes `create secret` for `ImagePullSecrets`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
import subprocess | |
import sys | |
# expects the output of `aws ecr get-login --region <whatevs>` piped into it, translates command line into `kubectl` | |
if len(sys.argv) != 2: | |
exit('usage: aws ecr get-login | {} <keyname>'.format(sys.argv[0])) | |
secret_name = sys.argv[1] | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-u', '--username') | |
parser.add_argument('-p', '--password') | |
parser.add_argument('-e', '--email') | |
parser.add_argument('url', nargs=1) | |
command = sys.stdin.readline() | |
aws_args = parser.parse_args(command.split()[2:]) | |
kube_cmd = "kubectl create secret docker-registry {} --docker-server={} --docker-username={} --docker-password={} --docker-email={}" | |
print(kube_cmd.format(secret_name, aws_args.url[0], aws_args.username, aws_args.password, aws_args.email)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment