Skip to content

Commit

Permalink
Merge branch 'main' into drop-constructors-from-discovery-properties
Browse files Browse the repository at this point in the history
  • Loading branch information
wind57 committed Sep 6, 2024
2 parents 7aec860 + af673ba commit a16c381
Show file tree
Hide file tree
Showing 442 changed files with 9,122 additions and 4,924 deletions.
48 changes: 48 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "main"
schedule:
interval: "weekly"
- package-ecosystem: maven
directory: /
schedule:
interval: daily
target-branch: main
ignore:
# only upgrade by minor or patch
- dependency-name: "*"
update-types:
- version-update:semver-major
- package-ecosystem: maven
directory: /
schedule:
interval: daily
target-branch: 3.1.x
ignore:
# only upgrade by minor or patch
- dependency-name: "*"
update-types:
- version-update:semver-major
- version-update:semver-minor
- package-ecosystem: npm
target-branch: docs-build
directory: /
schedule:
interval: weekly
- package-ecosystem: npm
target-branch: main
directory: /docs
schedule:
interval: weekly
- package-ecosystem: npm
target-branch: 3.1.x
directory: /docs
schedule:
interval: weekly
10 changes: 5 additions & 5 deletions .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: github-workflow

on:
push:
branches: [ main, 3.0.x ]
branches: [ main, 3.1.x, 3.0.x ]
pull_request:
branches: [ main, 3.0.x ]
branches: [ main, 3.1.x, 3.0.x ]

jobs:
build:
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
- name: setup project jdk-17
id: jdk_17
uses: ./.github/workflows/composites/setup-jdk17
if: env.BASE_BRANCH == 'main' || env.BASE_BRANCH == '3.0.x'
if: env.BASE_BRANCH == 'main' || env.BASE_BRANCH == '3.0.x' || env.BASE_BRANCH == '3.1.x'

- name: cache local maven repository
uses: ./.github/workflows/composites/cache
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:

- name: setup project jdk-17
uses: ./.github/workflows/composites/setup-jdk17
if: env.BASE_BRANCH == 'main' || env.BASE_BRANCH == '3.0.x'
if: env.BASE_BRANCH == 'main' || env.BASE_BRANCH == '3.0.x' || env.BASE_BRANCH == '3.1.x'

- name: pre-test-actions
uses: ./.github/workflows/composites/pre-test-actions
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:

- name: setup project jdk-17
uses: ./.github/workflows/composites/setup-jdk17
if: env.BASE_BRANCH == 'main' || env.BASE_BRANCH == '3.0.x'
if: env.BASE_BRANCH == 'main' || env.BASE_BRANCH == '3.0.x' || env.BASE_BRANCH == '3.1.x'

- name: pre-test-actions
uses: ./.github/workflows/composites/pre-test-actions
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ crashlytics-build.properties
node
node_modules
build
package.json
/package.json
package-lock.json
11 changes: 2 additions & 9 deletions docs/antora-playbook.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
antora:
extensions:
- '@springio/antora-extensions/partial-build-extension'
# atlas-extension must be before latest-version-extension so latest versions are applied to imported versions
- '@antora/atlas-extension'
- require: '@springio/antora-extensions/latest-version-extension'
- require: '@springio/antora-extensions/inject-collector-cache-config-extension'
- '@antora/collector-extension'
- require: '@springio/antora-extensions/root-component-extension'
- require: '@springio/antora-extensions'
root_component_name: 'cloud-kubernetes'
- '@springio/antora-extensions/static-page-extension'
site:
title: Spring Cloud Kubernetes
url: https://docs.spring.io/spring-cloud-kubernetes/reference/
Expand Down Expand Up @@ -37,4 +30,4 @@ runtime:
format: pretty
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.11/ui-bundle.zip
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.15/ui-bundle.zip
2 changes: 2 additions & 0 deletions docs/modules/ROOT/pages/property-source-config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ If you would like to load Kubernetes ``PropertySource``s during the bootstrap ph
you can either add `spring-cloud-starter-bootstrap` to your application's classpath or set `spring.cloud.bootstrap.enabled=true`
as an environment variable.

NOTE: It is not supported to load properties during Bootstrap (using `spring-cloud-starter-bootstrap` or `spring.cloud.bootstrap.enabled=true` and load properties using `spring.config.import`. You must use one or the other method.

60 changes: 30 additions & 30 deletions docs/modules/ROOT/partials/_configprops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,28 @@
|spring.cloud.kubernetes.config.retry | |
|spring.cloud.kubernetes.config.sources | |
|spring.cloud.kubernetes.config.use-name-as-prefix | `+++false+++` |
|spring.cloud.kubernetes.discovery.all-namespaces | `+++false+++` |
|spring.cloud.kubernetes.discovery.cache-loading-timeout-seconds | `+++60+++` |
|spring.cloud.kubernetes.discovery.all-namespaces | `+++false+++` | if discover is enabled for all namespaces
|spring.cloud.kubernetes.discovery.cache-loading-timeout-seconds | `+++60+++` | timeout for initializing discovery cache, will abort the application if exceeded.
|spring.cloud.kubernetes.discovery.discovery-server-url | |
|spring.cloud.kubernetes.discovery.enabled | `+++true+++` |
|spring.cloud.kubernetes.discovery.filter | |
|spring.cloud.kubernetes.discovery.include-external-name-services | `+++false+++` |
|spring.cloud.kubernetes.discovery.include-not-ready-addresses | `+++false+++` |
|spring.cloud.kubernetes.discovery.known-secure-ports | `+++[443, 8443]+++` |
|spring.cloud.kubernetes.discovery.metadata.add-annotations | `+++true+++` |
|spring.cloud.kubernetes.discovery.metadata.add-labels | `+++true+++` |
|spring.cloud.kubernetes.discovery.metadata.add-pod-annotations | `+++false+++` |
|spring.cloud.kubernetes.discovery.metadata.add-pod-labels | `+++false+++` |
|spring.cloud.kubernetes.discovery.metadata.add-ports | `+++true+++` |
|spring.cloud.kubernetes.discovery.metadata.annotations-prefix | |
|spring.cloud.kubernetes.discovery.metadata.labels-prefix | |
|spring.cloud.kubernetes.discovery.metadata.ports-prefix | `+++port.+++` |
|spring.cloud.kubernetes.discovery.namespaces | |
|spring.cloud.kubernetes.discovery.enabled | `+++true+++` | if kubernetes discovery is enabled
|spring.cloud.kubernetes.discovery.filter | | SpEL expression to filter services after they have been retrieved from the Kubernetes API server.
|spring.cloud.kubernetes.discovery.include-external-name-services | `+++false+++` | should the discovery also search for services that have "type: ExternalName" in their spec.
|spring.cloud.kubernetes.discovery.include-not-ready-addresses | `+++false+++` | include as discovered if endpoint addresses is not marked with 'ready' by kubernetes
|spring.cloud.kubernetes.discovery.known-secure-ports | `+++[443, 8443]+++` | set of known secure ports
|spring.cloud.kubernetes.discovery.metadata.add-annotations | `+++true+++` | include annotations as metadata
|spring.cloud.kubernetes.discovery.metadata.add-labels | `+++true+++` | include labels as metadata
|spring.cloud.kubernetes.discovery.metadata.add-pod-annotations | `+++false+++` | add pod annotations as part of the response.
|spring.cloud.kubernetes.discovery.metadata.add-pod-labels | `+++false+++` | add pod labels as part of the response.
|spring.cloud.kubernetes.discovery.metadata.add-ports | `+++true+++` | include ports as metadata
|spring.cloud.kubernetes.discovery.metadata.annotations-prefix | | prefix for the annotations
|spring.cloud.kubernetes.discovery.metadata.labels-prefix | | prefix for the labels
|spring.cloud.kubernetes.discovery.metadata.ports-prefix | `+++port.+++` | prefix for the ports, by default it is "port."
|spring.cloud.kubernetes.discovery.namespaces | | If set and allNamespaces is false, then only the services and endpoints matching these namespaces will be fetched from the Kubernetes API server.
|spring.cloud.kubernetes.discovery.order | `+++0+++` |
|spring.cloud.kubernetes.discovery.primary-port-name | |
|spring.cloud.kubernetes.discovery.service-labels | |
|spring.cloud.kubernetes.discovery.use-endpoint-slices | `+++false+++` |
|spring.cloud.kubernetes.discovery.wait-cache-ready | `+++true+++` |
|spring.cloud.kubernetes.discovery.primary-port-name | | If set then the port with a given name is used as primary when multiple ports are defined for a service.
|spring.cloud.kubernetes.discovery.service-labels | | if set, then only the services matching these labels will be fetched from the Kubernetes API server.
|spring.cloud.kubernetes.discovery.use-endpoint-slices | `+++false+++` | use EndpointSlice instead of Endpoints
|spring.cloud.kubernetes.discovery.wait-cache-ready | `+++true+++` | wait for the discovery cache (service and endpoints) to be fully loaded, otherwise aborts the application on starting
|spring.cloud.kubernetes.leader.auto-startup | `+++true+++` | Should leader election be started automatically on startup. Default: true
|spring.cloud.kubernetes.leader.config-map-name | `+++leaders+++` | Kubernetes ConfigMap where leaders information will be stored. Default: leaders
|spring.cloud.kubernetes.leader.create-config-map | `+++true+++` | Enable/disable creating ConfigMap if it does not exist. Default: true
Expand All @@ -91,17 +91,17 @@
|spring.cloud.kubernetes.leader.update-period | `+++60000ms+++` | Leadership status check period. Default: 60s
|spring.cloud.kubernetes.loadbalancer.cluster-domain | `+++cluster.local+++` | cluster domain.
|spring.cloud.kubernetes.loadbalancer.enabled | `+++true+++` | Load balancer enabled,default true.
|spring.cloud.kubernetes.loadbalancer.mode | | {@link KubernetesLoadBalancerMode} setting load balancer server list with ip of pod or service name. default value is POD.
|spring.cloud.kubernetes.loadbalancer.mode | `+++pod+++` | {@link KubernetesLoadBalancerMode} setting load balancer server list with ip of pod or service name. default value is POD.
|spring.cloud.kubernetes.loadbalancer.port-name | `+++http+++` | service port name.
|spring.cloud.kubernetes.reload.enable-reload-filtering | `+++false+++` |
|spring.cloud.kubernetes.reload.enabled | `+++false+++` |
|spring.cloud.kubernetes.reload.max-wait-for-restart | `+++2s+++` |
|spring.cloud.kubernetes.reload.mode | `+++EVENT+++` |
|spring.cloud.kubernetes.reload.monitoring-config-maps | `+++true+++` |
|spring.cloud.kubernetes.reload.monitoring-secrets | `+++false+++` |
|spring.cloud.kubernetes.reload.namespaces | |
|spring.cloud.kubernetes.reload.period | `+++15000ms+++` |
|spring.cloud.kubernetes.reload.strategy | `+++REFRESH+++` |
|spring.cloud.kubernetes.reload.enable-reload-filtering | `+++false+++` | create an informer only for sources that have 'spring.cloud.kubernetes.config.informer.enabled=true' label. This property is only relevant for event based reloading.
|spring.cloud.kubernetes.reload.enabled | `+++false+++` | Enables the Kubernetes configuration reload on change.
|spring.cloud.kubernetes.reload.max-wait-for-restart | `+++2s+++` | Restart or Shutdown strategies are used, Spring Cloud Kubernetes waits a random amount of time before restarting. This is done in order to avoid having all instances of the same application restart at the same time. This property configures the maximum of amount of wait time from the moment the signal is received that a restart is needed until the moment the restart is actually triggered
|spring.cloud.kubernetes.reload.mode | `+++EVENT+++` | Sets the detection mode for Kubernetes configuration reload.
|spring.cloud.kubernetes.reload.monitoring-config-maps | `+++true+++` | Enables monitoring on secrets to detect changes.
|spring.cloud.kubernetes.reload.monitoring-secrets | `+++false+++` | Monitor secrets or not.
|spring.cloud.kubernetes.reload.namespaces | | namespaces where an informer will be set-up. this property is only relevant for event based reloading.
|spring.cloud.kubernetes.reload.period | `+++15000ms+++` | Sets the polling period to use when the detection mode is POLLING.
|spring.cloud.kubernetes.reload.strategy | `+++REFRESH+++` | Sets reload strategy for Kubernetes configuration reload on change.
|spring.cloud.kubernetes.secrets.enable-api | `+++false+++` |
|spring.cloud.kubernetes.secrets.enabled | `+++true+++` | Enable the Secrets property source locator.
|spring.cloud.kubernetes.secrets.fail-fast | `+++false+++` |
Expand Down
10 changes: 10 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
"antora": "3.2.0-alpha.4",
"@antora/atlas-extension": "1.0.0-alpha.2",
"@antora/collector-extension": "1.0.0-alpha.3",
"@asciidoctor/tabs": "1.0.0-beta.6",
"@springio/antora-extensions": "1.11.1",
"@springio/asciidoctor-extensions": "1.0.0-alpha.13"
}
}
4 changes: 2 additions & 2 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-kubernetes</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<packaging>jar</packaging>
Expand Down Expand Up @@ -66,7 +66,7 @@
<artifactId>antora-component-version-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.spring.maven.antora</groupId>
<groupId>org.antora</groupId>
<artifactId>antora-maven-plugin</artifactId>
</plugin>
<plugin>
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>4.1.2-SNAPSHOT</version>
<version>4.2.0-SNAPSHOT</version>
<relativePath/>
</parent>

<artifactId>spring-cloud-kubernetes</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Spring Cloud Kubernetes</name>

Expand Down Expand Up @@ -70,10 +70,10 @@
<failsafe-reports-directory>failsafe-reports</failsafe-reports-directory>
<!-- Dependency Versions -->
<mockito-inline.version>4.8.1</mockito-inline.version>
<spring-cloud-commons.version>4.1.3-SNAPSHOT</spring-cloud-commons.version>
<spring-cloud-config.version>4.1.2-SNAPSHOT</spring-cloud-config.version>
<spring-cloud-bus.version>4.1.2-SNAPSHOT</spring-cloud-bus.version>
<spring-cloud-contract.version>4.1.3-SNAPSHOT</spring-cloud-contract.version>
<spring-cloud-commons.version>4.2.0-SNAPSHOT</spring-cloud-commons.version>
<spring-cloud-config.version>4.2.0-SNAPSHOT</spring-cloud-config.version>
<spring-cloud-bus.version>4.2.0-SNAPSHOT</spring-cloud-bus.version>
<spring-cloud-contract.version>4.2.0-SNAPSHOT</spring-cloud-contract.version>

<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>
<maven-checkstyle-plugin.failsOnViolation>true
Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-kubernetes-client-autoconfig/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>spring-cloud-kubernetes</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>3.1.2-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@ class ActuatorDisabledHealthTest {

@Test
void healthEndpointShouldNotContainKubernetes() {
this.webClient.get().uri("http://localhost:{port}/actuator/health", this.port)
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk().expectBody()
.jsonPath("components.kubernetes").doesNotExist();
this.webClient.get()
.uri("http://localhost:{port}/actuator/health", this.port)
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus()
.isOk()
.expectBody()
.jsonPath("components.kubernetes")
.doesNotExist();

Assertions.assertNull(registry.getContributor("kubernetes"),
"reactive kubernetes contributor must NOT be present when 'management.health.kubernetes.enabled=false'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static void mocks() {
pathsMockedStatic = Mockito.mockStatic(Paths.class);

envReaderMockedStatic.when(() -> EnvReader.getEnv(KubernetesClientPodUtils.KUBERNETES_SERVICE_HOST))
.thenReturn("k8s-host");
.thenReturn("k8s-host");
envReaderMockedStatic.when(() -> EnvReader.getEnv(KubernetesClientPodUtils.HOSTNAME)).thenReturn("host");

Path serviceAccountTokenPath = Mockito.mock(Path.class);
Expand All @@ -104,7 +104,7 @@ KubernetesClientPodUtils kubernetesPodUtils() throws ApiException {
mocks();

Mockito.when(coreV1Api.readNamespacedPod("host", "my-namespace", null))
.thenThrow(new RuntimeException("just because"));
.thenThrow(new RuntimeException("just because"));

return new KubernetesClientPodUtils(coreV1Api, "my-namespace", FAIL_FAST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ class ActuatorEnabledHealthTest {

@Test
void healthEndpointShouldContainKubernetes() {
this.webClient.get().uri("http://localhost:{port}/actuator/health", this.port)
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk().expectBody()
.jsonPath("components.kubernetes").exists();
this.webClient.get()
.uri("http://localhost:{port}/actuator/health", this.port)
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus()
.isOk()
.expectBody()
.jsonPath("components.kubernetes")
.exists();

Assertions.assertNotNull(registry.getContributor("kubernetes"),
"reactive kubernetes contributor must be present when 'management.health.kubernetes.enabled=true'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static void mocks() {
pathsMockedStatic = Mockito.mockStatic(Paths.class);

envReaderMockedStatic.when(() -> EnvReader.getEnv(KubernetesClientPodUtils.KUBERNETES_SERVICE_HOST))
.thenReturn("k8s-host");
.thenReturn("k8s-host");
envReaderMockedStatic.when(() -> EnvReader.getEnv(KubernetesClientPodUtils.HOSTNAME)).thenReturn("host");

Path serviceAccountTokenPath = Mockito.mock(Path.class);
Expand All @@ -107,7 +107,7 @@ KubernetesClientPodUtils kubernetesPodUtils() throws ApiException {
mocks();

Mockito.when(coreV1Api.readNamespacedPod("host", "my-namespace", null))
.thenThrow(new RuntimeException("just because"));
.thenThrow(new RuntimeException("just because"));

return new KubernetesClientPodUtils(coreV1Api, "my-namespace", FAIL_FAST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class KubernetesClientHealthIndicatorNotInsideTests {
@Test
public void test() {
assertThatThrownBy(() -> context.getBean(KubernetesClientHealthIndicator.class))
.isInstanceOf(NoSuchBeanDefinitionException.class);
.isInstanceOf(NoSuchBeanDefinitionException.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class KubernetesClientInfoContributorNotInsideTests {
@Test
public void test() {
assertThatThrownBy(() -> context.getBean(KubernetesClientInfoContributor.class))
.isInstanceOf(NoSuchBeanDefinitionException.class);
.isInstanceOf(NoSuchBeanDefinitionException.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void after() {
@Test
void constructorThrowsIllegalArgumentExceptionWhenKubeClientIsNull() {
assertThatThrownBy(() -> new KubernetesClientPodUtils(null, "namespace", false))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Must provide an instance of KubernetesClient");
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Must provide an instance of KubernetesClient");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void testNamespaceFromProvider() {
@Test
void testNamespaceResolutionFailed() {
assertThatThrownBy(() -> KubernetesClientUtils.getApplicationNamespace("", "target", null))
.isInstanceOf(NamespaceResolutionFailedException.class);
.isInstanceOf(NamespaceResolutionFailedException.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void testApiClientUserAgentDefaultHeader() throws MalformedURLException {
Request.Builder builder = new Request.Builder();
apiClient.processHeaderParams(Collections.emptyMap(), builder);
assertThat(builder.url(new URL("http://example.com")).build().headers().get("User-Agent"))
.isEqualTo("Spring-Cloud-Kubernetes-Application");
.isEqualTo("Spring-Cloud-Kubernetes-Application");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void testApiClientUserAgentDefaultHeader() throws MalformedURLException {
Request.Builder builder = new Request.Builder();
apiClient.processHeaderParams(Collections.emptyMap(), builder);
assertThat(builder.url(new URL("http://example.com")).build().headers().get("User-Agent"))
.isEqualTo("non-default");
.isEqualTo("non-default");
}

}
Loading

0 comments on commit a16c381

Please sign in to comment.