Skip to content

Kenblair1226/docker-gcloud-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

A container with gcloud sdk and kubectl

####Ultities for doing CI/CD in a containerized environment

Inspired from Scott Smerchek's Pushing to Google Container Registry from CircleCI


You need to set up your gcloud service account as container dev first.

Then set up credentials as environment variable in your CI/CD configuration:

Name Value
GCLOUD_EMAIL {string_of_characters}@developer.gserviceaccount.com
GCLOUD_KEY base64-encoded version of project_name-xxxxx.json
On OSX and Linux, you can get the base64 encoded version like this:
cat project_name-xxxxx.json | base64

And configure environment variables accordingly in your CI/CD yml file:

environment:
  CLOUDSDK_CORE_DISABLE_PROMPTS: 1
  CLOUDSDK_COMPUTE_ZONE: $GCLOUD_ZONE
  CLOUDSDK_CORE_PROJECT: $GCLOUD_PROJECTID
  GOOGLE_APPLICATION_CREDENTIALS: gcloud.json

Then you can authenticate with service account and manage k8s with kubectl:

script:
  - echo $GCLOUD_KEY | base64 -d > $GOOGLE_APPLICATION_CREDENTIALS
  - gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
  - gcloud container clusters get-credentials XXXXX
  - kubectl get pods

About

dockerized gcloud sdk

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published