From da85be1d0ae61a77e4f4e7798414369a4e25bb6d Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Mon, 26 Aug 2024 19:10:43 +0200 Subject: [PATCH 1/9] k8s: added basic manifest files --- docker-compose-kompose.yaml | 153 ++++++++++++++++++++++++++ k8s/api-deployment.yaml | 50 +++++++++ k8s/api-service.yaml | 16 +++ k8s/cache-deployment.yaml | 37 +++++++ k8s/cache-service.yaml | 16 +++ k8s/db-deployment.yaml | 50 +++++++++ k8s/db-persistent-volume-claim.yaml | 13 +++ k8s/db-persistent-volume.yaml | 15 +++ k8s/db-service.yaml | 16 +++ k8s/jaeger-deployment.yaml | 47 ++++++++ k8s/jaeger-service.yaml | 22 ++++ k8s/otel-collector-cm0-configmap.yaml | 45 ++++++++ k8s/otel-collector-deployment.yaml | 55 +++++++++ k8s/otel-collector-service.yaml | 25 +++++ k8s/queue-deployment.yaml | 38 +++++++ k8s/queue-service.yaml | 19 ++++ k8s/rpc-deployment.yaml | 52 +++++++++ k8s/rpc-service.yaml | 16 +++ k8s/worker-deployment.yaml | 40 +++++++ 19 files changed, 725 insertions(+) create mode 100644 docker-compose-kompose.yaml create mode 100644 k8s/api-deployment.yaml create mode 100644 k8s/api-service.yaml create mode 100644 k8s/cache-deployment.yaml create mode 100644 k8s/cache-service.yaml create mode 100644 k8s/db-deployment.yaml create mode 100644 k8s/db-persistent-volume-claim.yaml create mode 100644 k8s/db-persistent-volume.yaml create mode 100644 k8s/db-service.yaml create mode 100644 k8s/jaeger-deployment.yaml create mode 100644 k8s/jaeger-service.yaml create mode 100644 k8s/otel-collector-cm0-configmap.yaml create mode 100644 k8s/otel-collector-deployment.yaml create mode 100644 k8s/otel-collector-service.yaml create mode 100644 k8s/queue-deployment.yaml create mode 100644 k8s/queue-service.yaml create mode 100644 k8s/rpc-deployment.yaml create mode 100644 k8s/rpc-service.yaml create mode 100644 k8s/worker-deployment.yaml diff --git a/docker-compose-kompose.yaml b/docker-compose-kompose.yaml new file mode 100644 index 0000000..ef5bd57 --- /dev/null +++ b/docker-compose-kompose.yaml @@ -0,0 +1,153 @@ +version: '3.5' +name: pokeshop + +services: + db: + image: postgres:14 + ports: + - 5434:5432 + environment: + POSTGRES_USER: ashketchum + POSTGRES_PASSWORD: squirtle123 + POSTGRES_DB: pokeshop + healthcheck: + test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB'] + interval: 1s + timeout: 5s + retries: 60 + + cache: + image: redis:6 + ports: + - 6379:6379 + healthcheck: + test: ['CMD', 'redis-cli', 'ping'] + interval: 1s + timeout: 3s + retries: 60 + + queue: + image: rabbitmq:3.12 + restart: unless-stopped + ports: + - 5672:5672 + - 15672:15672 + healthcheck: + test: rabbitmq-diagnostics -q check_running + interval: 1s + timeout: 5s + retries: 60 + + jaeger: + image: jaegertracing/all-in-one:latest + ports: + - 14250:14250 + - 16685:16685 + - 16686:16686 + environment: + - COLLECTOR_ZIPKIN_HOST_PORT=:9411 + - COLLECTOR_OTLP_ENABLED=true + healthcheck: + test: ['CMD', 'wget', '--spider', 'localhost:16686'] + interval: 1s + timeout: 3s + retries: 60 + + otel-collector: + image: otel/opentelemetry-collector-contrib:0.59.0 + restart: unless-stopped + extra_hosts: + - 'host.docker.internal:host-gateway' + ports: + - 55679:55679 + - 8888:8888 + - 4317:4317 + - 4318:4318 + command: + - '--config' + - '/otel-local-config.yaml' + volumes: + - ./collector.config.yaml:/otel-local-config.yaml + environment: + - JAEGER_ENDPOINT=jaeger:14250 + depends_on: + jaeger: + condition: service_healthy + + api: + build: . + environment: + REDIS_URL: cache + DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public + RABBITMQ_HOST: queue + POKE_API_BASE_URL: https://pokeapi.co/api/v2 + COLLECTOR_ENDPOINT: http://otel-collector:4317 + ZIPKIN_URL: http://localhost:9411 + healthcheck: + test: ['CMD', 'wget', '--spider', 'localhost:8081/pokemon/healthcheck'] + interval: 1s + timeout: 3s + retries: 60 + ports: + - 8081:8081 + depends_on: + db: + condition: service_healthy + cache: + condition: service_healthy + queue: + condition: service_healthy + jaeger: + condition: service_healthy + otel-collector: + condition: service_started + rpc: + build: . + environment: + REDIS_URL: cache + DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public + RABBITMQ_HOST: queue + POKE_API_BASE_URL: https://pokeapi.co/api/v2 + COLLECTOR_ENDPOINT: http://otel-collector:4317 + ZIPKIN_URL: http://localhost:9411 + NPM_RUN_COMMAND: rpc + healthcheck: + test: ['CMD', 'wget', '--spider', 'localhost:8081/pokemon/healthcheck'] + interval: 1s + timeout: 3s + retries: 60 + ports: + - 8082:8082 + depends_on: + db: + condition: service_healthy + cache: + condition: service_healthy + queue: + condition: service_healthy + jaeger: + condition: service_healthy + otel-collector: + condition: service_started + + worker: + build: . + environment: + REDIS_URL: cache + DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public + RABBITMQ_HOST: queue + POKE_API_BASE_URL: https://pokeapi.co/api/v2 + COLLECTOR_ENDPOINT: http://otel-collector:4317 + ZIPKIN_URL: http://localhost:9411 + NPM_RUN_COMMAND: worker + depends_on: + db: + condition: service_healthy + cache: + condition: service_healthy + queue: + condition: service_healthy + jaeger: + condition: service_healthy + otel-collector: + condition: service_started diff --git a/k8s/api-deployment.yaml b/k8s/api-deployment.yaml new file mode 100644 index 0000000..ed5460d --- /dev/null +++ b/k8s/api-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: api + name: api +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: api + template: + metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: api + spec: + containers: + - env: + - name: COLLECTOR_ENDPOINT + value: http://otel-collector.default.svc.cluster.local:4317 + - name: DATABASE_URL + value: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public + - name: POKE_API_BASE_URL + value: https://pokeapi.co/api/v2 + - name: RABBITMQ_HOST + value: guest:guest@queue + - name: REDIS_URL + value: cache + image: kubeshop/demo-pokemon-api:latest + imagePullPolicy: Always + livenessProbe: + exec: + command: + - wget + - --spider + - localhost:8081/pokemon/healthcheck + failureThreshold: 60 + periodSeconds: 1 + timeoutSeconds: 3 + name: api + ports: + - containerPort: 8081 + protocol: TCP + restartPolicy: Always diff --git a/k8s/api-service.yaml b/k8s/api-service.yaml new file mode 100644 index 0000000..140ab3b --- /dev/null +++ b/k8s/api-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: api + name: api +spec: + ports: + - name: "8081" + port: 8081 + targetPort: 8081 + selector: + io.kompose.service: api diff --git a/k8s/cache-deployment.yaml b/k8s/cache-deployment.yaml new file mode 100644 index 0000000..1712362 --- /dev/null +++ b/k8s/cache-deployment.yaml @@ -0,0 +1,37 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: cache + name: cache +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: cache + template: + metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: cache + spec: + containers: + - image: redis:6 + livenessProbe: + exec: + command: + - redis-cli + - ping + failureThreshold: 60 + periodSeconds: 1 + timeoutSeconds: 3 + name: cache + ports: + - containerPort: 6379 + protocol: TCP + restartPolicy: Always diff --git a/k8s/cache-service.yaml b/k8s/cache-service.yaml new file mode 100644 index 0000000..997aff6 --- /dev/null +++ b/k8s/cache-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: cache + name: cache +spec: + ports: + - name: "6379" + port: 6379 + targetPort: 6379 + selector: + io.kompose.service: cache diff --git a/k8s/db-deployment.yaml b/k8s/db-deployment.yaml new file mode 100644 index 0000000..40b4bad --- /dev/null +++ b/k8s/db-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: db + name: db +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: db + template: + metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: db + spec: + containers: + - env: + - name: POSTGRES_DB + value: pokeshop + - name: POSTGRES_PASSWORD + value: squirtle123 + - name: POSTGRES_USER + value: ashketchum + image: postgres:14 + livenessProbe: + exec: + command: + - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB + failureThreshold: 60 + periodSeconds: 1 + timeoutSeconds: 5 + name: db + ports: + - containerPort: 5432 + protocol: TCP + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: dbdata + volumes: + - name: dbdata + persistentVolumeClaim: + claimName: db-volume-claim + restartPolicy: Always diff --git a/k8s/db-persistent-volume-claim.yaml b/k8s/db-persistent-volume-claim.yaml new file mode 100644 index 0000000..3eac9d6 --- /dev/null +++ b/k8s/db-persistent-volume-claim.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: db-volume-claim + labels: + io.kompose.service: db +spec: + storageClassName: manual + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10Gi diff --git a/k8s/db-persistent-volume.yaml b/k8s/db-persistent-volume.yaml new file mode 100644 index 0000000..e02d217 --- /dev/null +++ b/k8s/db-persistent-volume.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: db-volume + labels: + type: local + io.kompose.service: db +spec: + storageClassName: manual + capacity: + storage: 10Gi + accessModes: + - ReadWriteMany + hostPath: + path: /data/postgresql diff --git a/k8s/db-service.yaml b/k8s/db-service.yaml new file mode 100644 index 0000000..9d5785a --- /dev/null +++ b/k8s/db-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: db + name: db +spec: + ports: + - name: "5434" + port: 5434 + targetPort: 5432 + selector: + io.kompose.service: db diff --git a/k8s/jaeger-deployment.yaml b/k8s/jaeger-deployment.yaml new file mode 100644 index 0000000..970616b --- /dev/null +++ b/k8s/jaeger-deployment.yaml @@ -0,0 +1,47 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: jaeger + name: jaeger +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: jaeger + template: + metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: jaeger + spec: + containers: + - env: + - name: COLLECTOR_OTLP_ENABLED + value: "true" + - name: COLLECTOR_ZIPKIN_HOST_PORT + value: :9411 + image: jaegertracing/all-in-one:latest + livenessProbe: + exec: + command: + - wget + - --spider + - localhost:16686 + failureThreshold: 60 + periodSeconds: 1 + timeoutSeconds: 3 + name: jaeger + ports: + - containerPort: 14250 + protocol: TCP + - containerPort: 16685 + protocol: TCP + - containerPort: 16686 + protocol: TCP + restartPolicy: Always diff --git a/k8s/jaeger-service.yaml b/k8s/jaeger-service.yaml new file mode 100644 index 0000000..9e139f5 --- /dev/null +++ b/k8s/jaeger-service.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: jaeger + name: jaeger +spec: + ports: + - name: "14250" + port: 14250 + targetPort: 14250 + - name: "16685" + port: 16685 + targetPort: 16685 + - name: "16686" + port: 16686 + targetPort: 16686 + selector: + io.kompose.service: jaeger diff --git a/k8s/otel-collector-cm0-configmap.yaml b/k8s/otel-collector-cm0-configmap.yaml new file mode 100644 index 0000000..2ebde60 --- /dev/null +++ b/k8s/otel-collector-cm0-configmap.yaml @@ -0,0 +1,45 @@ +apiVersion: v1 +data: + collector.config.yaml: | + receivers: + otlp: + protocols: + grpc: + http: + cors: + allowed_origins: + - "http://*" + - "https://*" + + processors: + batch: + + exporters: + logging: + loglevel: debug + jaeger: + endpoint: ${JAEGER_ENDPOINT} + tls: + insecure: true + otlp/trace: + endpoint: ${TRACETEST_AGENT_ENDPOINT} + tls: + insecure: true + + service: + pipelines: + traces: + receivers: [otlp] + processors: [] + exporters: [logging, jaeger] + traces/1: + receivers: [otlp] + processors: [batch] + exporters: [otlp/trace] +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: otel-collector + name: otel-collector-cm0 diff --git a/k8s/otel-collector-deployment.yaml b/k8s/otel-collector-deployment.yaml new file mode 100644 index 0000000..c3ae11b --- /dev/null +++ b/k8s/otel-collector-deployment.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: otel-collector + name: otel-collector +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: otel-collector + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: otel-collector + spec: + containers: + - args: + - --config + - /config/otel-local-config.yaml + env: + - name: JAEGER_ENDPOINT + value: jaeger.default.svc.cluster.local:14250 + - name: TRACETEST_AGENT_ENDPOINT + value: tracetest-agent.default.svc.cluster.local:4317 + image: otel/opentelemetry-collector-contrib:0.59.0 + name: otel-collector + ports: + - containerPort: 55679 + protocol: TCP + - containerPort: 8888 + protocol: TCP + - containerPort: 4317 + protocol: TCP + - containerPort: 4318 + protocol: TCP + volumeMounts: + - mountPath: /config + name: otel-collector-cm0 + restartPolicy: Always + volumes: + - configMap: + items: + - key: collector.config.yaml + path: otel-local-config.yaml + name: otel-collector-cm0 + name: otel-collector-cm0 diff --git a/k8s/otel-collector-service.yaml b/k8s/otel-collector-service.yaml new file mode 100644 index 0000000..4a0e098 --- /dev/null +++ b/k8s/otel-collector-service.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: otel-collector + name: otel-collector +spec: + ports: + - name: "55679" + port: 55679 + targetPort: 55679 + - name: "8888" + port: 8888 + targetPort: 8888 + - name: "4317" + port: 4317 + targetPort: 4317 + - name: "4318" + port: 4318 + targetPort: 4318 + selector: + io.kompose.service: otel-collector diff --git a/k8s/queue-deployment.yaml b/k8s/queue-deployment.yaml new file mode 100644 index 0000000..338b958 --- /dev/null +++ b/k8s/queue-deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: queue + name: queue +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: queue + template: + metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: queue + spec: + containers: + - image: rabbitmq:3.12 + livenessProbe: + exec: + command: + - rabbitmq-diagnostics -q check_running + failureThreshold: 60 + periodSeconds: 1 + timeoutSeconds: 5 + name: queue + ports: + - containerPort: 5672 + protocol: TCP + - containerPort: 15672 + protocol: TCP + restartPolicy: Always diff --git a/k8s/queue-service.yaml b/k8s/queue-service.yaml new file mode 100644 index 0000000..8e0f489 --- /dev/null +++ b/k8s/queue-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: queue + name: queue +spec: + ports: + - name: "5672" + port: 5672 + targetPort: 5672 + - name: "15672" + port: 15672 + targetPort: 15672 + selector: + io.kompose.service: queue diff --git a/k8s/rpc-deployment.yaml b/k8s/rpc-deployment.yaml new file mode 100644 index 0000000..2a4ad22 --- /dev/null +++ b/k8s/rpc-deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: rpc + name: rpc +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: rpc + template: + metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: rpc + spec: + containers: + - env: + - name: NPM_RUN_COMMAND + value: rpc + - name: COLLECTOR_ENDPOINT + value: http://otel-collector.default.svc.cluster.local:4317 + - name: DATABASE_URL + value: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public + - name: POKE_API_BASE_URL + value: https://pokeapi.co/api/v2 + - name: RABBITMQ_HOST + value: guest:guest@queue + - name: REDIS_URL + value: cache + image: kubeshop/demo-pokemon-api:latest + imagePullPolicy: Always + livenessProbe: + exec: + command: + - wget + - --spider + - localhost:8081/pokemon/healthcheck + failureThreshold: 60 + periodSeconds: 1 + timeoutSeconds: 3 + name: rpc + ports: + - containerPort: 8082 + protocol: TCP + restartPolicy: Always diff --git a/k8s/rpc-service.yaml b/k8s/rpc-service.yaml new file mode 100644 index 0000000..60e306b --- /dev/null +++ b/k8s/rpc-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: rpc + name: rpc +spec: + ports: + - name: "8082" + port: 8082 + targetPort: 8082 + selector: + io.kompose.service: rpc diff --git a/k8s/worker-deployment.yaml b/k8s/worker-deployment.yaml new file mode 100644 index 0000000..1902b4e --- /dev/null +++ b/k8s/worker-deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: worker + name: worker +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: worker + template: + metadata: + annotations: + kompose.cmd: kompose convert -f docker-compose.yaml + kompose.version: 1.34.0 (HEAD) + labels: + io.kompose.service: worker + spec: + containers: + - env: + - name: NPM_RUN_COMMAND + value: worker + - name: COLLECTOR_ENDPOINT + value: http://otel-collector.default.svc.cluster.local:4317 + - name: DATABASE_URL + value: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public + - name: POKE_API_BASE_URL + value: https://pokeapi.co/api/v2 + - name: RABBITMQ_HOST + value: guest:guest@queue + - name: REDIS_URL + value: cache + image: kubeshop/demo-pokemon-api:latest + imagePullPolicy: Always + name: worker + restartPolicy: Always From 1371d42b783d106e0d65a3a1f26177039c81d010 Mon Sep 17 00:00:00 2001 From: Matheus Nogueira Date: Mon, 26 Aug 2024 16:02:48 -0300 Subject: [PATCH 2/9] fix postgres manifest --- k8s/db-deployment.yaml | 7 ------- k8s/db-service.yaml | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/k8s/db-deployment.yaml b/k8s/db-deployment.yaml index 40b4bad..11e0d71 100644 --- a/k8s/db-deployment.yaml +++ b/k8s/db-deployment.yaml @@ -29,13 +29,6 @@ spec: - name: POSTGRES_USER value: ashketchum image: postgres:14 - livenessProbe: - exec: - command: - - pg_isready -U $POSTGRES_USER -d $POSTGRES_DB - failureThreshold: 60 - periodSeconds: 1 - timeoutSeconds: 5 name: db ports: - containerPort: 5432 diff --git a/k8s/db-service.yaml b/k8s/db-service.yaml index 9d5785a..fbbfa1f 100644 --- a/k8s/db-service.yaml +++ b/k8s/db-service.yaml @@ -9,8 +9,8 @@ metadata: name: db spec: ports: - - name: "5434" - port: 5434 + - name: "5432" + port: 5432 targetPort: 5432 selector: io.kompose.service: db From a784e0aa08602d7bcc3f010ac29878b89d0f6ab2 Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Tue, 27 Aug 2024 14:35:24 +0200 Subject: [PATCH 3/9] cleanup --- k8s/jaeger-deployment.yaml | 2 ++ k8s/jaeger-service.yaml | 3 +++ k8s/otel-collector-cm0-configmap.yaml | 18 ++++++++---------- k8s/otel-collector-deployment.yaml | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/k8s/jaeger-deployment.yaml b/k8s/jaeger-deployment.yaml index 970616b..6dea5cb 100644 --- a/k8s/jaeger-deployment.yaml +++ b/k8s/jaeger-deployment.yaml @@ -38,6 +38,8 @@ spec: timeoutSeconds: 3 name: jaeger ports: + - containerPort: 4317 + protocol: TCP - containerPort: 14250 protocol: TCP - containerPort: 16685 diff --git a/k8s/jaeger-service.yaml b/k8s/jaeger-service.yaml index 9e139f5..7a81880 100644 --- a/k8s/jaeger-service.yaml +++ b/k8s/jaeger-service.yaml @@ -9,6 +9,9 @@ metadata: name: jaeger spec: ports: + - name: "4317" + port: 4317 + targetPort: 4317 - name: "14250" port: 14250 targetPort: 14250 diff --git a/k8s/otel-collector-cm0-configmap.yaml b/k8s/otel-collector-cm0-configmap.yaml index 2ebde60..6dfb2a4 100644 --- a/k8s/otel-collector-cm0-configmap.yaml +++ b/k8s/otel-collector-cm0-configmap.yaml @@ -5,11 +5,9 @@ data: otlp: protocols: grpc: + endpoint: 0.0.0.0:4317 http: - cors: - allowed_origins: - - "http://*" - - "https://*" + endpoint: 0.0.0.0:4318 processors: batch: @@ -17,25 +15,25 @@ data: exporters: logging: loglevel: debug - jaeger: + otlp/jaeger: endpoint: ${JAEGER_ENDPOINT} tls: insecure: true - otlp/trace: + otlp/tracetest: endpoint: ${TRACETEST_AGENT_ENDPOINT} tls: insecure: true service: pipelines: - traces: + traces/jaeger: receivers: [otlp] processors: [] - exporters: [logging, jaeger] - traces/1: + exporters: [logging, otlp/jaeger] + traces/tracetest: receivers: [otlp] processors: [batch] - exporters: [otlp/trace] + exporters: [otlp/tracetest] kind: ConfigMap metadata: annotations: diff --git a/k8s/otel-collector-deployment.yaml b/k8s/otel-collector-deployment.yaml index c3ae11b..9982a91 100644 --- a/k8s/otel-collector-deployment.yaml +++ b/k8s/otel-collector-deployment.yaml @@ -28,10 +28,10 @@ spec: - /config/otel-local-config.yaml env: - name: JAEGER_ENDPOINT - value: jaeger.default.svc.cluster.local:14250 + value: jaeger.default.svc.cluster.local:4317 - name: TRACETEST_AGENT_ENDPOINT value: tracetest-agent.default.svc.cluster.local:4317 - image: otel/opentelemetry-collector-contrib:0.59.0 + image: otel/opentelemetry-collector-contrib:0.107.0 #0.59.0 name: otel-collector ports: - containerPort: 55679 From 298c44990f757b60ac7343f28ec435483583bb99 Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Tue, 27 Aug 2024 14:39:57 +0200 Subject: [PATCH 4/9] add tt agent --- k8s/tracetest-agent.yaml | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 k8s/tracetest-agent.yaml diff --git a/k8s/tracetest-agent.yaml b/k8s/tracetest-agent.yaml new file mode 100644 index 0000000..b95380f --- /dev/null +++ b/k8s/tracetest-agent.yaml @@ -0,0 +1,59 @@ +--- +# Service +apiVersion: v1 +kind: Service +metadata: + name: tracetest-agent + labels: + app.kubernetes.io/name: tracetest-agent + app.kubernetes.io/instance: tracetest-agent +spec: + selector: + app.kubernetes.io/name: tracetest-agent + app.kubernetes.io/instance: tracetest-agent + ports: + - name: grpc-collector-entrypoint + protocol: TCP + port: 4317 + targetPort: 4317 + - name: http-collector-entrypoint + protocol: TCP + port: 4318 + targetPort: 4318 +--- +# Deployment +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tracetest-agent + labels: + app: tracetest-agent + app.kubernetes.io/name: tracetest-agent + app.kubernetes.io/instance: tracetest-agent +spec: + selector: + matchLabels: + app.kubernetes.io/name: tracetest-agent + app.kubernetes.io/instance: tracetest-agent + template: + metadata: + labels: + app.kubernetes.io/name: tracetest-agent + app.kubernetes.io/instance: tracetest-agent + spec: + containers: + - name: agent + image: "kubeshop/tracetest-agent:latest" + imagePullPolicy: Always + args: [ + "--environment", + "", # Add your env id + "--api-key", + "$TRACETEST_API_KEY", + "--server-url", + "https://app.tracetest.io", + "--mode='verbose'", + ] + env: + - name: TRACETEST_API_KEY + value: "" # Add your API key From 7999587a8ef5735bfed4cd2740e3269562bb8e9e Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Tue, 27 Aug 2024 15:00:40 +0200 Subject: [PATCH 5/9] simplify manifests --- k8s/api-service.yaml | 16 --- k8s/{api-deployment.yaml => api.yaml} | 21 +++- k8s/cache-service.yaml | 16 --- k8s/{cache-deployment.yaml => cache.yaml} | 24 +++- k8s/db-persistent-volume-claim.yaml | 13 --- k8s/db-persistent-volume.yaml | 15 --- k8s/db-service.yaml | 16 --- k8s/{db-deployment.yaml => db.yaml} | 58 +++++++++- k8s/jaeger-service.yaml | 25 ---- k8s/{jaeger-deployment.yaml => jaeger.yaml} | 33 +++++- k8s/otel-collector-cm0-configmap.yaml | 43 ------- k8s/otel-collector-deployment.yaml | 55 --------- k8s/otel-collector-service.yaml | 25 ---- k8s/otel-collector.yaml | 119 ++++++++++++++++++++ k8s/queue-service.yaml | 19 ---- k8s/{queue-deployment.yaml => queue.yaml} | 27 ++++- k8s/rpc-service.yaml | 16 --- k8s/{rpc-deployment.yaml => rpc.yaml} | 26 +++-- k8s/{worker-deployment.yaml => worker.yaml} | 8 +- 19 files changed, 276 insertions(+), 299 deletions(-) delete mode 100644 k8s/api-service.yaml rename k8s/{api-deployment.yaml => api.yaml} (84%) delete mode 100644 k8s/cache-service.yaml rename k8s/{cache-deployment.yaml => cache.yaml} (72%) delete mode 100644 k8s/db-persistent-volume-claim.yaml delete mode 100644 k8s/db-persistent-volume.yaml delete mode 100644 k8s/db-service.yaml rename k8s/{db-deployment.yaml => db.yaml} (52%) delete mode 100644 k8s/jaeger-service.yaml rename k8s/{jaeger-deployment.yaml => jaeger.yaml} (71%) delete mode 100644 k8s/otel-collector-cm0-configmap.yaml delete mode 100644 k8s/otel-collector-deployment.yaml delete mode 100644 k8s/otel-collector-service.yaml create mode 100644 k8s/otel-collector.yaml delete mode 100644 k8s/queue-service.yaml rename k8s/{queue-deployment.yaml => queue.yaml} (70%) delete mode 100644 k8s/rpc-service.yaml rename k8s/{rpc-deployment.yaml => rpc.yaml} (81%) rename k8s/{worker-deployment.yaml => worker.yaml} (80%) diff --git a/k8s/api-service.yaml b/k8s/api-service.yaml deleted file mode 100644 index 140ab3b..0000000 --- a/k8s/api-service.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: api - name: api -spec: - ports: - - name: "8081" - port: 8081 - targetPort: 8081 - selector: - io.kompose.service: api diff --git a/k8s/api-deployment.yaml b/k8s/api.yaml similarity index 84% rename from k8s/api-deployment.yaml rename to k8s/api.yaml index ed5460d..1f34f8c 100644 --- a/k8s/api-deployment.yaml +++ b/k8s/api.yaml @@ -1,9 +1,8 @@ +# Deployment +--- apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: api name: api @@ -48,3 +47,19 @@ spec: - containerPort: 8081 protocol: TCP restartPolicy: Always + +# Service +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: api + name: api +spec: + ports: + - name: "8081" + port: 8081 + targetPort: 8081 + selector: + io.kompose.service: api diff --git a/k8s/cache-service.yaml b/k8s/cache-service.yaml deleted file mode 100644 index 997aff6..0000000 --- a/k8s/cache-service.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: cache - name: cache -spec: - ports: - - name: "6379" - port: 6379 - targetPort: 6379 - selector: - io.kompose.service: cache diff --git a/k8s/cache-deployment.yaml b/k8s/cache.yaml similarity index 72% rename from k8s/cache-deployment.yaml rename to k8s/cache.yaml index 1712362..563703d 100644 --- a/k8s/cache-deployment.yaml +++ b/k8s/cache.yaml @@ -1,9 +1,8 @@ +# Deployment +--- apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: cache name: cache @@ -14,9 +13,6 @@ spec: io.kompose.service: cache template: metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: cache spec: @@ -35,3 +31,19 @@ spec: - containerPort: 6379 protocol: TCP restartPolicy: Always + +# Service +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: cache + name: cache +spec: + ports: + - name: "6379" + port: 6379 + targetPort: 6379 + selector: + io.kompose.service: cache diff --git a/k8s/db-persistent-volume-claim.yaml b/k8s/db-persistent-volume-claim.yaml deleted file mode 100644 index 3eac9d6..0000000 --- a/k8s/db-persistent-volume-claim.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: db-volume-claim - labels: - io.kompose.service: db -spec: - storageClassName: manual - accessModes: - - ReadWriteMany - resources: - requests: - storage: 10Gi diff --git a/k8s/db-persistent-volume.yaml b/k8s/db-persistent-volume.yaml deleted file mode 100644 index e02d217..0000000 --- a/k8s/db-persistent-volume.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: db-volume - labels: - type: local - io.kompose.service: db -spec: - storageClassName: manual - capacity: - storage: 10Gi - accessModes: - - ReadWriteMany - hostPath: - path: /data/postgresql diff --git a/k8s/db-service.yaml b/k8s/db-service.yaml deleted file mode 100644 index fbbfa1f..0000000 --- a/k8s/db-service.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: db - name: db -spec: - ports: - - name: "5432" - port: 5432 - targetPort: 5432 - selector: - io.kompose.service: db diff --git a/k8s/db-deployment.yaml b/k8s/db.yaml similarity index 52% rename from k8s/db-deployment.yaml rename to k8s/db.yaml index 11e0d71..e8d08b2 100644 --- a/k8s/db-deployment.yaml +++ b/k8s/db.yaml @@ -1,9 +1,8 @@ +# Deployment +--- apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: db name: db @@ -14,9 +13,6 @@ spec: io.kompose.service: db template: metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: db spec: @@ -41,3 +37,53 @@ spec: persistentVolumeClaim: claimName: db-volume-claim restartPolicy: Always + +# Service +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: db + name: db +spec: + ports: + - name: "5432" + port: 5432 + targetPort: 5432 + selector: + io.kompose.service: db + +# Persistent Volume +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: db-volume + labels: + type: local + io.kompose.service: db +spec: + storageClassName: manual + capacity: + storage: 10Gi + accessModes: + - ReadWriteMany + hostPath: + path: /data/postgresql + +# Persistent Volume Claim +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: db-volume-claim + labels: + io.kompose.service: db +spec: + storageClassName: manual + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10Gi diff --git a/k8s/jaeger-service.yaml b/k8s/jaeger-service.yaml deleted file mode 100644 index 7a81880..0000000 --- a/k8s/jaeger-service.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: jaeger - name: jaeger -spec: - ports: - - name: "4317" - port: 4317 - targetPort: 4317 - - name: "14250" - port: 14250 - targetPort: 14250 - - name: "16685" - port: 16685 - targetPort: 16685 - - name: "16686" - port: 16686 - targetPort: 16686 - selector: - io.kompose.service: jaeger diff --git a/k8s/jaeger-deployment.yaml b/k8s/jaeger.yaml similarity index 71% rename from k8s/jaeger-deployment.yaml rename to k8s/jaeger.yaml index 6dea5cb..6d3d840 100644 --- a/k8s/jaeger-deployment.yaml +++ b/k8s/jaeger.yaml @@ -1,9 +1,8 @@ +# Deployment +--- apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: jaeger name: jaeger @@ -14,9 +13,6 @@ spec: io.kompose.service: jaeger template: metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: jaeger spec: @@ -47,3 +43,28 @@ spec: - containerPort: 16686 protocol: TCP restartPolicy: Always + +# Service +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: jaeger + name: jaeger +spec: + ports: + - name: "4317" + port: 4317 + targetPort: 4317 + - name: "14250" + port: 14250 + targetPort: 14250 + - name: "16685" + port: 16685 + targetPort: 16685 + - name: "16686" + port: 16686 + targetPort: 16686 + selector: + io.kompose.service: jaeger diff --git a/k8s/otel-collector-cm0-configmap.yaml b/k8s/otel-collector-cm0-configmap.yaml deleted file mode 100644 index 6dfb2a4..0000000 --- a/k8s/otel-collector-cm0-configmap.yaml +++ /dev/null @@ -1,43 +0,0 @@ -apiVersion: v1 -data: - collector.config.yaml: | - receivers: - otlp: - protocols: - grpc: - endpoint: 0.0.0.0:4317 - http: - endpoint: 0.0.0.0:4318 - - processors: - batch: - - exporters: - logging: - loglevel: debug - otlp/jaeger: - endpoint: ${JAEGER_ENDPOINT} - tls: - insecure: true - otlp/tracetest: - endpoint: ${TRACETEST_AGENT_ENDPOINT} - tls: - insecure: true - - service: - pipelines: - traces/jaeger: - receivers: [otlp] - processors: [] - exporters: [logging, otlp/jaeger] - traces/tracetest: - receivers: [otlp] - processors: [batch] - exporters: [otlp/tracetest] -kind: ConfigMap -metadata: - annotations: - use-subpath: "true" - labels: - io.kompose.service: otel-collector - name: otel-collector-cm0 diff --git a/k8s/otel-collector-deployment.yaml b/k8s/otel-collector-deployment.yaml deleted file mode 100644 index 9982a91..0000000 --- a/k8s/otel-collector-deployment.yaml +++ /dev/null @@ -1,55 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: otel-collector - name: otel-collector -spec: - replicas: 1 - selector: - matchLabels: - io.kompose.service: otel-collector - strategy: - type: Recreate - template: - metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: otel-collector - spec: - containers: - - args: - - --config - - /config/otel-local-config.yaml - env: - - name: JAEGER_ENDPOINT - value: jaeger.default.svc.cluster.local:4317 - - name: TRACETEST_AGENT_ENDPOINT - value: tracetest-agent.default.svc.cluster.local:4317 - image: otel/opentelemetry-collector-contrib:0.107.0 #0.59.0 - name: otel-collector - ports: - - containerPort: 55679 - protocol: TCP - - containerPort: 8888 - protocol: TCP - - containerPort: 4317 - protocol: TCP - - containerPort: 4318 - protocol: TCP - volumeMounts: - - mountPath: /config - name: otel-collector-cm0 - restartPolicy: Always - volumes: - - configMap: - items: - - key: collector.config.yaml - path: otel-local-config.yaml - name: otel-collector-cm0 - name: otel-collector-cm0 diff --git a/k8s/otel-collector-service.yaml b/k8s/otel-collector-service.yaml deleted file mode 100644 index 4a0e098..0000000 --- a/k8s/otel-collector-service.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: otel-collector - name: otel-collector -spec: - ports: - - name: "55679" - port: 55679 - targetPort: 55679 - - name: "8888" - port: 8888 - targetPort: 8888 - - name: "4317" - port: 4317 - targetPort: 4317 - - name: "4318" - port: 4318 - targetPort: 4318 - selector: - io.kompose.service: otel-collector diff --git a/k8s/otel-collector.yaml b/k8s/otel-collector.yaml new file mode 100644 index 0000000..1e2c460 --- /dev/null +++ b/k8s/otel-collector.yaml @@ -0,0 +1,119 @@ +# Deployment +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + io.kompose.service: otel-collector + name: otel-collector +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: otel-collector + strategy: + type: Recreate + template: + metadata: + labels: + io.kompose.service: otel-collector + spec: + containers: + - args: + - --config + - /config/otel-local-config.yaml + env: + - name: JAEGER_ENDPOINT + value: jaeger.default.svc.cluster.local:4317 + - name: TRACETEST_AGENT_ENDPOINT + value: tracetest-agent.default.svc.cluster.local:4317 + image: otel/opentelemetry-collector-contrib:0.107.0 + name: otel-collector + ports: + - containerPort: 55679 + protocol: TCP + - containerPort: 8888 + protocol: TCP + - containerPort: 4317 + protocol: TCP + - containerPort: 4318 + protocol: TCP + volumeMounts: + - mountPath: /config + name: otel-collector-cm0 + restartPolicy: Always + volumes: + - configMap: + items: + - key: collector.config.yaml + path: otel-local-config.yaml + name: otel-collector-cm0 + name: otel-collector-cm0 + +# Service +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: otel-collector + name: otel-collector +spec: + ports: + - name: "55679" + port: 55679 + targetPort: 55679 + - name: "8888" + port: 8888 + targetPort: 8888 + - name: "4317" + port: 4317 + targetPort: 4317 + - name: "4318" + port: 4318 + targetPort: 4318 + selector: + io.kompose.service: otel-collector + +# ConfigMap +--- +apiVersion: v1 +data: + collector.config.yaml: | + receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 + processors: + batch: + exporters: + logging: + loglevel: debug + otlp/jaeger: + endpoint: ${JAEGER_ENDPOINT} + tls: + insecure: true + otlp/tracetest: + endpoint: ${TRACETEST_AGENT_ENDPOINT} + tls: + insecure: true + service: + pipelines: + traces/jaeger: + receivers: [otlp] + processors: [] + exporters: [logging, otlp/jaeger] + traces/tracetest: + receivers: [otlp] + processors: [batch] + exporters: [otlp/tracetest] +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: otel-collector + name: otel-collector-cm0 diff --git a/k8s/queue-service.yaml b/k8s/queue-service.yaml deleted file mode 100644 index 8e0f489..0000000 --- a/k8s/queue-service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: queue - name: queue -spec: - ports: - - name: "5672" - port: 5672 - targetPort: 5672 - - name: "15672" - port: 15672 - targetPort: 15672 - selector: - io.kompose.service: queue diff --git a/k8s/queue-deployment.yaml b/k8s/queue.yaml similarity index 70% rename from k8s/queue-deployment.yaml rename to k8s/queue.yaml index 338b958..535111b 100644 --- a/k8s/queue-deployment.yaml +++ b/k8s/queue.yaml @@ -1,9 +1,8 @@ +# Deployment +--- apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: queue name: queue @@ -14,9 +13,6 @@ spec: io.kompose.service: queue template: metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: queue spec: @@ -36,3 +32,22 @@ spec: - containerPort: 15672 protocol: TCP restartPolicy: Always + +# Service +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: queue + name: queue +spec: + ports: + - name: "5672" + port: 5672 + targetPort: 5672 + - name: "15672" + port: 15672 + targetPort: 15672 + selector: + io.kompose.service: queue diff --git a/k8s/rpc-service.yaml b/k8s/rpc-service.yaml deleted file mode 100644 index 60e306b..0000000 --- a/k8s/rpc-service.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) - labels: - io.kompose.service: rpc - name: rpc -spec: - ports: - - name: "8082" - port: 8082 - targetPort: 8082 - selector: - io.kompose.service: rpc diff --git a/k8s/rpc-deployment.yaml b/k8s/rpc.yaml similarity index 81% rename from k8s/rpc-deployment.yaml rename to k8s/rpc.yaml index 2a4ad22..13cb947 100644 --- a/k8s/rpc-deployment.yaml +++ b/k8s/rpc.yaml @@ -1,9 +1,8 @@ +# Deployment +--- apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: rpc name: rpc @@ -14,9 +13,6 @@ spec: io.kompose.service: rpc template: metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: rpc spec: @@ -41,7 +37,7 @@ spec: command: - wget - --spider - - localhost:8081/pokemon/healthcheck + - 0.0.0.0:8081/pokemon/healthcheck failureThreshold: 60 periodSeconds: 1 timeoutSeconds: 3 @@ -50,3 +46,19 @@ spec: - containerPort: 8082 protocol: TCP restartPolicy: Always + +# Service +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: rpc + name: rpc +spec: + ports: + - name: "8082" + port: 8082 + targetPort: 8082 + selector: + io.kompose.service: rpc diff --git a/k8s/worker-deployment.yaml b/k8s/worker.yaml similarity index 80% rename from k8s/worker-deployment.yaml rename to k8s/worker.yaml index 1902b4e..a600a69 100644 --- a/k8s/worker-deployment.yaml +++ b/k8s/worker.yaml @@ -1,9 +1,8 @@ +# Deployment +--- apiVersion: apps/v1 kind: Deployment metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: worker name: worker @@ -14,9 +13,6 @@ spec: io.kompose.service: worker template: metadata: - annotations: - kompose.cmd: kompose convert -f docker-compose.yaml - kompose.version: 1.34.0 (HEAD) labels: io.kompose.service: worker spec: From 10e5d6fe5c84160877972f2620c92772a332850d Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Tue, 27 Aug 2024 15:02:51 +0200 Subject: [PATCH 6/9] add readme --- k8s/readme.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 k8s/readme.md diff --git a/k8s/readme.md b/k8s/readme.md new file mode 100644 index 0000000..f496c16 --- /dev/null +++ b/k8s/readme.md @@ -0,0 +1,9 @@ +# Install Pokeshop with K8s Manifests + +1. [Get your Tracetest API key and env id](https://app.tracetest.io/retrieve-token) +2. Add your API key and env id in the `tracetest-agent.yaml` +3. Apply all resources + + ```bash + kubectl apply -f . + ``` From a659ef4bfa5b2b23c1a4b38bffa1453e9f60481f Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Tue, 27 Aug 2024 15:08:44 +0200 Subject: [PATCH 7/9] improve readme --- k8s/readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/k8s/readme.md b/k8s/readme.md index f496c16..c20fb20 100644 --- a/k8s/readme.md +++ b/k8s/readme.md @@ -7,3 +7,13 @@ ```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 }` + - **GET** `http://api.default.svc.cluster.local:8081/pokemon` + + ![](https://res.cloudinary.com/djwdcmwdz/image/upload/v1724764008/docs/app.tracetest.io_organizations_ttorg_e66318ba6544b856_environments_ttenv_4b0e8945dbe5045a_test_tTFZ453Ig_run_9_selectedSpan_bb8ba205b42a8619_nylqid.png) + +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) \ No newline at end of file From 11516b798ceff4ba3a8bcfe02eefc6c2ff145741 Mon Sep 17 00:00:00 2001 From: Matheus Nogueira Date: Tue, 27 Aug 2024 18:22:07 -0300 Subject: [PATCH 8/9] add port env --- k8s/rpc.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/k8s/rpc.yaml b/k8s/rpc.yaml index 13cb947..aeebb4e 100644 --- a/k8s/rpc.yaml +++ b/k8s/rpc.yaml @@ -30,6 +30,8 @@ spec: value: guest:guest@queue - name: REDIS_URL value: cache + - name: RPC_PORT + value: "8082" image: kubeshop/demo-pokemon-api:latest imagePullPolicy: Always livenessProbe: From c5cbd6aa5349efa5cf26147a02c9d33a636eed43 Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Wed, 28 Aug 2024 13:49:25 +0200 Subject: [PATCH 9/9] delete kompose file --- docker-compose-kompose.yaml | 153 ------------------------------------ 1 file changed, 153 deletions(-) delete mode 100644 docker-compose-kompose.yaml diff --git a/docker-compose-kompose.yaml b/docker-compose-kompose.yaml deleted file mode 100644 index ef5bd57..0000000 --- a/docker-compose-kompose.yaml +++ /dev/null @@ -1,153 +0,0 @@ -version: '3.5' -name: pokeshop - -services: - db: - image: postgres:14 - ports: - - 5434:5432 - environment: - POSTGRES_USER: ashketchum - POSTGRES_PASSWORD: squirtle123 - POSTGRES_DB: pokeshop - healthcheck: - test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB'] - interval: 1s - timeout: 5s - retries: 60 - - cache: - image: redis:6 - ports: - - 6379:6379 - healthcheck: - test: ['CMD', 'redis-cli', 'ping'] - interval: 1s - timeout: 3s - retries: 60 - - queue: - image: rabbitmq:3.12 - restart: unless-stopped - ports: - - 5672:5672 - - 15672:15672 - healthcheck: - test: rabbitmq-diagnostics -q check_running - interval: 1s - timeout: 5s - retries: 60 - - jaeger: - image: jaegertracing/all-in-one:latest - ports: - - 14250:14250 - - 16685:16685 - - 16686:16686 - environment: - - COLLECTOR_ZIPKIN_HOST_PORT=:9411 - - COLLECTOR_OTLP_ENABLED=true - healthcheck: - test: ['CMD', 'wget', '--spider', 'localhost:16686'] - interval: 1s - timeout: 3s - retries: 60 - - otel-collector: - image: otel/opentelemetry-collector-contrib:0.59.0 - restart: unless-stopped - extra_hosts: - - 'host.docker.internal:host-gateway' - ports: - - 55679:55679 - - 8888:8888 - - 4317:4317 - - 4318:4318 - command: - - '--config' - - '/otel-local-config.yaml' - volumes: - - ./collector.config.yaml:/otel-local-config.yaml - environment: - - JAEGER_ENDPOINT=jaeger:14250 - depends_on: - jaeger: - condition: service_healthy - - api: - build: . - environment: - REDIS_URL: cache - DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public - RABBITMQ_HOST: queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - ZIPKIN_URL: http://localhost:9411 - healthcheck: - test: ['CMD', 'wget', '--spider', 'localhost:8081/pokemon/healthcheck'] - interval: 1s - timeout: 3s - retries: 60 - ports: - - 8081:8081 - depends_on: - db: - condition: service_healthy - cache: - condition: service_healthy - queue: - condition: service_healthy - jaeger: - condition: service_healthy - otel-collector: - condition: service_started - rpc: - build: . - environment: - REDIS_URL: cache - DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public - RABBITMQ_HOST: queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - ZIPKIN_URL: http://localhost:9411 - NPM_RUN_COMMAND: rpc - healthcheck: - test: ['CMD', 'wget', '--spider', 'localhost:8081/pokemon/healthcheck'] - interval: 1s - timeout: 3s - retries: 60 - ports: - - 8082:8082 - depends_on: - db: - condition: service_healthy - cache: - condition: service_healthy - queue: - condition: service_healthy - jaeger: - condition: service_healthy - otel-collector: - condition: service_started - - worker: - build: . - environment: - REDIS_URL: cache - DATABASE_URL: postgresql://ashketchum:squirtle123@db:5432/pokeshop?schema=public - RABBITMQ_HOST: queue - POKE_API_BASE_URL: https://pokeapi.co/api/v2 - COLLECTOR_ENDPOINT: http://otel-collector:4317 - ZIPKIN_URL: http://localhost:9411 - NPM_RUN_COMMAND: worker - depends_on: - db: - condition: service_healthy - cache: - condition: service_healthy - queue: - condition: service_healthy - jaeger: - condition: service_healthy - otel-collector: - condition: service_started