Skip to content

Latest commit

 

History

History
77 lines (55 loc) · 2.94 KB

quickstart-gke.md

File metadata and controls

77 lines (55 loc) · 2.94 KB

Quick start for GKE

Prerequisites

  1. GCP Account. Sign up for a free trial here.

Setup

  1. Open a Cloud Shell window

  2. Create a Kubernetes Engine cluster if you don't already have one.

    gcloud container clusters create skaffold --zone us-west1-a
  3. Clone the Skaffold repository then change directories to the sample application.

    git clone https://github.com/GoogleCloudPlatform/skaffold.git
    cd skaffold/examples/getting-started
  4. Install skaffold.

    curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
    chmod +x skaffold
    sudo mv skaffold /usr/local/bin

Continuous development

The sample application you will use is a simple Go process that logs a statement every second.

As a new developer on-boarding you need to start Skaffold in dev mode to begin iterating on the application and seeing the updates happen in real time. The development team working on the application has already setup the Dockerfile, Kubernetes manifests, and Skaffold manifest necessary to get you started.

  1. Change the references in skaffold-gcb.yaml to point to your Container Registry.

    sed -i s#k8s-skaffold#${GOOGLE_CLOUD_PROJECT}#g skaffold-gcb.yaml
  2. Take a look at the contents of skaffold-gcb.yaml. You'll notice in the build section you will be using Google Container Builder to build and push your image. The deploy section is configured to use kubectl to apply the Kubernetes manifests.

    cat skaffold-gcb.yaml
  3. Run Skaffold in dev mode. This will use Container Builder to build a new image from the local source code, push it to your Container Registry and then deploy your application to your Kubernetes Engine cluster.

    skaffold dev -f skaffold-gcb.yaml
  4. You will see the application's logs printing to the screen.

    Starting deploy...
    Deploying k8s-pod.yaml...
    Deploy complete.
    [getting-started getting-started] Hello world!
    [getting-started getting-started] Hello world!
    [getting-started getting-started] Hello world!
  5. Click the editor toggle button editor button in the top right of the Cloud Shell interface. The Cloud Shell editor is now open and displaying the contents of your Cloud Shell home directory.

  6. Navigate to the skaffold/examples/getting-started directory in the left hand file navigation pane.

  7. Click the main.go file to open it.

  8. Edit the Hello World message to say something different. Your change will be saved automatically by the editor. Once the save is complete Skaffold will detect that a file has been changed and then rebuild, repush and redeploy the change. You will see your new log line now streaming back from the Kubernetes cluster.