-
Notifications
You must be signed in to change notification settings - Fork 8
/
simple-application.yaml
74 lines (67 loc) · 1.64 KB
/
simple-application.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
apiVersion: v1
kind: ConfigMap
metadata:
name: komodor-python-script
data:
python-script: |-
import time
import os
import sys
import logging
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
exit_code = int(os.getenv('EXIT_CODE')) if os.getenv('EXIT_CODE') else 0
def start_service():
initialize_connections()
def initialize_connections():
fetch_configuration()
def fetch_configuration():
create_connection()
def create_connection():
conn_auth()
def conn_auth():
if exit_code == 0:
logging.info("connection established")
else:
raise Exception("Can't perform the requested task - authentication error")
time.sleep(10)
start_service()
while True:
logging.info("service loop")
time.sleep(10)
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
app: komo-application-error
labels:
app: komo-application-error
name: komo-application-error
spec:
replicas: 1
selector:
matchLabels:
app: komo-application-error
template:
metadata:
labels:
app: komo-application-error
spec:
containers:
- env:
- name: LOG_LEVEL
value: "INFO"
- name: EXIT_CODE
value: "0"
image: python:3.11-alpine
name: python
command: ["python"]
args: ["/usr/share/app/code.py"]
volumeMounts:
- name: komodor-python-script
mountPath: /usr/share/app/code.py
subPath: python-script
volumes:
- name: komodor-python-script
configMap:
name: komodor-python-script