Skip to content

Commit

Permalink
Add kubernetes example for hotrod app (#3645)
Browse files Browse the repository at this point in the history
* Add kubernetes example for hotrod app

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Remove grafana-agent optional configuration

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Add redis container to kubernetes deployment example

Also reduces the cpu/memory limits as they were excessive initially.

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Move kubernetes example into hotrod/kubernetes

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Add jaeger all-in-one to kubernetes example

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Add one-liner for port-forward to see traces

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Tracing port needs to be UDP not TCP

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Update examples/hotrod/README.md

Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Move up kubernetes section in hotrod example README

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Add cleanup to k8s example READMEs

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Remove redis from hotrod example

Signed-off-by: Brandon High <highb@users.noreply.github.com>

* Use pod local/localhost for jaeger-all-in-one

Signed-off-by: Brandon High <highb@users.noreply.github.com>

Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
  • Loading branch information
highb and yurishkuro committed May 10, 2022
1 parent 7ad154e commit 8fd5c0c
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/hotrod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ to view the traces. A tutorial / walkthrough is available:

Alternatively, you can run each component separately as described below.

### Run everything in Kubernetes

```bash
kustomize build ./kubernetes | kubectl apply -f -
kubectl port-forward -n example-hotrod service/example-hotrod 8080:frontend
# In another terminal
kubectl port-forward -n example-hotrod service/jaeger 16686:frontend

# To cleanup
kustomize build ./kubernetes | kubectl delete -f -
```

Access Jaeger UI at http://localhost:16686 and HotROD app at http://localhost:8080

### Run Jaeger backend

An all-in-one Jaeger backend is packaged as a Docker container with in-memory storage.
Expand Down
17 changes: 17 additions & 0 deletions examples/hotrod/kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Hot R.O.D. - Rides on Demand on Kubernetes

Example k8s manifests for deploying the [hotrod app](..) to your k8s environment of choice. e.g. minikube, k3s, EKS, GKE

## Usage

```bash
kustomize build . | kubectl apply -f -
kubectl port-forward -n example-hotrod service/example-hotrod 8080:frontend
# In another terminal
kubectl port-forward -n example-hotrod service/jaeger 16686:frontend

# To cleanup
kustomize build . | kubectl delete -f -
```

Access Jaeger UI at <http://localhost:16686> and HotROD app at <http://localhost:8080>
40 changes: 40 additions & 0 deletions examples/hotrod/kubernetes/base/hotrod/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: example-hotrod
name: example-hotrod
spec:
replicas: 1
selector:
matchLabels:
app: example-hotrod
strategy: {}
template:
metadata:
labels:
app: example-hotrod
spec:
containers:
- image: jaegertracing/example-hotrod:latest
name: example-hotrod
args: ["all"]
env:
- name: JAEGER_AGENT_HOST
value: localhost
- name: JAEGER_AGENT_PORT
value: "6831"
ports:
- containerPort: 8080
name: frontend
- containerPort: 8081
name: customer
- containerPort: 8083
name: route
resources:
limits:
cpu: 100m
memory: 100M
requests:
cpu: 100m
memory: 100M
6 changes: 6 additions & 0 deletions examples/hotrod/kubernetes/base/hotrod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml
- service.yaml
12 changes: 12 additions & 0 deletions examples/hotrod/kubernetes/base/hotrod/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: example-hotrod
spec:
selector:
app: example-hotrod
ports:
- name: frontend
protocol: TCP
port: 8080
targetPort: frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../hotrod

resources:
- service.yaml

patches:
- target:
group: apps
version: v1
kind: Deployment
name: example-hotrod
patch: |-
- op: add
path: /spec/template/spec/containers/-
value:
image: jaegertracing/all-in-one:latest
name: jaeger
ports:
- containerPort: 6831
name: tracing-jaeger
- containerPort: 16686
name: frontend-jaeger
resources:
limits:
cpu: 100m
memory: 100M
requests:
cpu: 100m
memory: 100M
16 changes: 16 additions & 0 deletions examples/hotrod/kubernetes/base/jaeger-all-in-one/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: jaeger
spec:
selector:
app: example-hotrod
ports:
- name: tracing
protocol: UDP
port: 6831
targetPort: tracing-jaeger
- name: frontend
protocol: TCP
port: 16686
targetPort: frontend-jaeger
12 changes: 12 additions & 0 deletions examples/hotrod/kubernetes/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
# If you only want the hotrod application, uncomment this line and comment out jaeger-all-in-one
# - base/hotrod
- base/jaeger

namespace: example-hotrod

resources:
- namespace.yaml
4 changes: 4 additions & 0 deletions examples/hotrod/kubernetes/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: example-hotrod

0 comments on commit 8fd5c0c

Please sign in to comment.