-
Notifications
You must be signed in to change notification settings - Fork 1
/
myapi-kubernetes.yaml
177 lines (170 loc) · 3.63 KB
/
myapi-kubernetes.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
apiVersion: v1
kind: ConfigMap
metadata:
name: myapi-config
data:
application.properties: |-
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
kafka.bootstrap-servers=kafka-service:9092
---
apiVersion: v1
kind: Secret
metadata:
name: myapi-secrets
type: Opaque
data:
username: cG9zdGdyZXM=
password: cG9zdGdyZXM=
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: zookeeper
spec:
replicas: 2
selector:
matchLabels:
app: zookeeper
template:
metadata:
labels:
app: zookeeper
spec:
containers:
- name: zookeeper
image: docker.io/bitnami/zookeeper:3.9
ports:
- containerPort: 2181
volumeMounts:
- name: zookeeper-data
mountPath: /bitnami
env:
- name: ALLOW_ANONYMOUS_LOGIN
value: "yes"
volumes:
- name: zookeeper-data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: zookeeper-service
spec:
ports:
- port: 2181
targetPort: 2181
selector:
app: zookeeper
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kafka
spec:
replicas: 2
selector:
matchLabels:
app: kafka
template:
metadata:
labels:
app: kafka
spec:
containers:
- name: kafka
image: docker.io/bitnami/kafka:3.4
ports:
- containerPort: 9092
volumeMounts:
- name: kafka-data
mountPath: /bitnami
env:
- name: KAFKA_CFG_ZOOKEEPER_CONNECT
value: zookeeper-service:2181
- name: KAFKA_ADVERTISED_LISTENERS
value: PLAINTEXT://kafka-service:9092
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
value: PLAINTEXT:PLAINTEXT
- name: KAFKA_INTER_BROKER_LISTENER_NAME
value: PLAINTEXT
volumes:
- name: kafka-data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: kafka-service
spec:
ports:
- port: 9092
targetPort: 9092
selector:
app: kafka
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapi-deployment
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # Defines the maximum number of pods that can be created over the desired number of pods.
maxUnavailable: 1 # Defines the maximum number of pods that can be unavailable during the update.
selector:
matchLabels:
app: myapi
template:
metadata:
labels:
app: myapi
spec:
containers:
- name: myapi
image: sherifs82/myapi:v1
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: myapi-config
env:
- name: SPRING_DATASOURCE_URL
value: jdbc:postgresql://db-service:5432/postgres
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
name: myapi-secrets
key: username
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: myapi-secrets
key: password
---
apiVersion: v1
kind: Service
metadata:
name: myapi-service
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: 8080
selector:
app: myapi
---
apiVersion: v1
kind: Service
metadata:
name: myapi-service
spec:
type: LoadBalancer
ports:
- port: 8080
targetPort: 8080
selector:
app: myapi