forked from Odania-IT/aws-kubectl
-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·29 lines (25 loc) · 962 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env sh
set -e
echo "Retrieving Docker Credentials for the AWS ECR Registry ${AWS_ACCOUNT}"
DOCKER_REGISTRY_SERVER=https://${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com
DOCKER_USER=AWS
DOCKER_PASSWORD=`aws ecr get-login --region ${AWS_REGION} --registry-ids ${AWS_ACCOUNT} | cut -d' ' -f6`
for namespace in ${NAMESPACES}
do
echo
echo "Working in Namespace ${namespace}"
echo
echo "Removing previous secret in namespace ${namespace}"
kubectl --namespace=${namespace} delete secret aws-registry || true
echo "Creating new secret in namespace ${namespace}"
kubectl create secret docker-registry aws-registry \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
--docker-password=$DOCKER_PASSWORD \
--namespace=${namespace}
echo
echo
done
echo "Patching default serviceaccount"
echo kubectl patch serviceaccount default -p '{"imagePullSecrets":[{"name":"aws-registry"}]}'