Skip to content

Instantly share code, notes, and snippets.

@jpweber
Created February 22, 2018 15:55
Show Gist options
  • Select an option

  • Save jpweber/6bdac1e9d568c37ec328b596382eeb0e to your computer and use it in GitHub Desktop.

Select an option

Save jpweber/6bdac1e9d568c37ec328b596382eeb0e to your computer and use it in GitHub Desktop.
Example of how you could template a manifest file and what values you would make variable
## template with a lot of options
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.Values.name}}
namespace: {{.Values.environ}}
spec:
replicas: {{.Values.replicas}}
template:
metadata:
labels:
app: {{.Values.name}}
tier: {{ .Values.tier }}
version: {{.Values.version}}
annotations:
spec:
containers:
- name: {{.Values.name}}
image: gcr.io/{{.Values.regnamespace}}/{{.Values.name}}:{{.Values.version}}
resources:
requests:
memory: {{ .Values.requestmemory }}
cpu: {{ .Values.requestcpu }}
limits:
memory: {{ .Values.limitmemory }}
cpu: {{ .Values.limitcpu }}
readinessProbe:
httpGet:
path: {{ .Values.readinessprobepath }}
port: {{ .Values.serviceport }}
initialDelaySeconds: 120
timeoutSeconds: 1
periodSeconds: 3
livenessProbe:
httpGet:
path: {{ .Values.livenessprobepath }}
port: {{ .Values.serviceport }}
initialDelaySeconds: 120
periodSeconds: 10
env:
- name: SOME_ENV_VAR
valueFrom:
configMapKeyRef:
name: env-config
key: env.name
imagePullPolicy: Always
ports:
- containerPort: {{ .Values.serviceport }}
nodeSelector:
environment: {{.Values.environ}}
---
apiVersion: v1
kind: Service
metadata:
name: {{.Values.name}}
namespace: {{.Values.environ}}
annotations:
prometheus.io/probe: "{{ .Values.prometheusprobe }}"
prometheus.io/path: "{{ .Values.prometheusprobepath }}"
spec:
ports:
- protocol: TCP
port: {{ .Values.serviceport }}
selector:
app: {{.Values.name}}
-------------------------------
## values for above template
---
name: cool-api # name of application. Will be used as pod and service name
regnamespace: releases # registry namespace
version: 1.1.0 # container/app version. Will be used as image tag
replicas: 2
environ: stage # In this example it is used to choose what hosts to go to
tier: backend # just for metadata purposes
requestMemory: "1.5Gi"
requestCPU: "100m"
limitMemory: "1.9Gi"
limitCPU: "200m"
servicePort: "8080" # port that will be used for the service and container
livenessProbePath: "/healthcheck/version" # paths to use for probes
readinessProbePath: "/healthcheck/version" # paths to use for probes
prometheusProbePath: "/healthcheck/version" # paths to use for probes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment