Skip to content

Commit

Permalink
Add simplified Helm chart with a guide (#43)
Browse files Browse the repository at this point in the history
* k8s: added basic manifest files

* fix postgres manifest

* cleanup

* add tt agent

* simplify manifests

* add readme

* improve readme

* add port env

* delete kompose file

* added deps to helm chart

* remove stream simplify chart

---------

Co-authored-by: Matheus Nogueira <[email protected]>
  • Loading branch information
adnanrahic and mathnogueira authored Sep 3, 2024
1 parent e04430a commit 5da696c
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 124 deletions.
16 changes: 11 additions & 5 deletions helm-chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 11.1.19
version: 12.1.6
- name: rabbitmq
repository: https://charts.bitnami.com/bitnami
version: 8.30.0
version: 11.2.2
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 16.8.5
digest: sha256:7cba0f80b53fc0f7da7cf6402dd131cbfbeab5d7615feb26a005f3f861277195
generated: "2022-04-15T14:45:15.128266901-03:00"
version: 17.3.17
- name: opentelemetry-collector
repository: https://open-telemetry.github.io/opentelemetry-helm-charts
version: 0.92.0
- name: jaeger
repository: https://jaegertracing.github.io/helm-charts
version: 3.0.10
digest: sha256:3004524c4ef3f6cb0d3b04bd4f652b239ff0f0ffb73b39ae96c89f71d7221591
generated: "2024-08-28T14:20:10.713465+02:00"
6 changes: 6 additions & 0 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ dependencies:
- name: redis
version: 17.3.17
repository: https://charts.bitnami.com/bitnami
- name: opentelemetry-collector
version: 0.92.0
repository: https://open-telemetry.github.io/opentelemetry-helm-charts
- name: jaeger
version: 3.0.10
repository: https://jaegertracing.github.io/helm-charts
27 changes: 27 additions & 0 deletions helm-chart/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Install Pokeshop with Helm

1. Update Helm dependencies

```bash
helm dependency update
```

2. Install the Helm chart

```bash
helm install -f ./values.yaml pokeshop .
```

3. [Get your Tracetest API key and env id](https://app.tracetest.io/retrieve-token)
4. Install Tracetest Agent

```bash
helm repo add tracetestcloud https://kubeshop.github.io/tracetest-cloud-charts --force-update && helm install agent tracetestcloud/tracetest-agent --set agent.apiKey=<TRACETEST_API_KEY> --set agent.environmentId=<TRACETEST_ENVIRONMENT_ID>
```

5. Create and run a test by going to [`app.tracetest.io`](https://app.tracetest.io) and using the internal Kubernetes service networking:

- **POST** `http://pokeshop-pokemon-api:8081/pokemon/import` - Body: `{ "id": 1 }`
- **GET** `http://pokeshop-pokemon-api:8081/pokemon`

![](https://res.cloudinary.com/djwdcmwdz/image/upload/v1725358889/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_4b0e8945dbe5045a_test_Q6Mr5o3Ig_run_24_trigger_agj1ls.png)
23 changes: 5 additions & 18 deletions helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- $rpcPort := .Values.service.rpcPort -}}
{{- $httpPort := .Values.service.httpPort -}}
{{- $port := .Values.service.port -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -36,7 +38,7 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
containerPort: {{ $httpPort }}
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
Expand Down Expand Up @@ -79,23 +81,8 @@ spec:
value: rpc
- name: SERVICE_NAME
value: pokeshop
{{- toYaml .Values.env | nindent 12 }}
- name: {{ .Chart.Name }}-stream-worker
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: NPM_RUN_COMMAND
value: stream-worker
- name: SERVICE_NAME
value: pokeshop-stream-worker
- name: RPC_PORT
value: "8082"
{{- toYaml .Values.env | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
Expand Down
4 changes: 4 additions & 0 deletions helm-chart/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 80
protocol: TCP
name: ingress
- port: {{ .Values.service.httpPort }}
targetPort: 8081
protocol: TCP
name: http
Expand Down
68 changes: 0 additions & 68 deletions helm-chart/templates/stream.deployment.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions helm-chart/templates/stream.service.yaml

This file was deleted.

113 changes: 101 additions & 12 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,21 @@ replicaCount: 1

image:
repository: kubeshop/demo-pokemon-api
pullPolicy: IfNotPresent
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: latest

env:
- name: COLLECTOR_ENDPOINT
value: http://pokeshop-opentelemetry-collector:44317
- name: DATABASE_URL
value: postgresql://ashketchum:squirtle123@postgresql:5432/pokeshop?schema=public
- name: REDIS_URL
value: redis-master
value: redis-headless
- name: RABBITMQ_HOST
value: guest:guest@rabbitmq-headless
- name: POKE_API_BASE_URL
value: https://pokeapi.co/api/v2
- name: COLLECTOR_ENDPOINT
value: http://otel-collector.tracetest.svc.cluster.local:4317
- name: ZIPKIN_URL
value: http://jaeger-agent.tracetest.svc.cluster.local:9411
- name: KAFKA_BROKER
value: stream:9092
- name: KAFKA_TOPIC
value: pokemon
- name: KAFKA_CLIENT_ID
value: streaming-worker

imagePullSecrets: []
nameOverride: ""
Expand Down Expand Up @@ -61,6 +53,7 @@ securityContext:
service:
type: ClusterIP
port: 80
httpPort: 8081
rpcPort: 8082

ingress:
Expand Down Expand Up @@ -144,3 +137,99 @@ rabbitmq:
requests:
cpu: 400m
memory: 512Mi

opentelemetry-collector:
mode: deployment

image:
repository: "otel/opentelemetry-collector-contrib"


ports:
otlp:
enabled: true
containerPort: 4317
servicePort: 44317
hostPort: 44317
protocol: TCP
appProtocol: grpc
otlp-http:
enabled: true
containerPort: 4318
servicePort: 44318
hostPort: 44318
protocol: TCP
jaeger-compact:
enabled: false
jaeger-thrift:
enabled: false
jaeger-grpc:
enabled: false
zipkin:
enabled: false

config:
receivers:
otlp:
protocols:
http:
grpc:

processors:
batch:
timeout: 5s

exporters:
debug/noop:
verbosity: normal
sampling_initial: 0
sampling_thereafter: 0

debug:
verbosity: detailed

otlp/jaeger:
endpoint: pokeshop-jaeger-collector:4317
tls:
insecure: true

otlp/tracetest:
endpoint: agent-tracetest-agent:4317
tls:
insecure: true

service:
pipelines:
logs:
exporters: [debug/noop]
processors: [memory_limiter, batch]
receivers: [otlp]
metrics:
exporters: [debug/noop]
processors: [memory_limiter, batch]
receivers: [otlp,prometheus]
traces/jaeger:
receivers: [otlp]
processors: [batch]
exporters: [otlp/jaeger]
traces/tracetest:
receivers: [otlp]
processors: [batch]
exporters: [otlp/tracetest]

jaeger:
enabled: true
provisionDataStore:
cassandra: false
allInOne:
enabled: true

storage:
type: memory

agent:
enabled: false
collector:
enabled: false
query:
enabled: false
3 changes: 2 additions & 1 deletion k8s/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
```bash
kubectl apply -f .
```

4. Create and run a test by going to [`app.tracetest.io`](https://app.tracetest.io) and using the internal Kubernetes service networking:

- **POST** `http://api.default.svc.cluster.local:8081/pokemon/import` - Body: `{ "id": 1 }`
Expand All @@ -16,4 +17,4 @@

5. View the trace and create test specs by going to the `Test` tab.

![](https://res.cloudinary.com/djwdcmwdz/image/upload/v1724764098/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_4b0e8945dbe5045a_test_tTFZ453Ig_run_9_selectedSpan_bb8ba205b42a8619_1_xaxlbi.png)
![](https://res.cloudinary.com/djwdcmwdz/image/upload/v1724764098/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_4b0e8945dbe5045a_test_tTFZ453Ig_run_9_selectedSpan_bb8ba205b42a8619_1_xaxlbi.png)

0 comments on commit 5da696c

Please sign in to comment.