Last active
October 1, 2019 12:59
-
-
Save mr-karan/78fc50dcce01f323572fc44f277157ff to your computer and use it in GitHub Desktop.
Passing arbitary arguments to containers in K8s
This file contains 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
#!/bin/sh | |
echo Your container args are: "$@" |
This file contains 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: 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)' |
This file contains 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
FROM alpine:latest | |
COPY ./arg.sh / | |
ENTRYPOINT ["/arg.sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output is:
Your container args are: 2019-10-01T12