Created
July 17, 2020 20:37
-
-
Save pyramation/8bb042f4a11d3e22440381030e6ac502 to your computer and use it in GitHub Desktop.
example of init containers
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: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: my-app | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: my-app | |
spec: | |
containers: | |
- name: my-app-container | |
resources: | |
limits: | |
cpu: 200m | |
memory: 200Mi | |
image: mhart/alpine-node:10.11.0 | |
ports: | |
- containerPort: 5000 | |
env: | |
- name: NODE_ENV | |
value: production | |
- name: NPM_CONFIG_LOGLEVEL | |
value: warn | |
command: ["/bin/sh"] | |
args: ["-c", "cd /var/www/app; yarn start"] | |
volumeMounts: | |
- name: git-repo | |
mountPath: /var/www/app | |
initContainers: | |
- name: init-git | |
image: alpine/git | |
env: | |
- name: GH_TOKEN | |
valueFrom: | |
secretKeyRef: | |
name: github-token-secret | |
key: GH_TOKEN | |
args: | |
- clone | |
- --single-branch | |
- -- | |
- https://$(GH_TOKEN)@github.com/yourorganization/yourapp.git | |
- /var/www/app | |
volumeMounts: | |
- name: git-repo | |
mountPath: /var/www/app | |
- name: init-yarn | |
image: mhart/alpine-node:10.11.0 | |
env: | |
- name: NODE_ENV | |
value: production | |
- name: NPM_CONFIG_LOGLEVEL | |
value: warn | |
- name: NPM_TOKEN | |
valueFrom: | |
secretKeyRef: | |
name: npm-token-secret | |
key: NPM_TOKEN | |
command: ["/bin/sh"] | |
args: | |
[ | |
"-c", | |
"cd /var/www/app; echo \\/\\/registry.npmjs.org\\/:_authToken=$(NPM_TOKEN) > .npmrc; yarn install; rm .npmrc;", | |
] | |
volumeMounts: | |
- name: git-repo | |
mountPath: /var/www/app | |
volumes: | |
- name: git-repo | |
emptyDir: {} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment