kolla-kubernetes/helm/microservice/test-ceph-mon-daemonset/templates/test_ceph_mon_daemonset.yaml

129 lines
5.4 KiB
YAML

{{- $resourceName := "test-ceph-mon-daemonset" }}
{{- $searchPath := ":global.kolla.ceph.mon.daemonset:global.kolla.ceph.mon.all:global.kolla.ceph.all:global.kolla.all" }}
{{- $c := dict "searchPath" $searchPath "Values" .Values }}
{{- $_ := set $c "contName" "ceph-mon" }}
{{- $_ := set $c "imageName" "image_full" }}
{{- $_ := set $c "tagName" "image_tag" }}
{{- $imageFull := include "kolla_build_image_full" $c }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "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 ) }}
{{- $storageInterface := include "kolla_val_get_str" (dict "key" "storage_interface" "searchPath" $searchPath "Values" .Values ) }}
{{- $initialMember := include "kolla_val_get_str" (dict "key" "initial_member" "searchPath" $searchPath "Values" .Values ) }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" $searchPath "Values" .Values ) }}
{{- $netHostTrue := true }}
{{- $podTypeBootstrap := false }}
{{- $localVals := dict }}
{{- $c := dict "searchPath" .searchPath "Values" .Values }}
{{- $_ := set $c "key" "ceph.monitors" }}
{{- $_ := set $c "retDict" $localVals }}
{{- $_ := set $c "retKey" "monitors" }}
{{- $_ := include "kolla_val_get_raw" $c }}
{{- with $env := dict "netHostTrue" $netHostTrue "podTypeBootstrap" false "resourceName" $resourceName "Values" .Values "Release" .Release "searchPath" $searchPath }}
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: test-ceph-mon
labels:
component: ceph
system: mon
spec:
template:
metadata:
labels:
component: ceph
system: mon
spec:
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: True
hostPID: True
nodeSelector:
{{ $selectorKey }}: {{ $selectorValue | quote }}
initContainers:
- 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/;
STORAGE_INTERFACE={{ $storageInterface }};
F=/var/lib/kolla-kubernetes/ceph-mon/storage_interface;
[ -f $F ] && STORAGE_INTERFACE=$(<$F);
IP=$(ip addr list {{ $storageInterface }} | grep 'inet ' |cut -d' ' -f6|cut -d/ -f1);
CONF=/srv/pod-main-config/ceph.conf;
found=0;
{{- range $localVals.monitors }}
[ $IP == '{{ . }}' ] && found=1 || true;
{{- end }}
echo $found > /srv/pod-main-config/inlist;
sed -i '/^mon host.*/d;/^mon host/d;/^mon addr/d' $CONF;
sed -i '/^\[global\]/a mon host = '$IP $CONF;
sed -i '/^\[global\]/a mon addr = '$IP':6789' $CONF;
sed -i '/^\[global\]/a mon initial members = {{ $initialMember }}' $CONF;
sed -i 's/@MONID@/'$(hostname)'/;s/@MONADDR@/'$IP'/' /srv/pod-main-config/config.json;
volumeMounts:
- name: ceph-mon-config
mountPath: /srv/configmap
- name: pod-main-config
mountPath: /srv/pod-main-config
- name: ceph-mon
mountPath: /var/lib/ceph/mon
containers:
- image: {{ $imageFull | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
command:
- /bin/bash
- -ec
- |
if [ $(cat {{ $containerConfigDirectory }}/inlist) == "0" ]; then
echo "Not a mon... blocking.";
while true; do sleep 10000; done;
fi;
kolla_start
env:
{{- include "common_env_vars" . | indent 12 }}
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
- mountPath: {{ $containerConfigDirectory }}/ceph.conf
name: pod-main-config
readOnly: true
subPath: ceph.conf
- mountPath: {{ $containerConfigDirectory }}/config.json
name: pod-main-config
readOnly: true
subPath: config.json
- mountPath: /var/lib/ceph
name: ceph-mon
- mountPath: {{ $containerConfigDirectory }}/ceph.client.mon.keyring
subPath: data
name: ceph-client-mon-keyring
- mountPath: {{ $containerConfigDirectory }}/ceph.client.admin.keyring
subPath: data
name: ceph-client-admin-keyring
- mountPath: {{ $containerConfigDirectory }}/ceph.monmap
subPath: data
name: ceph-monmap
volumes:
{{- include "common_volumes" $env | indent 8 }}
- name: pod-main-config
emptyDir: {}
- name: ceph-mon-config
configMap:
name: ceph-mon
- name: ceph-client-mon-keyring
secret:
secretName: ceph-client-mon-keyring
- name: ceph-client-admin-keyring
secret:
secretName: ceph-client-admin-keyring
- name: ceph-monmap
secret:
secretName: ceph-monmap
- name: ceph-mon
hostPath:
path: /var/lib/kolla/volumes/ceph-mon
{{- end }}