Skip to content

Latest commit

 

History

History
74 lines (57 loc) · 3.18 KB

quickstart-gke.adoc

File metadata and controls

74 lines (57 loc) · 3.18 KB

Quick start for GKE

Prerequisites

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

Setup

Open in Cloud Shell
  1. Create a Kubernetes Engine cluster if you don’t already have one.

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

    git clone https://github.com/GoogleContainerTools/skaffold.git
    cd skaffold/examples/getting-started
  3. 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.yaml and k8s-pod.yaml to point to your Container Registry.

    sed -i -e s#k8s-skaffold#${GOOGLE_CLOUD_PROJECT}#g skaffold.yaml
    sed -i -e s#k8s-skaffold#${GOOGLE_CLOUD_PROJECT}#g k8s-pod.yaml
  2. Take a look at the contents of skaffold.yaml. You’ll notice a profile named gcb that 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.yaml
  3. Run Skaffold in dev mode with the gcb profile enabled. 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 -p gcb
  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.