kubernetes

Local Access to GKE

with gcloud


bit.ly/k8s-gcloud

presented by @ryanj, Developer Advocate at Red Hat

ryanj

GKE Overview

  1. What Is GKE?
  2. Google Cloud Project Setup
  3. gcloud installation
  4. gcloud configuration
  5. Configure kubectl to connect to your new GKE-hosted Kubernetes environment

Q: What Is Container Engine (GKE)

A: Managed Kubernetes from Google

  • Google runs the Kubernetes master and etcd instances
  • Infrastructure is provided by Google Cloud Platform
    • Built in Logging, Monitoring, etc
    • Worker nodes are GCE instances in your project
### GKE Pricing * First 5 nodes are free, $.15/hr over 5 nodes * Worker nodes are priced separately (through GCE)
## GCP Project Access Workshop Attendees: 1. Log in to GCP using the provided username & password at: [console.cloud.google.com](https://console.cloud.google.com) 2. Accept the Terms of Service 3. Select the workshop project from drop-down menu ![Select project](http://i.imgur.com/kEjJ1pT.png)

Remote Workshop Participants

  1. Login to GCP using your Google account at:
    console.cloud.google.com
  2. Accept the Terms of Service
  3. Create a Billing Account
    • Sign up for the $300 12/month free trial
    • https://console.cloud.google.com/freetrial
    • Your credit card won't be charged at end of free trial
  4. Create a new project for this workshop
Create project
## Cloud Shell 1. A free GCE instance for your project 2. A cloud-based CLI environment, available on-demand 3. An excellent alternative for folks who lack a local environment to work in ![Cloud Shell](https://cloud.google.com/shell/docs/images/shell_icon.png)

The top left menu icon provides access to:

  1. API Manager (enable new APIs)
  2. Billing
  3. Logging and Monitoring
  4. Compute Engine
  5. Container Engine

For now, click Container Engine and wait for initialization…

Installing the gcloud CLI

Command line tool for interacting with GCP resources

curl https://sdk.cloud.google.com | bash
exec -l $SHELL # restart shell

Other install instructions are available on the Google Cloud SDK Download page

Use kubectl to manage Kubernetes resources, and gcloud to manage GCP resources

Configuring glcoud

Configure gcloud to use the correct project and availability zone

gcloud config set project your-project-id
gcloud config set compute/zone us-central1-b

List all clusters

gcloud container clusters list

Create a new cluster. Compute Engine will require a few minutes to initialize new projects

gcloud container clusters create test-cluster

Verify GKE Accessibility

To verify that both GKE and gcloud have been configured correctly, switch your kubectl context to GKE:

gcloud container clusters get-credentials test-cluster

Then, list your GCE-provided Kubernetes worker nodes:

kubectl get nodes

If kubectl isn't available, you may need to configure your machine for local development with the k8s-minikube workshop.

Presented by: @ryanj