Skip to content

Commit

Permalink
minikube-skaffold-helm manifest working example
Browse files Browse the repository at this point in the history
  • Loading branch information
shsma committed Aug 11, 2023
1 parent fd482d8 commit 45185f0
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 3 deletions.
97 changes: 97 additions & 0 deletions helm/go-kafka.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
apiVersion: v1
kind: Namespace
metadata:
name: go-kafka
---
apiVersion: v1
kind: ConfigMap
metadata:
name: go-kafka-config
namespace: go-kafka
data:
server.properties: |
broker.id=0
listeners=PLAINTEXT://:9092
log.dirs=/var/lib/go-kafka/data
auto.create.topics.enable=false
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: go-kafka
namespace: go-kafka
spec:
selector:
matchLabels:
app: go-kafka
serviceName: go-kafka-headless
replicas: 1
template:
metadata:
labels:
app: go-kafka
spec:
containers:
- name: go-kafka
image: confluentinc/cp-kafka:latest
ports:
- containerPort: 9092
env:
- name: KAFKA_BROKER_ID
value: "1"
- name: KAFKA_AUTO_CREATE_TOPICS_ENABLE
value: "true"
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
value: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
value: "1"
- name: KAFKA_TRANSACTION_STATE_LOG_MIN_ISR
value: "1"
- name: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
value: "1"
- name: KAFKA_ZOOKEEPER_CONNECT
value: zookeeper:2181
- name: KAFKA_ADVERTISED_LISTENERS
value: "PLAINTEXT://go-kafka:9092,PLAINTEXT_HOST://localhost:19092"

volumeMounts:
- name: go-kafka-data
mountPath: /var/lib/go-kafka/data
volumeClaimTemplates:
- metadata:
name: go-kafka-data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: standard
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: Service
metadata:
name: go-kafka
namespace: go-kafka
spec:
type: NodePort
ports:
- name: go-kafka
port: 9092
targetPort: 9092
selector:
app: go-kafka
---
apiVersion: v1
kind: Service
metadata:
name: go-kafka-headless
namespace: go-kafka
spec:
clusterIP: None
ports:
- name: go-kafka
port: 9092
targetPort: 9092
selector:
app: go-kafka

40 changes: 40 additions & 0 deletions helm/zookeeper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: v1
kind: Service
metadata:
name: zookeeper
namespace: go-kafka
spec:
selector:
app: zookeeper
ports:
- protocol: TCP
port: 2181
targetPort: 2181
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: zookeeper
namespace: go-kafka
spec:
serviceName: zookeeper
replicas: 1
selector:
matchLabels:
app: zookeeper
template:
metadata:
labels:
app: zookeeper
spec:
containers:
- name: zookeeper
image: confluentinc/cp-zookeeper:6.2.0
ports:
- containerPort: 2181
env:
- name: ZOOKEEPER_CLIENT_PORT
value: "2181"
- name: ZOOKEEPER_TICK_TIME
value: "2000"

2 changes: 1 addition & 1 deletion internal/broker/producer/order_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type OrderProducer struct {

func NewOrderProducer(topic string) *OrderProducer {
p, err := kafka.NewProducer(&kafka.ConfigMap{
"bootstrap.servers": "127.0.0.1:9092",
"bootstrap.servers": "0.0.0.0:9092",
"client.id": "goapp-consumer",
"acks": "all",
})
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func main() {
if err != nil {
log.Fatalf("failed to produce: %v", err)
}
time.Sleep(3 * time.Second)
time.Sleep(time.Second * 3)
}

}
23 changes: 23 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: skaffold/v2beta28
kind: Config
metadata:
name: go-kafka-zookeeper
build:
artifacts: []
deploy:
kubectl:
manifests:
- helm/go-kafka.yaml
- helm/zookeeper.yaml

portForward:
- resourceType: service
resourceName: go-kafka
namespace: go-kafka
port: 9092
localPort: 9092
- resourceType: service
resourceName: zookeeper
namespace: go-kafka
port: 2181
localPort: 2181

0 comments on commit 45185f0

Please sign in to comment.