Merge branch 'master' into oc-instrument-python

This commit is contained in:
Chris Kleinknecht 2018-12-10 23:10:58 -08:00
commit 679ffec91e
No known key found for this signature in database
GPG key ID: 860B7D4FF3B8AC6C
20 changed files with 76 additions and 59 deletions

View file

@ -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

View file

@ -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.

View file

@ -1,17 +1,25 @@
# This file is used to build and deploy the app into a GKE cluster using Google
# Cloud Build.
# This configuration file is used to build and deploy the app into a
# GKE cluster using Google Cloud Build.
#
# 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'

View file

@ -25,7 +25,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/microservices-demo-app/adservice
image: adservice
ports:
- containerPort: 9555
env:

View file

@ -25,7 +25,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/microservices-demo-app/cartservice
image: cartservice
ports:
- containerPort: 7070
env:

View file

@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: server
image: gcr.io/microservices-demo-app/checkoutservice
image: checkoutservice
ports:
- containerPort: 5050
readinessProbe:

View file

@ -25,7 +25,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/microservices-demo-app/currencyservice
image: currencyservice
ports:
- name: grpc
containerPort: 7000

View file

@ -25,7 +25,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: emailservice
image: gcr.io/microservices-demo-app/emailservice
image: emailservice
ports:
- containerPort: 8080
readinessProbe:

View file

@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: server
image: gcr.io/microservices-demo-app/frontend
image: frontend
ports:
- containerPort: 8080
readinessProbe:

View file

@ -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"

View file

@ -25,7 +25,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/microservices-demo-app/paymentservice
image: paymentservice
ports:
- containerPort: 50051
readinessProbe:

View file

@ -25,7 +25,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/microservices-demo-app/productcatalogservice
image: productcatalogservice
ports:
- containerPort: 3550
readinessProbe:

View file

@ -25,7 +25,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: recommendationservice
image: gcr.io/microservices-demo-app/recommendationservice
image: recommendationservice
ports:
- containerPort: 8080
readinessProbe:

View file

@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: server
image: gcr.io/microservices-demo-app/shippingservice
image: shippingservice
ports:
- containerPort: 50051
readinessProbe:

View file

@ -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: {}

View file

@ -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<maxAttempts; i++) {
try {
StackdriverTraceExporter.createAndRegister(
StackdriverTraceConfiguration.builder().build());
StackdriverStatsExporter.createAndRegister(
StackdriverStatsConfiguration.builder()
.setExportInterval(Duration.create(15, 0))
.build());
if (!traceExporterRegistered) {
StackdriverTraceExporter.createAndRegister(
StackdriverTraceConfiguration.builder().build());
traceExporterRegistered = true;
}
if (!statsExporterRegistered) {
StackdriverStatsExporter.createAndRegister(
StackdriverStatsConfiguration.builder()
.setExportInterval(Duration.create(60, 0))
.build());
statsExporterRegistered = true;
}
} catch (Exception e) {
if (i==(maxAttempts-1)) {
logger.log(Level.WARN, "Failed to register Stackdriver Exporter." +

View file

@ -99,6 +99,7 @@ func main() {
}
func initStats(exporter *stackdriver.Exporter) {
view.SetReportingPeriod(60 * time.Second)
view.RegisterExporter(exporter)
if err := view.Register(ocgrpc.DefaultServerViews...); err != nil {
log.Warn("Error registering default server views")

View file

@ -143,6 +143,7 @@ func main() {
}
func initStats(log logrus.FieldLogger, exporter *stackdriver.Exporter) {
view.SetReportingPeriod(60 * time.Second)
view.RegisterExporter(exporter)
if err := view.Register(ochttp.DefaultServerViews...); err != nil {
log.Warn("Error registering http default server views")

View file

@ -90,6 +90,7 @@ func run(port int) string {
}
func initStats(exporter *stackdriver.Exporter) {
view.SetReportingPeriod(60 * time.Second)
view.RegisterExporter(exporter)
if err := view.Register(ocgrpc.DefaultServerViews...); err != nil {
log.Info("Error registering default server views")

View file

@ -129,6 +129,7 @@ func (s *server) ShipOrder(ctx context.Context, in *pb.ShipOrderRequest) (*pb.Sh
}
func initStats(exporter *stackdriver.Exporter) {
view.SetReportingPeriod(60 * time.Second)
view.RegisterExporter(exporter)
if err := view.Register(ocgrpc.DefaultServerViews...); err != nil {
log.Warn("Error registering default server views")