Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ spring:
includeProfileSpecificSources: false
----

NOTE: Since version `5.0.0-M1`, `includeProfileSpecificSources` is only supported for named sources (`spring.cloud.kubernetes.sources.name=XXX`); support for labeled sources has been removed.
NOTE: Since version `5.0.0`, `includeProfileSpecificSources` is only supported for named sources (`spring.cloud.kubernetes.sources.name=XXX`); support for labeled sources has been removed.


Notice that just like before, there are two levels where you can specify this property: for all config maps or
Expand Down Expand Up @@ -588,6 +588,9 @@ NOTE: If you already have `spring-retry` and `spring-boot-starter-aspectj` on th
and want to enable fail-fast, but do not want retry to be enabled; you can disable retry for `ConfigMap` `PropertySources`
by setting `spring.cloud.kubernetes.config.retry.enabled=false`.


NOTE: Since version `5.0.0`, we have introduced the possibility to read sources individually. Until now, we would go to the namespace and read all the configmaps / secrets available and then filter out the ones requested. Since `5.0.0-M3` you can specify that you want to read them individually, by setting the property: `spring.cloud.kubernetes.config.read-type=SINGLE`. The previous option to read them all in a namespace is controlled by `spring.cloud.kubernetes.config.read-type=BATCH` and it is the default option.

.Properties:
[options="header,footer"]
|===
Expand Down
20 changes: 11 additions & 9 deletions docs/modules/ROOT/pages/spring-cloud-kubernetes-configserver.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,39 @@ A default image is located on https://hub.docker.com/r/springcloud/spring-cloud-
the code and image yourself. However, if you need to customize the config server behavior or prefer to build the image yourself you can easily build your own
image from the https://github.com/spring-cloud/spring-cloud-kubernetes/tree/main/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver[source code on GitHub] and use that.

## Configuration
== Configuration

### Enabling The Kubernetes Environment Repository
=== Enabling The Kubernetes Environment Repository
To enable the Kubernetes environment repository the `kubernetes` profile must be included in the list of active profiles.
You may activate other profiles as well to use other environment repository implementations.

### Config Map and Secret PropertySources
=== Config Map and Secret PropertySources
By default, only Config Map data will be fetched. To enable Secrets as well you will need to set `spring.cloud.kubernetes.secrets.enableApi=true`.
You can disable the Config Map `PropertySource` by setting `spring.cloud.kubernetes.config.enableApi=false`.

### Fetching Config Map and Secret Data From Additional Namespaces
=== Fetching Config Map and Secret Data From Additional Namespaces
By default, the Kubernetes environment repository will only fetch Config Map and Secrets from the namespace in which it is deployed.
If you want to include data from other namespaces you can set `spring.cloud.kubernetes.configserver.config-map-namespaces` and/or `spring.cloud.kubernetes.configserver.secrets-namespaces` to a comma separated
list of namespace values.

NOTE: If you set `spring.cloud.kubernetes.configserver.config-map-namespaces` and/or `spring.cloud.kubernetes.configserver.secrets-namespaces`
you will need to include the namespace in which the Config Server is deployed in order to continue to fetch Config Map and Secret data from that namespace.

### Using Advanced Features Of Spring Vault
=== Using Advanced Features Of Spring Vault
In order to use some of the https://docs.spring.io/spring-cloud-config/reference/server/environment-repository/vault-backend.html[more advanced Spring Vault features] of the **Spring Cloud Config Server**, https://mvnrepository.com/artifact/org.springframework.vault/spring-vault-core[`spring-vault-core`] must be on the classpath. By default, Spring Cloud Kubernetes can generate a Docker image for deploying Config Server to Kubernetes, but it does not include `spring-vault-core` in the classpath. If you need `spring-vault-core` to enable certain functionality in the Config Server you can build your own version of Docker image by enabling the `vault` Maven profile when running Maven build.

Example:
```bash

[source,bash]
----
$ ../../mvnw clean install -Pvault
```
----

### Kubernetes Access Controls
=== Kubernetes Access Controls
The Kubernetes Config Server uses the Kubernetes API server to fetch Config Map and Secret data. In order for it to do that
it needs ability to `get` and `list` Config Map and Secrets (depending on what you enable/disable).

## Deployment Yaml
== Deployment Yaml

Below is a sample deployment, service and permissions configuration you can use to deploy a basic Config Server to Kubernetes.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.kubernetes.client.openapi.apis.CoreV1Api;

import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
import org.springframework.cloud.kubernetes.commons.config.ReadType;
import org.springframework.core.env.Environment;

/**
Expand All @@ -27,10 +28,5 @@
* @author wind57
*/
public record KubernetesClientConfigContext(CoreV1Api client, NormalizedSource normalizedSource, String namespace,
Environment environment, boolean includeDefaultProfileData) {

public KubernetesClientConfigContext(CoreV1Api client, NormalizedSource normalizedSource, String namespace,
Environment environment) {
this(client, normalizedSource, namespace, environment, true);
}
Environment environment, boolean includeDefaultProfileData, ReadType readType) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected void registerBeans(ConfigDataLocationResolverContext resolverContext,
coreV1Api, configMapProperties, namespaceProvider);
if (isRetryEnabledForConfigMap(configMapProperties)) {
configMapPropertySourceLocator = new ConfigDataRetryableConfigMapPropertySourceLocator(
configMapPropertySourceLocator, configMapProperties, new KubernetesClientConfigMapsCache());
configMapPropertySourceLocator, configMapProperties);
}

registerSingle(bootstrapContext, ConfigMapPropertySourceLocator.class, configMapPropertySourceLocator,
Expand All @@ -76,7 +76,7 @@ protected void registerBeans(ConfigDataLocationResolverContext resolverContext,
coreV1Api, namespaceProvider, secretsProperties);
if (isRetryEnabledForSecrets(secretsProperties)) {
secretsPropertySourceLocator = new ConfigDataRetryableSecretsPropertySourceLocator(
secretsPropertySourceLocator, secretsProperties, new KubernetesClientSecretsCache());
secretsPropertySourceLocator, secretsProperties);
}

registerSingle(bootstrapContext, SecretsPropertySourceLocator.class, secretsPropertySourceLocator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties;
import org.springframework.cloud.kubernetes.commons.config.ConfigMapPropertySourceLocator;
import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
import org.springframework.cloud.kubernetes.commons.config.ReadType;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;

import static org.springframework.cloud.kubernetes.client.KubernetesClientUtils.getApplicationNamespace;
import static org.springframework.cloud.kubernetes.client.config.KubernetesClientSourcesBatchRead.discardConfigMaps;

/**
* @author Ryan Baxter
Expand All @@ -41,19 +45,26 @@ public class KubernetesClientConfigMapPropertySourceLocator extends ConfigMapPro

public KubernetesClientConfigMapPropertySourceLocator(CoreV1Api coreV1Api, ConfigMapConfigProperties properties,
KubernetesNamespaceProvider kubernetesNamespaceProvider) {
super(properties, new KubernetesClientConfigMapsCache());
super(properties);
this.coreV1Api = coreV1Api;
this.kubernetesNamespaceProvider = kubernetesNamespaceProvider;
}

public PropertySource<?> locate(Environment environment) {
PropertySource<?> propertySource = super.locate(environment);
discardConfigMaps();
return propertySource;
}

@Override
protected MapPropertySource getMapPropertySource(NormalizedSource source, ConfigurableEnvironment environment) {
protected MapPropertySource getMapPropertySource(NormalizedSource source, ConfigurableEnvironment environment,
ReadType readType) {

String normalizedNamespace = source.namespace().orElse(null);
String namespace = getApplicationNamespace(normalizedNamespace, source.target(), kubernetesNamespaceProvider);

KubernetesClientConfigContext context = new KubernetesClientConfigContext(coreV1Api, source, namespace,
environment);
environment, true, readType);
return new KubernetesClientConfigMapPropertySource(context);
}

Expand Down

This file was deleted.

Loading
Loading