Skip to content

Instantly share code, notes, and snippets.

@pyramation
Created July 17, 2020 20:37
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 pyramation/8bb042f4a11d3e22440381030e6ac502 to your computer and use it in GitHub Desktop.
Save pyramation/8bb042f4a11d3e22440381030e6ac502 to your computer and use it in GitHub Desktop.
example of init containers
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