kolla-kubernetes/helm/microservice/test-ceph-init-mon-job/templates/test_ceph_init_mon_job.yaml

87 lines
3.9 KiB
YAML

{{- $resourceName := "test-ceph-init-mon-job" }}
{{- $searchPath := ":global.kolla.ceph.mon.init.job: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 ) }}
{{- $node := include "kolla_val_get_str" (dict "key" "node" "searchPath" $searchPath "Values" .Values ) }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" $searchPath "Values" .Values ) }}
{{- $netHostTrue := true }}
{{- $podTypeBootstrap := false }}
{{- with $env := dict "netHostTrue" $netHostTrue "podTypeBootstrap" false "resourceName" $resourceName "Values" .Values "Release" .Release "searchPath" $searchPath }}
apiVersion: batch/v1
kind: Job
metadata:
name: test-ceph-init-mon
spec:
template:
spec:
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: True
hostPID: True
nodeSelector:
kubernetes.io/hostname: {{ $node }}
initContainers:
- name: update-config
image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
command:
- /bin/sh
- -xec
- |
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) || true;
IP=$(ip addr list {{ $storageInterface }} | grep 'inet ' |cut -d' ' -f6|cut -d/ -f1);
CONF=/srv/pod-main-config/ceph.conf;
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 = {{ $node }}' $CONF;
cat $CONF;
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
- |
export MON_IP=$(grep '^mon host' {{ $containerConfigDirectory }}/ceph.conf | awk '{print $4}');
kolla_start
echo -n 'FETCH_CEPH_KEYS: '; fetch_ceph_keys.py
env:
{{- include "common_bootstrap_env_vars" . | indent 12 }}
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
- mountPath: {{ $containerConfigDirectory }}
name: pod-main-config
readOnly: true
- mountPath: /var/lib/ceph
name: ceph-mon
volumes:
{{- include "common_volumes" $env | indent 8 }}
- name: pod-main-config
emptyDir: {}
- name: ceph-mon-config
configMap:
name: ceph-mon
- name: ceph-mon
hostPath:
path: /var/lib/kolla/volumes/ceph-mon
restartPolicy: OnFailure
{{- end }}