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

215 lines
8.4 KiB
YAML

{{- $searchPath := ":global.kolla.nova.compute.daemonset:global.kolla.nova.compute.all:global.kolla.nova.all:global.kolla.all" }}
{{- $novncSearchPath := "global.kolla.nova.novncproxy.all" }}
{{- $resourceName := "nova-compute" }}
{{- $netHostTrue := true }}
{{- $podTypeBootstrap := false }}
{{- $serviceName := "nova" }}
{{- $serviceType := "compute" }}
{{- $privileged := true }}
{{- $novncProxyHost := include "kolla_val_get_str" (dict "key" "host" "searchPath" $novncSearchPath "Values" .Values) }}
{{- $novncProxyPort := include "kolla_val_get_str" (dict "key" "port" "searchPath" $novncSearchPath "Values" .Values) }}
{{- $c := dict "searchPath" $searchPath "Values" .Values }}
{{- $_ := set $c "contName" "nova-compute" }}
{{- $_ := 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 ) }}
{{- $tunnelInterface := include "kolla_val_get_str" (dict "key" "tunnel_interface" "searchPath" $searchPath "Values" .Values ) }}
{{- $elementName := .Values.element_name | default $resourceName }}
{{- define "nova_compute_extra_dep_volume_mounts" }}
{
"name": "run",
"mountPath": "/var/run"
}
{{- end }}
{{- $extraDepVolumeMounts := "nova_compute_extra_dep_volume_mounts" }}
{{- with $env := dict "netHostTrue" $netHostTrue "podTypeBootstrap" $podTypeBootstrap "imageFull" $imageFull "resourceName" $resourceName "serviceName" $serviceName "serviceType" $serviceType "privileged" $privileged "Values" .Values "Release" .Release "searchPath" $searchPath "extraDepVolumeMounts" $extraDepVolumeMounts }}
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: {{ $elementName }}
labels:
component: {{ $serviceName }}
system: {{ $elementName }}
spec:
template:
metadata:
labels:
component: {{ $serviceName }}
system: {{ $elementName }}
annotations:
pod.beta.kubernetes.io/init-containers: '[
{{- include "common_dependency_container_multi" $env | indent 10 }}
{
"name": "initialize-nova-compute",
"image": {{ include "kolla_toolbox_image_full" . | quote }},
"imagePullPolicy": {{ $imagePullPolicy | quote }},
"command": [
"sh",
"-xec",
"cp -a /config/..data/* /nova/;
IP=$(ip addr show dev {{ $tunnelInterface }} | grep -G ''inet '' | awk ''{print $2}'' | sed ''s@/.*@@'');
mkdir -p /var/log/kolla/nova-init;
echo Using $IP | tee /var/log/kolla/nova-init/ip.log;
crudini --set /nova/nova.conf DEFAULT my_ip $IP;
crudini --set /nova/nova.conf vnc novncproxy_host $IP;
crudini --set /nova/nova.conf vnc vncserver_listen $IP;
crudini --set /nova/nova.conf vnc vncserver_proxyclient_address $IP;
{{- if $localVals.libvirt_tcp }}
sed -i ''s|^connection_uri.*=.*|connection_uri=\"qemu+tcp://127.0.0.1/system\"|g'' /nova/nova.conf;
{{- end }}
{{- if $localVals.ceph_backend }}
cp -a /secret/a/..data/ceph.client.nova.keyring /nova/ceph.client.nova.keyring;
cp -a /config2/..data/ceph.conf /nova/ceph.conf;
{{- end }}
"],
"volumeMounts": [
{{- if $localVals.ceph_backend }}
{
"name": "ceph-conf",
"mountPath": "/config2/"
},
{
"name": "ceph-client-nova-keyring",
"mountPath": "/secret/a/"
},
{{- end }}
{
"name": "kolla-logs",
"mountPath": "/var/log/kolla/"
},
{
"name": "nova-compute-config",
"mountPath": "/config/"
},
{
"name": "nova-config",
"mountPath": "/nova/"
}
]
},
{
"name": "initialize-nova",
"image": "{{ $imageFull }}",
"imagePullPolicy": {{ $imagePullPolicy | quote }},
"command": [
"sh",
"-ce",
"[ ! -d /var/lib/nova/instances ] && mkdir -p /var/lib/nova/instances;
chown nova: /var/lib/nova;
chown nova: /var/lib/nova/instances;
"],
"securityContext": {
"runAsUser": 0
},
"volumeMounts": [
{
"name": "nova-compute-persistent-storage",
"mountPath": "/var/lib/nova"
}
]
},
{
"name": "initialize-iscsi-iqn",
"image": "{{ $imageFull }}",
"imagePullPolicy": {{ $imagePullPolicy | quote }},
"securityContext": {
"runAsUser": 0,
"privileged": true
},
"command": [
"bash",
"-ce",
"if [ ! -f /etc/iscsi/initiatorname.iscsi ]; then
iqn=$( cat /dev/urandom | tr -dc ''a-f0-9'' | head -c 12 );
echo InitiatorName=iqn.2010-10.org.openstack:$iqn > /etc/iscsi/initiatorname.iscsi;
chmod 640 /etc/iscsi/initiatorname.iscsi;
fi;
"],
"volumeMounts": [
{
"name": "iscsi-info",
"mountPath": "/etc/iscsi"
}
]
}
]'
spec:
hostNetwork: True
nodeSelector:
{{ $selectorKey }}: {{ $selectorValue | quote }}
{{- if not $localVals.libvirt_tcp }}
hostIPC: True
{{- end }}
containers:
- name: main
imagePullPolicy: {{ $imagePullPolicy | quote }}
image: "{{ $imageFull }}"
securityContext:
privileged: true
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
- mountPath: {{ $containerConfigDirectory }}
name: nova-config
- 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: /etc/iscsi
name: iscsi-info
env:
{{- include "common_env_vars" $env | indent 12 }}
{{- include "common_containers" $env | indent 8 }}
volumes:
{{- include "common_volumes" $env | indent 8 }}
- name: nova-compute-config
configMap:
name: {{ $elementName }}
- name: nova-compute-persistent-storage
hostPath:
path: /var/lib/nova
- 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: {}
- name: iscsi-info
hostPath:
path: /var/lib/kolla/iscsi
{{- if $localVals.ceph_backend }}
- name: ceph-conf
configMap:
name: ceph-conf
- name: ceph-client-nova-keyring
secret:
secretName: ceph-client-nova-keyring
{{- end }}
{{- end }}