diff --git a/spring-cloud-kubernetes.html b/spring-cloud-kubernetes.html index ab1afdde..d975cbf9 100644 --- a/spring-cloud-kubernetes.html +++ b/spring-cloud-kubernetes.html @@ -336,7 +336,7 @@ Using native kubernetes service discovery ensures compatibility with additional

Kubernetes PropertySource implementations

-

The most common approach to configuring your Spring Boot application is to create an application.properties or applicaiton.yaml or +

The most common approach to configuring your Spring Boot application is to create an application.properties or application.yaml or an application-profile.properties or application-profile.yaml file that contains key-value pairs that provide customization values to your application or Spring Boot starters. You can override these properties by specifying system properties or environment variables.

@@ -564,26 +564,98 @@ data:

If both profiles are active, the property that appears last within the ConfigMap overwrites any preceding values.

-

To tell Spring Boot which profile should be enabled at bootstrap, you can pass a system property to the Java -command. To do so, you can launch your Spring Boot application with an environment variable that you can define with the OpenShift -DeploymentConfig or Kubernetes ReplicationConfig resource file, as follows:

+

Another option is to create a different config map per profile and spring boot will automatically fetch it based +on active profiles

-
apiVersion: v1
-kind: DeploymentConfig
+
kind: ConfigMap
+apiVersion: v1
+metadata:
+  name: demo
+data:
+  application.yml: |-
+    greeting:
+      message: Say Hello to the World
+    farewell:
+      message: Say Goodbye
+
+
+
+
+
+
+
+
+
kind: ConfigMap
+apiVersion: v1
+metadata:
+  name: demo-development
+data:
+  application.yml: |-
+    spring:
+      profiles: development
+    greeting:
+      message: Say Hello to the Developers
+    farewell:
+      message: Say Goodbye to the Developers
+
+
+
+
+
+
+
+
+
kind: ConfigMap
+apiVersion: v1
+metadata:
+  name: demo-production
+data:
+  application.yml: |-
+    spring:
+      profiles: production
+    greeting:
+      message: Say Hello to the Ops
+    farewell:
+      message: Say Goodbye
+
+
+
+
+
+

To tell Spring Boot which profile should be enabled at bootstrap, you can pass SPRING_PROFILES_ACTIVE environment variable. + To do so, you can launch your Spring Boot application with an environment variable that you can define it in the PodSpec at the container specification. + Deployment resource file, as follows:

+
+
+
+
+
+
apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: deployment-name
+  labels:
+    app: deployment-name
 spec:
   replicas: 1
-  ...
-    spec:
-      containers:
-      - env:
-        - name: JAVA_APP_DIR
-          value: /deployments
-        - name: JAVA_OPTIONS
-          value: -Dspring.profiles.active=developer
+ selector: + matchLabels: + app: deployment-name + template: + metadata: + labels: + app: deployment-name + spec: + containers: + - name: container-name + image: your-image + env: + - name: SPRING_PROFILES_ACTIVE + value: "development"
@@ -1127,6 +1199,61 @@ the PortName key. If you want to specify in which Kubernetes namesp the KubernetesNamespace key, remembering in both instances to prefix these keys with your service name and ribbon prefix, as specified earlier.

+ + +++++ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4. Spring Cloud Kubernetes Ribbon Configuration
Property KeyTypeDefault Value

spring.cloud.kubernetes.ribbon.enabled

boolean

true

spring.cloud.kubernetes.ribbon.mode

KubernetesRibbonMode

POD

spring.cloud.kubernetes.ribbon.cluster-domain

string

cluster.local

+
+ +

The following examples use this module for ribbon discovery: