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
+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
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.
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"
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.
| Property Key | +Type | +Default Value | +
|---|---|---|
spring.cloud.kubernetes.ribbon.enabled |
+boolean |
+true |
+
spring.cloud.kubernetes.ribbon.mode |
+
|
+POD |
+
spring.cloud.kubernetes.ribbon.cluster-domain |
+string |
+cluster.local |
+
spring.cloud.kubernetes.ribbon.mode supports POD and SERVICE modes.
The POD mode is to achieve load balancing by obtaining the Pod IP address of Kubernetes and using Ribbon.
+POD mode uses the load balancing of the Ribbon Does not support Kubernetes load balancing, The traffic policy of Istio is not supported.
the SERVICE mode is directly based on the service name of the Ribbon. Get
+The Kubernetes service is concatenated into service-name.{namespace}.svc.{cluster.domain}:{port} such as: demo1.default.svc.cluster.local:8080.
+the SERVICE mode uses load balancing of the Kubernetes service to support Istio’s traffic policy.
spring.cloud.kubernetes.ribbon.cluster-domain Set the custom Kubernetes cluster domain suffix. The default value is: 'cluster.local'
The following examples use this module for ribbon discovery: