-
Notifications
You must be signed in to change notification settings - Fork 0
Deploy Dislog on Google Kubernetes Engine
First, set up with Google Cloud by creating an account and Google Kubernetes Engine (GKE) cluster and configuring your computer’s Docker and kubectl to work with the cloud services. GKE is GCP’s managed Kubernetes service, enabling you to create a Kubernetes cluster with a single-click. GKE clusters are managed by Google’s Site Reliability Engineers, who ensure that the cluster is available and up-to-date so that you can focus on your applications instead of Kubernetes.
Open the GCP sign-up form and log in to your existing Google account or make a new account. Follow the form instructions, filling in the form with your details until you’ve started your free trial. Then continue to the next step to create a Kubernetes cluster.
Navigate to the Kubernetes Engine service and click Create cluster to open the cluster creation form. In the form, change the name field from its default cluster-1 to dislog. Keep the location type as its default (Zonal). In the master version section, select the Release channel radio and select the current Regular channel. Then click the Create button at the bottom of the page. The page will refresh and show a spinner that indicates GCP is provisioning the cluster.
Google Cloud provides a cloud software development kit (SDK) with various tools and libraries for working with Google’s services. The SDK includes the gcloud CLI, which we need to interact with the Google Cloud APIs and configure Docker. Install the latest Cloud SDK by following the installation instructions for your OS from the Google Cloud Developer Tools page.
After you’ve installed the gcloud CLI, authenticate the CLI for your account by running this command:
gcloud auth login
Now that you’ve authenticated the CLI, you can run gcloud commands against resources in your account. Get your project’s ID, and configure gcloud to use the project by default by running the following:
PROJECT_ID=$(gcloud projects list | tail -n 1 | cut -d' ' -f1)
gcloud config set project $PROJECT_ID
We’ll refer this PROJECT_ID environment variable several times, so if you make a new terminal session, make sure you set the variable again.
We need to make our service’s image pullable by our GKE cluster’s nodes by pushing its image to Google’s Container Registry. Run the following to push the image to the registry:
gcloud auth configure-docker
docker tag github.com/pouriaamini/dislog:0.0.1 \
gcr.io/$PROJECT_ID/dislog:0.0.1
docker push gcr.io/$PROJECT_ID/dislog:0.0.1
The first line configures Docker to use Google’s Container Registry and use
gcloud as the credential helper for those registries. You can open your Docker
configuration file (at ~/.docker/config.json
by default) to see the
configuration changes. The second line creates a new tag for the gcr.io registry
name. The gcr.io
registry hosts images in the United States
(though that may change). You’ll also find us.gcr.io
, eu.gcr.io
, and asia.gcr.io
if you need your images in specific regions. The third line pushes the image to
the registry.
The last bit of setup allows kubectl and Helm to call our GKE cluster:
gcloud container clusters get-credentials dislog --zone us-central1-c
This command updates your kubeconfig
file (at ~/.kube/config
by default) with
the credentials and configuration to point kubectl at your cluster in GKE. Helm
uses the kubeconfig
file, too.
Okay, we’ve set up our Google Cloud project, created a GKE cluster, and configured our clients to manage the cluster.