From ba37e1cabe079bdaada44e5782cfc14bbc27e6a2 Mon Sep 17 00:00:00 2001 From: DTadrzak Date: Tue, 6 Dec 2016 17:21:39 +0100 Subject: [PATCH] Adding support for glance serivce. Signed-off-by: DTadrzak --- glance/Chart.yaml | 3 + glance/requirements.yaml | 19 ++++ glance/templates/_helpers.tpl | 5 + glance/templates/api.yaml | 80 +++++++++++++++ .../templates/ceph.client.glance.keyring.yaml | 9 ++ glance/templates/ceph.conf.yaml | 18 ++++ glance/templates/db-sync.sh.yaml | 10 ++ glance/templates/db-sync.yaml | 55 +++++++++++ glance/templates/glance-api.conf.yaml | 47 +++++++++ glance/templates/glance-registry.conf.yaml | 34 +++++++ glance/templates/init.sh.yaml | 12 +++ glance/templates/init.yaml | 52 ++++++++++ glance/templates/post.sh.yaml | 14 +++ glance/templates/post.yaml | 49 +++++++++ glance/templates/registry.yaml | 57 +++++++++++ glance/templates/service-api.yaml | 9 ++ glance/templates/service-registry.yaml | 9 ++ glance/templates/start.sh.yaml | 12 +++ glance/values.yaml | 99 +++++++++++++++++++ 19 files changed, 593 insertions(+) create mode 100644 glance/Chart.yaml create mode 100644 glance/requirements.yaml create mode 100644 glance/templates/_helpers.tpl create mode 100644 glance/templates/api.yaml create mode 100644 glance/templates/ceph.client.glance.keyring.yaml create mode 100644 glance/templates/ceph.conf.yaml create mode 100644 glance/templates/db-sync.sh.yaml create mode 100644 glance/templates/db-sync.yaml create mode 100644 glance/templates/glance-api.conf.yaml create mode 100644 glance/templates/glance-registry.conf.yaml create mode 100644 glance/templates/init.sh.yaml create mode 100644 glance/templates/init.yaml create mode 100644 glance/templates/post.sh.yaml create mode 100644 glance/templates/post.yaml create mode 100644 glance/templates/registry.yaml create mode 100644 glance/templates/service-api.yaml create mode 100644 glance/templates/service-registry.yaml create mode 100644 glance/templates/start.sh.yaml create mode 100644 glance/values.yaml diff --git a/glance/Chart.yaml b/glance/Chart.yaml new file mode 100644 index 0000000000..016ef755de --- /dev/null +++ b/glance/Chart.yaml @@ -0,0 +1,3 @@ +description: A Helm chart for glance +name: glance +version: 0.1.0 diff --git a/glance/requirements.yaml b/glance/requirements.yaml new file mode 100644 index 0000000000..6fc22a5704 --- /dev/null +++ b/glance/requirements.yaml @@ -0,0 +1,19 @@ +dependencies: + - name: common + repository: http://localhost:8879/charts + version: 0.1.0 + - name: mariadb + repository: http://localhost:8879/charts + version: 0.1.0 + - name: rabbitmq + repository: http://localhost:8879/charts + version: 0.1.0 + - name: memcached + repository: http://localhost:8879/charts + version: 0.1.0 + - name: keystone + repository: http://localhost:8879/charts + version: 0.1.0 + - name: keystone + repository: http://localhost:8879/charts + version: 0.1.0 \ No newline at end of file diff --git a/glance/templates/_helpers.tpl b/glance/templates/_helpers.tpl new file mode 100644 index 0000000000..fafa1447a6 --- /dev/null +++ b/glance/templates/_helpers.tpl @@ -0,0 +1,5 @@ +{{- define "joinListWithColon" -}} +{{ range $k, $v := . }}{{ if $k }},{{ end }}{{ $v }}{{ end }} +{{- end -}} + +{{ define "keystone_auth" }}auth: "{'auth_url':'{{ .Values.keystone.auth_url }}', 'username':'{{ .Values.keystone.admin_user }}','password':'{{ .Values.keystone.admin_password }}','project_name':'{{ .Values.keystone.admin_project_name }}','domain_name':'default'}"{{end}} diff --git a/glance/templates/api.yaml b/glance/templates/api.yaml new file mode 100644 index 0000000000..979df7cd41 --- /dev/null +++ b/glance/templates/api.yaml @@ -0,0 +1,80 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: glance-api +spec: + replicas: {{ .Values.replicas }} + template: + metadata: + labels: + app: glance-api + annotations: + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "init", + "image": "quay.io/stackanetes/kubernetes-entrypoint:v0.1.0", + "env": [ + { + "name": "NAMESPACE", + "value": "{{ .Release.Namespace }}" + }, + { + "name": "DEPENDENCY_SERVICE", + "value": "{{ include "joinListWithColon" .Values.dependencies.api.service }}" + }, + { + "name": "DEPENDENCY_JOBS", + "value": "{{ include "joinListWithColon" .Values.dependencies.api.jobs }}" + }, + { + "name": "COMMAND", + "value": "echo done" + } + ] + } + ]' + spec: + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + containers: + - name: glance-api + image: {{ .Values.images.api }} + imagePullPolicy: Always + command: + - bash + - /tmp/start.sh + ports: + - containerPort: {{ .Values.network.port.api }} + readinessProbe: + tcpSocket: + port: {{ .Values.network.port.api }} + volumeMounts: + - name: glanceapiconf + mountPath: /etc/glance/glance-api.conf + subPath: glance-api.conf + - name: startsh + mountPath: /tmp/start.sh + subPath: start.sh + - name: etcglance + mountPath: /etc/glance + - name: cephconf + mountPath: /etc/ceph/ceph.conf + subPath: ceph.conf + - name: cephclientglancekeyring + mountPath: /etc/ceph/ceph.client.{{ .Values.ceph.glance_user }}.keyring + subPath: ceph.client.{{ .Values.ceph.glance_user }}.keyring + volumes: + - name: glanceapiconf + configMap: + name: glance-glanceapiconf + - name: startsh + configMap: + name: glance-startsh + - name: cephconf + configMap: + name: glance-cephconf + - name: cephclientglancekeyring + configMap: + name: glance-cephclientglancekeyring + - name: etcglance + emptyDir: {} diff --git a/glance/templates/ceph.client.glance.keyring.yaml b/glance/templates/ceph.client.glance.keyring.yaml new file mode 100644 index 0000000000..27eeac7ed2 --- /dev/null +++ b/glance/templates/ceph.client.glance.keyring.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glance-cephclientglancekeyring +data: + ceph.client.{{ .Values.ceph.glance_user }}.keyring: |+ + [client.{{ .Values.ceph.glance_user }}] + key = {{ .Values.ceph.glance_keyring }} + diff --git a/glance/templates/ceph.conf.yaml b/glance/templates/ceph.conf.yaml new file mode 100644 index 0000000000..28982f320e --- /dev/null +++ b/glance/templates/ceph.conf.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glance-cephconf +data: + ceph.conf: |+ + [global] + rgw_thread_pool_size = 1024 + rgw_num_rados_handles = 100 + [mon] + {{ range .Values.ceph.monitors }} + [mon.{{ . }}] + host = {{ . }} + mon_addr = {{ . }} + {{ end }} + [client] + rbd_cache_enabled = true + rbd_cache_writethrough_until_flush = true diff --git a/glance/templates/db-sync.sh.yaml b/glance/templates/db-sync.sh.yaml new file mode 100644 index 0000000000..78a95b4cd4 --- /dev/null +++ b/glance/templates/db-sync.sh.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glance-dbsyncsh +data: + db-sync.sh: |+ + #!/bin/bash + set -ex + + glance-manage db_sync diff --git a/glance/templates/db-sync.yaml b/glance/templates/db-sync.yaml new file mode 100644 index 0000000000..37e0685eea --- /dev/null +++ b/glance/templates/db-sync.yaml @@ -0,0 +1,55 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: glance-db-sync +spec: + template: + metadata: + annotations: + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "init", + "image": "quay.io/stackanetes/kubernetes-entrypoint:v0.1.0", + "env": [ + { + "name": "NAMESPACE", + "value": "{{ .Release.Namespace }}" + }, + { + "name": "DEPENDENCY_SERVICE", + "value": "{{ include "joinListWithColon" .Values.dependencies.db_sync.service }}" + }, + { + "name": "DEPENDENCY_JOBS", + "value": "{{ include "joinListWithColon" .Values.dependencies.db_sync.jobs }}" + }, + { + "name": "COMMAND", + "value": "echo done" + } + ] + } + ]' + spec: + restartPolicy: OnFailure + containers: + - name: glance-db-sync + image: {{ .Values.images.db_sync }} + imagePullPolicy: Always + command: + - bash + - /tmp/db-sync.sh + volumeMounts: + - name: glanceapiconf + mountPath: /etc/glance/glance-api.conf + subPath: glance-api.conf + - name: dbsyncsh + mountPath: /tmp/db-sync.sh + subPath: db-sync.sh + volumes: + - name: glanceapiconf + configMap: + name: glance-glanceapiconf + - name: dbsyncsh + configMap: + name: glance-dbsyncsh diff --git a/glance/templates/glance-api.conf.yaml b/glance/templates/glance-api.conf.yaml new file mode 100644 index 0000000000..b7e45d36e7 --- /dev/null +++ b/glance/templates/glance-api.conf.yaml @@ -0,0 +1,47 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glance-glanceapiconf +data: + glance-api.conf: |+ + [DEFAULT] + debug = {{ .Values.misc.debug }} + use_syslog = False + use_stderr = True + + bind_port = {{ .Values.network.port.api }} + + workers = {{ .Values.misc.workers }} + registry_host = glance-registry + + # Enable Copy-on-Write + show_image_direct_url = True + + [database] + connection = mysql+pymysql://{{ .Values.database.glance_user }}:{{ .Values.database.glance_password }}@{{ .Values.database.address }}/{{ .Values.database.glance_database_name }} + max_retries = -1 + + [keystone_authtoken] + auth_uri = {{ .Values.keystone.auth_uri }} + auth_url = {{ .Values.keystone.auth_url }} + auth_type = password + project_domain_id = default + user_domain_id = default + project_name = service + username = {{ .Values.keystone.glance_user }} + password = {{ .Values.keystone.glance_password }} + + [paste_deploy] + flavor = keystone + + [oslo_messaging_notifications] + driver = noop + + [glance_store] + filesystem_store_datadir = /var/lib/glance/images/ + stores = file, http, rbd + default_store = rbd + rbd_store_pool = {{ .Values.ceph.glance_pool }} + rbd_store_user = {{ .Values.ceph.glance_user }} + rbd_store_ceph_conf = /etc/ceph/ceph.conf + rbd_store_chunk_size = 8 diff --git a/glance/templates/glance-registry.conf.yaml b/glance/templates/glance-registry.conf.yaml new file mode 100644 index 0000000000..81629caa46 --- /dev/null +++ b/glance/templates/glance-registry.conf.yaml @@ -0,0 +1,34 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glance-glanceregistryconf +data: + glance-registry.conf: |+ + [DEFAULT] + debug = {{ .Values.misc.debug }} + use_syslog = False + use_stderr = True + + bind_port = {{ .Values.network.port.registry }} + + workers = {{ .Values.misc.workers }} + + [database] + connection = mysql+pymysql://{{ .Values.database.glance_user }}:{{ .Values.database.glance_password }}@{{ .Values.database.address }}/{{ .Values.database.glance_database_name }} + max_retries = -1 + + [keystone_authtoken] + auth_uri = {{ .Values.keystone.auth_uri }} + auth_url = {{ .Values.keystone.auth_url }} + auth_type = password + project_domain_id = default + user_domain_id = default + project_name = service + username = {{ .Values.keystone.glance_user }} + password = {{ .Values.keystone.glance_password }} + + [paste_deploy] + flavor = keystone + + [oslo_messaging_notifications] + driver = noop diff --git a/glance/templates/init.sh.yaml b/glance/templates/init.sh.yaml new file mode 100644 index 0000000000..8605f7c544 --- /dev/null +++ b/glance/templates/init.sh.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glance-initsh +data: + init.sh: |+ + #!/bin/bash + set -ex + export HOME=/tmp + + ansible localhost -vvv -m mysql_db -a "login_host='{{ .Values.database.address }}' login_port='{{ .Values.database.port }}' login_user='{{ .Values.database.root_user }}' login_password='{{ .Values.database.root_password }}' name='{{ .Values.database.glance_database_name }}'" + ansible localhost -vvv -m mysql_user -a "login_host='{{ .Values.database.address }}' login_port='{{ .Values.database.port }}' login_user='{{ .Values.database.root_user }}' login_password='{{ .Values.database.root_password }}' name='{{ .Values.database.glance_user }}' password='{{ .Values.database.glance_password }}' host='%' priv='{{ .Values.database.glance_database_name }}.*:ALL' append_privs='yes'" diff --git a/glance/templates/init.yaml b/glance/templates/init.yaml new file mode 100644 index 0000000000..d789bdb842 --- /dev/null +++ b/glance/templates/init.yaml @@ -0,0 +1,52 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: glance-init +spec: + template: + metadata: + annotations: + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "init", + "image": "quay.io/stackanetes/kubernetes-entrypoint:v0.1.0", + "env": [ + { + "name": "NAMESPACE", + "value": "{{ .Release.Namespace }}" + }, + { + "name": "DEPENDENCY_SERVICE", + "value": "{{ include "joinListWithColon" .Values.dependencies.init.service }}" + }, + { + "name": "DEPENDENCY_JOBS", + "value": "{{ include "joinListWithColon" .Values.dependencies.init.jobs }}" + }, + { + "name": "COMMAND", + "value": "echo done" + } + ] + } + ]' + spec: + restartPolicy: OnFailure + containers: + - name: glance-init + image: {{ .Values.images.init }} + imagePullPolicy: Always + env: + - name: ANSIBLE_LIBRARY + value: /usr/share/ansible/ + command: + - bash + - /tmp/init.sh + volumeMounts: + - name: initsh + mountPath: /tmp/init.sh + subPath: init.sh + volumes: + - name: initsh + configMap: + name: glance-initsh diff --git a/glance/templates/post.sh.yaml b/glance/templates/post.sh.yaml new file mode 100644 index 0000000000..bd7b82219d --- /dev/null +++ b/glance/templates/post.sh.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glance-postsh +data: + post.sh: |+ + #!/bin/bash + set -ex + export HOME=/tmp + + ansible localhost -vvv -m kolla_keystone_service -a "service_name=glance service_type=image description='Openstack Image' endpoint_region={{ .Values.keystone.glance_region_name }} url='http://glance-api:{{ .Values.network.port.api }}' interface=admin region_name={{ .Values.keystone.admin_region_name }} auth='{{ include "keystone_auth" . }}'" -e "{ 'openstack_glance_auth': {{ include "keystone_auth" . }} }" + ansible localhost -vvv -m kolla_keystone_service -a "service_name=glance service_type=image description='Openstack Image' endpoint_region={{ .Values.keystone.glance_region_name }} url='http://glance-api:{{ .Values.network.port.api }}' interface=internal region_name={{ .Values.keystone.admin_region_name }} auth='{{ include "keystone_auth" . }}'" -e "{ 'openstack_glance_auth': {{ include "keystone_auth" . }} }" + ansible localhost -vvv -m kolla_keystone_service -a "service_name=glance service_type=image description='Openstack Image' endpoint_region={{ .Values.keystone.glance_region_name }} url='http://glance-api:{{ .Values.network.port.api }}' interface=public region_name={{ .Values.keystone.admin_region_name }} auth='{{ include "keystone_auth" . }}' " -e "{ 'openstack_glance_auth': {{ include "keystone_auth" . }} }" + ansible localhost -vvv -m kolla_keystone_user -a "project=service user={{ .Values.keystone.glance_user }} password={{ .Values.keystone.glance_password }} role=admin region_name={{ .Values.keystone.admin_region_name }} auth='{{ include "keystone_auth" . }}'" -e "{'openstack_glance_auth': {{ include "keystone_auth" .}}}" diff --git a/glance/templates/post.yaml b/glance/templates/post.yaml new file mode 100644 index 0000000000..a7a333902a --- /dev/null +++ b/glance/templates/post.yaml @@ -0,0 +1,49 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: glance-post +spec: + template: + metadata: + annotations: + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "init", + "image": "quay.io/stackanetes/kubernetes-entrypoint:v0.1.0", + "env": [ + { + "name": "NAMESPACE", + "value": "{{ .Release.Namespace }}" + }, + { + "name": "DEPENDENCY_SERVICE", + "value": "{{ include "joinListWithColon" .Values.dependencies.post.service }}" + }, + { + "name": "DEPENDENCY_JOBS", + "value": "{{ include "joinListWithColon" .Values.dependencies.post.jobs }}" + }, + { + "name": "COMMAND", + "value": "echo done" + } + ] + } + ]' + spec: + restartPolicy: OnFailure + containers: + - name: glance-post + image: {{ .Values.images.post }} + imagePullPolicy: Always + command: + - bash + - /tmp/post.sh + volumeMounts: + - name: postsh + mountPath: /tmp/post.sh + subPath: post.sh + volumes: + - name: postsh + configMap: + name: glance-postsh diff --git a/glance/templates/registry.yaml b/glance/templates/registry.yaml new file mode 100644 index 0000000000..b176aa0900 --- /dev/null +++ b/glance/templates/registry.yaml @@ -0,0 +1,57 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: glance-registry +spec: + replicas: {{ .Values.replicas }} + template: + metadata: + labels: + app: glance-registry + annotations: + pod.beta.kubernetes.io/init-containers: '[ + { + "name": "init", + "image": "quay.io/stackanetes/kubernetes-entrypoint:v0.1.0", + "env": [ + { + "name": "NAMESPACE", + "value": "{{ .Release.Namespace }}" + }, + { + "name": "DEPENDENCY_SERVICE", + "value": "{{ include "joinListWithColon" .Values.dependencies.registry.service }}" + }, + { + "name": "DEPENDENCY_JOBS", + "value": "{{ include "joinListWithColon" .Values.dependencies.registry.jobs }}" + }, + { + "name": "COMMAND", + "value": "echo done" + } + ] + } + ]' + spec: + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + containers: + - name: glance-registry + image: {{ .Values.images.registry }} + imagePullPolicy: Always + command: + - glance-registr + ports: + - containerPort: {{ .Values.network.port.registry }} + readinessProbe: + tcpSocket: + port: {{ .Values.network.port.registry }} + volumeMounts: + - name: glanceregistryconf + mountPath: /etc/glance/glance-registry.conf + subPath: glance-registry.conf + volumes: + - name: glanceregistryconf + configMap: + name: glance-glanceregistryconf diff --git a/glance/templates/service-api.yaml b/glance/templates/service-api.yaml new file mode 100644 index 0000000000..7520120a22 --- /dev/null +++ b/glance/templates/service-api.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Service +metadata: + name: glance-api +spec: + ports: + - port: {{ .Values.network.port.api }} + selector: + app: glance-api diff --git a/glance/templates/service-registry.yaml b/glance/templates/service-registry.yaml new file mode 100644 index 0000000000..f8802cd3a0 --- /dev/null +++ b/glance/templates/service-registry.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Service +metadata: + name: glance-registry +spec: + ports: + - port: {{ .Values.network.port.registry }} + selector: + app: glance-registry diff --git a/glance/templates/start.sh.yaml b/glance/templates/start.sh.yaml new file mode 100644 index 0000000000..e9b3d40ec9 --- /dev/null +++ b/glance/templates/start.sh.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glance-startsh +data: + start.sh: |+ + #!/bin/bash + set -ex + + cp `find / -not -path "/etc/*" -name glance-api-paste.ini` /etc/glance/ + + glance-api diff --git a/glance/values.yaml b/glance/values.yaml new file mode 100644 index 0000000000..cc01d1983d --- /dev/null +++ b/glance/values.yaml @@ -0,0 +1,99 @@ +# Default values for keystone. +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. +# name: value + +replicas: 1 + +labels: + node_selector_key: openstack-control-plane + node_selector_value: enabled + +images: + db_sync: quay.io/stackanetes/stackanetes-glance-api:newton + api: quay.io/stackanetes/stackanetes-glance-api:newton + init: quay.io/stackanetes/stackanetes-kolla-toolbox:newton + registry: quay.io/stackanetes/stackanetes-glance-registry:newton + post: quay.io/stackanetes/stackanetes-kolla-toolbox:newton + +keystone: + auth_uri: "http://keystone-api:5000" + auth_url: "http://keystone-api:35357" + admin_user: "admin" + admin_password: "password" + admin_project_name: "admin" + admin_region_name: "RegionOne" + + glance_user: "glance" + glance_password: "password" + glance_region_name: "RegionOne" + +network: + port: + api: 9292 + registry: 9191 + ip_address: "{{ .IP }}" + +database: + address: mariadb + port: 3306 + root_user: root + root_password: password + glance_database_name: glance + glance_password: password + glance_user: glance + +ceph: + enabled: true + monitors: [] + glance_user: "glance" + glance_pool: "images" + glance_keyring: "" + +misc: + workers: 8 + debug: false + +dependencies: + api: + jobs: + - glance-init + - glance-db-sync + - keystone-db-sync + service: + - keystone-api + - mariadb + registry: + jobs: + - glance-init + - glance-db-sync + - keystone-db-sync + service: + - keystone-api + - mariadb + - glance-api + db_sync: + jobs: + - keystone-init + - keystone-db-sync + - glance-init + - mariadb-seed + service: + - mariadb + init: + jobs: + - mariadb-seed + service: + - mariadb + post: + jobs: + - glance-init + - glance-db-sync + - keystone-db-sync + - keystone-init + - mariadb-init + service: + - mariadb + - keystone-api + - glance-api + - glance-registry \ No newline at end of file