Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save haysclark/bc2c3e4dd5e4122bc468e2258d7a55c8 to your computer and use it in GitHub Desktop.
Save haysclark/bc2c3e4dd5e4122bc468e2258d7a55c8 to your computer and use it in GitHub Desktop.
Jenkins-X scale Previews to Zero with Osiris for dev packs with `preview/values.yaml.gotoml` (note: I'm using "_" in filename instead of "/" because of Gist limitation)
{{- if .Values.knativeDeploy }}
{{- else }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "fullname" . }}
labels:
draft: {{ default "draft-app" .Values.draft }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- if .Values.deploymentLabels }}
{{ toYaml .Values.deploymentLabels | indent 4 }}
{{- end }}
{{- if .Values.deploymentAnnotations }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{ tpl (toYaml .) $ | trim | indent 4 }}
{{- end }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "fullname" . }}
{{- if .Values.hpa.enabled }}
{{- else }}
replicas: {{ .Values.replicaCount }}
{{- end }}
template:
metadata:
labels:
draft: {{ default "draft-app" .Values.draft }}
app: {{ template "fullname" . }}
{{- if .Values.podsLabels }}
{{ toYaml .Values.podsLabels | indent 6 }}
{{- end }}
{{- if .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
{{- if .Values.serviceAccount.enabled }}
{{- if .Values.serviceAccount.name }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- else }}
serviceAccountName: {{ template "fullname" . }}
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: VERSION
value: {{ .Chart.Version }}
{{- range $pkey, $pval := .Values.env }}
- name: {{ $pkey }}
value: {{ quote $pval }}
{{- end }}
envFrom:
{{ toYaml .Values.envFrom | indent 10 }}
ports:
- name: http
containerPort: {{ .Values.service.internalPort }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.probePath | default .Values.probePath }}
port: {{ .Values.service.internalPort }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
readinessProbe:
httpGet:
path: {{ .Values.readinessProbe.probePath | default .Values.probePath }}
port: {{ .Values.service.internalPort }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
resources:
{{ toYaml .Values.resources | indent 12 }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
imagePullSecrets:
{{- range $pval := .Values.jx.imagePullSecrets }}
- name: {{ quote $pval }}
{{- end }}
{{- end }}
{{- if or .Values.knativeDeploy .Values.canary.enabled }}
{{- else }}
apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.name }}
name: {{ .Values.service.name }}
{{- else }}
name: {{ template "fullname" . }}
{{- end }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
{{- if .Values.service.annotations }}
{{- with .Values.service.annotations }}
annotations:
{{ tpl (toYaml .) $ | trim | indent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: http
selector:
app: {{ template "fullname" . }}
{{- end }}
jxRequirements:
ingress:
namespaceSubDomain: "-pr{{ requiredEnv "PULL_NUMBER" }}."
image:
repository: "{{ requiredEnv "DOCKER_REGISTRY" }}/{{ requiredEnv "DOCKER_REGISTRY_ORG" }}/{{ requiredEnv "APP_NAME" }}"
tag: "{{ requiredEnv "VERSION" }}"
pullPolicy: "Always"
deploymentAnnotations:
osiris.dm.gg/enableScaling: "true"
osiris.dm.gg/metricsCheckInterval: "120"
podAnnotations:
osiris.dm.gg/collectMetrics: "true"
service:
annotations:
osiris.dm.gg/manageEndpoints: "true"
osiris.dm.gg/deployment: '{{"{{ template \"fullname\" . }}"}}'
osiris.dm.gg/loadBalancerHostname: '{{"{{ .Values.service.name }}{{ .Values.jxRequirements.ingress.namespaceSubDomain }}{{ .Values.jxRequirements.ingress.domain }}"}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment