support database.service.class=null for in-memory/no service instance

This commit is contained in:
Dr Nic Williams 2018-11-05 16:01:24 +10:00
parent 9853157a47
commit 766e3e15f0
4 changed files with 25 additions and 2 deletions

17
README.md Normal file
View File

@ -0,0 +1,17 @@
# Spring Music for Kubernetes Service Catalog
To deploy Spring Music, with a service instance/binding from your Service Catalog:
```shell
helm upgrade --install spring-music . \
--set "database.service.class=cleardb,database.service.plan=spark"
```
In the example above, it is assumed that your Service Catalog has a service class "cleardb" with a service plan "spark".
To run Spring Music without a database service instnace/binding:
```shell
helm upgrade --install spring-music . \
--set "database.service.class=null"
```

View File

@ -1,4 +1,4 @@
---
{{- if .Values.database.service.class -}}
# svcat bind app-db --name db-binding --secret-name db-secret
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceBinding
@ -8,3 +8,4 @@ spec:
instanceRef:
name: {{ include "app-with-binding.fullname" . }}-db-instance
secretName: {{ template "app-with-binding.fullname" . }}-db-secret
{{- end -}}

View File

@ -1,4 +1,4 @@
---
{{- if .Values.database.service.class -}}
# svcat provision app-db --class cleardb --plan spark
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
@ -7,3 +7,4 @@ metadata:
spec:
clusterServiceClassExternalName: {{ .Values.database.service.class }}
clusterServicePlanExternalName: {{ .Values.database.service.plan }}
{{- end -}}

View File

@ -28,6 +28,7 @@ spec:
- name: http
containerPort: 8080
protocol: TCP
{{- if .Values.database.service.class }}
env:
- name: DATABASE_URL
valueFrom:
@ -49,6 +50,7 @@ spec:
secretKeyRef:
name: {{ template "app-with-binding.fullname" . }}-db-secret
key: password
{{- end }}
livenessProbe:
httpGet:
path: /
@ -57,7 +59,9 @@ spec:
httpGet:
path: /
port: http
{{- if .Values.database.service.class }}
volumes:
- name: db-credentials
secret:
secretName: {{ template "app-with-binding.fullname" . }}-db-secret
{{- end }}