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.
This commit is contained in:
parent
d69f1a4f25
commit
8dabe7ff94
14 changed files with 55 additions and 51 deletions
21
README.md
21
README.md
|
@ -103,24 +103,17 @@ Find **Protocol Buffers Descriptions** at the [`./pb` directory](./pb).
|
||||||
|
|
||||||
kubectl get nodes
|
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:
|
`docker` CLI to authenticate to GCR:
|
||||||
|
|
||||||
gcloud services enable containerregistry.googleapis.com
|
gcloud services enable containerregistry.googleapis.com
|
||||||
|
|
||||||
gcloud auth configure-docker -q
|
gcloud auth configure-docker -q
|
||||||
|
|
||||||
3. Set your project ID on image names:
|
1. In the root of this repository, run `skaffold run --default-repo=gcr.io/[PROJECT_ID]`,
|
||||||
|
where [PROJECT_ID] is your GCP project ID.
|
||||||
|
|
||||||
- Edit `skaffold.yaml`, update the `imageName:` fields that look like
|
This command:
|
||||||
`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:
|
|
||||||
- builds the container images
|
- builds the container images
|
||||||
- pushes them to GCR
|
- pushes them to GCR
|
||||||
- applies the `./kubernetes-manifests` deploying the application to
|
- 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,
|
**Troubleshooting:** If you get "No space left on device" error on Google Cloud Shell,
|
||||||
you can build the images on Google Cloud Build:
|
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.
|
browser to confirm installation.
|
||||||
|
|
||||||
kubectl get service frontend-external
|
kubectl get service frontend-external
|
||||||
|
@ -168,7 +161,7 @@ Find **Protocol Buffers Descriptions** at the [`./pb` directory](./pb).
|
||||||
|
|
||||||
This is required only once.
|
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.
|
6. Run `kubectl get pods` to see pods are in a healthy and ready state.
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
# This file is used to build and deploy the app into a GKE cluster using Google
|
# Cloudbuild.yaml to deploy to staging
|
||||||
# Cloud Build.
|
|
||||||
#
|
#
|
||||||
# Requirements:
|
# PREREQUISITES:
|
||||||
# - Give the Google Cloud Build service account "Kubernetes Engine Developer"
|
# - Cloud Build service account must have role: "Kubernetes Engine Developer"
|
||||||
# IAM role on the GCP project.
|
|
||||||
# - Set up Google Cloud Build trigger on Cloud Console.
|
# 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:
|
steps:
|
||||||
- name: gcr.io/k8s-skaffold/skaffold:v0.16.0
|
- id: 'Deploy application to cluster'
|
||||||
args: ['skaffold', 'run', '-f=skaffold.yaml']
|
name: 'gcr.io/k8s-skaffold/skaffold:v0.18.0'
|
||||||
env:
|
entrypoint: 'bash'
|
||||||
- 'CLOUDSDK_COMPUTE_ZONE=us-central1-b'
|
args:
|
||||||
- 'CLOUDSDK_CONTAINER_CLUSTER=demo-app-staging'
|
- '-c'
|
||||||
timeout: 1800s
|
- >
|
||||||
options: # Add more power, and more time, for heavy Skaffold build
|
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'
|
machineType: 'N1_HIGHCPU_8'
|
|
@ -25,7 +25,7 @@ spec:
|
||||||
terminationGracePeriodSeconds: 5
|
terminationGracePeriodSeconds: 5
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/adservice
|
image: adservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 9555
|
- containerPort: 9555
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
||||||
terminationGracePeriodSeconds: 5
|
terminationGracePeriodSeconds: 5
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/cartservice
|
image: cartservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 7070
|
- containerPort: 7070
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -24,7 +24,7 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/checkoutservice
|
image: checkoutservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5050
|
- containerPort: 5050
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
||||||
terminationGracePeriodSeconds: 5
|
terminationGracePeriodSeconds: 5
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/currencyservice
|
image: currencyservice
|
||||||
ports:
|
ports:
|
||||||
- name: grpc
|
- name: grpc
|
||||||
containerPort: 7000
|
containerPort: 7000
|
||||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
||||||
terminationGracePeriodSeconds: 5
|
terminationGracePeriodSeconds: 5
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/emailservice
|
image: emailservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
|
|
|
@ -24,7 +24,7 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/frontend
|
image: frontend
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
|
|
|
@ -38,7 +38,7 @@ spec:
|
||||||
value: "frontend:80"
|
value: "frontend:80"
|
||||||
containers:
|
containers:
|
||||||
- name: main
|
- name: main
|
||||||
image: gcr.io/microservices-demo-app/loadgenerator
|
image: loadgenerator
|
||||||
env:
|
env:
|
||||||
- name: FRONTEND_ADDR
|
- name: FRONTEND_ADDR
|
||||||
value: "frontend:80"
|
value: "frontend:80"
|
||||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
||||||
terminationGracePeriodSeconds: 5
|
terminationGracePeriodSeconds: 5
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/paymentservice
|
image: paymentservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 50051
|
- containerPort: 50051
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
||||||
terminationGracePeriodSeconds: 5
|
terminationGracePeriodSeconds: 5
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/productcatalogservice
|
image: productcatalogservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 3550
|
- containerPort: 3550
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
||||||
terminationGracePeriodSeconds: 5
|
terminationGracePeriodSeconds: 5
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/recommendationservice
|
image: recommendationservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
|
|
|
@ -24,7 +24,7 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gcr.io/microservices-demo-app/shippingservice
|
image: shippingservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 50051
|
- containerPort: 50051
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
|
|
|
@ -16,27 +16,31 @@ apiVersion: skaffold/v1alpha5
|
||||||
kind: Config
|
kind: Config
|
||||||
build:
|
build:
|
||||||
artifacts:
|
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
|
context: src/emailservice
|
||||||
- image: gcr.io/microservices-demo-app/productcatalogservice
|
- image: productcatalogservice
|
||||||
context: src/productcatalogservice
|
context: src/productcatalogservice
|
||||||
- image: gcr.io/microservices-demo-app/recommendationservice
|
- image: recommendationservice
|
||||||
context: src/recommendationservice
|
context: src/recommendationservice
|
||||||
- image: gcr.io/microservices-demo-app/shippingservice
|
- image: shippingservice
|
||||||
context: src/shippingservice
|
context: src/shippingservice
|
||||||
- image: gcr.io/microservices-demo-app/checkoutservice
|
- image: checkoutservice
|
||||||
context: src/checkoutservice
|
context: src/checkoutservice
|
||||||
- image: gcr.io/microservices-demo-app/paymentservice
|
- image: paymentservice
|
||||||
context: src/paymentservice
|
context: src/paymentservice
|
||||||
- image: gcr.io/microservices-demo-app/currencyservice
|
- image: currencyservice
|
||||||
context: src/currencyservice
|
context: src/currencyservice
|
||||||
- image: gcr.io/microservices-demo-app/cartservice
|
- image: cartservice
|
||||||
context: src/cartservice
|
context: src/cartservice
|
||||||
- image: gcr.io/microservices-demo-app/frontend
|
- image: frontend
|
||||||
context: src/frontend
|
context: src/frontend
|
||||||
- image: gcr.io/microservices-demo-app/loadgenerator
|
- image: loadgenerator
|
||||||
context: src/loadgenerator
|
context: src/loadgenerator
|
||||||
- image: gcr.io/microservices-demo-app/adservice
|
- image: adservice
|
||||||
context: src/adservice
|
context: src/adservice
|
||||||
tagPolicy:
|
tagPolicy:
|
||||||
gitCommit: {}
|
gitCommit: {}
|
||||||
|
|
Loading…
Reference in a new issue