mirror of
https://github.com/amix/vimrc
synced 2024-12-24 19:03:07 +00:00
591 lines
15 KiB
Text
591 lines
15 KiB
Text
snippet service_sample_spec
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
{{- if .Values.$1.service.annotations }}
|
|
annotations:
|
|
{{ toYaml .Values.$1.service.annotations | indent 4 }}
|
|
{{- end }}
|
|
labels:
|
|
{{- if .Values.$1.service.labels }}
|
|
{{ toYaml .Values.$1.service.labels | indent 4 }}
|
|
{{- end }}
|
|
app: {{ template "$2.name" . }}
|
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
|
component: "{{ .Values.$1.name }}"
|
|
heritage: {{ .Release.Service }}
|
|
release: {{ .Release.Name }}
|
|
name: {{ template "$2.$1.fullname" . }}
|
|
spec:
|
|
clusterIP: "{{ .Values.$1.service.clusterIP }}"
|
|
{{- if .Values.$1.service.externalIPs }}
|
|
externalIPs:
|
|
{{ toYaml .Values.$1.service.externalIPs | indent 4 }}
|
|
{{- end }}
|
|
{{- if .Values.$1.service.loadBalancerIP }}
|
|
loadBalancerIP: "{{ .Values.$1.service.loadBalancerIP }}"
|
|
{{- end }}
|
|
{{- if .Values.$1.service.loadBalancerSourceRanges }}
|
|
loadBalancerSourceRanges:
|
|
{{ toYaml .Values.$1.service.loadBalancerSourceRanges | indent 4 }}
|
|
{{- end }}
|
|
healthCheckNodePort: {{ .Values.$1.service.healthCheckNodePort }}
|
|
ports:
|
|
- name: http
|
|
port: 80
|
|
protocol: TCP
|
|
targetPort: {{ .Values.$1.service.targetPorts.http }}
|
|
{{- if (and (eq .Values.$1.service.type "NodePort") (not (empty .Values.$1.service.nodePorts.http))) }}
|
|
nodePort: {{ .Values.$1.service.nodePorts.http }}
|
|
{{- end }}
|
|
- name: https
|
|
port: 443
|
|
protocol: TCP
|
|
targetPort: {{ .Values.$1.service.targetPorts.https }}
|
|
{{- if (and (eq .Values.$1.service.type "NodePort") (not (empty .Values.$1.service.nodePorts.https))) }}
|
|
nodePort: {{ .Values.$1.service.nodePorts.https }}
|
|
{{- end }}
|
|
{{- range $key, $value := .Values.tcp }}
|
|
- name: "{{ $key }}-tcp"
|
|
port: {{ $key }}
|
|
protocol: TCP
|
|
targetPort: "{{ $key }}-tcp"
|
|
{{- end }}
|
|
{{- range $key, $value := .Values.udp }}
|
|
- name: "{{ $key }}-udp"
|
|
port: {{ $key }}
|
|
protocol: UDP
|
|
targetPort: "{{ $key }}-udp"
|
|
{{- end }}
|
|
selector:
|
|
app: {{ template "${2:chartName}.name" . }}
|
|
component: "{{ .Values.$1.name }}"
|
|
release: {{ .Release.Name }}
|
|
type: "{{ .Values.${1:value_key}.service.type }}"
|
|
|
|
snippet service_spec
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
{{- if .Values.$1.service.annotations }}
|
|
annotations:
|
|
{{ toYaml .Values.$1.service.annotations | indent 4 }}
|
|
{{- end }}
|
|
labels:
|
|
{{- if .Values.$1.service.labels }}
|
|
{{ toYaml .Values.$1.service.labels | indent 4 }}
|
|
{{- end }}
|
|
app: {{ template "$2.name" . }}
|
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
|
component: "{{ .Values.$1.name }}"
|
|
heritage: {{ .Release.Service }}
|
|
release: {{ .Release.Name }}
|
|
name: {{ template "${2:chartName}.${1:value_key}.fullname" . }}
|
|
# spec
|
|
${0}
|
|
|
|
snippet annotations_spec
|
|
{{- if .Values.$1.service.annotations }}
|
|
annotations:
|
|
{{ toYaml .Values.${1:value_key}.service.annotations | indent 4 }}
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet labels_spec
|
|
labels:
|
|
{{- if .Values.$1.service.labels }}
|
|
{{ toYaml .Values.$1.service.labels | indent 4 }}
|
|
{{- end }}
|
|
app: {{ template "$2.name" . }}
|
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
|
component: "{{ .Values.$1.name }}"
|
|
heritage: {{ .Release.Service }}
|
|
release: {{ .Release.Name }}
|
|
name: {{ template "${2:chartName}.${1:value_key}.fullname" . }}
|
|
${0}
|
|
|
|
snippet service_spec
|
|
spec:
|
|
type: "{{ .Values.$1.service.type }}"
|
|
clusterIP: "{{ .Values.$1.service.clusterIP }}"
|
|
{{- if .Values.$1.service.externalIPs }}
|
|
externalIPs:
|
|
{{ toYaml .Values.$1.service.externalIPs | indent 4 }}
|
|
{{- end }}
|
|
{{- if .Values.$1.service.loadBalancerIP }}
|
|
loadBalancerIP: "{{ .Values.$1.service.loadBalancerIP }}"
|
|
{{- end }}
|
|
{{- if .Values.$1.service.loadBalancerSourceRanges }}
|
|
loadBalancerSourceRanges:
|
|
{{ toYaml .Values.$1.service.loadBalancerSourceRanges | indent 4 }}
|
|
{{- end }}
|
|
{{- if and (semverCompare ">=1.7-0" .Capabilities.KubeVersion.GitVersion) (.Values.$1.service.externalTrafficPolicy) }}
|
|
externalTrafficPolicy: "{{ .Values.$1.service.externalTrafficPolicy }}"
|
|
{{- end }}
|
|
{{- if and (semverCompare ">=1.7-0" .Capabilities.KubeVersion.GitVersion) (.Values.$1.service.healthCheckNodePort) }}
|
|
healthCheckNodePort: {{ .Values.${1:value_key}.service.healthCheckNodePort }}
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet ports_spec
|
|
ports:
|
|
${0}
|
|
|
|
snippet portHTTP_spec
|
|
- name: http
|
|
port: 80
|
|
protocol: TCP
|
|
targetPort: {{ .Values.$1.service.targetPorts.http }}
|
|
{{- if (and (eq .Values.$1.service.type "NodePort") (not (empty .Values.$1.service.nodePorts.http))) }}
|
|
nodePort: {{ .Values.${1:value_key}.service.nodePorts.http }}
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet portHTTPS_spec
|
|
- name: https
|
|
port: 443
|
|
protocol: TCP
|
|
targetPort: {{ .Values.$1.service.targetPorts.https }}
|
|
{{- if (and (eq .Values.$1.service.type "NodePort") (not (empty .Values.$1.service.nodePorts.https))) }}
|
|
nodePort: {{ .Values.${1:value_key}.service.nodePorts.https }}
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet portTCP_spec
|
|
{{- range $key, $value := .Values.tcp }}
|
|
- name: "{{ $key }}-tcp"
|
|
port: {{ $key }}
|
|
protocol: TCP
|
|
targetPort: "{{ $key }}-tcp"
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet portUDP_spec
|
|
{{- range $key, $value := .Values.udp }}
|
|
- name: "{{ $key }}-udp"
|
|
port: {{ $key }}
|
|
protocol: UDP
|
|
targetPort: "{{ $key }}-udp"
|
|
{{- end }}
|
|
${0}
|
|
|
|
|
|
snippet selector_spec
|
|
selector:
|
|
app: {{ template "${2:chartName}.name" . }}
|
|
component: "{{ .Values.${1:value_key}.name }}"
|
|
release: {{ .Release.Name }}
|
|
${0}
|
|
|
|
|
|
snippet deploy_sample_spec
|
|
{{- if .Values.$1.enabled }}
|
|
apiVersion: extensions/v1beta1
|
|
kind: Deployment
|
|
metadata:
|
|
labels:
|
|
app: {{ template "$2.name" . }}
|
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
|
component: "{{ .Values.$1.name }}"
|
|
heritage: {{ .Release.Service }}
|
|
release: {{ .Release.Name }}
|
|
name: {{ template "$2.$1.fullname" . }}
|
|
spec:
|
|
replicas: {{ .Values.$1.replicaCount }}
|
|
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
|
|
template:
|
|
metadata:
|
|
{{- if .Values.$1.podAnnotations }}
|
|
annotations:
|
|
{{ toYaml .Values.$1.podAnnotations | indent 8 }}
|
|
{{- end }}
|
|
labels:
|
|
app: {{ template "$2.name" . }}
|
|
component: "{{ .Values.$1.name }}"
|
|
release: {{ .Release.Name }}
|
|
{{- if .Values.$1.podLabels }}
|
|
{{ toYaml .Values.$1.podLabels | indent 8 }}
|
|
{{- end }}
|
|
spec:
|
|
{{- if .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{ toYaml .Values.imagePullSecrets | indent 8 }}
|
|
{{- end }}
|
|
containers:
|
|
- name: {{ template "${2:chartName}.name" . }}-{{ .Values.$1.name }}
|
|
image: "{{ .Values.$1.image.repository }}:{{ .Values.$1.image.tag }}"
|
|
imagePullPolicy: "{{ .Values.$1.image.pullPolicy }}"
|
|
args:
|
|
{{- range $key, $value := .Values.$1.extraArgs }}
|
|
{{- if $value }}
|
|
- --{{ $key }}={{ $value }}
|
|
{{- else }}
|
|
- --{{ $key }}
|
|
{{- end }}
|
|
{{- end }}
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /healthz
|
|
port: 8080
|
|
scheme: HTTP
|
|
initialDelaySeconds: 30
|
|
timeoutSeconds: 5
|
|
ports:
|
|
- name: http
|
|
containerPort: 8080
|
|
protocol: TCP
|
|
resources:
|
|
{{ toYaml .Values.$1.resources | indent 12 }}
|
|
{{- if .Values.$1.nodeSelector }}
|
|
nodeSelector:
|
|
{{ toYaml .Values.$1.nodeSelector | indent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.$1.tolerations }}
|
|
tolerations:
|
|
{{ toYaml .Values.$1.tolerations | indent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.$1.affinity }}
|
|
affinity:
|
|
{{ toYaml .Values.${1:value_key}.affinity | indent 8 }}
|
|
{{- end }}
|
|
terminationGracePeriodSeconds: 60
|
|
{{- end }}
|
|
|
|
|
|
|
|
snippet deploy_spec
|
|
{{- if .Values.$1.enabled }}
|
|
apiVersion: extensions/v1beta1
|
|
kind: Deployment
|
|
metadata:
|
|
labels:
|
|
app: {{ template "$2.name" . }}
|
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
|
component: "{{ .Values.$1.name }}"
|
|
heritage: {{ .Release.Service }}
|
|
release: {{ .Release.Name }}
|
|
name: {{ template "${2:chartName}.${1:value_key}.fullname" . }}
|
|
# spec
|
|
# containers_spec
|
|
# livenessProbe_spec
|
|
# PersistentVolumeClaim_spec
|
|
# initContainers_spec
|
|
# resources_spec
|
|
# nodeselector_spec
|
|
# tolerations_spec
|
|
# affinity_spec
|
|
${0}
|
|
|
|
snippet spec_spec
|
|
spec:
|
|
replicas: {{ .Values.$1.replicaCount }}
|
|
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
|
|
template:
|
|
metadata:
|
|
{{- if .Values.$1.podAnnotations }}
|
|
annotations:
|
|
{{ toYaml .Values.$1.podAnnotations | indent 8 }}
|
|
{{- end }}
|
|
labels:
|
|
app: {{ template "${2:chartName}.name" . }}
|
|
component: "{{ .Values.$1.name }}"
|
|
release: {{ .Release.Name }}
|
|
{{- if .Values.$1.podLabels }}
|
|
{{ toYaml .Values.${1:value_key}.podLabels | indent 8 }}
|
|
{{- end }}
|
|
spec:
|
|
{{- if .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{ toYaml .Values.imagePullSecrets | indent 8 }}
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet imagePullSecrets_spec
|
|
{{- if .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{ toYaml .Values.imagePullSecrets | indent 8 }}
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet imagePullPolicy_spec
|
|
imagePullPolicy: ${1:imagePullPolicy}
|
|
${0}
|
|
|
|
snippet containers_spec
|
|
containers:
|
|
- name: {{ template "${2:chartName}.name" . }}-{{ .Values.$1.name }}
|
|
image: "{{ .Values.$1.image.repository }}:{{ .Values.$1.image.tag }}"
|
|
imagePullPolicy: "{{ .Values.${1:value_key}.image.pullPolicy }}"
|
|
${0}
|
|
snippet args_spec
|
|
args:
|
|
{{- range $key, $value := .Values.${1:value_key}.extraArgs }}
|
|
{{- if $value }}
|
|
- --{{ $key }}={{ $value }}
|
|
{{- else }}
|
|
- --{{ $key }}
|
|
{{- end }}
|
|
{{- end }}
|
|
${0}
|
|
snippet livenessProbe_spec
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /healthz
|
|
port: 8080
|
|
scheme: HTTP
|
|
initialDelaySeconds: 30
|
|
timeoutSeconds: 5
|
|
${0}
|
|
snippet readinessProbe_spec
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /go/api/v1/health
|
|
port: 8153
|
|
initialDelaySeconds: {{ .Values.$1.healthCheck.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.$1.healthCheck.periodSeconds }}
|
|
failureThreshold: {{ .Values.$1.healthCheck.failureThreshold }}
|
|
${0}
|
|
snippet resources_spec
|
|
resources:
|
|
{{ toYaml .Values.${1:value_key}.resources | indent 12 }}
|
|
${0}
|
|
snippet nodeselector_spec
|
|
{{- if .Values.$1.nodeSelector }}
|
|
nodeSelector:
|
|
{{ toYaml .Values.${1:value_key}.nodeSelector | indent 8 }}
|
|
{{- end }}
|
|
${0}
|
|
snippet tolerations_spec
|
|
{{- if .Values.$1.tolerations }}
|
|
tolerations:
|
|
{{ toYaml .Values.${1:value_key}.tolerations | indent 8 }}
|
|
{{- end }}
|
|
${0}
|
|
snippet affinity_spec
|
|
{{- if .Values.$1.affinity }}
|
|
affinity:
|
|
{{ toYaml .Values.${1:value_key}.affinity | indent 8 }}
|
|
{{- end }}
|
|
terminationGracePeriodSeconds: 60
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet PersistentVolumeClaim_spec
|
|
kind: PersistentVolumeClaim
|
|
apiVersion: v1
|
|
metadata:
|
|
name: {{ template "${2}.$1.fullname" . }}
|
|
labels:
|
|
app: {{ template "${2:chartName}.name" . }}
|
|
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
|
release: "{{ .Release.Name }}"
|
|
heritage: "{{ .Release.Service }}"
|
|
spec:
|
|
accessModes:
|
|
- {{ .Values.$1.persistence.accessMode | quote }}
|
|
resources:
|
|
requests:
|
|
storage: {{ .Values.$1.persistence.size | quote }}
|
|
{{- if .Values.$1.persistence.storageClass }}
|
|
{{- if (eq "-" .Values.$1.persistence.storageClass) }}
|
|
storageClassName: ""
|
|
{{- else }}
|
|
storageClassName: "{{ .Values.${1:value_key}.persistence.storageClass }}"
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet configMap_spec
|
|
{{- if .Values.artifactory.enabled -}}
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: {{ template "${2:chartName}.fullname" . }}-${1:value_key}-config
|
|
labels:
|
|
app: {{ template "${2}.name" . }}
|
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
|
heritage: {{ .Release.Service }}
|
|
release: {{ .Release.Name }}
|
|
data:
|
|
${3:nameOfConfigFile}.conf: |
|
|
# data goes here
|
|
{{- end -}}
|
|
${0}
|
|
|
|
snippet initContainers_spec
|
|
{{- if .Values.$1.initContainers }}
|
|
initContainers:
|
|
- name: wait-workers
|
|
image: "{{ .Values.$1.image.repository }}:{{ .Values.$1.image.tag }}"
|
|
imagePullPolicy: {{ .Values.${1:value_key}.image.pullPolicy }}
|
|
# env
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
until printf "." && nc -z -w 2 {{ template "${2:chartName}.fullname" . }} {{ .Values.postgresql.service.port }}; do
|
|
sleep 2;
|
|
done;
|
|
|
|
echo 'PostgreSQL OK ✓'
|
|
# args
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet pvc_spec
|
|
kind: PersistentVolumeClaim
|
|
apiVersion: v1
|
|
metadata:
|
|
name: {{ template "$2.fullname" . }}
|
|
labels:
|
|
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
|
release: "{{ .Release.Name }}"
|
|
heritage: "{{ .Release.Service }}"
|
|
app: {{ template "${2:chartName}.fullname" . }}
|
|
spec:
|
|
accessModes:
|
|
- {{ .Values.persistence.accessMode | quote }}
|
|
resources:
|
|
requests:
|
|
storage: {{ .Values.persistence.size | quote }}
|
|
{{- if .Values.persistence.storageClass }}
|
|
{{- if (eq "-" .Values.persistence.storageClass) }}
|
|
storageClassName: ""
|
|
{{- else }}
|
|
storageClassName: "{{ .Values.persistence.storageClass }}"
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
${0}
|
|
|
|
snippet pv_nfs_spec
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata:
|
|
name: {{ template "$2.fullname" . }}-data-pv
|
|
labels:
|
|
app: {{ template "$2.name" . }}
|
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
|
heritage: {{ .Release.Service }}
|
|
release: {{ .Release.Name }}
|
|
id: {{ template "${2:chartName}.name" . }}-data-pv
|
|
type: nfs-volume
|
|
spec:
|
|
capacity:
|
|
storage: {{ .Values.$1.persistence.nfs.capacity }}
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
persistentVolumeReclaimPolicy: Retain
|
|
nfs:
|
|
server: {{ .Values.$1.persistence.nfs.ip }}
|
|
path: "{{ .Values.${1:value_key}.persistence.nfs.haDataMount }}"
|
|
readOnly: false
|
|
${0}
|
|
|
|
snippet pvc_hostpath_spec
|
|
{{- if and .Values.persistence.enabled .Values.persistence.$1.hostPath (not
|
|
.Values.persistence.$1.existingClaim) -}}
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata:
|
|
name: {{ template "${2:chartName}.fullname" . }}-$1
|
|
spec:
|
|
accessModes:
|
|
- {{ .Values.persistence.$1.accessMode | quote }}
|
|
capacity:
|
|
storage: {{ .Values.persistence.$1.size | quote }}
|
|
hostPath:
|
|
path: {{ .Values.persistence.${1:value_key}.hostPath | quote }}
|
|
{{- end -}}
|
|
${0}
|
|
|
|
snippet deploy_values
|
|
$1:
|
|
name: ${1:value_key}
|
|
image:
|
|
repository:
|
|
tag:
|
|
pullPolicy: IfNotPresent
|
|
hostNetwork: false
|
|
dnsPolicy: ClusterFirst
|
|
daemonset:
|
|
useHostPort: false
|
|
podLabels: {}
|
|
scope:
|
|
enabled: false
|
|
namespace: "" # defaults to .Release.Namespace
|
|
extraArgs: {}
|
|
extraEnvs: []
|
|
kind: Deployment
|
|
updateStrategy: {}
|
|
minReadySeconds: 0
|
|
tolerations: []
|
|
affinity: {}
|
|
nodeSelector: {}
|
|
podAnnotations: {}
|
|
replicaCount: 1
|
|
minAvailable: 1
|
|
resources: {}
|
|
autoscaling:
|
|
enabled: false
|
|
extraContainers: {}
|
|
extraVolumeMounts: {}
|
|
extraVolumes: {}
|
|
extraInitContainers: []
|
|
lifecycle: {}
|
|
revisionHistoryLimit: 10
|
|
${0}
|
|
|
|
snippet rbac_values
|
|
${1:value_key}:
|
|
rbac:
|
|
create: true
|
|
serviceAccount:
|
|
create: true
|
|
name:
|
|
imagePullSecrets: []
|
|
${0}
|
|
|
|
snippet service_values
|
|
${1:value_key}:
|
|
service:
|
|
annotations: {}
|
|
labels: {}
|
|
clusterIP: ""
|
|
externalIPs: []
|
|
loadBalancerIP: ""
|
|
loadBalancerSourceRanges: []
|
|
externalTrafficPolicy: ""
|
|
healthCheckNodePort: 0
|
|
targetPorts:
|
|
http: http
|
|
https: https
|
|
type: LoadBalancer
|
|
nodePorts:
|
|
http: ""
|
|
https: ""
|
|
${0}
|
|
|
|
snippet readinessProbe_values
|
|
${1:value_key}:
|
|
readinessProbe:
|
|
failureThreshold: 3
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 10
|
|
successThreshold: 1
|
|
timeoutSeconds: 1
|
|
port: 10254
|
|
${0}
|
|
|
|
snippet livenessProbe_values
|
|
${1:value_key}:
|
|
livenessProbe:
|
|
failureThreshold: 3
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 10
|
|
successThreshold: 1
|
|
timeoutSeconds: 1
|
|
port: 10254
|
|
${0}
|