Created
August 23, 2023 11:23
-
-
Save ccollicutt/8952af816a77b872b137977b98386e9c to your computer and use it in GitHub Desktop.
Don't build a container image, just mount your app as a configmap!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: hello-world-configmap | |
data: | |
hello.py: | | |
import logging | |
import time | |
import signal | |
import sys | |
def graceful_shutdown(signum, frame): | |
logging.info("Received termination signal. Shutting down gracefully...") | |
# Perform cleanup actions here | |
sys.exit(0) | |
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
signal.signal(signal.SIGTERM, graceful_shutdown) | |
while True: | |
logger.info("Hello, World!") | |
time.sleep(2) | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: hello-world-deployment | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: hello-world | |
template: | |
metadata: | |
labels: | |
app: hello-world | |
spec: | |
containers: | |
- name: hello-world-container | |
image: python:3.11 | |
command: ["python", "/app/hello.py"] | |
volumeMounts: | |
- name: config-volume | |
mountPath: /app | |
volumes: | |
- name: config-volume | |
configMap: | |
name: hello-world-configmap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment