Skip to content
This repository was archived by the owner on Jul 9, 2022. It is now read-only.

Commit de6b096

Browse files
trisbergericbottard
authored andcommitted
Add support for accessing ConfigMap and Secrets for the Server
Resolves #111
1 parent bb9d0db commit de6b096

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed

pom.xml

+19-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>org.springframework.cloud</groupId>
1010
<artifactId>spring-cloud-dataflow-parent</artifactId>
11-
<version>1.1.0.BUILD-SNAPSHOT</version>
11+
<version>1.1.0.M2</version>
1212
<relativePath /> <!-- lookup parent from repository -->
1313
</parent>
1414

@@ -19,8 +19,10 @@
1919
</modules>
2020

2121
<properties>
22-
<spring-cloud-dataflow.version>1.1.0.BUILD-SNAPSHOT</spring-cloud-dataflow.version>
22+
<spring-cloud-dataflow.version>1.1.0.M2</spring-cloud-dataflow.version>
2323
<spring-cloud-deployer-kubernetes.version>1.1.0.BUILD-SNAPSHOT</spring-cloud-deployer-kubernetes.version>
24+
<spring-cloud-kubernetes.version>0.1.1</spring-cloud-kubernetes.version>
25+
<netflix-archaius.version>0.7.4</netflix-archaius.version>
2426
</properties>
2527

2628
<dependencyManagement>
@@ -35,6 +37,21 @@
3537
<artifactId>spring-cloud-dataflow-server-core</artifactId>
3638
<version>${spring-cloud-dataflow.version}</version>
3739
</dependency>
40+
<dependency>
41+
<groupId>io.fabric8</groupId>
42+
<artifactId>spring-cloud-starter-kubernetes</artifactId>
43+
<version>${spring-cloud-kubernetes.version}</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>io.fabric8</groupId>
47+
<artifactId>spring-cloud-kubernetes-archaius</artifactId>
48+
<version>${spring-cloud-kubernetes.version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.netflix.archaius</groupId>
52+
<artifactId>archaius-core</artifactId>
53+
<version>${netflix-archaius.version}</version>
54+
</dependency>
3855
</dependencies>
3956
</dependencyManagement>
4057

spring-cloud-dataflow-server-kubernetes-docs/src/main/asciidoc/getting-started.adoc

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ CREATE DATABASE test;
4747
```
4848
. Update configuration files with values needed to connect to Kubernetes and MySQL.
4949
+
50-
The Data Flow Server uses the https://github.com/fabric8io/kubernetes-client[fabric8 Java client library] to connect to the Kubernetes cluster. We are using environment variables to set the values needed when deploying the Data Flow server to Kubernetes. The settings are specified in the `src/etc/kubernetes/scdf-controller.yml` file. Modify `\<<mysql-username>>`, `\<<mysql-password>>` and DB schema name to match what you used when creating the service.
50+
The Data Flow Server uses the https://github.com/fabric8io/kubernetes-client[Fabric8 Java client library] to connect to the Kubernetes cluster. We are using environment variables to set the values needed when deploying the Data Flow server to Kubernetes. We are also using the https://github.com/fabric8io/spring-cloud-kubernetes[Fabric8 Spring Cloud integration with Kubernetes library] to access Kubernetes http://kubernetes.io/docs/user-guide/configmap/[ConfigMap] and http://kubernetes.io/docs/user-guide/secrets/[Secrets] settings.
51+
The ConfigMap settings are specified in the `src/etc/kubernetes/scdf-config.yml` file and the Secrets in the `src/etc/kubernetes/scdf-secrets.yml` file. Modify the password for MySQL in the latter if you changed it. It has to be provided encoded as base64.
5152
+
5253
This approach supports using one Data Flow Server instance per Kubernetes namespace.
5354
+
5455
. Deploy the Spring Cloud Data Flow Server for Kubernetes using the Docker image and the configuration settings you just modified.
5556
+
5657
```
57-
$ kubectl create -f src/etc/kubernetes/scdf-controller.yml
58+
$ kubectl create -f src/etc/kubernetes/scdf-config.yml
59+
$ kubectl create -f src/etc/kubernetes/scdf-secrets.yml
5860
$ kubectl create -f src/etc/kubernetes/scdf-service.yml
61+
$ kubectl create -f src/etc/kubernetes/scdf-controller.yml
5962
```
6063
+
6164
NOTE: We haven't tuned the memory use of the OOTB apps yet, so to be on the safe side we are increasing the memory for the pods by providing the following property: `spring.cloud.deployer.kubernetes.memory=640Mi`

spring-cloud-dataflow-server-kubernetes/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@
2828
<artifactId>postgresql</artifactId>
2929
<scope>runtime</scope>
3030
</dependency>
31+
<!-- Fabric8 spring-cloud-kubernetes dependencies -->
32+
<dependency>
33+
<groupId>io.fabric8</groupId>
34+
<artifactId>spring-cloud-starter-kubernetes</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.fabric8</groupId>
38+
<artifactId>spring-cloud-kubernetes-archaius</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.netflix.archaius</groupId>
42+
<artifactId>archaius-core</artifactId>
43+
</dependency>
3144
</dependencies>
3245
<build>
3346
<resources>

src/etc/kubernetes/scdf-config.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: scdf-config
5+
data:
6+
application.yaml: |-
7+
spring:
8+
datasource:
9+
url: jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT}/test
10+
driverClassName: org.mariadb.jdbc.Driver
11+
testOnBorrow": true
12+
validationQuery: "SELECT 1"

src/etc/kubernetes/scdf-controller.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ spec:
2323
fieldRef:
2424
fieldPath: "metadata.namespace"
2525
- name: SPRING_APPLICATION_JSON
26-
value: '{"spring.datasource.url":"jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT}/test","spring.datasource.driverClassName":"org.mariadb.jdbc.Driver","spring.datasource.username":"<<mysql-username>>","spring.datasource.password":"<<mysql-password>>","spring.datasource.testOnBorrow":true,"spring.datasource.validationQuery":"SELECT 1","spring.cloud.deployer.kubernetes.memory":"640Mi"}'
26+
value: '{"spring.cloud.deployer.kubernetes.memory":"640Mi"}'
27+
- name: SPRING_CLOUD_KUBERNETES_SECRETS_ENABLE_API
28+
value: 'true'
29+
- name: SPRING_CLOUD_KUBERNETES_SECRETS_NAME
30+
value: scdf-secrets
31+
- name: SPRING_CLOUD_KUBERNETES_CONFIG_NAME
32+
value: scdf-config

src/etc/kubernetes/scdf-secrets.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: scdf-secrets
5+
data:
6+
spring.datasource.username: cm9vdA==
7+
spring.datasource.password: eW91cnBhc3N3b3Jk

0 commit comments

Comments
 (0)