Skip to content

Commit 71afad6

Browse files
committed
Update SNAPSHOT to 1.1.0.M1
1 parent 599f96a commit 71afad6

File tree

42 files changed

+202
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+202
-132
lines changed

README.adoc

Lines changed: 85 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ spring.cloud.kubernetes.discovery.enabled=false
124124
Some Spring Cloud components use the `DiscoveryClient` in order to obtain information about the local service instance. For
125125
this to work, you need to align the Kubernetes service name with the `spring.application.name` property.
126126

127+
Spring Cloud Kubernetes can also watch the Kubernetes service catalog for changes and update the
128+
`DiscoveryClient` implementation accordingly. In order to enable this functionality you need to add
129+
`@EnableScheduling` on a configuration class in your application.
130+
127131
== Kubernetes native service discovery
128132

129133
Kubernetes itself is capable of (server side) service discovery (see: https://kubernetes.io/docs/concepts/services-networking/service/#discovering-services).
@@ -138,7 +142,7 @@ Additionally, you can use Hystrix for:
138142

139143
== Kubernetes PropertySource implementations
140144

141-
The most common approach to configuring your Spring Boot application is to create an `application.properties` or `applicaiton.yaml` or
145+
The most common approach to configuring your Spring Boot application is to create an `application.properties` or `application.yaml` or
142146
an `application-profile.properties` or `application-profile.yaml` file that contains key-value pairs that provide customization values to your
143147
application or Spring Boot starters. You can override these properties by specifying system properties or environment
144148
variables.
@@ -320,26 +324,89 @@ However, if the `production` profile is active, the configuration becomes:
320324

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

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

324-
To tell Spring Boot which `profile` should be enabled at bootstrap, you can pass a system property to the Java
325-
command. To do so, you can launch your Spring Boot application with an environment variable that you can define with the OpenShift
326-
`DeploymentConfig` or Kubernetes `ReplicationConfig` resource file, as follows:
327-
328330
====
329331
[source,yaml]
330332
----
333+
kind: ConfigMap
334+
apiVersion: v1
335+
metadata:
336+
name: demo
337+
data:
338+
application.yml: |-
339+
greeting:
340+
message: Say Hello to the World
341+
farewell:
342+
message: Say Goodbye
343+
----
344+
====
345+
====
346+
[source,yaml]
347+
----
348+
kind: ConfigMap
331349
apiVersion: v1
332-
kind: DeploymentConfig
350+
metadata:
351+
name: demo-development
352+
data:
353+
application.yml: |-
354+
spring:
355+
profiles: development
356+
greeting:
357+
message: Say Hello to the Developers
358+
farewell:
359+
message: Say Goodbye to the Developers
360+
----
361+
====
362+
====
363+
[source,yaml]
364+
----
365+
kind: ConfigMap
366+
apiVersion: v1
367+
metadata:
368+
name: demo-production
369+
data:
370+
application.yml: |-
371+
spring:
372+
profiles: production
373+
greeting:
374+
message: Say Hello to the Ops
375+
farewell:
376+
message: Say Goodbye
377+
----
378+
====
379+
380+
381+
To tell Spring Boot which `profile` should be enabled at bootstrap, you can pass `SPRING_PROFILES_ACTIVE` environment variable.
382+
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.
383+
Deployment resource file, as follows:
384+
385+
====
386+
[source,yaml]
387+
----
388+
apiVersion: apps/v1
389+
kind: Deployment
390+
metadata:
391+
name: deployment-name
392+
labels:
393+
app: deployment-name
333394
spec:
334395
replicas: 1
335-
...
336-
spec:
337-
containers:
338-
- env:
339-
- name: JAVA_APP_DIR
340-
value: /deployments
341-
- name: JAVA_OPTIONS
342-
value: -Dspring.profiles.active=developer
396+
selector:
397+
matchLabels:
398+
app: deployment-name
399+
template:
400+
metadata:
401+
labels:
402+
app: deployment-name
403+
spec:
404+
containers:
405+
- name: container-name
406+
image: your-image
407+
env:
408+
- name: SPRING_PROFILES_ACTIVE
409+
value: "development"
343410
----
344411
====
345412

@@ -584,7 +651,7 @@ The reload feature supports two operating modes:
584651
Any event produces a re-check on the configuration and, in case of changes, a reload.
585652
The `view` role on the service account is required in order to listen for config map changes. A higher level role (such as `edit`) is required for secrets
586653
(by default, secrets are not monitored).
587-
* Polling: Oeriodically re-creates the configuration from config maps and secrets to see if it has changed.
654+
* Polling: Periodically re-creates the configuration from config maps and secrets to see if it has changed.
588655
You can configure the polling period by using the `spring.cloud.kubernetes.reload.period` property and defaults to 15 seconds.
589656
It requires the same role as the monitored property source.
590657
This means, for example, that using polling on file-mounted secret sources does not require particular privileges.
@@ -596,7 +663,7 @@ This means, for example, that using polling on file-mounted secret sources does
596663
| `spring.cloud.kubernetes.reload.enabled` | `Boolean` | `false` | Enables monitoring of property sources and configuration reload
597664
| `spring.cloud.kubernetes.reload.monitoring-config-maps` | `Boolean` | `true` | Allow monitoring changes in config maps
598665
| `spring.cloud.kubernetes.reload.monitoring-secrets` | `Boolean` | `false` | Allow monitoring changes in secrets
599-
| `spring.cloud.kubernetes.reload.strategy ` | `Enum` | `refresh` | The strategy to use when firing a reload (`refresh`, `restart_context`, or `shutdown`)
666+
| `spring.cloud.kubernetes.reload.strategy` | `Enum` | `refresh` | The strategy to use when firing a reload (`refresh`, `restart_context`, or `shutdown`)
600667
| `spring.cloud.kubernetes.reload.mode` | `Enum` | `event` | Specifies how to listen for changes in property sources (`event` or `polling`)
601668
| `spring.cloud.kubernetes.reload.period` | `Duration`| `15s` | The period for verifying changes when using the `polling` strategy
602669
|===
@@ -652,7 +719,6 @@ the `PortName` key. If you want to specify in which Kubernetes namespace the tar
652719
the `KubernetesNamespace` key, remembering in both instances to prefix these keys with your service name and
653720
`ribbon` prefix, as specified earlier.
654721

655-
656722
.Spring Cloud Kubernetes Ribbon Configuration
657723
|===
658724
|Property Key |Type |Default Value
@@ -679,7 +745,6 @@ the `SERVICE` mode uses load balancing of the Kubernetes service to support Isti
679745

680746
* `spring.cloud.kubernetes.ribbon.cluster-domain` Set the custom Kubernetes cluster domain suffix. The default value is: 'cluster.local'
681747

682-
683748
The following examples use this module for ribbon discovery:
684749

685750
* link:./spring-cloud-kubernetes-examples/kubernetes-circuitbreaker-ribbon-example[Spring Cloud Circuitbreaker and Ribbon]
@@ -1011,6 +1076,7 @@ $ touch .springformat
10111076
==== Intellij IDEA
10121077

10131078
In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin.
1079+
The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project.
10141080

10151081
.spring-cloud-build-tools/
10161082
----
@@ -1055,4 +1121,4 @@ Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on t
10551121
- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL.
10561122
- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`.
10571123

1058-
IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources.
1124+
IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources.

docs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>org.springframework.cloud</groupId>
1010
<artifactId>spring-cloud-kubernetes</artifactId>
11-
<version>1.1.0.BUILD-SNAPSHOT</version>
11+
<version>1.1.0.M1</version>
1212
</parent>
1313
<packaging>pom</packaging>
1414
<name>Spring Cloud Kubernetes Docs</name>

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
<parent>
2525
<groupId>org.springframework.cloud</groupId>
2626
<artifactId>spring-cloud-build</artifactId>
27-
<version>2.2.0.BUILD-SNAPSHOT</version>
27+
<version>2.2.0.M3</version>
2828
<relativePath/>
2929
</parent>
3030

3131
<groupId>org.springframework.cloud</groupId>
3232
<artifactId>spring-cloud-kubernetes</artifactId>
33-
<version>1.1.0.BUILD-SNAPSHOT</version>
33+
<version>1.1.0.M1</version>
3434
<packaging>pom</packaging>
3535
<name>Spring Cloud Kubernetes</name>
3636

@@ -63,9 +63,9 @@
6363

6464
<properties>
6565
<!-- Dependency Versions -->
66-
<spring-cloud-commons.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-commons.version>
67-
<spring-cloud-netflix.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-netflix.version>
68-
<spring-cloud-config.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-config.version>
66+
<spring-cloud-commons.version>2.2.0.M1</spring-cloud-commons.version>
67+
<spring-cloud-netflix.version>2.2.0.M1</spring-cloud-netflix.version>
68+
<spring-cloud-config.version>2.2.0.M1</spring-cloud-config.version>
6969

7070
<!-- Maven Plugin Versions -->
7171
<maven-compiler-plugin.version>3.5</maven-compiler-plugin.version>

spring-cloud-kubernetes-config/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>spring-cloud-kubernetes</artifactId>
77
<groupId>org.springframework.cloud</groupId>
8-
<version>1.1.0.BUILD-SNAPSHOT</version>
8+
<version>1.1.0.M1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

spring-cloud-kubernetes-config/src/main/java/org/springframework/cloud/kubernetes/config/ConfigMapPropertySource.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,18 @@ private static Map<String, String> getData(KubernetesClient client, String name,
9999
}
100100

101101
if (environment != null) {
102-
for (String activeProfile:environment.getActiveProfiles()) {
102+
for (String activeProfile : environment.getActiveProfiles()) {
103103

104104
String mapNameWithProfile = name + "-" + activeProfile;
105105

106106
ConfigMap mapWithProfile = StringUtils.isEmpty(namespace)
107-
? client.configMaps().withName(mapNameWithProfile).get()
108-
: client.configMaps().inNamespace(namespace).withName(mapNameWithProfile).get();
107+
? client.configMaps().withName(mapNameWithProfile).get()
108+
: client.configMaps().inNamespace(namespace)
109+
.withName(mapNameWithProfile).get();
109110

110111
if (mapWithProfile != null) {
111-
result.putAll(processAllEntries(mapWithProfile.getData(), environment));
112+
result.putAll(
113+
processAllEntries(mapWithProfile.getData(), environment));
112114
}
113115

114116
}
@@ -125,7 +127,6 @@ private static Map<String, String> getData(KubernetesClient client, String name,
125127
return new HashMap<>();
126128
}
127129

128-
129130
private static Map<String, String> processAllEntries(Map<String, String> input,
130131
Environment environment) {
131132

spring-cloud-kubernetes-config/src/test/java/org/springframework/cloud/kubernetes/config/ConfigMapsFromFilePathsTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
properties = { "spring.application.name=configmap-path-example",
4545
"spring.cloud.kubernetes.config.enableApi=false",
4646
"spring.cloud.kubernetes.config.paths="
47-
+ ConfigMapsFromFilePathsTests.FIRST_FILE_NAME_FULL_PATH
48-
+ ","
47+
+ ConfigMapsFromFilePathsTests.FIRST_FILE_NAME_FULL_PATH + ","
4948
+ ConfigMapsFromFilePathsTests.SECOND_FILE_NAME_FULL_PATH })
5049
public class ConfigMapsFromFilePathsTests {
5150

spring-cloud-kubernetes-config/src/test/java/org/springframework/cloud/kubernetes/config/ConfigMapsMixedTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
@RunWith(SpringRunner.class)
4444
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
4545
classes = App.class,
46-
properties = {
47-
"spring.application.name="
48-
+ ConfigMapsMixedTests.APPLICATION_NAME,
46+
properties = { "spring.application.name=" + ConfigMapsMixedTests.APPLICATION_NAME,
4947
"spring.cloud.kubernetes.config.enableApi=true",
5048
"spring.cloud.kubernetes.config.paths="
5149
+ ConfigMapsMixedTests.FILE_NAME_FULL_PATH })

spring-cloud-kubernetes-config/src/test/java/org/springframework/cloud/kubernetes/config/ConfigMapsWithActiveProfilesNameTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@
4242
* @author Ali Shahbour
4343
*/
4444
@RunWith(SpringRunner.class)
45-
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = App.class, properties = {
46-
"spring.application.name=configmap-with-active-profile-name-example",
47-
"spring.cloud.kubernetes.reload.enabled=false" })
45+
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = App.class,
46+
properties = {
47+
"spring.application.name=configmap-with-active-profile-name-example",
48+
"spring.cloud.kubernetes.reload.enabled=false" })
4849
@ActiveProfiles("development")
4950
@AutoConfigureWebTestClient
5051
public class ConfigMapsWithActiveProfilesNameTests {

spring-cloud-kubernetes-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.springframework.cloud</groupId>
2424
<artifactId>spring-cloud-kubernetes</artifactId>
25-
<version>1.1.0.BUILD-SNAPSHOT</version>
25+
<version>1.1.0.M1</version>
2626
</parent>
2727
<modelVersion>4.0.0</modelVersion>
2828

spring-cloud-kubernetes-core/src/main/java/org/springframework/cloud/kubernetes/profile/KubernetesProfileEnvironmentPostProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public class KubernetesProfileEnvironmentPostProcessor
4343
public void postProcessEnvironment(ConfigurableEnvironment environment,
4444
SpringApplication application) {
4545

46-
final String enabledStr = environment.getProperty("spring.cloud.kubernetes.enabled", "true");
46+
final String enabledStr = environment
47+
.getProperty("spring.cloud.kubernetes.enabled", "true");
4748
if ("false".equals(enabledStr.toLowerCase())) {
4849
return;
4950
}

spring-cloud-kubernetes-dependencies/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
<parent>
2424
<artifactId>spring-cloud-dependencies-parent</artifactId>
2525
<groupId>org.springframework.cloud</groupId>
26-
<version>2.2.0.BUILD-SNAPSHOT</version>
26+
<version>2.2.0.M3</version>
2727
<relativePath/>
2828
</parent>
2929
<artifactId>spring-cloud-kubernetes-dependencies</artifactId>
30-
<version>1.1.0.BUILD-SNAPSHOT</version>
30+
<version>1.1.0.M1</version>
3131
<packaging>pom</packaging>
3232
<name>Spring Cloud Kubernetes :: Dependencies</name>
3333
<description>Spring Cloud Kubernetes Dependencies</description>

spring-cloud-kubernetes-discovery/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.springframework.cloud</groupId>
2424
<artifactId>spring-cloud-kubernetes</artifactId>
25-
<version>1.1.0.BUILD-SNAPSHOT</version>
25+
<version>1.1.0.M1</version>
2626
</parent>
2727
<modelVersion>4.0.0</modelVersion>
2828

spring-cloud-kubernetes-examples/kubernetes-circuitbreaker-ribbon-example/greeting-service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>org.springframework.cloud</groupId>
2525
<artifactId>kubernetes-circuitbreaker-ribbon-example</artifactId>
26-
<version>1.1.0.BUILD-SNAPSHOT</version>
26+
<version>1.1.0.M1</version>
2727
</parent>
2828

2929
<artifactId>greeting-service</artifactId>

spring-cloud-kubernetes-examples/kubernetes-circuitbreaker-ribbon-example/name-service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>org.springframework.cloud</groupId>
2525
<artifactId>kubernetes-circuitbreaker-ribbon-example</artifactId>
26-
<version>1.1.0.BUILD-SNAPSHOT</version>
26+
<version>1.1.0.M1</version>
2727
</parent>
2828

2929
<artifactId>name-service</artifactId>

spring-cloud-kubernetes-examples/kubernetes-circuitbreaker-ribbon-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>spring-cloud-kubernetes-examples</artifactId>
2525
<groupId>org.springframework.cloud</groupId>
26-
<version>1.1.0.BUILD-SNAPSHOT</version>
26+
<version>1.1.0.M1</version>
2727
</parent>
2828

2929
<groupId>org.springframework.cloud</groupId>

spring-cloud-kubernetes-examples/kubernetes-hello-world-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>spring-cloud-kubernetes-examples</artifactId>
77
<groupId>org.springframework.cloud</groupId>
8-
<version>1.1.0.BUILD-SNAPSHOT</version>
8+
<version>1.1.0.M1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.springframework.cloud</groupId>
88
<artifactId>spring-cloud-kubernetes-examples</artifactId>
9-
<version>1.1.0.BUILD-SNAPSHOT</version>
9+
<version>1.1.0.M1</version>
1010
</parent>
1111

1212
<artifactId>kubernetes-leader-election-example</artifactId>

spring-cloud-kubernetes-examples/kubernetes-reload-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>spring-cloud-kubernetes-examples</artifactId>
2424
<groupId>org.springframework.cloud</groupId>
25-
<version>1.1.0.BUILD-SNAPSHOT</version>
25+
<version>1.1.0.M1</version>
2626
</parent>
2727
<modelVersion>4.0.0</modelVersion>
2828

spring-cloud-kubernetes-examples/kubernetes-zipkin-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>spring-cloud-kubernetes-examples</artifactId>
2424
<groupId>org.springframework.cloud</groupId>
25-
<version>1.1.0.BUILD-SNAPSHOT</version>
25+
<version>1.1.0.M1</version>
2626
</parent>
2727
<modelVersion>4.0.0</modelVersion>
2828

spring-cloud-kubernetes-examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>spring-cloud-kubernetes</artifactId>
2525
<groupId>org.springframework.cloud</groupId>
26-
<version>1.1.0.BUILD-SNAPSHOT</version>
26+
<version>1.1.0.M1</version>
2727
</parent>
2828

2929
<artifactId>spring-cloud-kubernetes-examples</artifactId>

0 commit comments

Comments
 (0)