From 424692befa68629e882ee64c3351b4556205e411 Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Wed, 14 Nov 2018 11:21:23 -0800 Subject: [PATCH 1/4] upgrade skaffold to 0.18 (#97) Signed-off-by: Ahmet Alp Balkan --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4850744..50a839e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ services: - docker install: -- curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v0.16.0/skaffold-linux-amd64 +- curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v0.18.0/skaffold-linux-amd64 - chmod +x skaffold - sudo mv skaffold /usr/local/bin From d69f1a4f25dfb5ab260cf0e575ea8f4bd15b8d2b Mon Sep 17 00:00:00 2001 From: rghetia Date: Wed, 14 Nov 2018 14:49:17 -0500 Subject: [PATCH 2/4] increase reporting interval. (#96) also fixed a bug in SD export registration in Ads. --- .../src/main/java/hipstershop/AdService.java | 22 +++++++++++++------ src/checkoutservice/main.go | 1 + src/frontend/main.go | 1 + src/productcatalogservice/server.go | 1 + src/shippingservice/main.go | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/adservice/src/main/java/hipstershop/AdService.java b/src/adservice/src/main/java/hipstershop/AdService.java index 9ba3329..1224efe 100644 --- a/src/adservice/src/main/java/hipstershop/AdService.java +++ b/src/adservice/src/main/java/hipstershop/AdService.java @@ -207,16 +207,24 @@ public class AdService { // Registers logging trace exporter. LoggingTraceExporter.register(); long sleepTime = 10; /* seconds */ - int maxAttempts = 3; + int maxAttempts = 5; + boolean statsExporterRegistered = false; + boolean traceExporterRegistered = false; for (int i=0; i Date: Mon, 3 Dec 2018 17:19:12 -0500 Subject: [PATCH 3/4] remove gcr repo name from images (#98) This removes hardcoded GCP project name from images and requires an explicit repository flag to skaffold. Also updating the cloudbuild.yaml for staging with the gcr.io/k8s-skaffold/skaffold image. Fixes #17. --- README.md | 23 +++++------- cloudbuild.yaml | 35 +++++++++++-------- kubernetes-manifests/adservice.yaml | 2 +- kubernetes-manifests/cartservice.yaml | 2 +- kubernetes-manifests/checkoutservice.yaml | 2 +- kubernetes-manifests/currencyservice.yaml | 2 +- kubernetes-manifests/emailservice.yaml | 2 +- kubernetes-manifests/frontend.yaml | 2 +- kubernetes-manifests/loadgenerator.yaml | 2 +- kubernetes-manifests/paymentservice.yaml | 2 +- .../productcatalogservice.yaml | 2 +- .../recommendationservice.yaml | 2 +- kubernetes-manifests/shippingservice.yaml | 2 +- skaffold.yaml | 26 ++++++++------ 14 files changed, 55 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index dd510e1..623046f 100644 --- a/README.md +++ b/README.md @@ -103,24 +103,17 @@ Find **Protocol Buffers Descriptions** at the [`./pb` directory](./pb). kubectl get nodes -2. Enable Google Container Registry (GCR) on your GCP project and configure the +1. Enable Google Container Registry (GCR) on your GCP project and configure the `docker` CLI to authenticate to GCR: gcloud services enable containerregistry.googleapis.com gcloud auth configure-docker -q -3. Set your project ID on image names: - - - Edit `skaffold.yaml`, update the `imageName:` fields that look like - `gcr.io/[PROJECT_ID]` with your own GCP project ID. - - - Similarly, edit all Kubernetes Deployment manifests in the - [`./kubernetes-manifests`](./kubernetes-manifests) directory. Find the - `image:` fields with `gcr.io/[...]` and change them to your own GCP project - ID. - -5. Run `skaffold run` from the root of this repository. This command: +1. In the root of this repository, run `skaffold run --default-repo=gcr.io/[PROJECT_ID]`, + where [PROJECT_ID] is your GCP project ID. + + This command: - builds the container images - pushes them to GCR - applies the `./kubernetes-manifests` deploying the application to @@ -128,9 +121,9 @@ Find **Protocol Buffers Descriptions** at the [`./pb` directory](./pb). **Troubleshooting:** If you get "No space left on device" error on Google Cloud Shell, you can build the images on Google Cloud Build: - [Enable the Cloud Build API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com), then run `skaffold run -p gcb` instead. + [Enable the Cloud Build API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com), then run `skaffold run -p gcb --default-repo=gcr.io/[PROJECT_ID]` instead. -6. Find the IP address of your application, then visit the application on your +1. Find the IP address of your application, then visit the application on your browser to confirm installation. kubectl get service frontend-external @@ -168,7 +161,7 @@ Find **Protocol Buffers Descriptions** at the [`./pb` directory](./pb). This is required only once. -5. Deploy the application with `skaffold run`. +5. Deploy the application with `skaffold run --default-repo=gcr.io/[PROJECT_ID]`. 6. Run `kubectl get pods` to see pods are in a healthy and ready state. diff --git a/cloudbuild.yaml b/cloudbuild.yaml index bd3e4cc..d8404c8 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,17 +1,24 @@ -# This file is used to build and deploy the app into a GKE cluster using Google -# Cloud Build. +# Cloudbuild.yaml to deploy to staging # -# Requirements: -# - Give the Google Cloud Build service account "Kubernetes Engine Developer" -# IAM role on the GCP project. -# - Set up Google Cloud Build trigger on Cloud Console. +# PREREQUISITES: +# - Cloud Build service account must have role: "Kubernetes Engine Developer" + +# USAGE: +# GCP zone and GKE target cluster must be specified as substitutions +# Example invocation: +# `gcloud builds submit --config=cloudbuild.yaml --substitutions=_ZONE=us-central1-b,_CLUSTER=demo-app-staging .` steps: -- name: gcr.io/k8s-skaffold/skaffold:v0.16.0 - args: ['skaffold', 'run', '-f=skaffold.yaml'] - env: - - 'CLOUDSDK_COMPUTE_ZONE=us-central1-b' - - 'CLOUDSDK_CONTAINER_CLUSTER=demo-app-staging' -timeout: 1800s -options: # Add more power, and more time, for heavy Skaffold build - machineType: 'N1_HIGHCPU_8' +- id: 'Deploy application to cluster' + name: 'gcr.io/k8s-skaffold/skaffold:v0.18.0' + entrypoint: 'bash' + args: + - '-c' + - > + gcloud container clusters get-credentials --zone=$_ZONE $_CLUSTER; + skaffold run -f=skaffold.yaml --default-repo=gcr.io/$PROJECT_ID; + +# Add more power, and more time, for heavy Skaffold build +timeout: '3600s' +options: + machineType: 'N1_HIGHCPU_8' \ No newline at end of file diff --git a/kubernetes-manifests/adservice.yaml b/kubernetes-manifests/adservice.yaml index 37ee35a..dc0879f 100644 --- a/kubernetes-manifests/adservice.yaml +++ b/kubernetes-manifests/adservice.yaml @@ -25,7 +25,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: gcr.io/microservices-demo-app/adservice + image: adservice ports: - containerPort: 9555 env: diff --git a/kubernetes-manifests/cartservice.yaml b/kubernetes-manifests/cartservice.yaml index 55aa5be..5484017 100644 --- a/kubernetes-manifests/cartservice.yaml +++ b/kubernetes-manifests/cartservice.yaml @@ -25,7 +25,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: gcr.io/microservices-demo-app/cartservice + image: cartservice ports: - containerPort: 7070 env: diff --git a/kubernetes-manifests/checkoutservice.yaml b/kubernetes-manifests/checkoutservice.yaml index 23668a6..aec9591 100644 --- a/kubernetes-manifests/checkoutservice.yaml +++ b/kubernetes-manifests/checkoutservice.yaml @@ -24,7 +24,7 @@ spec: spec: containers: - name: server - image: gcr.io/microservices-demo-app/checkoutservice + image: checkoutservice ports: - containerPort: 5050 readinessProbe: diff --git a/kubernetes-manifests/currencyservice.yaml b/kubernetes-manifests/currencyservice.yaml index b344b1a..6e38247 100644 --- a/kubernetes-manifests/currencyservice.yaml +++ b/kubernetes-manifests/currencyservice.yaml @@ -25,7 +25,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: gcr.io/microservices-demo-app/currencyservice + image: currencyservice ports: - name: grpc containerPort: 7000 diff --git a/kubernetes-manifests/emailservice.yaml b/kubernetes-manifests/emailservice.yaml index 7479c2e..4a5363d 100644 --- a/kubernetes-manifests/emailservice.yaml +++ b/kubernetes-manifests/emailservice.yaml @@ -25,7 +25,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: gcr.io/microservices-demo-app/emailservice + image: emailservice ports: - containerPort: 8080 readinessProbe: diff --git a/kubernetes-manifests/frontend.yaml b/kubernetes-manifests/frontend.yaml index 27d1b8e..e4b8e89 100644 --- a/kubernetes-manifests/frontend.yaml +++ b/kubernetes-manifests/frontend.yaml @@ -24,7 +24,7 @@ spec: spec: containers: - name: server - image: gcr.io/microservices-demo-app/frontend + image: frontend ports: - containerPort: 8080 readinessProbe: diff --git a/kubernetes-manifests/loadgenerator.yaml b/kubernetes-manifests/loadgenerator.yaml index ee84c3a..2032b8c 100644 --- a/kubernetes-manifests/loadgenerator.yaml +++ b/kubernetes-manifests/loadgenerator.yaml @@ -38,7 +38,7 @@ spec: value: "frontend:80" containers: - name: main - image: gcr.io/microservices-demo-app/loadgenerator + image: loadgenerator env: - name: FRONTEND_ADDR value: "frontend:80" diff --git a/kubernetes-manifests/paymentservice.yaml b/kubernetes-manifests/paymentservice.yaml index 8f28410..a3c2e31 100644 --- a/kubernetes-manifests/paymentservice.yaml +++ b/kubernetes-manifests/paymentservice.yaml @@ -25,7 +25,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: gcr.io/microservices-demo-app/paymentservice + image: paymentservice ports: - containerPort: 50051 readinessProbe: diff --git a/kubernetes-manifests/productcatalogservice.yaml b/kubernetes-manifests/productcatalogservice.yaml index 1196356..f6a15cd 100644 --- a/kubernetes-manifests/productcatalogservice.yaml +++ b/kubernetes-manifests/productcatalogservice.yaml @@ -25,7 +25,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: gcr.io/microservices-demo-app/productcatalogservice + image: productcatalogservice ports: - containerPort: 3550 readinessProbe: diff --git a/kubernetes-manifests/recommendationservice.yaml b/kubernetes-manifests/recommendationservice.yaml index 15be40f..20a85d1 100644 --- a/kubernetes-manifests/recommendationservice.yaml +++ b/kubernetes-manifests/recommendationservice.yaml @@ -25,7 +25,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: gcr.io/microservices-demo-app/recommendationservice + image: recommendationservice ports: - containerPort: 8080 readinessProbe: diff --git a/kubernetes-manifests/shippingservice.yaml b/kubernetes-manifests/shippingservice.yaml index 107b574..f0b0dae 100644 --- a/kubernetes-manifests/shippingservice.yaml +++ b/kubernetes-manifests/shippingservice.yaml @@ -24,7 +24,7 @@ spec: spec: containers: - name: server - image: gcr.io/microservices-demo-app/shippingservice + image: shippingservice ports: - containerPort: 50051 readinessProbe: diff --git a/skaffold.yaml b/skaffold.yaml index ce4eb49..eb2f9c4 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -16,27 +16,31 @@ apiVersion: skaffold/v1alpha5 kind: Config build: artifacts: - - image: gcr.io/microservices-demo-app/emailservice + # image tags are relative; to specify an image repo (e.g. GCR), you + # must provide a "default repo" using one of the methods described + # here: + # https://github.com/GoogleContainerTools/skaffold/blob/master/docs/concepts.adoc#2-push + - image: emailservice context: src/emailservice - - image: gcr.io/microservices-demo-app/productcatalogservice + - image: productcatalogservice context: src/productcatalogservice - - image: gcr.io/microservices-demo-app/recommendationservice + - image: recommendationservice context: src/recommendationservice - - image: gcr.io/microservices-demo-app/shippingservice + - image: shippingservice context: src/shippingservice - - image: gcr.io/microservices-demo-app/checkoutservice + - image: checkoutservice context: src/checkoutservice - - image: gcr.io/microservices-demo-app/paymentservice + - image: paymentservice context: src/paymentservice - - image: gcr.io/microservices-demo-app/currencyservice + - image: currencyservice context: src/currencyservice - - image: gcr.io/microservices-demo-app/cartservice + - image: cartservice context: src/cartservice - - image: gcr.io/microservices-demo-app/frontend + - image: frontend context: src/frontend - - image: gcr.io/microservices-demo-app/loadgenerator + - image: loadgenerator context: src/loadgenerator - - image: gcr.io/microservices-demo-app/adservice + - image: adservice context: src/adservice tagPolicy: gitCommit: {} From cb241e197d58b145720c443d15172d2e7edb1b48 Mon Sep 17 00:00:00 2001 From: Dave Stanke Date: Mon, 3 Dec 2018 17:59:18 -0500 Subject: [PATCH 4/4] Clarify description of cloudbuild.yaml (#102) --- cloudbuild.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index d8404c8..bf8aea7 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,4 +1,5 @@ -# Cloudbuild.yaml to deploy to staging +# This configuration file is used to build and deploy the app into a +# GKE cluster using Google Cloud Build. # # PREREQUISITES: # - Cloud Build service account must have role: "Kubernetes Engine Developer"