Skip to content

Commit

Permalink
Merge pull request #10 from metalbear-co/kc2024
Browse files Browse the repository at this point in the history
kustomize++
  • Loading branch information
aviramha authored Nov 3, 2024
2 parents c29b744 + 9053b4f commit 60e2c52
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 20 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build-ip-visit-sqs-consumer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release ip visit sqs 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-sqs-consumer/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
context: ip-visit-sqs-consumer/
push: true
tags: |
ghcr.io/metalbear-co/playground-ip-visit-sqs-consumer:latest
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ip-visit-sqs-consumer/ip-visit-sqs-consumer
ip-visit-sqs-consumer/ip-visit-sqs-consumer
**/.DS_Store
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ To enable SQS:
6. `aws iam create-policy --policy-name SQSPlaygroundPolicy --policy-document file://ip-visit-sqs-consumer/policy.json`
7. `aws iam attach-user-policy --policy-arn arn:aws:iam::526936346962:policy/SQSPlaygroundPolicy --user-name SQSPlayground`
8. Set Region in app.yaml in `ip-visit-counter` and `ip-visit-sqs-consumer`


## Minikube/Local

```
kubectl apply -k ./base/local
```
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion ip-visit-counter/app.yaml → base/ip-visit-counter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ spec:
secretKeyRef:
name: aws-credentials
key: AWS_ACCESS_KEY_ID
optional: true
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: aws-credentials
key: AWS_SECRET_ACCESS_KEY
key: AWS_SECRET_ACCESS_KEY
optional: true
File renamed without changes.
8 changes: 8 additions & 0 deletions base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- kafka.yaml
- redis.yaml
- ip-visit-counter.yaml
- ip-visit-consumer.yaml
- ip-info.yaml
File renamed without changes.
12 changes: 8 additions & 4 deletions ip-visit-counter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ func getCount(c *gin.Context) {
RedisClient.Expire(c, key, RedisKeyTtl)
message, _ := json.Marshal(IpMessage{Ip: ip})

SendSqsMessage(c, message)
if sqsClient != nil {
SendSqsMessage(c, message)
}

err = KafkaWriter.WriteMessages(c, kafka.Message{Value: []byte(message)})
if err != nil {
Expand Down Expand Up @@ -227,10 +229,12 @@ func main() {
}

SetupKafka(config.KafkaAddress, config.KafkaTopic)
err = SetupSqs(config.SqsQueueName)
if config.SqsQueueName != "" {
err = SetupSqs(config.SqsQueueName)

if err != nil {
panic(err)
if err != nil {
panic(err)
}
}

router := gin.Default()
Expand Down
14 changes: 0 additions & 14 deletions kustomization.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions overlays/gke/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ingress.yaml
- certificate.yaml
- secret.yaml
- ip-visit-frontend.yaml
- ip-visit-sqs-consumer.yaml
- sqs-queueregistry.yaml
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions overlays/local/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:
- ../../base
patches:
- path: patch-nodeport.yaml
6 changes: 6 additions & 0 deletions overlays/local/patch-nodeport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Service
metadata:
name: ip-visit-counter
spec:
type: NodePort

0 comments on commit 60e2c52

Please sign in to comment.