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
23
README.md
23
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.
|
||||
|
||||
|
|
|
@ -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'
|
|
@ -25,7 +25,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/adservice
|
||||
image: adservice
|
||||
ports:
|
||||
- containerPort: 9555
|
||||
env:
|
||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/cartservice
|
||||
image: cartservice
|
||||
ports:
|
||||
- containerPort: 7070
|
||||
env:
|
||||
|
|
|
@ -24,7 +24,7 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/checkoutservice
|
||||
image: checkoutservice
|
||||
ports:
|
||||
- containerPort: 5050
|
||||
readinessProbe:
|
||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/currencyservice
|
||||
image: currencyservice
|
||||
ports:
|
||||
- name: grpc
|
||||
containerPort: 7000
|
||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/emailservice
|
||||
image: emailservice
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
|
|
|
@ -24,7 +24,7 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/frontend
|
||||
image: frontend
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/paymentservice
|
||||
image: paymentservice
|
||||
ports:
|
||||
- containerPort: 50051
|
||||
readinessProbe:
|
||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/productcatalogservice
|
||||
image: productcatalogservice
|
||||
ports:
|
||||
- containerPort: 3550
|
||||
readinessProbe:
|
||||
|
|
|
@ -25,7 +25,7 @@ spec:
|
|||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/recommendationservice
|
||||
image: recommendationservice
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
|
|
|
@ -24,7 +24,7 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: server
|
||||
image: gcr.io/microservices-demo-app/shippingservice
|
||||
image: shippingservice
|
||||
ports:
|
||||
- containerPort: 50051
|
||||
readinessProbe:
|
||||
|
|
|
@ -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: {}
|
||||
|
|
Loading…
Reference in a new issue