From 86c9374cea2160716e59708891a42a112b772dd4 Mon Sep 17 00:00:00 2001 From: cahe Date: Tue, 20 Feb 2024 16:07:16 -0300 Subject: [PATCH] feat: python app --- kustomize/mycrd.yaml | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/kustomize/mycrd.yaml b/kustomize/mycrd.yaml index ad9b5b3..8a61ca8 100644 --- a/kustomize/mycrd.yaml +++ b/kustomize/mycrd.yaml @@ -24,3 +24,61 @@ spec: requests: cpu: 100m memory: 200Mi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: python-deployment +spec: + selector: + matchLabels: + app: python-deployment + template: + metadata: + labels: + app: python-deployment + spec: + containers: + - name: app + args: + - '/bin/python3' + - '/app/app.py' + livenessProbe: + httpGet: + path: / + port: 8000 + image: python:3 + ports: + - containerPort: 8000 + volumeMounts: + - name: app-script-volume + mountPath: "/app" + readOnly: true + volumes: + - name: app-script-volume + configMap: + name: app-script-config +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: app-script-config +data: + app.py: | + #! /bin/python3 + from http.server import BaseHTTPRequestHandler + from time import sleep + + class GetHandler(BaseHTTPRequestHandler): + def do_GET(self): + sleep(60) + x = self.wfile.write + self.send_response(200) + self.send_header("Content-type", "text/html") + self.end_headers() + + if __name__ == '__main__': + from http.server import HTTPServer + server = HTTPServer(('', 8000), GetHandler) + print('Starting server, use to stop') + server.serve_forever()