Skip to content

Instantly share code, notes, and snippets.

@mr-karan
Last active October 1, 2019 12:59
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 mr-karan/78fc50dcce01f323572fc44f277157ff to your computer and use it in GitHub Desktop.
Save mr-karan/78fc50dcce01f323572fc44f277157ff to your computer and use it in GitHub Desktop.
Passing arbitary arguments to containers in K8s
#!/bin/sh
echo Your container args are: "$@"
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
spec:
selector:
matchLabels:
app: hello
replicas: 1
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello
imagePullPolicy: Never
image: homelab/argtest:latest
command:
- sh
- -c
- 'exec ./arg.sh $(date +%Y-%m-%dT%H)'
FROM alpine:latest
COPY ./arg.sh /
ENTRYPOINT ["/arg.sh"]
@mr-karan
Copy link
Author

mr-karan commented Oct 1, 2019

Output is:

Your container args are: 2019-10-01T12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment