From 1289be43cb6ac63cf5a2129566d5766d1d1e4577 Mon Sep 17 00:00:00 2001 From: Kevin Fox Date: Mon, 17 Apr 2017 10:34:13 -0700 Subject: [PATCH] Test Ceph OSD Chart This PS finishes the migration of the test Ceph to Helm. Change-Id: I669976c366edfbb42b41152c934be7fc9557ee9a --- .../microservice/test-ceph-osd-pod/Chart.yaml | 13 ++ .../test-ceph-osd-pod/requirements.yaml | 4 + .../templates/test-ceph-osd-pod.yaml | 119 ++++++++++++++++++ tests/bin/build_test_ceph.sh | 15 ++- 4 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 helm/microservice/test-ceph-osd-pod/Chart.yaml create mode 100644 helm/microservice/test-ceph-osd-pod/requirements.yaml create mode 100644 helm/microservice/test-ceph-osd-pod/templates/test-ceph-osd-pod.yaml diff --git a/helm/microservice/test-ceph-osd-pod/Chart.yaml b/helm/microservice/test-ceph-osd-pod/Chart.yaml new file mode 100644 index 000000000..01c346546 --- /dev/null +++ b/helm/microservice/test-ceph-osd-pod/Chart.yaml @@ -0,0 +1,13 @@ +name: test-ceph-osd-pod +version: 0.7.0-1 #FIXME make this changable +description: ceph-osd pod for kolla-kubernetes +keywords: + - openstack + - test + - ceph + - osd + - pod +sources: + - http://github.com/openstack +engine: gotpl +#icon: A URL to an SVG or PNG image to be used as an icon (optional). make this point to the new project icons when ready diff --git a/helm/microservice/test-ceph-osd-pod/requirements.yaml b/helm/microservice/test-ceph-osd-pod/requirements.yaml new file mode 100644 index 000000000..038deff5a --- /dev/null +++ b/helm/microservice/test-ceph-osd-pod/requirements.yaml @@ -0,0 +1,4 @@ +dependencies: + - name: kolla-common + repository: file://../../kolla-common + version: 0.7.0-1 diff --git a/helm/microservice/test-ceph-osd-pod/templates/test-ceph-osd-pod.yaml b/helm/microservice/test-ceph-osd-pod/templates/test-ceph-osd-pod.yaml new file mode 100644 index 000000000..0572eeaa5 --- /dev/null +++ b/helm/microservice/test-ceph-osd-pod/templates/test-ceph-osd-pod.yaml @@ -0,0 +1,119 @@ +{{- $resourceName := "test-ceph-osd-pod" }} +{{- $searchPath := ":global.kolla.ceph.osd.pod:global.kolla.ceph.osd.all:global.kolla.ceph.all:global.kolla.all" }} +{{- $c := dict "searchPath" $searchPath "Values" .Values }} +{{- $_ := set $c "contName" "ceph-osd" }} +{{- $_ := 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 ) }} +{{- $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 ) }} +{{- $index := .Values.index }} +{{- $initial_mon := .Values.initial_mon }} +{{- $netHostTrue := true }} +{{- $podTypeBootstrap := false }} +{{- with $env := dict "netHostTrue" $netHostTrue "podTypeBootstrap" false "resourceName" $resourceName "Values" .Values "Release" .Release "searchPath" $searchPath }} +apiVersion: v1 +kind: Pod +metadata: + name: ceph-osd{{ $index }} + annotations: +#FIXME Once out of alpha, this should be converted to yaml. + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "update-config", + "image": {{ include "kolla_toolbox_image_full" . | quote }}, + "imagePullPolicy": "IfNotPresent", + "command": [ + "/bin/sh", + "-c", + "cp -a /srv/configmap/..data/* /srv/pod-main-config/; + STORAGE_INTERFACE={{ $storageInterface }}; + F=/var/lib/kolla-kubernetes/ceph-osd/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 = {{ $initial_mon }}'' $CONF; + sed -i ''s/@HOSTADDR@/''$IP''/g;s/@CLUSTERADDR@/''$IP''/g'' /srv/pod-main-config/config.json;" + ], + "volumeMounts": [ + { + "name": "ceph-osd-config", + "mountPath": "/srv/configmap" + }, + { + "name": "pod-main-config", + "mountPath": "/srv/pod-main-config" + }, + { + "name": "ceph-osd", + "mountPath": "/var/lib/ceph/osd" + } + ] + } + ]' +spec: + hostNetwork: True + hostPID: True + nodeSelector: + kubernetes.io/hostname: {{ $initial_mon }} + restartPolicy: Never + containers: + - image: "{{ $imageFull }}" + imagePullPolicy: {{ $imagePullPolicy }} + name: main + command: + - /bin/bash + - -exc + - | + mount /dev/loop{{ $index }}p2 /var/lib/ceph/osd/ceph-{{ $index }} + kolla_start + securityContext: + privileged: true + env: + - name: KOLLA_CONFIG_STRATEGY + value: COPY_ONCE + - name: OSD_ID + value: "{{ $index }}" + - name: JOURNAL_PARTITION + value: "/dev/loop{{ $index }}p1" + - name: HOSTNAME + value: {{ $initial_mon }} + volumeMounts: +{{- include "common_volume_mounts" $env | indent 8 }} + - 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-osd + - mountPath: {{ $containerConfigDirectory }}/ceph.client.admin.keyring + subPath: data + name: ceph-client-admin-keyring + - mountPath: /dev + name: host-dev + volumes: +{{- include "common_volumes" $env | indent 4 }} + - name: pod-main-config + emptyDir: {} + - name: ceph-osd-config + configMap: + name: ceph-osd + - name: ceph-osd + hostPath: + path: /var/lib/kolla/volumes/ceph-osd + - name: host-dev + hostPath: + path: /dev + - name: ceph-client-admin-keyring + secret: + secretName: ceph-client-admin-keyring +{{- end }} diff --git a/tests/bin/build_test_ceph.sh b/tests/bin/build_test_ceph.sh index 9281cef44..3dd38e7a9 100755 --- a/tests/bin/build_test_ceph.sh +++ b/tests/bin/build_test_ceph.sh @@ -88,8 +88,19 @@ wait_for_ceph_bootstrap kolla helm delete --purge test-ceph-init-osd0-job helm delete --purge test-ceph-init-osd1-job -kollakube res create pod ceph-osd0 -kollakube res create pod ceph-osd1 + +helm install kolla/test-ceph-osd-pod --version $VERSION \ + --namespace kolla \ + --name ceph-osds0 \ + --values /tmp/general_config.yaml \ + --values /tmp/ceph_config.yaml \ + --set index=0 +helm install kolla/test-ceph-osd-pod --version $VERSION \ + --namespace kolla \ + --name ceph-osds1 \ + --values /tmp/general_config.yaml \ + --values /tmp/ceph_config.yaml \ + --set index=1 $DIR/tools/wait_for_pods.sh kolla