kolla-kubernetes/helm/microservice/ironic-inspector-deployment/templates/ironic-inspector.yaml

216 lines
9.8 KiB
YAML

{{- $searchPath := ":global.kolla.ironic.inspector.deployment:global.kolla.ironic.inspector.all:global.kolla.ironic.all:global.kolla.all" }}
{{- $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 ) }}
{{- $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 ) }}
{{- $portName := "inspector" }}
{{- $resourceName := "ironic-inspector" }}
{{- $netHostTrue := true }}
{{- $podTypeBootstrap := false }}
{{- $serviceName := "ironic" }}
{{- $serviceType := "inspector" }}
{{- $privileged := true }}
{{- $c := dict "searchPath" $searchPath "Values" .Values }}
{{- $_ := set $c "contName" "dnsmasq" }}
{{- $_ := set $c "imageName" "dnsmasq_image_full" }}
{{- $_ := set $c "tagName" "dnsmasq_image_tag" }}
{{- $imageFullDnsmasq := include "kolla_build_image_full" $c }}
{{- $c := dict "searchPath" $searchPath "Values" .Values }}
{{- $_ := set $c "contName" "ironic-pxe" }}
{{- $_ := set $c "imageName" "ironic_pxe_image_full" }}
{{- $_ := set $c "tagName" "ironic_pxe_image_tag" }}
{{- $imageFullPXE := include "kolla_build_image_full" $c }}
{{- $c := dict "searchPath" $searchPath "Values" .Values }}
{{- $_ := set $c "contName" "ironic-inspector" }}
{{- $_ := set $c "imageName" "image_full" }}
{{- $_ := set $c "tagName" "image_tag" }}
{{- $imageFull := include "kolla_build_image_full" $c }}
{{- $ironicInterface := include "kolla_val_get_str" (dict "key" "ironic_interface" "searchPath" $searchPath "Values" .Values ) }}
{{- $elementName := .Values.element_name | default $resourceName }}
{{- $url1 := include "kolla_val_get_str" (dict "key" "initramfs_url" "searchPath" $searchPath "Values" .Values )}}
{{- $url2 := include "kolla_val_get_str" (dict "key" "kernel_url" "searchPath" $searchPath "Values" .Values )}}
{{- $ironicInterface := include "kolla_val_get_str" (dict "key" "ironic_interface" "searchPath" $searchPath "Values" .Values )}}
{{- $ironicInspectionCIDR := include "kolla_val_get_str" (dict "key" "ironic_inspection_cidr" "searchPath" $searchPath "Values" .Values )}}
{{- $ironicDHCPrange := include "kolla_val_get_str" (dict "key" "ironic_dhcp_range" "searchPath" $searchPath "Values" .Values )}}
{{- $ironicInspectLLDP := include "kolla_val_get_str" (dict "key" "inspect_lldp" "searchPath" $searchPath "Values" .Values )}}
{{- 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: Deployment
metadata:
name: {{ $resourceName }}
labels:
component: {{ $serviceName }}
system: {{ $elementName }}
spec:
replicas: {{ $replicas }}
template:
metadata:
labels:
service: {{ $serviceName }}
type: {{ $serviceType }}
annotations:
pod.beta.kubernetes.io/init-containers: '[
{{- include "common_dependency_container_multi" $env | indent 10 }}
{
"name": "initialize-ironic-dnsmasq",
"image": {{ include "kolla_toolbox_image_full" . | quote }},
"imagePullPolicy": {{ $imagePullPolicy | quote }},
"command": [
"sh",
"-xec",
"IP=$(ip addr show dev {{ $ironicInterface }} to {{ $ironicInspectionCIDR }} | grep -m1 -G ''inet'' | awk ''{print $2}'' | cut -d ''/'' -f 1);
if test -z $IP; then exit 1; fi;
cp -a /config/dnsmasq/..data/* /dnsmasq/;
cp -a /config/pxe/..data/* /pxe/;
curl -L {{ $url1 }} -o /tftpboot/ironic-agent.initramfs;
curl -L {{ $url2 }} -o /tftpboot/ironic-agent.kernel;
jq ''.command = \"in.tftpd -v -L -u root -a ''$IP'':69 --map-file /map-file /tftpboot\"'' /config/pxe/..data/config.json > /pxe/config.json;
sed -i ''s|ironic-inspector|''$IP''|g'' /pxe/default;
{{- if $ironicInspectLLDP }}
sed -i ''/^append/ s/$/ ipa-collect-lldp=1/'' /pxe/default;
{{- end }}
sed -i ''s|interface=.*|interface={{ $ironicInterface }}|g'' /dnsmasq/dnsmasq.conf;
sed -i ''s|dhcp-option=option:tftp-server,.*|dhcp-option=option:tftp-server,''$IP''|g'' /dnsmasq/dnsmasq.conf;
sed -i ''s|dhcp-option=option:server-ip-address,.*|dhcp-option=option:server-ip-address,''$IP''|g'' /dnsmasq/dnsmasq.conf;
sed -i ''s|dhcp-range=.*|dhcp-range={{ $ironicDHCPrange }}|g'' /dnsmasq/dnsmasq.conf;
"],
"volumeMounts": [
{
"name": "kolla-logs",
"mountPath": "/var/log/kolla/"
},
{
"name": "dnsmasq-config",
"mountPath": "/config/dnsmasq"
},
{
"name": "ironic-pxe-config",
"mountPath": "/pxe/"
},
{
"name": "pxe-config",
"mountPath": "/config/pxe"
},
{
"name": "ironic-dnsmasq-config",
"mountPath": "/dnsmasq/"
},
{
"name": "tftpboot",
"mountPath": "/tftpboot/"
}
]
},
{
"name": "pxelinux",
"image": {{ $imageFullPXE | quote }},
"imagePullPolicy": {{ $imagePullPolicy | quote }},
"command": [
"sh",
"-xec",
"if [ -f /var/lib/tftpboot/pxelinux.0 ]; then
cp /var/lib/tftpboot/pxelinux.0 /tftpboot;
fi;
if [ -f /usr/share/syslinux/chain.c32 ]; then
cp /usr/share/syslinux/chain.c32 /tftpboot;
fi;
if [ -f /usr/lib/PXELINUX/pxelinux.0 ]; then
cp /usr/lib/PXELINUX/pxelinux.0 /tftpboot;
fi;
if [ -f /usr/lib/syslinux/modules/bios/chain.c32 ]; then
cp /usr/lib/syslinux/modules/bios/chain.c32 /tftpboot;
fi;
"],
"volumeMounts": [
{
"name": "tftpboot",
"mountPath": "/tftpboot/"
}
]
},
{
"name": "update-inspector-config",
"image": {{ include "kolla_toolbox_image_full" . | quote }},
"imagePullPolicy": {{ $imagePullPolicy | quote }},
"command": [
"/bin/sh",
"-c",
"cp -a /srv/configmap/..data/* /srv/pod-main-config/;
crudini --set /srv/pod-main-config/inspector.conf firewall dnsmasq_interface {{ $ironicInterface }};
"],
"volumeMounts": [
{
"name": "inspector-config",
"mountPath": "/srv/configmap"
},
{
"name": "ironic-inspector-config",
"mountPath": "/srv/pod-main-config"
}
]
}
]'
spec:
hostNetwork: True
nodeSelector:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- name: pxe
imagePullPolicy: {{ $imagePullPolicy | quote }}
image: "{{ $imageFullPXE }}"
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
- mountPath: {{ $containerConfigDirectory }}
name: ironic-pxe-config
- mountPath: /tftpboot
name: tftpboot
env:
{{- include "common_env_vars" $env | indent 12 }}
- name: dnsmasq
securityContext:
privileged: true
imagePullPolicy: {{ $imagePullPolicy | quote }}
image: "{{ $imageFullDnsmasq }}"
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
- mountPath: {{ $containerConfigDirectory }}
name: ironic-dnsmasq-config
- mountPath: /tftpboot
name: tftpboot
env:
{{- include "common_env_vars" $env | indent 12 }}
- name: main
securityContext:
privileged: true
imagePullPolicy: {{ $imagePullPolicy | quote }}
image: "{{ $imageFull }}"
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
- mountPath: {{ $containerConfigDirectory }}
name: ironic-inspector-config
env:
{{- include "common_env_vars" $env | indent 12 }}
{{- include "common_containers" $env | indent 8 }}
volumes:
{{- include "common_volumes" $env | indent 8 }}
- name: dnsmasq-config
configMap:
name: ironic-dnsmasq
- name: ironic-dnsmasq-config
emptyDir: {}
- name: tftpboot
emptyDir: {}
- name: pxe-config
configMap:
name: ironic-inspector-tftp
- name: ironic-pxe-config
emptyDir: {}
- name: ironic-inspector-config
emptyDir: {}
- name: inspector-config
configMap:
name: ironic-inspector
{{- end }}