@@ -24,7 +24,8 @@ Then create a `config.yaml` file following the
2424receivers :
2525 opencensus :
2626 address : " 127.0.0.1:55678"
27-
27+ cors_allowed_origins :
28+ - http://localhost:*
2829exporters :
2930 # Pick and configure an exporter e.g. stackdriver, zipkin, aws-xray, honeycomb
3031```
@@ -63,6 +64,85 @@ the trace viewer for the exporter you set up and view the trace of your initial
6364page load. It will be named ` Nav./index.html ` (or just ` Nav./ ` if you left off
6465the actual ` index.html ` part when you visited the URL).
6566
66- ## Deploying to Kubernetes
67+ ## Deploying to GKE (Kubernetes on Google Cloud Platform)
68+
69+ ### 1. Install needed tools
70+
71+ Install [ gcloud] ( https://cloud.google.com/sdk/install ) .
72+ Then run ` gcloud components install kubectl ` to install ` kubectl ` .
73+
74+ ### 2. Set up GKE cluster and configure container registry
75+
76+ To create a cluster with the following commands:
77+
78+ ``` bash
79+ gcloud services enable container.googleapis.com
80+ gcloud container clusters create opencensus-web-demo --enable-autoupgrade --num-nodes=1 --zone=us-central1-a
81+ ```
82+ You also need to enable Google Container Registry (GCR) on your GCP project and configure the docker CLI to authenticate to GCR:
83+
84+ ``` bash
85+ gcloud services enable containerregistry.googleapis.com
86+ gcloud auth configure-docker -q
87+ ```
88+
89+ ### 3. Deploy the OpenCensus Agent
90+
91+ To deploy the agent, run the following commands:
92+
93+ ``` bash
94+ # Get the project you are using with gcloud
95+ PROJECT_ID=" $( gcloud config list --format ' value(core.project)' ) "
96+
97+ # Substitute the project ID in the k8s config and deploy it
98+ cat ./kubernetes/oc-agent-cors.template.yaml | \
99+ sed " s/{{PROJECT-ID}}/$PROJECT_ID /" | \
100+ kubectl apply -f -
101+ ```
102+ Note that this uses the [ omnition/opencensus-agent] ( ./kubernetes/agent-cors.yaml )
103+ container from the Docker Hub. You can also build your own container by
104+ following the
105+ [ OpenCensus Agent] ( https://github.com/census-instrumentation/opencensus-service#opencensus-agent )
106+ docs.
107+
108+ ### 5. Build the demo application container
109+
110+ First build the OpenCensus Web scripts that will be deployed with the
111+ application:
112+
113+ ``` bash
114+ npm run build:prod --prefix=../../packages/opencensus-web-all
115+ mkdir -p static
116+ cp ../../packages/opencensus-web-all/dist/* .js ./static
117+ ```
118+ Then build the server container and push it to GCR:
119+
120+ ``` bash
121+ PROJECT_ID=" $( gcloud config list --format ' value(core.project)' ) "
122+ docker build . -t gcr.io/$PROJECT_ID /oc-web-initial-load:latest
123+ gcloud docker -- push gcr.io/$PROJECT_ID /oc-web-initial-load:latest
124+ ```
125+
126+ ### 4. Deploy the demo application
127+
128+ Run the command ` kubectl get svc oc-agent-service ` to check if the
129+ ` EXTERNAL-IP ` column has been filled in. If it is still pending, then wait a bit
130+ and run it again until it's available.
131+
132+ Once the agent has an external IP, you can deploy the example service that uses
133+ it by running the following commands:
134+
135+ ``` bash
136+ PROJECT_ID=" $( gcloud config list --format ' value(core.project)' ) "
137+ AGENT_IP=" $( kubectl get svc oc-agent-service \
138+ -o=custom-columns=" IP ADDRESS:.status.loadBalancer.ingress[*].ip" | \
139+ tail -n 1) "
140+ cat ./kubernetes/initial-load-demo.template.yaml | \
141+ sed " s/{{PROJECT-ID}}/$PROJECT_ID /; s/{{AGENT-IP}}/$AGENT_IP /" | \
142+ kubectl apply -f -
143+ ```
144+
145+ Then run ` kubectl get svc oc-web-initial-load-service ` to see the external IP
146+ address for the demo app, which you can then visit in your browser.
67147
68- TODO(draffensperger): develop example Kubernetes deployment instructions .
148+ You can then view traces in the [ Stackdriver Trace ] ( https://console.cloud.google.com/traces/traces ) console in GCP. The traces will be named ` Nav./ ` .
0 commit comments