Merge pull request #294 from larryrensing/feat/bootstrap-services-glance

feat: image bootstrap for glance
This commit is contained in:
wilkers-steve 2017-04-06 16:17:07 -05:00 committed by GitHub
commit 7fc4a735af
4 changed files with 143 additions and 0 deletions

View File

@ -0,0 +1,41 @@
#!/bin/bash
# Copyright 2017 The Openstack-Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
export HOME=/tmp
{{ if .Values.bootstrap.enabled }}
cd /tmp/images
{{ range .Values.bootstrap.images }}
openstack image show {{ .name | quote }} || \
{ curl -O {{ .source_url }}{{ .image_file }}; \
openstack image create {{ .name | quote }} \
--min-disk {{ .min_disk }} \
--disk-format {{ .image_type }} \
--file {{ .image_file }} \
{{ if .properties -}} {{ range $key, $value := .properties }}--property {{$key}}={{$value}} {{ end }}{{ end -}} \
--container-format {{ .container_format | quote }} \
{{ if .private -}}
--private
{{- else -}}
--public
{{- end -}}; }
{{ end }}
{{ end }}
exit 0

View File

@ -27,3 +27,5 @@ data:
{{- include "helm-toolkit.keystone_endpoints" . | indent 4 }}
ks-user.sh: |+
{{- include "helm-toolkit.keystone_user" . | indent 4 }}
bootstrap.sh: |+
{{ tuple "bin/_bootstrap.sh.tpl" . | include "helm-toolkit.template" | indent 4 }}

View File

@ -0,0 +1,70 @@
# Copyright 2017 The Openstack-Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{{- $envAll := . }}
{{- $ksAdminSecret := $envAll.Values.keystone.admin_secret | default "glance-env-keystone-admin" }}
{{- $dependencies := .Values.dependencies.bootstrap }}
apiVersion: batch/v1
kind: Job
metadata:
name: glance-bootstrap
spec:
template:
metadata:
annotations:
pod.beta.kubernetes.io/init-containers: '[
{{ tuple $envAll $dependencies | include "helm-toolkit.kubernetes_entrypoint_init_container" | indent 10 }}
]'
spec:
restartPolicy: OnFailure
nodeSelector:
{{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
containers:
- name: glance-bootstrap
image: {{ .Values.images.db_init }}
imagePullPolicy: {{ .Values.images.pull_policy }}
{{- if .Values.resources.enabled }}
resources:
limits:
cpu: {{ .Values.resources.jobs.bootstrap.limits.cpu | quote }}
memory: {{ .Values.resources.jobs.bootstrap.limits.memory | quote }}
requests:
cpu: {{ .Values.resources.jobs.bootstrap.requests.cpu | quote }}
memory: {{ .Values.resources.jobs.bootstrap.requests.memory | quote }}
{{- end }}
env:
{{- with $env := dict "ksUserSecret" $ksAdminSecret }}
{{- include "helm-toolkit.keystone_openrc_env_vars" $env | indent 12 }}
{{- end }}
command:
- bash
- /tmp/bootstrap.sh
volumeMounts:
- name: imagedir
mountPath: /tmp/images
- name: bootstrapsh
mountPath: /tmp/bootstrap.sh
subPath: bootstrap.sh
- name: glanceapiconf
mountPath: /etc/glance/glance-api.conf
subPath: glance-api.conf
volumes:
- name: imagedir
emptyDir: {}
- name: bootstrapsh
configMap:
name: glance-bin
- name: glanceapiconf
configMap:
name: glance-etc

View File

@ -47,6 +47,21 @@ upgrades:
max_unavailable: 1
max_surge: 3
bootstrap:
enabled: true
images:
ubuntu_precise64:
name: "Ubuntu Precise 64-bit"
source_url: "http://cloud-images.ubuntu.com/precise/current/"
image_file: "precise-server-cloudimg-amd64-disk1.img"
min_disk: 20
image_type: qcow2
container_format: bare
private: true
properties:
hypervisor_type: "qemu"
os_distro: "ubuntu"
keystone:
admin_user: "admin"
admin_user_domain: "default"
@ -129,6 +144,13 @@ resources:
requests:
memory: "128Mi"
cpu: "500m"
bootstrap:
limits:
memory: "128Mi"
cpu: "500m"
requests:
memory: "128Mi"
cpu: "500m"
dependencies:
db_init:
@ -141,6 +163,14 @@ dependencies:
- glance-db-init
service:
- mariadb
bootstrap:
jobs:
- glance-db-sync
- glance-ks-user
- glance-ks-endpoints
service:
- mariadb
- glance-api
ks_user:
service:
- keystone-api