Skip to content

Instantly share code, notes, and snippets.

@ccollicutt
Created August 23, 2023 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccollicutt/8952af816a77b872b137977b98386e9c to your computer and use it in GitHub Desktop.
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!
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