-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kafka & redis
- Loading branch information
Showing
13 changed files
with
488 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: kafdrop | ||
labels: | ||
app: kafdrop | ||
namespace: prod | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: kafdrop | ||
template: | ||
metadata: | ||
labels: | ||
app: kafdrop | ||
spec: | ||
containers: | ||
- name: kafdrop | ||
image: docker.io/obsidiandynamics/kafdrop:3.31.0-SNAPSHOT | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: KAFKA_BROKERCONNECT | ||
value: kafka-service:9092 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kafdrop | ||
labels: | ||
app: kafdrop | ||
namespace: prod | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: kafdrop | ||
ports: | ||
- port: 9000 | ||
targetPort: 9000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: kafka-deployment | ||
namespace: prod | ||
labels: | ||
app: kafka-service | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: kafka-service | ||
minReadySeconds: 10 | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxSurge: 1 | ||
maxUnavailable: 0 | ||
replicas: 1 | ||
template: | ||
metadata: | ||
name: kafka-pod | ||
labels: | ||
app: kafka-service | ||
spec: | ||
containers: | ||
- name: kafka1 | ||
image: confluentinc/cp-kafka | ||
ports: | ||
- containerPort: 9092 | ||
env: | ||
- name: KAFKA_NODE_ID | ||
value: "1" | ||
- name: KAFKA_CONTROLLER_LISTENER_NAMES | ||
value: "CONTROLLER" | ||
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP | ||
value: "CONTROLLER:PLAINTEXT,INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT" | ||
- name: KAFKA_LISTENERS | ||
value: "INTERNAL://localhost:29092,CONTROLLER://localhost:29093,EXTERNAL://0.0.0.0:9092" | ||
- name: KAFKA_ADVERTISED_LISTENERS | ||
value: "INTERNAL://localhost:29092,EXTERNAL://kafka-service:9092" | ||
- name: KAFKA_INTER_BROKER_LISTENER_NAME | ||
value: "INTERNAL" | ||
- name: KAFKA_CONTROLLER_QUORUM_VOTERS | ||
value: "1@localhost:29093" | ||
- name: KAFKA_PROCESS_ROLES | ||
value: "broker,controller" | ||
- name: KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS | ||
value: "0" | ||
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR | ||
value: "1" | ||
- name: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR | ||
value: "1" | ||
- name: CLUSTER_ID | ||
value: "ciWo7IWazngRchmPES6q5A==" | ||
- name: KAFKA_LOG_DIRS | ||
value: "/var/lib/kafka/data" | ||
readinessProbe: | ||
tcpSocket: | ||
port: 9092 | ||
initialDelaySeconds: 30 | ||
periodSeconds: 20 | ||
livenessProbe: | ||
tcpSocket: | ||
port: 9092 | ||
initialDelaySeconds: 30 | ||
periodSeconds: 20 | ||
securityContext: | ||
runAsUser: 0 | ||
runAsGroup: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kafka-service | ||
namespace: prod | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: external | ||
targetPort: 9092 | ||
port: 9092 | ||
- name: external2 | ||
targetPort: 29092 | ||
port: 29092 | ||
- name: controller | ||
targetPort: 29093 | ||
port: 29093 | ||
selector: | ||
app: kafka-service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-accn-service | ||
namespace: prod | ||
labels: | ||
app: redis-accn | ||
spec: | ||
ports: | ||
- port: 6379 | ||
clusterIP: None | ||
selector: | ||
app: redis-accn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: redis-accn-ss | ||
namespace: prod | ||
spec: | ||
serviceName: redis-accn-service | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: redis-accn | ||
template: | ||
metadata: | ||
labels: | ||
app: redis-accn | ||
spec: | ||
initContainers: | ||
- name: init-redis | ||
image: redis:latest | ||
command: | ||
- bash | ||
- "-c" | ||
- | | ||
set -ex | ||
# Generate redis server-id from pod ordinal index. | ||
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1 | ||
ordinal=${BASH_REMATCH[1]} | ||
# Copy appropriate redis config files from config-map to respective directories. | ||
if [[ $ordinal -eq 0 ]]; then | ||
cp /mnt/master.conf /etc/redis-config.conf | ||
else | ||
cp /mnt/slave.conf /etc/redis-config.conf | ||
fi | ||
volumeMounts: | ||
- name: redis-claim | ||
mountPath: /etc | ||
- name: config-map | ||
mountPath: /mnt/ | ||
containers: | ||
- name: redis | ||
image: redis:latest | ||
ports: | ||
- containerPort: 6379 | ||
name: redis-ss | ||
command: | ||
- redis-server | ||
- "/etc/redis-config.conf" | ||
volumeMounts: | ||
- name: redis-data | ||
mountPath: /data | ||
- name: redis-claim | ||
mountPath: /etc | ||
volumes: | ||
- name: config-map | ||
configMap: | ||
name: redis-ss-configuration | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: redis-claim | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
- metadata: | ||
name: redis-data | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: 1Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-auction-service | ||
namespace: prod | ||
labels: | ||
app: redis-auction | ||
spec: | ||
ports: | ||
- port: 6379 | ||
clusterIP: None | ||
selector: | ||
app: redis-auction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: redis-auction-ss | ||
namespace: prod | ||
spec: | ||
serviceName: redis-auction-service | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: redis-auction | ||
template: | ||
metadata: | ||
labels: | ||
app: redis-auction | ||
spec: | ||
initContainers: | ||
- name: init-redis | ||
image: redis:latest | ||
command: | ||
- bash | ||
- "-c" | ||
- | | ||
set -ex | ||
# Generate redis server-id from pod ordinal index. | ||
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1 | ||
ordinal=${BASH_REMATCH[1]} | ||
# Copy appropriate redis config files from config-map to respective directories. | ||
if [[ $ordinal -eq 0 ]]; then | ||
cp /mnt/master.conf /etc/redis-config.conf | ||
else | ||
cp /mnt/slave.conf /etc/redis-config.conf | ||
fi | ||
volumeMounts: | ||
- name: redis-claim | ||
mountPath: /etc | ||
- name: config-map | ||
mountPath: /mnt/ | ||
containers: | ||
- name: redis | ||
image: redis:latest | ||
ports: | ||
- containerPort: 6379 | ||
name: redis-ss | ||
command: | ||
- redis-server | ||
- "/etc/redis-config.conf" | ||
volumeMounts: | ||
- name: redis-data | ||
mountPath: /data | ||
- name: redis-claim | ||
mountPath: /etc | ||
volumes: | ||
- name: config-map | ||
configMap: | ||
name: redis-ss-configuration | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: redis-claim | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
- metadata: | ||
name: redis-data | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: 1Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: redis-ss-configuration | ||
namespace: prod | ||
labels: | ||
app: redis | ||
data: | ||
master.conf: | | ||
requirepass bitroot | ||
maxmemory 400mb | ||
maxmemory-policy allkeys-lru | ||
maxclients 20000 | ||
timeout 300 | ||
appendonly yes | ||
dbfilename dump.rdb | ||
dir /data | ||
slave.conf: | | ||
requirepass bitroot | ||
slaveof redis-ss-0.redis-ss.redis 6379 | ||
maxmemory 400mb | ||
maxmemory-policy allkeys-lru | ||
maxclients 20000 | ||
timeout 300 | ||
dir /data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redis-payment-service | ||
namespace: prod | ||
labels: | ||
app: redis-payment | ||
spec: | ||
ports: | ||
- port: 6379 | ||
clusterIP: None | ||
selector: | ||
app: redis-payment |
Oops, something went wrong.