brusnika-stage: support plaintext Kafka in premises via ConfigMap
This commit is contained in:
parent
e46f0b060c
commit
c277aca334
@ -12,6 +12,8 @@ spec:
|
||||
metadata:
|
||||
labels:
|
||||
app: premises-backend
|
||||
annotations:
|
||||
checksum/kafka-compat: 2d571098fc185256dca02661d95be6f560dac96c96a1d7e2881bd687e5c90ca9
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
@ -22,6 +24,17 @@ spec:
|
||||
- sh
|
||||
- -ec
|
||||
- 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:
|
||||
- name: backend
|
||||
image: cr.yandex/crp3ccidau046kdj8g9q/premises-backend:production_216148a9
|
||||
@ -100,8 +113,19 @@ spec:
|
||||
port: http
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 30
|
||||
volumeMounts:
|
||||
- name: patched-code
|
||||
mountPath: /premises/src/app/api.py
|
||||
subPath: api.py
|
||||
readOnly: true
|
||||
tolerations:
|
||||
- key: dedicated
|
||||
operator: Equal
|
||||
value: processing-light
|
||||
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
|
||||
- service.yaml
|
||||
- postgresql.yaml
|
||||
- kafka-compat-configmap.yaml
|
||||
|
||||
Loading…
Reference in New Issue
Block a user