You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that the data contains Base64-encoded versions of the literal provided by the create command.
293
281
294
282
This secret can then be used by your application for example by exporting the secret's value as environment variables:
295
283
296
-
```yaml
284
+
[source,yaml]
297
285
apiVersion: v1
298
286
kind: Deployment
299
287
metadata:
@@ -313,7 +301,6 @@ spec:
313
301
secretKeyRef:
314
302
name: db-secret
315
303
key: password
316
-
```
317
304
318
305
You can select the Secrets to consume in a number of ways:
319
306
@@ -381,7 +368,8 @@ Example:
381
368
382
369
Assuming that the reload feature is enabled with default settings (*`refresh`* mode), the following bean will be refreshed when the config map changes:
383
370
384
-
```java
371
+
[source,java]
372
+
----
385
373
@Configuration
386
374
@ConfigurationProperties(prefix = "bean")
387
375
public class MyConfig {
@@ -391,11 +379,12 @@ public class MyConfig {
391
379
// getter and setters
392
380
393
381
}
394
-
```
382
+
----
395
383
396
384
A way to see that changes effectively happen is creating another bean that prints the message periodically.
397
385
398
-
```java
386
+
[source,java]
387
+
----
399
388
@Component
400
389
public class MyBean {
401
390
@@ -407,19 +396,20 @@ public class MyBean {
407
396
System.out.println("The message is: " + config.getMessage());
408
397
}
409
398
}
410
-
```
399
+
----
411
400
412
401
The message printed by the application can be changed using a `ConfigMap` as follows:
413
402
414
-
```yaml
403
+
[source,java]
404
+
----
415
405
apiVersion: v1
416
406
kind: ConfigMap
417
407
metadata:
418
408
name: reload-example
419
409
data:
420
410
application.properties: |-
421
411
bean.message=Hello World!
422
-
```
412
+
----
423
413
424
414
Any change to the property named `bean.message` in the `ConfigMap` associated to the pod will be reflected in the
425
415
output. More generally speaking, changes associated to properties prefixed with the value defined by the `prefix`
@@ -465,20 +455,18 @@ about such endpoints.
465
455
466
456
The implementation is part of the following starter that you can use by adding its dependency to your pom file:
When the list of the endpoints is populated, the Kubernetes client will search the registered endpoints living in
477
466
the current namespace/project matching the service name defined using the Ribbon Client annotation:
478
467
479
-
```java
468
+
[source,java]
480
469
@RibbonClient(name = "name-service")
481
-
```
482
470
483
471
You can configure Ribbon's behavior by providing properties in your `application.properties` (via your application's
484
472
dedicated `ConfigMap`) using the following format: `<name of your service>.ribbon.<Ribbon configuration key>` where:
@@ -542,7 +530,7 @@ The Kubernetes health indicator which is part of the core module exposes the fol
542
530
## Namespace
543
531
Most of the components provided in this project need to know the namespace. For Kubernetes (1.3+) the namespace is made available to pod as part of the service account secret and automatically detected by the client.
544
532
For earlier version it needs to be specified as an env var to the pod. A quick way to do this is:
0 commit comments