206 lines
8.3 KiB
YAML
206 lines
8.3 KiB
YAML
{{- define "common_api_python_deployment" }}
|
|
{{- $replicas := include "kolla_val_get_str" (dict "key" "replicas" "searchPath" .searchPath "Values" .Values ) }}
|
|
{{- $port := include "kolla_val_get_str" (dict "key" "port" "searchPath" .searchPath "Values" .Values ) }}
|
|
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
|
|
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" .searchPath "Values" .Values ) }}
|
|
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
|
|
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
|
|
{{- $novaMetadataSearchPath := ":global.kolla.nova.metadata.deployment:global.kolla.nova.metadata.all:global.kolla.nova.all:global.kolla.all" }}
|
|
{{- $novaMetadataPort := include "kolla_val_get_str" (dict "key" "port" "searchPath" $novaMetadataSearchPath "Values" .Values ) }}
|
|
{{- $gracePeriodSeconds := include "kolla_val_get_str" (dict "key" "grace_period_seconds" "searchPath" .searchPath "Values" .Values ) }}
|
|
{{- $localVals := dict }}
|
|
{{- $c := dict "searchPath" .searchPath "key" "haproxy_python_termination" "retDict" $localVals "retKey" "haproxy" "Values" .Values }}
|
|
{{- include "kolla_val_get_raw" $c }}
|
|
{{- $c := dict "searchPath" .searchPath "key" "prometheus_exporter" "retDict" $localVals "retKey" "prometheus" "Values" .Values }}
|
|
{{- include "kolla_val_get_raw" $c }}
|
|
{{- $c := dict "searchPath" .searchPath "key" "prometheus_port" "retDict" $localVals "retKey" "prometheusPort" "Values" .Values }}
|
|
{{- include "kolla_val_get_raw" $c }}
|
|
apiVersion: extensions/v1beta1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ .resourceName }}
|
|
spec:
|
|
replicas: {{ $replicas }}
|
|
strategy:
|
|
rollingUpdate:
|
|
maxSurge: 1
|
|
maxUnavailable: 1
|
|
type: RollingUpdate
|
|
template:
|
|
metadata:
|
|
labels:
|
|
service: {{ .serviceName }}
|
|
type: {{ .serviceType }}
|
|
annotations:
|
|
{{- if $localVals.haproxy }}
|
|
kolla_upgrade: minor_rolling_safe
|
|
{{- if $localVals.prometheus }}
|
|
"prometheus.io/port": {{ $localVals.prometheusPort | quote }}
|
|
"prometheus.io/scrape": "true"
|
|
{{- end }}
|
|
{{- end }}
|
|
spec:
|
|
#You've got 2 days to drain or figure out why it won't.
|
|
terminationGracePeriodSeconds: {{ $gracePeriodSeconds }}
|
|
nodeSelector:
|
|
{{ $selectorKey }}: {{ $selectorValue | quote }}
|
|
initContainers:
|
|
#FIXME once all services are converted, bind_host can be dropped here and changed to default to 127.0.0.1 instead of 0.0.0.0.
|
|
# The init container overrides the listen address and port to ensure it does not conflict with haproxy and prevent
|
|
# other containers from directly accessing the service
|
|
{{- include "common_dependency_container" . | indent 8 }}
|
|
- name: update-config
|
|
image: {{ include "kolla_toolbox_image_full" . | quote }}
|
|
imagePullPolicy: {{ $imagePullPolicy | quote }}
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
cp -a /srv/configmap/..data/* /srv/pod-main-config/;
|
|
{{- if eq .resourceName "kibana" }}
|
|
IP=\"127.0.0.1\";
|
|
PORT=\"8080\";
|
|
sed -i 's|^elasticsearch.url:.*|elasticsearch.url: \"http://elasticsearch:9200\"|g' /srv/pod-main-config/kibana.yml;
|
|
sed -i 's|^server.host:.*|server.host: \"'$IP'\"|g' /srv/pod-main-config/kibana.yml;
|
|
sed -i 's|^server.port:.*|server.port: \"'$PORT'\"|g' /srv/pod-main-config/kibana.yml;
|
|
{{- else }}
|
|
CONF=/srv/pod-main-config/{{ .configFileName }};
|
|
{{- if $localVals.haproxy }}
|
|
{{- if eq .resourceName "nova-api" }}
|
|
crudini --set $CONF DEFAULT metadata_listen 127.0.0.1;
|
|
crudini --set $CONF DEFAULT metadata_listen_port 8081;
|
|
{{- end }}
|
|
crudini --set $CONF {{ .configSectionName }} {{ .configListenHostParameter }} 127.0.0.1;
|
|
crudini --set $CONF {{ .configSectionName }} {{ .configListenPortParameter }} 8080;
|
|
{{- end }}
|
|
{{- end }}
|
|
volumeMounts:
|
|
- name: service-configmap
|
|
mountPath: /srv/configmap
|
|
- name: pod-main-config
|
|
mountPath: /srv/pod-main-config
|
|
{{- if .initContainers }}
|
|
{{- include .initContainers . | indent 8 }}
|
|
{{- end }}
|
|
containers:
|
|
{{- if $localVals.haproxy }}
|
|
- name: haproxy
|
|
image: {{ include "haproxy_image_full" . | quote }}
|
|
imagePullPolicy: {{ $imagePullPolicy | quote }}
|
|
command:
|
|
- /bin/bash
|
|
- -c
|
|
- |
|
|
kolla_start;
|
|
touch /var/lib/kolla-kubernetes/event/shutdown;
|
|
readinessProbe:
|
|
httpGet:
|
|
path: {{ .checkPath }}
|
|
port: {{ $port }}
|
|
initialDelaySeconds: 5
|
|
timeoutSeconds: 5
|
|
lifecycle:
|
|
preStop:
|
|
exec:
|
|
#FIXME move script into haproxy container
|
|
#NOTE this only works if you arn't doing a haproxy reconfigure too.
|
|
#But shouldn't ever have to do that in a setup like this.
|
|
command:
|
|
- /bin/bash
|
|
- -c
|
|
- |
|
|
kill -USR1 $(</var/run/haproxy.pid);
|
|
while true; do sleep 1000; done
|
|
volumeMounts:
|
|
{{ include "common_volume_mounts" . | indent 12 }}
|
|
- mountPath: /var/lib/kolla-kubernetes/event
|
|
name: kolla-kubernetes-events
|
|
- mountPath: {{ $containerConfigDirectory }}
|
|
name: haproxy-config
|
|
- mountPath: /haproxy
|
|
name: socket
|
|
env:
|
|
- name: KOLLA_CONFIG_STRATEGY
|
|
value: COPY_ONCE
|
|
ports:
|
|
- containerPort: {{ $port }}
|
|
name: {{ .portName }}
|
|
{{- if eq .resourceName "nova-api" }}
|
|
- containerPort: {{ $novaMetadataPort }}
|
|
name: nova-metadata
|
|
{{- end }}
|
|
{{- if $localVals.prometheus }}
|
|
- name: exporter
|
|
image: {{ include "haproxy_prometheus_image_full" . | quote }}
|
|
imagePullPolicy: {{ $imagePullPolicy | quote }}
|
|
command: [haproxy_exporter, "--haproxy.scrape-uri=unix:/haproxy/haproxy.sock", "--web.listen-address=:{{ $localVals.prometheusPort}}"]
|
|
volumeMounts:
|
|
- mountPath: /haproxy
|
|
name: socket
|
|
ports:
|
|
- containerPort: {{ $localVals.prometheusPort }}
|
|
name: prometheus
|
|
{{- end }}
|
|
{{- end }}
|
|
- name: main
|
|
image: "{{ .imageFull }}"
|
|
imagePullPolicy: {{ $imagePullPolicy | quote }}
|
|
{{- if $localVals.haproxy }}
|
|
lifecycle:
|
|
preStop:
|
|
exec:
|
|
command:
|
|
- /bin/bash
|
|
- -c
|
|
- while true; do sleep 1; [ -f /var/lib/kolla-kubernetes/event/shutdown ] && break; done
|
|
{{- end }}
|
|
volumeMounts:
|
|
{{ include "common_volume_mounts" . | indent 12 }}
|
|
- mountPath: /var/lib/kolla-kubernetes/event
|
|
name: kolla-kubernetes-events
|
|
- mountPath: {{ $containerConfigDirectory }}
|
|
name: pod-main-config
|
|
{{- if .extraVolumeMounts }}
|
|
{{- include .extraVolumeMounts . | indent 12 }}
|
|
{{- end }}
|
|
{{- if .privileged }}
|
|
securityContext:
|
|
privileged: true
|
|
{{- end }}
|
|
env:
|
|
- name: KOLLA_CONFIG_STRATEGY
|
|
value: COPY_ONCE
|
|
{{- if not $localVals.haproxy }}
|
|
ports:
|
|
- containerPort: {{ $port }}
|
|
name: {{ .portName }}
|
|
{{- if eq .resourceName "nova-api" }}
|
|
- containerPort: {{ $novaMetadataPort }}
|
|
name: nova-metadata
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- include "common_containers" . | indent 8 }}
|
|
volumes:
|
|
{{- include "common_volumes" . | indent 8 }}
|
|
- name: kolla-kubernetes-events
|
|
emptyDir: {}
|
|
- name: socket
|
|
emptyDir: {}
|
|
- name: pod-main-config
|
|
emptyDir: {}
|
|
- name: service-configmap
|
|
configMap:
|
|
name: {{ .resourceName }}
|
|
{{- if .extraConfigmapConfig }}
|
|
{{- include .extraConfigmapConfig . | indent 12 }}
|
|
{{- end }}
|
|
{{- if $localVals.haproxy }}
|
|
- name: haproxy-config
|
|
configMap:
|
|
name: {{ .resourceName }}-haproxy
|
|
{{- end }}
|
|
{{- if .extraVolume }}
|
|
{{- include .extraVolume . | indent 8 }}
|
|
{{- end }}
|
|
{{- end }}
|