kolla-kubernetes/helm/microservice/nova-libvirt-daemonset/templates/nova-libvirt.yaml

157 lines
6.0 KiB
YAML

{{- $searchPath := ":global.kolla.nova.libvirt.daemonset:global.kolla.nova.libvirt.all:global.kolla.nova.compute.all:global.kolla.nova.all:global.kolla.all" }}
{{- $resourceName := "nova-libvirt" }}
{{- $netHostTrue := true }}
{{- $podTypeBootstrap := false }}
{{- $serviceName := "nova" }}
{{- $serviceType := "libvirt" }}
{{- $privileged := true }}
{{- $c := dict "searchPath" $searchPath "Values" .Values }}
{{- $_ := set $c "contName" "nova-libvirt" }}
{{- $_ := set $c "imageName" "image_full" }}
{{- $_ := set $c "tagName" "image_tag" }}
{{- $imageFull := include "kolla_build_image_full" $c }}
{{- $localVals := dict }}
{{- $c1 := dict "key" "libvirt_tcp" "searchPath" $searchPath "Values" .Values }}
{{- $_ := set $c1 "retDict" $localVals }}
{{- $_ := set $c1 "retKey" "libvirt_tcp" }}
{{- $_ := include "kolla_val_get_raw" $c1 }}
{{- $c2 := dict "key" "ceph_backend" "searchPath" $searchPath "Values" .Values }}
{{- $_ := set $c2 "retDict" $localVals }}
{{- $_ := set $c2 "retKey" "ceph_backend" }}
{{- $_ := include "kolla_val_get_raw" $c2 }}
{{- $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 ) }}
{{- $elementName := .Values.element_name | default $resourceName }}
{{- with $env := dict "netHostTrue" $netHostTrue "podTypeBootstrap" $podTypeBootstrap "imageFull" $imageFull "resourceName" $resourceName "serviceName" $serviceName "serviceType" $serviceType "privileged" $privileged "Values" .Values "Release" .Release "searchPath" $searchPath }}
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: {{ $elementName }}
labels:
component: {{ $serviceName }}
system: {{ $elementName }}
spec:
template:
metadata:
labels:
component: {{ $serviceName }}
system: {{ $elementName }}
spec:
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: True
hostPID: True
nodeSelector:
{{ $selectorKey }}: {{ $selectorValue | quote }}
{{- if not $localVals.libvirt_tcp }}
hostIPC: True
{{- end }}
initContainers:
{{- include "common_dependency_container" $env | indent 8 }}
- name: initialize-nova-libvirt
image: {{ $imageFull | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
command:
- sh
- -xec
- |
cp -a /config/..data/* /nova/;
{{- if $localVals.libvirt_tcp }}
sed -i 's|^listen_addr.*=.*|listen_addr="127.0.0.1"|g' /nova/libvirtd.conf;
{{- end }}
{{- if $localVals.ceph_backend }}
mkdir -p /nova/secrets/;
RDB_SECRET_UUID=$(sed -n 's|.*<uuid>\(.*\)</uuid>.*|\1|p' /secret/a/data);
cp -a /secret/a/..data/data /nova/secrets/$RDB_SECRET_UUID.xml;
cp -a /secret/b/..data/data /nova/secrets/$RDB_SECRET_UUID.base64;
cp -a /config2/..data/ceph.conf /nova;
{{- end }}
volumeMounts:
{{- if $localVals.ceph_backend }}
- name: ceph-conf
mountPath: /config2
- name: nova-libvirt-secret
mountPath: /secret/a/
- name: nova-libvirt-bin-secret
mountPath: /secret/b/
{{- end }}
- name: nova-libvirt-config
mountPath: /config/
- name: nova-config
mountPath: /nova/
containers:
- name: main
image: {{ $imageFull | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
command:
- /bin/bash
- -c
- |
modprobe rbd;
# Following is added to workaround bug
# https://bugs.launchpad.net/kolla/+bug/1649009
rpm -e qemu-system-x86 || true;
cp -a {{ $containerConfigDirectory }}/secrets /etc/libvirt;
kolla_start
securityContext:
privileged: true
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
- mountPath: {{ $containerConfigDirectory }}
name: nova-config
- mountPath: /var/lib/libvirt
name: nova-libvirt-persistent-storage
- mountPath: /var/lib/nova
name: nova-compute-persistent-storage
- mountPath: /lib/modules
name: lib-modules
- mountPath: /var/run
name: run
- mountPath: /dev
name: dev
- mountPath: /sys/fs/cgroup
name: sys-fs-cgroup
- mountPath: /nova
name: nova-config
env:
{{- include "common_env_vars" $env | indent 12 }}
{{- include "common_containers" $env | indent 8 }}
volumes:
{{- include "common_volumes" $env | indent 8 }}
- name: nova-compute-persistent-storage
hostPath:
path: /var/lib/nova
- name: nova-libvirt-config
configMap:
name: {{ $elementName }}
- name: nova-libvirt-persistent-storage
hostPath:
path: /var/lib/libvirt
- name: lib-modules
hostPath:
path: /lib/modules
- name: run
hostPath:
path: /var/run
- name: dev
hostPath:
path: /dev
- name: sys-fs-cgroup
hostPath:
path: /sys/fs/cgroup
- name: nova-config
emptyDir: {}
{{- if $localVals.ceph_backend }}
- name: ceph-conf
configMap:
name: ceph-conf
- name: nova-libvirt-secret
secret:
secretName: nova-libvirt
- name: nova-libvirt-bin-secret
secret:
secretName: nova-libvirt-bin
{{- end }}
{{- end }}