From 6836de8a047a5b77ad2a0074bbc569a6f22d3652 Mon Sep 17 00:00:00 2001 From: Aaron Prindle Date: Wed, 8 Feb 2017 16:06:35 -0800 Subject: [PATCH] Fixed issues with GCR --- README.md | 18 ++---------------- k8s/gcr-secret.yaml | 12 ------------ k8s/replicationController.yaml | 9 +++++++++ k8s/secret.yaml | 13 ++++++++++++- main.go | 3 +-- 5 files changed, 24 insertions(+), 31 deletions(-) delete mode 100644 k8s/gcr-secret.yaml diff --git a/README.md b/README.md index a44a0e15..883503f8 100644 --- a/README.md +++ b/README.md @@ -62,21 +62,7 @@ kubectl create -f k8s/secret.yaml 1. Clone the repo and navigate to directory -2. Input your application_default_credentials.json information into a secret with the template at k8s/gcr-secret.yaml: -```bash -apiVersion: v1 -data: - application_default_credentials.json: -kind: Secret -metadata: - name: gcr-secret - namespace: kube-system - labels: - app: gcr-creds - version: v1.2 - kubernetes.io/minikube-addons: gcr-creds -type: Opaque -``` +2. Input your application_default_credentials.json information into the secret.yaml template located [here](k8s/secret.yaml#L17): The value for application_default_credentials.json can be obtained with the following command: ```bash base64 -w $HOME/.config/gcloud/application_default_credentials.json @@ -84,7 +70,7 @@ base64 -w $HOME/.config/gcloud/application_default_credentials.json 3. Create the secret in kubernetes ```bash -kubectl create -f k8s/gcr-secret.yml +kubectl create -f k8s/secret.yml ``` 3. Create the replication controller: diff --git a/k8s/gcr-secret.yaml b/k8s/gcr-secret.yaml deleted file mode 100644 index cac3de17..00000000 --- a/k8s/gcr-secret.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -data: - application_default_credentials.json: -kind: Secret -metadata: - name: gcr-secret - namespace: kube-system - labels: - app: gcr-creds - version: v1.2 - kubernetes.io/minikube-addons: gcr-creds -type: Opaque diff --git a/k8s/replicationController.yaml b/k8s/replicationController.yaml index 05a70a1b..763a73a9 100644 --- a/k8s/replicationController.yaml +++ b/k8s/replicationController.yaml @@ -36,3 +36,12 @@ spec: secretKeyRef: name: registry-creds key: aws-account + volumeMounts: + - name: gcr-creds + mountPath: "/root/.config/gcloud" + readOnly: true + volumes: + - name: gcr-creds + secret: + secretName: gcr-secret + diff --git a/k8s/secret.yaml b/k8s/secret.yaml index 429495ec..3f772e15 100644 --- a/k8s/secret.yaml +++ b/k8s/secret.yaml @@ -1,4 +1,3 @@ - apiVersion: v1 data: AWS_ACCESS_KEY_ID: Y2hhbmdlbWU= @@ -13,3 +12,15 @@ metadata: version: v1.2 kubernetes.io/minikube-addons: registry-creds type: Opaque + +data: + application_default_credentials.json: Y2hhbmdlbWU= +kind: Secret +metadata: + name: gcr-secret + namespace: kube-system + labels: + app: gcr-creds + version: v1.2 + kubernetes.io/minikube-addons: gcr-creds +type: Opaque diff --git a/main.go b/main.go index c33963db..ccb6ee2a 100644 --- a/main.go +++ b/main.go @@ -307,7 +307,7 @@ func validateParams() providerConfig { var ecrEnabled bool awsAccountID = os.Getenv("awsaccount") - if len(awsAccountID) == 0 { + if len(awsAccountID) == 0 || awsAccountID == "changeme" { log.Print("Missing awsaccount env variable, assuming GCR usage") gcrEnabled = true ecrEnabled = false @@ -354,5 +354,4 @@ func main() { } } } - }