brusnika-stage: support plaintext Kafka in premises via ConfigMap
This commit is contained in:
parent
e46f0b060c
commit
c277aca334
@ -12,6 +12,8 @@ spec:
|
|||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: premises-backend
|
app: premises-backend
|
||||||
|
annotations:
|
||||||
|
checksum/kafka-compat: 2d571098fc185256dca02661d95be6f560dac96c96a1d7e2881bd687e5c90ca9
|
||||||
spec:
|
spec:
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: regcred
|
- name: regcred
|
||||||
@ -22,6 +24,17 @@ spec:
|
|||||||
- sh
|
- sh
|
||||||
- -ec
|
- -ec
|
||||||
- until pg_isready -h postgres -p 5432; do sleep 2; done
|
- until pg_isready -h postgres -p 5432; do sleep 2; done
|
||||||
|
- name: prepare-kafka-compat
|
||||||
|
image: cr.yandex/crp3ccidau046kdj8g9q/premises-backend:production_216148a9
|
||||||
|
command:
|
||||||
|
- python
|
||||||
|
- /compat/patch.py
|
||||||
|
volumeMounts:
|
||||||
|
- name: kafka-compat
|
||||||
|
mountPath: /compat
|
||||||
|
readOnly: true
|
||||||
|
- name: patched-code
|
||||||
|
mountPath: /patched
|
||||||
containers:
|
containers:
|
||||||
- name: backend
|
- name: backend
|
||||||
image: cr.yandex/crp3ccidau046kdj8g9q/premises-backend:production_216148a9
|
image: cr.yandex/crp3ccidau046kdj8g9q/premises-backend:production_216148a9
|
||||||
@ -100,8 +113,19 @@ spec:
|
|||||||
port: http
|
port: http
|
||||||
initialDelaySeconds: 60
|
initialDelaySeconds: 60
|
||||||
periodSeconds: 30
|
periodSeconds: 30
|
||||||
|
volumeMounts:
|
||||||
|
- name: patched-code
|
||||||
|
mountPath: /premises/src/app/api.py
|
||||||
|
subPath: api.py
|
||||||
|
readOnly: true
|
||||||
tolerations:
|
tolerations:
|
||||||
- key: dedicated
|
- key: dedicated
|
||||||
operator: Equal
|
operator: Equal
|
||||||
value: processing-light
|
value: processing-light
|
||||||
effect: NoSchedule
|
effect: NoSchedule
|
||||||
|
volumes:
|
||||||
|
- name: kafka-compat
|
||||||
|
configMap:
|
||||||
|
name: premises-kafka-compat
|
||||||
|
- name: patched-code
|
||||||
|
emptyDir: {}
|
||||||
|
|||||||
17
apps/premises/brusnika-stage/kafka-compat-configmap.yaml
Normal file
17
apps/premises/brusnika-stage/kafka-compat-configmap.yaml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: premises-kafka-compat
|
||||||
|
namespace: premises
|
||||||
|
data:
|
||||||
|
patch.py: |
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
source = Path("/premises/src/app/api.py").read_text()
|
||||||
|
old = " else:\n security = SASLScram512("
|
||||||
|
new = " elif config.kafka.username or config.kafka.password:\n security = SASLScram512("
|
||||||
|
if source.count(old) != 1:
|
||||||
|
raise RuntimeError("Unexpected Kafka security configuration in premises image")
|
||||||
|
patched = source.replace(old, new, 1)
|
||||||
|
compile(patched, "api.py", "exec")
|
||||||
|
Path("/patched/api.py").write_text(patched)
|
||||||
@ -5,3 +5,4 @@ resources:
|
|||||||
- backend.yaml
|
- backend.yaml
|
||||||
- service.yaml
|
- service.yaml
|
||||||
- postgresql.yaml
|
- postgresql.yaml
|
||||||
|
- kafka-compat-configmap.yaml
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user