diff --git a/creating-a-kubernetes-cluster.md b/creating-a-kubernetes-cluster.md index 83c5cb67a..100df161a 100644 --- a/creating-a-kubernetes-cluster.md +++ b/creating-a-kubernetes-cluster.md @@ -62,28 +62,6 @@ To use a k8s cluster running in GKE: --user=$GCP_USER ``` -7. Enable the GCR API: - - ```shell - gcloud --project=$PROJECT_ID service-management enable containerregistry.googleapis.com - ``` - -8. Install the `docker-credential-gcr` helper so Docker (and Bazel) can - authenticate with GCR: - - ```shell - gcloud components install docker-credential-gcr - ``` - -9. Add the GCR credentials to the Docker config file: - - ```shell - docker-credential-gcr configure-docker - ``` - -Now you can use `gcr.io/$PROJECT_ID` as your Docker repo and your GKE -cluster will automatically pull from it. - ## Minikube 1. [Install and configure @@ -106,10 +84,10 @@ minikube start \ You can use Google Container Registry as the registry for a Minikube cluster. -1. [Set up a GCR repo](TODO). Export the environment variable `PROJECT_ID` - as the name of your project. Also export `GCR_DOMAIN` as the domain name - of your GCR repo. This will be either `gcr.io` or a region-specific variant - like `us.gcr.io`. +1. [Set up a GCR repo](setting-up-a-docker-registry.md). Export the environment + variable `PROJECT_ID` as the name of your project. Also export `GCR_DOMAIN` + as the domain name of your GCR repo. This will be either `gcr.io` or a + region-specific variant like `us.gcr.io`. ```shell export PROJECT_ID=elafros-demo-project diff --git a/setting-up-a-docker-registry.md b/setting-up-a-docker-registry.md new file mode 100644 index 000000000..eca4c69d7 --- /dev/null +++ b/setting-up-a-docker-registry.md @@ -0,0 +1,80 @@ +# Setting Up A Docker Registry + +This document explains how to use different Docker registries with Elafros. It +assumes you have gone through the steps listed in +[DEVELOPMENT.md](/DEVELOPMENT.md) to set up your development environment (or +that you at least have installed `go`, set `GOPATH`, and put `$GOPATH/bin` on +your `PATH`). + +It currently only contains instructions for [Google Container Registry +(GCR)](https://cloud.google.com/container-registry/), but you should be able to +use any Docker registry. + +## Google Container Registry (GCR) + +### Required Tools + +Install the following tools: + +1. [`gcloud`](https://cloud.google.com/sdk/downloads) +1. [`docker-credential-gcr`](https://github.com/GoogleCloudPlatform/docker-credential-gcr) + + If you installed `gcloud` using the archive or installer, you can install + `docker-credential-gcr` like this: + + ```shell + gcloud components install docker-credential-gcr + ``` + + If you installed `gcloud` using a package manager, you may need to install + it with `go get`: + + ```shell + go get github.com/GoogleCloudPlatform/docker-credential-gcr + ``` + + If you used `go get` to install and `$GOPATH/bin` isn't already in `PATH`, + add it: + + ```shell + export PATH=$PATH:$GOPATH/bin + ``` + +### Setup + +1. If you haven't already set up a GCP project, create one and export its name + for use in later commands. + + ```shell + export PROJECT_ID=my-project-name + gcloud projects create "${PROJECT_ID}" + ``` + +1. Enable the GCR API. + + ```shell + gcloud --project="${PROJECT_ID}" service-management enable \ + containerregistry.googleapis.com + ``` + +1. Hook up your GCR credentials. Note that this may complain if you don't have + the docker CLI installed, but it is not necessary and should still work. + + ```shell + docker-credential-gcr configure-docker + ``` + +1. If you need to, update your `DOCKER_REPO_OVERRIDE` in your `.bashrc`. It + should now be + + ```shell + export DOCKER_REPO_OVERRIDE='us.gcr.io/' + ``` + + (You may need to use a different region than `us` if you didn`t pick a`us` + Google Cloud region.) + +1. You may need to run `bazel clean` after updating your `DOCKER_REPO_OVERRIDE` + environment variable for `bazel` to pick up the change. + +That's it, you're done!