diff --git a/Makefile b/Makefile index 4ca9917a35..86c6aa342a 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -.PHONY: ceph bootstrap mariadb keystone memcached rabbitmq common openstack neutron nova cinder heat maas all clean +.PHONY: ceph bootstrap mariadb postgresql keystone memcached rabbitmq common openstack neutron nova cinder heat maas all clean B64_DIRS := common/secrets B64_EXCLUDE := $(wildcard common/secrets/*.b64) -CHARTS := ceph mariadb rabbitmq memcached keystone glance horizon neutron nova cinder heat maas openstack +CHARTS := ceph mariadb postgresql rabbitmq memcached keystone glance horizon neutron nova cinder heat maas openstack COMMON_TPL := common/templates/_globals.tpl -all: common ceph bootstrap mariadb rabbitmq memcached keystone glance horizon neutron nova cinder heat maas openstack +all: common ceph bootstrap mariadb postgresql rabbitmq memcached keystone glance horizon neutron nova cinder heat maas openstack common: build-common @@ -17,6 +17,8 @@ bootstrap: build-bootstrap mariadb: build-mariadb +postgresql: build-postgresql + keystone: build-keystone cinder: build-cinder diff --git a/postgresql/Chart.yaml b/postgresql/Chart.yaml new file mode 100644 index 0000000000..83840a3571 --- /dev/null +++ b/postgresql/Chart.yaml @@ -0,0 +1,3 @@ +description: A Helm chart for postgresql +name: postgresql +version: 0.1.0 diff --git a/postgresql/README.md b/postgresql/README.md new file mode 100644 index 0000000000..6857bd2e19 --- /dev/null +++ b/postgresql/README.md @@ -0,0 +1,11 @@ +# openstack-helm/postgresql + +This chart leverages StatefulSets, with persistent storage. + +The StatefulSets all leverage PVCs to provide stateful storage to /var/lib/postgresql. + +You must ensure that your control nodes that should receive postgresql instances are labeled with openstack-control-plane=enabled, or whatever you have configured in values.yaml for the label configuration: + +``` +kubectl label nodes openstack-control-plane=enabled --all +``` diff --git a/postgresql/requirements.yaml b/postgresql/requirements.yaml new file mode 100644 index 0000000000..2350b1facb --- /dev/null +++ b/postgresql/requirements.yaml @@ -0,0 +1,4 @@ +dependencies: + - name: common + repository: http://localhost:8879/charts + version: 0.1.0 diff --git a/postgresql/templates/deployment.yaml b/postgresql/templates/deployment.yaml new file mode 100644 index 0000000000..6593b14b9e --- /dev/null +++ b/postgresql/templates/deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: {{ .Values.service_name }} +spec: + serviceName: {{ .Values.service_name }} + replicas: {{ .Values.replicas }} + template: + metadata: + labels: + app: {{ .Values.service_name }} + spec: + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + containers: + - name: {{ .Values.service_name }} + image: {{ .Values.images.postgresql }} + imagePullPolicy: {{ .Values.images.pull_policy }} + ports: + - containerPort: {{ .Values.network.port.postgresql }} + livenessProbe: + exec: + command: + - pg_isready + initialDelaySeconds: 20 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - pg_isready + initialDelaySeconds: 20 + timeoutSeconds: 5 + resources: +{{ toYaml .Values.resources | indent 10 }} + volumeMounts: + - name: postgresql-data + mountPath: /var/lib/postgresql + volumes: +{{- if .Values.development.enabled }} + - name: postgresql-data + hostPath: + path: {{ .Values.development.storage_path }} +{{- else }} + volumeClaimTemplates: + - metadata: + name: postgresql-data + annotations: + {{ .Values.volume.class_path }}: {{ .Values.volume.class_name }} + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: {{ .Values.volume.size }} +{{- end }} diff --git a/postgresql/templates/service.yaml b/postgresql/templates/service.yaml new file mode 100644 index 0000000000..223b79338c --- /dev/null +++ b/postgresql/templates/service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service_name }} +spec: + ports: + - name: db + port: {{ .Values.network.port.postgresql }} + selector: + app: {{ .Values.service_name }} diff --git a/postgresql/values.yaml b/postgresql/values.yaml new file mode 100644 index 0000000000..d8a340c52c --- /dev/null +++ b/postgresql/values.yaml @@ -0,0 +1,29 @@ +# Default values for postgresql. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +development: + enabled: true + storage_path: /data/openstack-helm/postgresql + +replicas: 1 #only 1 replica currently supported + +service_name: postgresql + +# using dockerhub postgresql: https://hub.docker.com/r/library/postgres/tags/ +images: + postgresql: "docker.io/postgres:9.5" + pull_policy: IfNotPresent + +volume: + class_path: volume.beta.kubernetes.io/storage-class + class_name: general + size: 20Gi + +labels: + node_selector_key: openstack-control-plane + node_selector_value: enabled + +network: + port: + postgresql: 5432