Skip to content

Commit

Permalink
add kafka and header propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
aviramha committed Jul 17, 2023
1 parent 53dbc39 commit d831e7f
Show file tree
Hide file tree
Showing 17 changed files with 1,044 additions and 51 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build-ip-visit-consumer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release ip visit consumer
on:
push:
branches: [main]
workflow_dispatch:

jobs:
image:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
file: ip-visit-consumer/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
context: ip-visit-consumer/
push: true
tags: |
ghcr.io/metalbear-co/playground-ip-visit-consumer:latest
7 changes: 7 additions & 0 deletions certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: networking.gke.io/v1
kind: ManagedCertificate
metadata:
name: playground-metalbear-dev-cert
spec:
domains:
- playground.metalbear.dev
25 changes: 25 additions & 0 deletions ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: playground-metalbear-dev-ingress
annotations:
networking.gke.io/managed-certificates: playground-metalbear-dev-cert
kubernetes.io/ingress.class: "gce"
spec:
rules:
- http:
paths:
- path: /count
pathType: Prefix
backend:
service:
name: ip-visit-counter
port:
number: 80
- path: /health
pathType: Prefix
backend:
service:
name: ip-visit-counter
port:
number: 80
15 changes: 15 additions & 0 deletions ip-visit-consumer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM --platform=$BUILDPLATFORM golang:1.20-alpine as build-env

WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY *.go ./

RUN GOARCH=$TARGETARCH go build -o /main

FROM gcr.io/distroless/static-debian11

COPY --from=build-env /main /main

CMD [ "/main" ]
3 changes: 3 additions & 0 deletions ip-visit-consumer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## ip-visit-consumer

Simple service that reads ip messages from kafka topic and prints it.
47 changes: 47 additions & 0 deletions ip-visit-consumer/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
name: ip-visit-consumer
spec:
selector:
matchLabels:
app: "ip-visit-consumer"
replicas: 1
template:
metadata:
labels:
app: ip-visit-consumer
spec:
containers:
- name: main
image: ghcr.io/metalbear-co/playground-ip-visit-consumer:latest
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 200m
memory: 200Mi
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /health
port: 80
initialDelaySeconds: 3
periodSeconds: 3
readinessProbe:
httpGet:
path: /health
port: 80
initialDelaySeconds: 3
periodSeconds: 3
env:
- name: PORT
value: "80"
- name: KAFKAADDRESS
value: "kafka:9092"
- name: KAFKATOPIC
value: "ip-visit"
- name: KAFKACONSUMERGROUP
value: "ip-visit-consumer"
50 changes: 50 additions & 0 deletions ip-visit-consumer/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module example/ip-visit-consumer

go 1.20

require (
github.com/gin-gonic/gin v1.9.0
github.com/redis/go-redis/v9 v9.0.2
github.com/spf13/viper v1.15.0
)

require (
github.com/bytedance/sonic v1.8.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/segmentio/kafka-go v0.4.42 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit d831e7f

Please sign in to comment.