Cinder Refactor WIP

This work is dependant on the Common Chart elements introduced with the Heat PR, and should not be merged prior to https://github.com/att-comdev/openstack-helm/pull/77
This commit is contained in:
portdirect 2017-01-09 02:09:40 +00:00 committed by Pete Birley
parent adbe8f7540
commit 4479a0d93f
48 changed files with 366 additions and 818 deletions

View File

@ -1,73 +0,0 @@
{{- define "joinListWithColon" -}}
{{ range $k, $v := . }}{{ if $k }},{{ end }}{{ $v }}{{ end }}
{{- end -}}
{{- define "env_admin_openrc" }}
- name: OS_IDENTITY_API_VERSION
value: "3"
- name: OS_AUTH_URL
valueFrom:
secretKeyRef:
name: cinder-env-keystone-admin
key: OS_AUTH_URL
- name: OS_REGION_NAME
valueFrom:
secretKeyRef:
name: cinder-env-keystone-admin
key: OS_REGION_NAME
- name: OS_PROJECT_DOMAIN_NAME
valueFrom:
secretKeyRef:
name: cinder-env-keystone-admin
key: OS_PROJECT_DOMAIN_NAME
- name: OS_PROJECT_NAME
valueFrom:
secretKeyRef:
name: cinder-env-keystone-admin
key: OS_PROJECT_NAME
- name: OS_USER_DOMAIN_NAME
valueFrom:
secretKeyRef:
name: cinder-env-keystone-admin
key: OS_USER_DOMAIN_NAME
- name: OS_USERNAME
valueFrom:
secretKeyRef:
name: cinder-env-keystone-admin
key: OS_USERNAME
- name: OS_PASSWORD
valueFrom:
secretKeyRef:
name: cinder-env-keystone-admin
key: OS_PASSWORD
{{- end }}
{{- define "container_ks_service" }}
image: {{ .Values.images.ks_service }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- bash
- /tmp/ks-service.sh
volumeMounts:
- name: ks-service-sh
mountPath: /tmp/ks-service.sh
subPath: ks-service.sh
readOnly: true
env:
{{ include "env_admin_openrc" . | indent 2 }}
{{- end }}
{{- define "container_ks_endpoint" }}
image: {{ .Values.images.ks_endpoints }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- bash
- /tmp/ks-endpoints.sh
volumeMounts:
- name: ks-endpoints-sh
mountPath: /tmp/ks-endpoints.sh
subPath: ks-endpoints.sh
readOnly: true
env:
{{ include "env_admin_openrc" . | indent 2 }}
{{- end }}

View File

@ -0,0 +1,21 @@
#!/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.cinder_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.cinder_user }}' \
password='{{ .Values.database.cinder_password }}' \
host='%' \
priv='{{ .Values.database.cinder_database_name }}.*:ALL' \
append_privs='yes'"

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-ini-api-paste
data:
api-paste.ini: |+
{{ tuple "contents/_cinder-api-paste.ini.tpl" . | include "template" | indent 4 }}

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-conf-api
data:
cinder-api.conf: |+
{{ tuple "contents/_cinder-api.conf.tpl" . | include "template" | indent 4 }}

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-conf-backend-rbd1
data:
cinder-backend-rbd1.conf: |+
{{ tuple "contents/_cinder-backend-rbd1.conf.tpl" . | include "template" | indent 4 }}

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-conf-backends
data:
cinder-backends.conf: |+
{{ tuple "contents/_cinder-backends.conf.tpl" . | include "template" | indent 4 }}

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-conf-concurrency
data:
cinder-concurrency.conf: |+
{{ tuple "contents/_cinder-concurrency.conf.tpl" . | include "template" | indent 4 }}

View File

@ -1,8 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: cinder-conf-db
type: Opaque
data:
cinder-db.conf: |
{{ tuple "contents/_cinder-db.conf.tpl" . | include "template" | b64enc | indent 4 }}

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-conf-glance
data:
cinder-glance.conf: |+
{{ tuple "contents/_cinder-glance.conf.tpl" . | include "template" | indent 4 }}

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-conf-log
data:
cinder-log.conf: |+
{{ tuple "contents/_cinder-log.conf.tpl" . | include "template" | indent 4 }}

View File

@ -1,8 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: cinder-conf-messaging
type: Opaque
data:
cinder-messaging.conf: |
{{ tuple "contents/_cinder-messaging.conf.tpl" . | include "template" | b64enc | indent 4 }}

View File

@ -1,12 +0,0 @@
[DEFAULT]
enable_v1_api = false
volume_name_template = %s
osapi_volume_workers = {{ .Values.api.workers }}
osapi_volume_listen = 0.0.0.0
osapi_volume_listen_port = {{ .Values.service.api.port }}
api_paste_config = /etc/cinder/api-paste.ini
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

View File

@ -1,11 +0,0 @@
[rbd1]
volume_driver = cinder.volume.drivers.rbd.RBDDriver
rbd_pool = {{ .Values.backends.rbd1.pool }}
rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_flatten_volume_from_snapshot = false
rbd_max_clone_depth = 5
rbd_store_chunk_size = 4
rados_connect_timeout = -1
rbd_user = {{ .Values.backends.rbd1.user }}
rbd_secret_uuid = {{ .Values.backends.rbd1.secret }}
report_discard_supported = True

View File

@ -1,2 +0,0 @@
[DEFAULT]
enabled_backends = {{ include "joinListWithColon" .Values.backends.enabled }}

View File

@ -1,2 +0,0 @@
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

View File

@ -1,3 +0,0 @@
[database]
connection = mysql+pymysql://{{ .Values.database.cinder_user }}:{{ .Values.database.cinder_password }}@{{ .Values.database.address }}:{{ .Values.database.port }}/{{ .Values.database.cinder_database_name }}
max_retries = -1

View File

@ -1,3 +0,0 @@
[DEFAULT]
glance_api_servers = "{{ .Values.glance.proto }}://{{ .Values.glance.host }}:{{ .Values.glance.port }}"
glance_api_version = {{ .Values.glance.version }}

View File

@ -1,13 +0,0 @@
[DEFAULT]
auth_strategy = keystone
os_region_name = {{ .Values.keystone.cinder_region_name }}
[keystone_authtoken]
auth_uri = {{ .Values.keystone.auth_uri }}
auth_url = {{ .Values.keystone.auth_url }}
auth_type = password
project_domain_name = {{ .Values.keystone.cinder_project_domain }}
user_domain_name = {{ .Values.keystone.cinder_user_domain }}
project_name = {{ .Values.keystone.cinder_project_name }}
username = {{ .Values.keystone.cinder_user }}
password = {{ .Values.keystone.cinder_password }}

View File

@ -1,4 +0,0 @@
[DEFAULT]
debug = {{ .Values.misc.debug }}
use_syslog = False
use_stderr = True

View File

@ -1,5 +0,0 @@
[oslo_messaging_rabbit]
rabbit_userid = {{ .Values.messaging.user }}
rabbit_password = {{ .Values.messaging.password }}
rabbit_ha_queues = true
rabbit_hosts = {{ .Values.messaging.hosts }}

View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-bin
data:
db-init.sh: |+
{{ tuple "bin/_db-init.sh.tpl" . | include "template" | indent 4 }}
ks-service.sh: |+
{{- include "common_keystone_service" . | indent 4 }}
ks-endpoints.sh: |+
{{- include "common_keystone_endpoints" . | indent 4 }}
ks-user.sh: |+
{{- include "common_keystone_user" . | indent 4 }}

View File

@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-etc
data:
cinder.conf: |+
{{ tuple "etc/_cinder.conf.tpl" . | include "template" | indent 4 }}
api-paste.ini: |+
{{ tuple "etc/_cinder-api-paste.ini.tpl" . | include "template" | indent 4 }}

View File

@ -0,0 +1,76 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cinder-api
spec:
replicas: {{ .Values.replicas }}
template:
metadata:
labels:
app: cinder-api
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init",
"image": {{ .Values.images.dep_check | quote }},
"imagePullPolicy": {{ .Values.images.pull_policy | quote }},
"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: cinder-api
image: {{ .Values.images.api }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- cinder-api
- --config-dir
- /etc/cinder/conf
ports:
- containerPort: {{ .Values.service.api.port }}
readinessProbe:
tcpSocket:
port: {{ .Values.service.api.port }}
volumeMounts:
- name: pod-etc-cinder
mountPath: /etc/cinder
- name: pod-var-cache-cinder
mountPath: /var/cache/cinder
- name: cinderconf
mountPath: /etc/cinder/conf/cinder.conf
subPath: cinder.conf
readOnly: true
- name: cinderpaste
mountPath: /etc/cinder/api-paste.ini
subPath: api-paste.ini
readOnly: true
volumes:
- name: pod-etc-cinder
emptyDir: {}
- name: pod-var-cache-cinder
emptyDir: {}
- name: cinderconf
configMap:
name: cinder-etc
- name: cinderpaste
configMap:
name: cinder-etc

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-api-sh
data:
start.sh: |+
{{ tuple "bin/_api.sh.tpl" . | include "template" | indent 4 }}

View File

@ -1,138 +0,0 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cinder-api
spec:
replicas: {{ .Values.replicas }}
template:
metadata:
labels:
app: cinder-api
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init",
"image": {{ .Values.images.dep_check | quote }},
"imagePullPolicy": {{ .Values.images.pull_policy | quote }},
"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: cinder-api
image: {{ .Values.images.api }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- bash
- /tmp/start.sh
ports:
- containerPort: {{ .Values.service.api.port }}
readinessProbe:
tcpSocket:
port: {{ .Values.service.api.port }}
volumeMounts:
- name: cinder-api-sh
mountPath: /tmp/start.sh
subPath: start.sh
readOnly: true
- name: pod-etc-cinder
mountPath: /etc/cinder
- name: pod-var-lib-cinder-tmp
mountPath: /var/lib/cinder/tmp
- name: cinder-ini-api-paste
mountPath: /etc/cinder/api-paste.ini
subPath: api-paste.ini
readOnly: true
- name: cinder-conf-api
mountPath: /etc/cinder/conf/cinder-api.conf
subPath: cinder-api.conf
readOnly: true
- name: cinder-conf-backends
mountPath: /etc/cinder/conf/cinder-backends.conf
subPath: cinder-backends.conf
readOnly: true
- name: cinder-conf-backend-rbd1
mountPath: /etc/cinder/conf/cinder-backend-rbd1.conf
subPath: cinder-backend-rbd1.conf
readOnly: true
- name: cinder-conf-concurrency
mountPath: /etc/cinder/conf/cinder-concurrency.conf
subPath: cinder-concurrency.conf
readOnly: true
- name: cinder-conf-db
mountPath: /etc/cinder/conf/cinder-db.conf
subPath: cinder-db.conf
readOnly: true
- name: cinder-conf-glance
mountPath: /etc/cinder/conf/cinder-glance.conf
subPath: cinder-glance.conf
readOnly: true
- name: cinder-conf-keystone
mountPath: /etc/cinder/conf/cinder-keystone.conf
subPath: cinder-keystone.conf
readOnly: true
- name: cinder-conf-log
mountPath: /etc/cinder/conf/cinder-log.conf
subPath: cinder-log.conf
readOnly: true
- name: cinder-conf-messaging
mountPath: /etc/cinder/conf/cinder-messaging.conf
subPath: cinder-messaging.conf
readOnly: true
volumes:
- name: cinder-api-sh
configMap:
name: cinder-api-sh
- name: pod-etc-cinder
emptyDir: {}
- name: pod-var-lib-cinder-tmp
emptyDir: {}
- name: cinder-ini-api-paste
configMap:
name: cinder-ini-api-paste
- name: cinder-conf-api
configMap:
name: cinder-conf-api
- name: cinder-conf-backends
configMap:
name: cinder-conf-backends
- name: cinder-conf-backend-rbd1
configMap:
name: cinder-conf-backend-rbd1
- name: cinder-conf-concurrency
configMap:
name: cinder-conf-concurrency
- name: cinder-conf-db
secret:
secretName: cinder-conf-db
- name: cinder-conf-glance
configMap:
name: cinder-conf-glance
- name: cinder-conf-keystone
secret:
secretName: cinder-conf-keystone
- name: cinder-conf-log
configMap:
name: cinder-conf-log
- name: cinder-conf-messaging
secret:
secretName: cinder-conf-messaging

View File

@ -1,19 +0,0 @@
#!/bin/bash
# Copyright 2017 Pete Birley
#
# 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
exec cinder-api --config-dir /etc/cinder/conf

View File

@ -0,0 +1,57 @@
[DEFAULT]
debug = {{ .Values.misc.debug }}
use_syslog = False
use_stderr = True
enable_v1_api = false
volume_name_template = %s
osapi_volume_workers = {{ .Values.api.workers }}
osapi_volume_listen = 0.0.0.0
osapi_volume_listen_port = {{ .Values.service.api.port }}
api_paste_config = /etc/cinder/api-paste.ini
glance_api_servers = "{{ .Values.glance.proto }}://{{ .Values.glance.host }}:{{ .Values.glance.port }}"
glance_api_version = {{ .Values.glance.version }}
enabled_backends = {{ include "joinListWithColon" .Values.backends.enabled }}
auth_strategy = keystone
os_region_name = {{ .Values.keystone.cinder_region_name }}
[database]
connection = mysql+pymysql://{{ .Values.database.cinder_user }}:{{ .Values.database.cinder_password }}@{{ .Values.database.address }}:{{ .Values.database.port }}/{{ .Values.database.cinder_database_name }}
max_retries = -1
[keystone_authtoken]
auth_uri = {{ .Values.keystone.auth_uri }}
auth_url = {{ .Values.keystone.auth_url }}
auth_type = password
project_domain_name = {{ .Values.keystone.cinder_project_domain }}
user_domain_name = {{ .Values.keystone.cinder_user_domain }}
project_name = {{ .Values.keystone.cinder_project_name }}
username = {{ .Values.keystone.cinder_user }}
password = {{ .Values.keystone.cinder_password }}
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[oslo_messaging_rabbit]
rabbit_userid = {{ .Values.messaging.user }}
rabbit_password = {{ .Values.messaging.password }}
rabbit_ha_queues = true
rabbit_hosts = {{ .Values.messaging.hosts }}
[rbd1]
volume_driver = cinder.volume.drivers.rbd.RBDDriver
rbd_pool = {{ .Values.backends.rbd1.pool }}
rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_flatten_volume_from_snapshot = false
rbd_max_clone_depth = 5
rbd_store_chunk_size = 4
rados_connect_timeout = -1
rbd_user = {{ .Values.backends.rbd1.user }}
rbd_secret_uuid = {{ .Values.backends.rbd1.secret }}
report_discard_supported = True

View File

@ -42,13 +42,13 @@ spec:
value: /usr/share/ansible/
command:
- bash
- /tmp/init.sh
- /tmp/db-init.sh
volumeMounts:
- name: db-init-sh
mountPath: /tmp/init.sh
subPath: init.sh
- name: dbinitsh
mountPath: /tmp/db-init.sh
subPath: db-init.sh
readOnly: true
volumes:
- name: db-init-sh
- name: dbinitsh
configMap:
name: cinder-db-init-sh
name: cinder-bin

View File

@ -38,32 +38,22 @@ spec:
image: {{ .Values.images.db_sync }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- bash
- /tmp/db-sync.sh
- cinder-manage
args:
- --config-dir
- /etc/cinder/conf
- db
- sync
volumeMounts:
- name: db-sync-sh
mountPath: /tmp/db-sync.sh
subPath: db-sync.sh
readOnly: true
- name: pod-etc-cinder
mountPath: /etc/cinder
- name: cinder-conf-db
mountPath: /etc/cinder/conf/cinder-db.conf
subPath: cinder-db.conf
readOnly: true
- name: cinder-conf-log
mountPath: /etc/cinder/conf/cinder-log.conf
subPath: cinder-log.conf
- name: cinderconf
mountPath: /etc/cinder/conf/cinder.conf
subPath: cinder.conf
readOnly: true
volumes:
- name: db-sync-sh
configMap:
name: cinder-db-sync-sh
- name: pod-etc-cinder
emptyDir: {}
- name: cinder-conf-db
secret:
secretName: cinder-conf-db
- name: cinder-conf-log
- name: cinderconf
configMap:
name: cinder-conf-log
name: cinder-etc

View File

@ -0,0 +1,65 @@
{{- $envAll := . }}
{{- $ksAdminSecret := $envAll.Values.keystone.admin_secret | default "cinder-env-keystone-admin" }}
apiVersion: batch/v1
kind: Job
metadata:
name: cinder-ks-endpoints
spec:
template:
metadata:
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init",
"image": {{ .Values.images.dep_check | quote }},
"imagePullPolicy": {{ .Values.images.pull_policy | quote }},
"env": [
{
"name": "NAMESPACE",
"value": "{{ .Release.Namespace }}"
},
{
"name": "DEPENDENCY_SERVICE",
"value": "{{ include "joinListWithColon" .Values.dependencies.ks_service.service }}"
},
{
"name": "COMMAND",
"value": "echo done"
}
]
}
]'
spec:
restartPolicy: OnFailure
containers:
{{- range $key1, $osServiceName := tuple "cinder" "cinderv2" "cinderv3" }}
{{- range $key2, $osServiceEndPoint := tuple "admin" "internal" "public" }}
- name: {{ $osServiceName }}-ks-endpoints-{{ $osServiceEndPoint }}
image: {{ $envAll.Values.images.ks_endpoints }}
imagePullPolicy: {{ $envAll.Values.images.pull_policy }}
command:
- bash
- /tmp/ks-endpoints.sh
volumeMounts:
- name: ks-endpoints-sh
mountPath: /tmp/ks-endpoints.sh
subPath: ks-endpoints.sh
readOnly: true
env:
{{- with $env := dict "ksUserSecret" $ksAdminSecret }}
{{- include "env_ks_openrc_tpl" $env | indent 12 }}
{{- end }}
- name: OS_SVC_ENDPOINT
value: {{ $osServiceEndPoint }}
- name: OS_SERVICE_NAME
value: {{ $osServiceName }}
- name: OS_SERVICE_TYPE
value: {{ tuple $osServiceName $envAll | include "endpoint_type_lookup" }}
- name: OS_SERVICE_ENDPOINT
value: {{ tuple $osServiceName $osServiceEndPoint "api" $envAll | include "endpoint_addr_lookup" }}
{{- end }}
{{- end }}
volumes:
- name: ks-endpoints-sh
configMap:
name: cinder-bin

View File

@ -0,0 +1,59 @@
{{- $envAll := . }}
{{- $ksAdminSecret := .Values.keystone.admin_secret | default "cinder-env-keystone-admin" }}
apiVersion: batch/v1
kind: Job
metadata:
name: cinder-ks-service
spec:
template:
metadata:
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init",
"image": {{ .Values.images.dep_check | quote }},
"imagePullPolicy": {{ .Values.images.pull_policy | quote }},
"env": [
{
"name": "NAMESPACE",
"value": "{{ .Release.Namespace }}"
},
{
"name": "DEPENDENCY_SERVICE",
"value": "{{ include "joinListWithColon" .Values.dependencies.ks_service.service }}"
},
{
"name": "COMMAND",
"value": "echo done"
}
]
}
]'
spec:
restartPolicy: OnFailure
containers:
{{- range $key1, $osServiceName := tuple "cinder" "cinderv2" "cinderv3" }}
- name: {{ $osServiceName }}-ks-service-registration
image: {{ $envAll.Values.images.ks_service }}
imagePullPolicy: {{ $envAll.Values.images.pull_policy }}
command:
- bash
- /tmp/ks-service.sh
volumeMounts:
- name: ks-service-sh
mountPath: /tmp/ks-service.sh
subPath: ks-service.sh
readOnly: true
env:
{{- with $env := dict "ksUserSecret" $ksAdminSecret }}
{{- include "env_ks_openrc_tpl" $env | indent 12 }}
{{- end }}
- name: OS_SERVICE_NAME
value: {{ $osServiceName }}
- name: OS_SERVICE_TYPE
value: {{ tuple $osServiceName $envAll | include "endpoint_type_lookup" }}
{{- end }}
volumes:
- name: ks-service-sh
configMap:
name: cinder-bin

View File

@ -1,3 +1,5 @@
{{- $ksAdminSecret := .Values.keystone.admin_secret | default "cinder-env-keystone-admin" }}
{{- $ksUserSecret := .Values.keystone.user_secret | default "cinder-env-keystone-user" }}
apiVersion: batch/v1
kind: Job
metadata:
@ -18,7 +20,7 @@ spec:
},
{
"name": "DEPENDENCY_SERVICE",
"value": "{{ include "joinListWithColon" .Values.dependencies.ks_user.service }}"
"value": "{{ include "joinListWithColon" .Values.dependencies.ks_user.service }}"
},
{
"name": "COMMAND",
@ -40,43 +42,19 @@ spec:
- name: ks-user-sh
mountPath: /tmp/ks-user.sh
subPath: ks-user.sh
readOnly: true
env:
{{ include "env_admin_openrc" . | indent 12 }}
{{- with $env := dict "ksUserSecret" $ksAdminSecret }}
{{- include "env_ks_openrc_tpl" $env | indent 12 }}
{{- end }}
- name: SERVICE_OS_SERVICE_NAME
value: "cinder"
- name: SERVICE_OS_REGION_NAME
valueFrom:
secretKeyRef:
name: cinder-conf-keystone
key: OS_REGION_NAME
- name: SERVICE_OS_PROJECT_DOMAIN_NAME
valueFrom:
secretKeyRef:
name: cinder-conf-keystone
key: OS_PROJECT_DOMAIN_NAME
- name: SERVICE_OS_PROJECT_NAME
valueFrom:
secretKeyRef:
name: cinder-conf-keystone
key: OS_PROJECT_NAME
- name: SERVICE_OS_USER_DOMAIN_NAME
valueFrom:
secretKeyRef:
name: cinder-conf-keystone
key: OS_USER_DOMAIN_NAME
- name: SERVICE_OS_USERNAME
valueFrom:
secretKeyRef:
name: cinder-conf-keystone
key: OS_USERNAME
- name: SERVICE_OS_PASSWORD
valueFrom:
secretKeyRef:
name: cinder-conf-keystone
key: OS_PASSWORD
{{- with $env := dict "ksUserSecret" $ksUserSecret }}
{{- include "env_ks_user_create_openrc_tpl" $env | indent 12 }}
{{- end }}
- name: SERVICE_OS_ROLE
value: {{ .Values.keystone.cinder_user_role | quote }}
volumes:
- name: ks-user-sh
configMap:
name: cinder-ks-user-sh
name: cinder-bin

View File

@ -1,6 +0,0 @@
#!/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.cinder_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.cinder_user }}' password='{{ .Values.database.cinder_password }}' host='%' priv='{{ .Values.database.cinder_database_name }}.*:ALL' append_privs='yes'"

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-db-init-sh
data:
init.sh: |+
{{ tuple "bin/_db-init.sh.tpl" . | include "template" | indent 4 }}

View File

@ -1,19 +0,0 @@
#!/bin/bash
# Copyright 2017 Pete Birley
#
# 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
cinder-manage --config-dir /etc/cinder/conf db sync

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-db-sync-sh
data:
db-sync.sh: |+
{{ tuple "bin/_db-sync.sh.tpl" . | include "template" | indent 4 }}

View File

@ -1,63 +0,0 @@
#!/bin/bash
# Copyright 2017 Pete Birley
#
# 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
# Get Service ID
OS_SERVICE_ID=$( openstack service list -f csv --quote none | \
grep ",${OS_SERVICE_NAME},${OS_SERVICE_TYPE}$" | \
sed -e "s/,${OS_SERVICE_NAME},${OS_SERVICE_TYPE}//g" )
# Get Endpoint ID if it exists
OS_ENDPOINT_ID=$( openstack endpoint list -f csv --quote none | \
grep "^[a-z0-9]*,${OS_REGION_NAME},${OS_SERVICE_NAME},${OS_SERVICE_TYPE},True,${OS_SERVICE_INTERFACE}," | \
awk -F ',' '{ print $1 }' )
# Making sure only a single endpoint exists for a service within a region
if [ "$(echo $OS_ENDPOINT_ID | wc -w)" -gt "1" ]; then
echo "More than one endpoint found, cleaning up"
for ENDPOINT_ID in $OS_ENDPOINT_ID; do
openstack endpoint delete ${ENDPOINT_ID}
done
unset OS_ENDPOINT_ID
fi
# Determine if Endpoint needs updated
if [[ ${OS_ENDPOINT_ID} ]]; then
OS_ENDPOINT_URL_CURRENT=$(openstack endpoint show ${OS_ENDPOINT_ID} --f value -c url)
if [ "${OS_ENDPOINT_URL_CURRENT}" == "${OS_SERVICE_ENDPOINT}" ]; then
echo "Endpoints Match: no action required"
OS_ENDPOINT_UPDATE="False"
else
echo "Endpoints Dont Match: removing existing entries"
openstack endpoint delete ${OS_ENDPOINT_ID}
OS_ENDPOINT_UPDATE="True"
fi
else
OS_ENDPOINT_UPDATE="True"
fi
# Update Endpoint if required
if [[ "${OS_ENDPOINT_UPDATE}" == "True" ]]; then
OS_ENDPOINT_ID=$( openstack endpoint create -f value -c id \
--region="${OS_REGION_NAME}" \
"${OS_SERVICE_ID}" \
${OS_SERVICE_INTERFACE} \
"${OS_SERVICE_ENDPOINT}" )
fi
# Display the Endpoint
openstack endpoint show ${OS_ENDPOINT_ID}

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-ks-endpoints-sh
data:
ks-endpoints.sh: |+
{{ tuple "bin/_ks-endpoints.sh.tpl" . | include "template" | indent 4 }}

View File

@ -1,130 +0,0 @@
apiVersion: batch/v1
kind: Job
metadata:
name: cinder-ks-endpoints
spec:
template:
metadata:
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init",
"image": {{ .Values.images.dep_check | quote }},
"imagePullPolicy": {{ .Values.images.pull_policy | quote }},
"env": [
{
"name": "NAMESPACE",
"value": "{{ .Release.Namespace }}"
},
{
"name": "DEPENDENCY_SERVICE",
"value": "{{ include "joinListWithColon" .Values.dependencies.ks_endpoints.service }}"
},
{
"name": "DEPENDENCY_JOBS",
"value": "{{ include "joinListWithColon" .Values.dependencies.ks_endpoints.jobs }}"
},
{
"name": "COMMAND",
"value": "echo done"
}
]
}
]'
spec:
restartPolicy: OnFailure
containers:
- name: cinder-ks-endpoints-v1-admin
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: admin
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volume
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v1/%(tenant_id)s
- name: cinder-ks-endpoints-v1-internal
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: internal
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volume
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v1/%(tenant_id)s
- name: cinder-ks-endpoints-v1-public
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: public
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volume
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v1/%(tenant_id)s
- name: cinder-ks-endpoints-v2-admin
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: admin
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volumev2
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v2/%(tenant_id)s
- name: cinder-ks-endpoints-v2-internal
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: internal
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volumev2
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v2/%(tenant_id)s
- name: cinder-ks-endpoints-v2-public
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: public
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volumev2
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v2/%(tenant_id)s
- name: cinder-ks-endpoints-v3-admin
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: admin
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volumev3
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v3/%(tenant_id)s
- name: cinder-ks-endpoints-v3-internal
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: internal
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volumev3
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v3/%(tenant_id)s
- name: cinder-ks-endpoints-v3-public
{{ include "container_ks_endpoint" . | indent 10 }}
- name: OS_SERVICE_INTERFACE
value: public
- name: OS_SERVICE_NAME
value: cinder
- name: OS_SERVICE_TYPE
value: volumev3
- name: OS_SERVICE_ENDPOINT
value: {{ .Values.service.api.proto }}://{{ .Values.service.api.name }}:{{ .Values.service.api.port }}/v3/%(tenant_id)s
volumes:
- name: ks-endpoints-sh
configMap:
name: cinder-ks-endpoints-sh

View File

@ -1,35 +0,0 @@
#!/bin/bash
# Copyright 2017 Pete Birley
#
# 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
# Service boilerplate description
OS_SERVICE_DESC="${OS_REGION_NAME}: ${OS_SERVICE_NAME} (${OS_SERVICE_TYPE}) service"
# Get Service ID if it exists
unset OS_SERVICE_ID
OS_SERVICE_ID=$( openstack service list -f csv --quote none | \
grep ",${OS_SERVICE_NAME},${OS_SERVICE_TYPE}$" | \
sed -e "s/,${OS_SERVICE_NAME},${OS_SERVICE_TYPE}//g" )
# If a Service ID was not found, then create the service
if [[ -z ${OS_SERVICE_ID} ]]; then
OS_SERVICE_ID=$(openstack service create -f value -c id \
--name="${OS_SERVICE_NAME}" \
--description "${OS_SERVICE_DESC}" \
--enable \
"${OS_SERVICE_TYPE}")
fi

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-ks-service-sh
data:
ks-service.sh: |+
{{ tuple "bin/_ks-service.sh.tpl" . | include "template" | indent 4 }}

View File

@ -1,54 +0,0 @@
apiVersion: batch/v1
kind: Job
metadata:
name: cinder-ks-service
spec:
template:
metadata:
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init",
"image": {{ .Values.images.dep_check | quote }},
"imagePullPolicy": {{ .Values.images.pull_policy | quote }},
"env": [
{
"name": "NAMESPACE",
"value": "{{ .Release.Namespace }}"
},
{
"name": "DEPENDENCY_SERVICE",
"value": "{{ include "joinListWithColon" .Values.dependencies.ks_service.service }}"
},
{
"name": "COMMAND",
"value": "echo done"
}
]
}
]'
spec:
restartPolicy: OnFailure
containers:
- name: cinder-ks-service-v1
{{ include "container_ks_service" . | indent 10 }}
- name: OS_SERVICE_NAME
value: "cinder"
- name: OS_SERVICE_TYPE
value: "volume"
- name: cinder-ks-service-v2
{{ include "container_ks_service" . | indent 10 }}
- name: OS_SERVICE_NAME
value: "cinder"
- name: OS_SERVICE_TYPE
value: "volumev2"
- name: cinder-ks-service-v3
{{ include "container_ks_service" . | indent 10 }}
- name: OS_SERVICE_NAME
value: "cinder"
- name: OS_SERVICE_TYPE
value: "volumev3"
volumes:
- name: ks-service-sh
configMap:
name: cinder-ks-service-sh

View File

@ -1,56 +0,0 @@
#!/bin/bash
# Copyright 2017 Pete Birley
#
# 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
# Manage user project
USER_PROJECT_ID=$(openstack project create --or-show --enable -f value -c id \
--domain="${SERVICE_OS_PROJECT_DOMAIN_NAME}" \
--description="Service Project for ${SERVICE_OS_REGION_NAME}/${SERVICE_OS_PROJECT_DOMAIN_NAME}" \
"${SERVICE_OS_PROJECT_NAME}");
# Display project
openstack project show "${USER_PROJECT_ID}"
# Manage user
USER_ID=$(openstack user create --or-show --enable -f value -c id \
--domain="${SERVICE_OS_USER_DOMAIN_NAME}" \
--project-domain="${SERVICE_OS_PROJECT_DOMAIN_NAME}" \
--project="${USER_PROJECT_ID}" \
--description="Service User for ${SERVICE_OS_REGION_NAME}/${SERVICE_OS_USER_DOMAIN_NAME}/${SERVICE_OS_SERVICE_NAME}" \
--password="${SERVICE_OS_PASSWORD}" \
"${SERVICE_OS_USERNAME}");
# Display user
openstack user show "${USER_ID}"
# Manage user role
USER_ROLE_ID=$(openstack role create --or-show -f value -c id \
"${SERVICE_OS_ROLE}");
# Manage user role assignment
openstack role add \
--user="${USER_ID}" \
--user-domain="${SERVICE_OS_USER_DOMAIN_NAME}" \
--project-domain="${SERVICE_OS_PROJECT_DOMAIN_NAME}" \
--project="${USER_PROJECT_ID}" \
"${USER_ROLE_ID}"
# Display user role assignment
openstack role assignment list \
--role="${SERVICE_OS_ROLE}" \
--user-domain="${SERVICE_OS_USER_DOMAIN_NAME}" \
--user="${USER_ID}"

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cinder-ks-user-sh
data:
ks-user.sh: |+
{{ tuple "bin/_ks-user.sh.tpl" . | include "template" | indent 4 }}

View File

@ -1,11 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: cinder-conf-keystone
name: cinder-env-keystone-user
type: Opaque
data:
cinder-keystone.conf: |
{{ tuple "contents/_cinder-keystone.conf.tpl" . | include "template" | b64enc | indent 4 }}
OS_AUTH_URL: |
{{ .Values.keystone.auth_url | b64enc | indent 4 }}
OS_REGION_NAME: |

View File

@ -108,3 +108,40 @@ dependencies:
service:
- mariadb
- keystone-api
endpoints:
keystone:
hosts:
default: keystone-api
path: /v3
type: identity
scheme: 'http'
port:
admin: 35357
public: 5000
cinder:
hosts:
default: cinder-api
path: '/v1/%(tenant_id)s'
type: volume
scheme: 'http'
port:
api: 8776
cinderv2:
name: cinder
hosts:
default: cinder-api
path: '/v2/%(tenant_id)s'
type: volumev2
scheme: 'http'
port:
api: 8776
cinderv3:
name: cinder
hosts:
default: cinder-api
path: '/v3/%(tenant_id)s'
type: volumev3
scheme: 'http'
port:
api: 8776