Initial commit
This commit is contained in:
86
spring-cloud-kubernetes-integration-tests/.flattened-pom.xml
Normal file
86
spring-cloud-kubernetes-integration-tests/.flattened-pom.xml
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests</url>
|
||||
</scm>
|
||||
</project>
|
||||
@@ -1,42 +0,0 @@
|
||||
Writing a new integration test should be done with minor things in mind, so that
|
||||
tests are picked up by our CI/CD pipeline and work as expected. In particular when you
|
||||
define the plugin that builds the image (integrations tests have a docker image build),
|
||||
you must name the image with the same name as the module. For example:
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<configuration>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build-image</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
Notice this line:
|
||||
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
|
||||
You must follow the same convention.
|
||||
|
||||
One more important part in this configuration is : "<skip>${skip.build.image}</skip>".
|
||||
We use this setting in the build pipeline where in some stages we skip the image build,
|
||||
only to have it build in some latter ones.
|
||||
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-parent</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Discovery Parent</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/discovery-parent</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/discovery-parent</url>
|
||||
</scm>
|
||||
</project>
|
||||
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-parent</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-client</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Discovery Client</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-client</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-client</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-client</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-client</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-fabric8-discovery</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-parent</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-service-a</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Discovery Service A</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-service-a</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-service-a</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-service-a</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-service-a</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-parent</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-service-b</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Discovery Service B</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-service-b</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-service-b</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-service-b</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/discovery-parent/discovery-service-b</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-parent</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>kubernetes-client-discovery</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Kubernetes Client Discovery</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/discovery-parent/kubernetes-client-discovery</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/kubernetes-client-discovery</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/kubernetes-client-discovery</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/discovery-parent/kubernetes-client-discovery</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-discovery</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>discovery-parent</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>tests</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Discovery Tests</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/discovery-parent/tests</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/tests</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/discovery-parent/tests</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/discovery-parent/tests</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.12.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
<version>3.12.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>load-balancer</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Load Balancer</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/load-balancer</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/load-balancer</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/load-balancer</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/load-balancer</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-fabric8-loadbalancer</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes</artifactId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<docker-java.version>3.2.13</docker-java.version>
|
||||
<testcontainers.version>1.18.0</testcontainers.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>${maven-deploy-plugin.version}</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>k3s</artifactId>
|
||||
<version>${testcontainers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
<module>spring-cloud-kubernetes-fabric8-client-configmap</module>
|
||||
<module>spring-cloud-kubernetes-fabric8-istio-it</module>
|
||||
<module>spring-cloud-kubernetes-fabric8-client-discovery</module>
|
||||
<module>spring-cloud-kubernetes-fabric8-client-loadbalancer</module>
|
||||
<module>spring-cloud-kubernetes-fabric8-client-configmap-polling-reload</module>
|
||||
<module>spring-cloud-kubernetes-fabric8-client-secrets-event-reload</module>
|
||||
<module>spring-cloud-kubernetes-fabric8-client-configmap-event-reload</module>
|
||||
|
||||
<module>spring-cloud-kubernetes-discoveryclient-it</module>
|
||||
<module>spring-cloud-kubernetes-client-loadbalancer-it</module>
|
||||
<module>spring-cloud-kubernetes-configuration-watcher-it</module>
|
||||
<module>spring-cloud-kubernetes-client-event-and-polling-reload</module>
|
||||
<module>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</module>
|
||||
<module>spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps</module>
|
||||
<module>spring-cloud-kubernetes-fabric8-client-catalog-watcher</module>
|
||||
<module>spring-cloud-kubernetes-client-catalog-watcher</module>
|
||||
<module>spring-cloud-kubernetes-client-discovery-it</module>
|
||||
<module>spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>simple-configmap</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Simple Configmap</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/simple-configmap</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/simple-configmap</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/simple-configmap</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/simple-configmap</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-fabric8-config</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.12.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
<version>3.12.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>simple-core</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<name>Spring Cloud Kubernetes :: Integration Tests :: Simple Core</name>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes
|
||||
cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/simple-core</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/simple-core</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/simple-core</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/simple-core</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
||||
<version>2.6.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-fabric8-autoconfig</artifactId>
|
||||
<version>2.1.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.12.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
<version>3.12.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-catalog-watcher</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-discovery</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,106 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-kubernetes-client-catalog-watcher</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-test-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<!-- build image in the 'package' phase, and ignore plain tests -->
|
||||
<!-- via maven-surefire-plugin::skipTests -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<configuration>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build-image</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- ignore plain tests (in the 'test' phase), so that we could build the image first, see above -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- run tests in the 'integration-tests' phase, one that is after 'package' (where we build the image) -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${testsToRun}</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.catalog;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.catalog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.EndpointNameAndNamespace;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* holds an EndpointNameAndNamespace object, needed so that the controller can poll to see
|
||||
* if anything has changed. And we call the controller from our tests.
|
||||
*
|
||||
* @author wind57
|
||||
*/
|
||||
@Service
|
||||
public class EndpointNameAndNamespaceService {
|
||||
|
||||
private List<EndpointNameAndNamespace> result;
|
||||
|
||||
public List<EndpointNameAndNamespace> result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(List<EndpointNameAndNamespace> result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.catalog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.EndpointNameAndNamespace;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Listener that will catch events from KubernetesCatalogWatch.
|
||||
*
|
||||
* @author wind57
|
||||
*/
|
||||
@Component
|
||||
public class HeartBeatListener implements ApplicationListener<ApplicationEvent> {
|
||||
|
||||
private final EndpointNameAndNamespaceService service;
|
||||
|
||||
public HeartBeatListener(EndpointNameAndNamespaceService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (event instanceof HeartbeatEvent heartbeatEvent) {
|
||||
List<EndpointNameAndNamespace> result = (List<EndpointNameAndNamespace>) heartbeatEvent.getValue();
|
||||
service.setResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.catalog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.EndpointNameAndNamespace;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class HeartbeatController {
|
||||
|
||||
private final EndpointNameAndNamespaceService service;
|
||||
|
||||
public HeartbeatController(EndpointNameAndNamespaceService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@GetMapping("/result")
|
||||
public List<EndpointNameAndNamespace> result() {
|
||||
return service.result();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.catalog;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import io.kubernetes.client.openapi.models.V1Deployment;
|
||||
import io.kubernetes.client.openapi.models.V1Ingress;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.EndpointNameAndNamespace;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.springframework.cloud.kubernetes.client.catalog.KubernetesClientCatalogWatchUtils.patchForEndpointSlices;
|
||||
import static org.springframework.cloud.kubernetes.client.catalog.KubernetesClientCatalogWatchUtils.patchForEndpointSlicesNamespaces;
|
||||
import static org.springframework.cloud.kubernetes.client.catalog.KubernetesClientCatalogWatchUtils.patchForEndpointsNamespaces;
|
||||
import static org.springframework.cloud.kubernetes.integration.tests.commons.Commons.waitForLogStatement;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class KubernetesClientCatalogWatchIT {
|
||||
|
||||
private static final String APP_NAME = "spring-cloud-kubernetes-client-catalog-watcher";
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final String NAMESPACE_A = "namespacea";
|
||||
|
||||
private static final String NAMESPACE_B = "namespaceb";
|
||||
|
||||
private static final K3sContainer K3S = Commons.container();
|
||||
|
||||
private static final String DOCKER_IMAGE = "docker.io/springcloud/" + APP_NAME + ":" + Commons.pomVersion();
|
||||
|
||||
private static Util util;
|
||||
|
||||
@BeforeAll
|
||||
static void beforeAll() throws Exception {
|
||||
K3S.start();
|
||||
Commons.validateImage(APP_NAME, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(APP_NAME, K3S);
|
||||
util = new Util(K3S);
|
||||
util.setUp(NAMESPACE);
|
||||
app(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() {
|
||||
util.deleteClusterWide(NAMESPACE, Set.of(NAMESPACE_A, NAMESPACE_B));
|
||||
util.deleteNamespace(NAMESPACE_A);
|
||||
util.deleteNamespace(NAMESPACE_B);
|
||||
app(Phase.DELETE);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
util.busybox(NAMESPACE, Phase.CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - we deploy a busybox service with 2 replica pods
|
||||
* - we receive an event from KubernetesCatalogWatcher, assert what is inside it
|
||||
* - delete the busybox service
|
||||
* - assert that we receive only spring-cloud-kubernetes-client-catalog-watcher pod
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Order(1)
|
||||
void testCatalogWatchWithEndpoints() {
|
||||
waitForLogStatement("stateGenerator is of type: KubernetesEndpointsCatalogWatch", K3S, APP_NAME);
|
||||
test();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void testCatalogWatchWithEndpointSlices() {
|
||||
patchForEndpointSlices(APP_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
waitForLogStatement("stateGenerator is of type: KubernetesEndpointSlicesCatalogWatch", K3S, APP_NAME);
|
||||
test();
|
||||
|
||||
testCatalogWatchWithEndpointsNamespaces();
|
||||
}
|
||||
|
||||
void testCatalogWatchWithEndpointsNamespaces() {
|
||||
util.createNamespace(NAMESPACE_A);
|
||||
util.createNamespace(NAMESPACE_B);
|
||||
util.setUpClusterWide(NAMESPACE, Set.of(NAMESPACE_A, NAMESPACE_B));
|
||||
util.busybox(NAMESPACE_A, Phase.CREATE);
|
||||
util.busybox(NAMESPACE_B, Phase.CREATE);
|
||||
patchForEndpointsNamespaces(APP_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
KubernetesClientCatalogWatchNamespacesDelegate.testCatalogWatchWithEndpointsNamespaces();
|
||||
|
||||
util.busybox(NAMESPACE_A, Phase.CREATE);
|
||||
util.busybox(NAMESPACE_B, Phase.CREATE);
|
||||
patchForEndpointSlicesNamespaces(APP_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
KubernetesClientCatalogWatchNamespacesDelegate.testCatalogWatchWithEndpointSlicesNamespaces();
|
||||
}
|
||||
|
||||
/**
|
||||
* the test is the same for both endpoints and endpoint slices, the set-up for them is
|
||||
* different.
|
||||
*/
|
||||
private void test() {
|
||||
|
||||
WebClient client = builder().baseUrl("http://localhost/result").build();
|
||||
EndpointNameAndNamespace[] holder = new EndpointNameAndNamespace[2];
|
||||
ResolvableType resolvableType = ResolvableType.forClassWithGenerics(List.class, EndpointNameAndNamespace.class);
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(240)).until(() -> {
|
||||
List<EndpointNameAndNamespace> result = (List<EndpointNameAndNamespace>) client.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(ParameterizedTypeReference.forType(resolvableType.getType()))
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
// we get 3 pods as input, but because they are sorted by name in the catalog
|
||||
// watcher implementation
|
||||
// we will get the first busybox instances here.
|
||||
|
||||
if (result != null) {
|
||||
if (result.size() != 3) {
|
||||
return false;
|
||||
}
|
||||
holder[0] = result.get(0);
|
||||
holder[1] = result.get(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
EndpointNameAndNamespace resultOne = holder[0];
|
||||
EndpointNameAndNamespace resultTwo = holder[1];
|
||||
|
||||
Assertions.assertNotNull(resultOne);
|
||||
Assertions.assertNotNull(resultTwo);
|
||||
|
||||
Assertions.assertTrue(resultOne.endpointName().contains("busybox"));
|
||||
Assertions.assertTrue(resultTwo.endpointName().contains("busybox"));
|
||||
Assertions.assertEquals("default", resultOne.namespace());
|
||||
Assertions.assertEquals("default", resultTwo.namespace());
|
||||
|
||||
util.busybox(NAMESPACE, Phase.DELETE);
|
||||
|
||||
// what we get after delete
|
||||
EndpointNameAndNamespace[] afterDelete = new EndpointNameAndNamespace[1];
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(240)).until(() -> {
|
||||
List<EndpointNameAndNamespace> result = (List<EndpointNameAndNamespace>) client.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(ParameterizedTypeReference.forType(resolvableType.getType()))
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
// we need to get the event from KubernetesCatalogWatch, but that happens
|
||||
// on periodic bases. So in order to be sure we got the event we care about
|
||||
// we wait until the result has a single entry, which means busybox was
|
||||
// deleted
|
||||
// + KubernetesCatalogWatch received the new update.
|
||||
if (result != null && result.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// we will only receive one pod here, our own
|
||||
if (result != null) {
|
||||
afterDelete[0] = result.get(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
Assertions.assertTrue(afterDelete[0].endpointName().contains(APP_NAME));
|
||||
Assertions.assertEquals("default", afterDelete[0].namespace());
|
||||
|
||||
}
|
||||
|
||||
private static void app(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util.yaml("app/watcher-deployment.yaml");
|
||||
V1Service service = (V1Service) util.yaml("app/watcher-service.yaml");
|
||||
V1Ingress ingress = (V1Ingress) util.yaml("app/watcher-ingress.yaml");
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, ingress, true);
|
||||
}
|
||||
else if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, ingress);
|
||||
}
|
||||
}
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.catalog;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.EndpointNameAndNamespace;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.springframework.cloud.kubernetes.integration.tests.commons.Commons.waitForLogStatement;
|
||||
|
||||
final class KubernetesClientCatalogWatchNamespacesDelegate {
|
||||
|
||||
private KubernetesClientCatalogWatchNamespacesDelegate() {
|
||||
|
||||
}
|
||||
|
||||
private static final String APP_NAME = "spring-cloud-kubernetes-client-catalog-watcher";
|
||||
|
||||
private static final String NAMESPACE_A = "namespacea";
|
||||
|
||||
private static final String NAMESPACE_B = "namespaceb";
|
||||
|
||||
private static final K3sContainer K3S = Commons.container();
|
||||
|
||||
private static Util util;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - we deploy one busybox service with 2 replica pods in namespace namespacea
|
||||
* - we deploy one busybox service with 2 replica pods in namespace namespaceb
|
||||
* - we enable the search to be made in namespacea and default ones
|
||||
* - we receive an event from KubernetesCatalogWatcher, assert what is inside it
|
||||
* - delete both busybox services in namespacea and namespaceb
|
||||
* - assert that we receive only spring-cloud-kubernetes-client-catalog-watcher pod
|
||||
* </pre>
|
||||
*/
|
||||
static void testCatalogWatchWithEndpointsNamespaces() {
|
||||
waitForLogStatement("stateGenerator is of type: KubernetesEndpointsCatalogWatch", K3S, APP_NAME);
|
||||
testForNamespacesFilter();
|
||||
}
|
||||
|
||||
static void testCatalogWatchWithEndpointSlicesNamespaces() {
|
||||
waitForLogStatement("stateGenerator is of type: KubernetesEndpointSlicesCatalogWatch", K3S, APP_NAME);
|
||||
testForNamespacesFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* the test is the same for both endpoints and endpoint slices, the set-up for them is
|
||||
* different.
|
||||
*/
|
||||
private static void testForNamespacesFilter() {
|
||||
|
||||
WebClient client = builder().baseUrl("http://localhost/result").build();
|
||||
EndpointNameAndNamespace[] holder = new EndpointNameAndNamespace[4];
|
||||
ResolvableType resolvableType = ResolvableType.forClassWithGenerics(List.class, EndpointNameAndNamespace.class);
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(240)).until(() -> {
|
||||
List<EndpointNameAndNamespace> result = (List<EndpointNameAndNamespace>) client.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(ParameterizedTypeReference.forType(resolvableType.getType()))
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
if (result != null) {
|
||||
// 2 from namespace-a, 2 from namespace-b
|
||||
Assertions.assertEquals(result.size(), 4);
|
||||
holder[0] = result.get(0);
|
||||
holder[1] = result.get(1);
|
||||
holder[2] = result.get(2);
|
||||
holder[3] = result.get(3);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
EndpointNameAndNamespace resultOne = holder[0];
|
||||
EndpointNameAndNamespace resultTwo = holder[1];
|
||||
EndpointNameAndNamespace resultThree = holder[2];
|
||||
EndpointNameAndNamespace resultFour = holder[3];
|
||||
|
||||
Assertions.assertTrue(resultOne.endpointName().contains("busybox"));
|
||||
Assertions.assertTrue(resultTwo.endpointName().contains("busybox"));
|
||||
Assertions.assertTrue(resultThree.endpointName().contains("busybox"));
|
||||
Assertions.assertTrue(resultFour.endpointName().contains("busybox"));
|
||||
|
||||
List<EndpointNameAndNamespace> sorted = Arrays.stream(holder)
|
||||
.sorted(Comparator.comparing(EndpointNameAndNamespace::namespace)).toList();
|
||||
|
||||
Assertions.assertEquals(NAMESPACE_A, sorted.get(0).namespace());
|
||||
Assertions.assertEquals(NAMESPACE_A, sorted.get(1).namespace());
|
||||
Assertions.assertEquals(NAMESPACE_B, sorted.get(2).namespace());
|
||||
Assertions.assertEquals(NAMESPACE_B, sorted.get(3).namespace());
|
||||
|
||||
util = new Util(K3S);
|
||||
util.busybox(NAMESPACE_A, Phase.DELETE);
|
||||
util.busybox(NAMESPACE_B, Phase.DELETE);
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(240)).until(() -> {
|
||||
List<EndpointNameAndNamespace> result = (List<EndpointNameAndNamespace>) client.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(ParameterizedTypeReference.forType(resolvableType.getType()))
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
// there is no update to receive anymore, as there is nothing in namespacea
|
||||
// and namespaceb
|
||||
return result.size() == 0;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private static RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.catalog;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util.patchWithReplace;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
final class KubernetesClientCatalogWatchUtils {
|
||||
|
||||
private static final Map<String, String> POD_LABELS = Map.of("app",
|
||||
"spring-cloud-kubernetes-client-catalog-watcher");
|
||||
|
||||
private KubernetesClientCatalogWatchUtils() {
|
||||
|
||||
}
|
||||
|
||||
private static final String BODY_ONE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-catalog-watcher",
|
||||
"image": "image_name_here",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_USE_ENDPOINT_SLICES",
|
||||
"value": "TRUE"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY_CATALOG",
|
||||
"value": "DEBUG"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_TWO = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-catalog-watcher",
|
||||
"image": "image_name_here",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_USE_ENDPOINT_SLICES",
|
||||
"value": "FALSE"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY_CATALOG",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_0",
|
||||
"value": "namespacea"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_1",
|
||||
"value": "namespaceb"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_THREE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-catalog-watcher",
|
||||
"image": "image_name_here",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_USE_ENDPOINT_SLICES",
|
||||
"value": "TRUE"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY_CATALOG",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_0",
|
||||
"value": "namespacea"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_1",
|
||||
"value": "namespaceb"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
static void patchForEndpointSlices(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_ONE, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForEndpointsNamespaces(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_TWO, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForEndpointSlicesNamespaces(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_THREE, POD_LABELS);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spring-cloud-kubernetes-client-catalog-watcher
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spring-cloud-kubernetes-client-catalog-watcher
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-client-catalog-watcher
|
||||
spec:
|
||||
serviceAccountName: spring-cloud-kubernetes-serviceaccount
|
||||
containers:
|
||||
- name: spring-cloud-kubernetes-client-catalog-watcher
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-client-catalog-watcher
|
||||
imagePullPolicy: IfNotPresent
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/readiness
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/liveness
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
env:
|
||||
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY_CATALOG
|
||||
value: "DEBUG"
|
||||
- name: SPRING_CLOUD_KUBERNETES_DISCOVERY_USE_ENDPOINT_SLICES
|
||||
value: "FALSE"
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: spring-cloud-kubernetes-client-catalog-watcher-ingress
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: spring-cloud-kubernetes-client-catalog-watcher-service
|
||||
port:
|
||||
number: 8080
|
||||
@@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-client-catalog-watcher-service
|
||||
name: spring-cloud-kubernetes-client-catalog-watcher-service
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: spring-cloud-kubernetes-client-catalog-watcher
|
||||
type: ClusterIP
|
||||
@@ -1,15 +0,0 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
<logger name="org.testcontainers" level="INFO"/>
|
||||
<logger name="com.github.dockerjava" level="WARN"/>
|
||||
<logger name="io.fabric8.kubernetes.client" level="ERROR"/>
|
||||
</configuration>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-config-it</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-config-it</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-config-it</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-config-it</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-config-it</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-client-config</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>4.0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</url>
|
||||
</scm>
|
||||
</project>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a</module>
|
||||
<module>spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b</module>
|
||||
<module>spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-kafka</artifactId>
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<artifactId>spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<configuration>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build-image</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.configuration.watcher.appA;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class AppATestApplication implements ApplicationListener<RefreshRemoteApplicationEvent> {
|
||||
|
||||
private final Log LOG = LogFactory.getLog(getClass());
|
||||
|
||||
private boolean value = false;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AppATestApplication.class, args);
|
||||
}
|
||||
|
||||
@GetMapping("/app-a")
|
||||
public boolean index() {
|
||||
LOG.info("Current value: " + value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(RefreshRemoteApplicationEvent refreshRemoteApplicationEvent) {
|
||||
LOG.info("Received remote refresh event from origin: " + refreshRemoteApplicationEvent.getOriginService()
|
||||
+ " to destination : " + refreshRemoteApplicationEvent.getDestinationService());
|
||||
this.value = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#logging:
|
||||
# level:
|
||||
# org.springframework: DEBUG
|
||||
#
|
||||
spring:
|
||||
application:
|
||||
name: spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a
|
||||
cloud:
|
||||
bus:
|
||||
refresh:
|
||||
enabled: false
|
||||
enabled: true
|
||||
destination: multiple-apps
|
||||
stream:
|
||||
default-binder: kafka
|
||||
management:
|
||||
endpoint:
|
||||
health:
|
||||
probes:
|
||||
enabled: true
|
||||
server:
|
||||
port: 8080
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<relativePath>../../spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</relativePath>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-kafka</artifactId>
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<relativePath>../../spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<artifactId>spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<configuration>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build-image</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.configuration.watcher.appB;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class AppBTestApplication implements ApplicationListener<RefreshRemoteApplicationEvent> {
|
||||
|
||||
private final Log LOG = LogFactory.getLog(getClass());
|
||||
|
||||
private boolean value = false;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AppBTestApplication.class, args);
|
||||
}
|
||||
|
||||
@GetMapping("/app-b")
|
||||
public boolean index() {
|
||||
LOG.info("Current value: " + value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(RefreshRemoteApplicationEvent refreshRemoteApplicationEvent) {
|
||||
LOG.info("Received remote refresh event from origin: " + refreshRemoteApplicationEvent.getOriginService()
|
||||
+ " to destination : " + refreshRemoteApplicationEvent.getDestinationService());
|
||||
this.value = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#logging:
|
||||
# level:
|
||||
# org.springframework: DEBUG
|
||||
#
|
||||
spring:
|
||||
application:
|
||||
name: spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b
|
||||
cloud:
|
||||
bus:
|
||||
refresh:
|
||||
enabled: false
|
||||
enabled: true
|
||||
destination: multiple-apps
|
||||
stream:
|
||||
default-binder: kafka
|
||||
management:
|
||||
endpoint:
|
||||
health:
|
||||
probes:
|
||||
enabled: true
|
||||
server:
|
||||
port: 8081
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<artifactId>spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-test-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<!-- ignore plain tests (in the 'test' phase), so that we could build the image first, see above -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${testsToRun}</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,197 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.configuration.watcher.multiple.apps;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.kubernetes.client.openapi.models.V1ConfigMap;
|
||||
import io.kubernetes.client.openapi.models.V1ConfigMapBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1Deployment;
|
||||
import io.kubernetes.client.openapi.models.V1Ingress;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
class ConfigurationWatcherMultipleAppsIT {
|
||||
|
||||
private static final String CONFIG_WATCHER_APP_A_IMAGE = "spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a";
|
||||
|
||||
private static final String CONFIG_WATCHER_APP_B_IMAGE = "spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b";
|
||||
|
||||
private static final String SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME = "spring-cloud-kubernetes-configuration-watcher";
|
||||
|
||||
private static final String CONFIG_MAP_NAME = "multiple-apps";
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final K3sContainer K3S = Commons.container();
|
||||
|
||||
private static Util util;
|
||||
|
||||
@BeforeAll
|
||||
static void beforeAll() throws Exception {
|
||||
K3S.start();
|
||||
util = new Util(K3S);
|
||||
|
||||
Commons.validateImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
|
||||
Commons.validateImage(CONFIG_WATCHER_APP_A_IMAGE, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(CONFIG_WATCHER_APP_A_IMAGE, K3S);
|
||||
|
||||
Commons.validateImage(CONFIG_WATCHER_APP_B_IMAGE, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(CONFIG_WATCHER_APP_B_IMAGE, K3S);
|
||||
|
||||
util = new Util(K3S);
|
||||
util.setUp(NAMESPACE);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() throws Exception {
|
||||
Commons.cleanUp(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
Commons.cleanUp(CONFIG_WATCHER_APP_A_IMAGE, K3S);
|
||||
Commons.cleanUp(CONFIG_WATCHER_APP_B_IMAGE, K3S);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
util.zookeeper(NAMESPACE, Phase.CREATE);
|
||||
util.kafka(NAMESPACE, Phase.CREATE);
|
||||
appA(Phase.CREATE);
|
||||
appB(Phase.CREATE);
|
||||
configWatcher(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
util.zookeeper(NAMESPACE, Phase.DELETE);
|
||||
util.kafka(NAMESPACE, Phase.DELETE);
|
||||
appA(Phase.DELETE);
|
||||
appB(Phase.DELETE);
|
||||
configWatcher(Phase.DELETE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRefresh() {
|
||||
|
||||
// configmap has one label, one that says that we should refresh
|
||||
// and one annotation that says that we should refresh some specific services
|
||||
V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName(CONFIG_MAP_NAME)
|
||||
.addToLabels("spring.cloud.kubernetes.config", "true")
|
||||
.addToAnnotations("spring.cloud.kubernetes.configmap.apps",
|
||||
"spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a, "
|
||||
+ "spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b")
|
||||
.endMetadata().addToData("foo", "hello world").build();
|
||||
util.createAndWait(NAMESPACE, configMap, null);
|
||||
|
||||
WebClient.Builder builderA = builder();
|
||||
WebClient serviceClientA = builderA.baseUrl("http://localhost:80/app-a").build();
|
||||
|
||||
WebClient.Builder builderB = builder();
|
||||
WebClient serviceClientB = builderB.baseUrl("http://localhost:80/app-b").build();
|
||||
|
||||
Boolean[] valueA = new Boolean[1];
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(240)).until(() -> {
|
||||
valueA[0] = serviceClientA.method(HttpMethod.GET).retrieve().bodyToMono(Boolean.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
return valueA[0];
|
||||
});
|
||||
|
||||
Assertions.assertTrue(valueA[0]);
|
||||
|
||||
Boolean[] valueB = new Boolean[1];
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(240)).until(() -> {
|
||||
valueB[0] = serviceClientB.method(HttpMethod.GET).retrieve().bodyToMono(Boolean.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
return valueB[0];
|
||||
});
|
||||
|
||||
Assertions.assertTrue(valueB[0]);
|
||||
util.deleteAndWait(NAMESPACE, configMap, null);
|
||||
}
|
||||
|
||||
private void appA(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util.yaml("app-a/app-a-deployment.yaml");
|
||||
V1Service service = (V1Service) util.yaml("app-a/app-a-service.yaml");
|
||||
V1Ingress ingress = (V1Ingress) util
|
||||
.yaml("ingress/spring-cloud-kubernetes-configuration-watcher-multiple-apps-ingress.yaml");
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, ingress, true);
|
||||
}
|
||||
else if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, ingress);
|
||||
}
|
||||
}
|
||||
|
||||
private void appB(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util.yaml("app-b/app-b-deployment.yaml");
|
||||
V1Service service = (V1Service) util.yaml("app-b/app-b-service.yaml");
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, null, true);
|
||||
}
|
||||
else if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void configWatcher(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-bus-kafka-deployment.yaml");
|
||||
V1Service service = (V1Service) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-service.yaml");
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, null, true);
|
||||
}
|
||||
else if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, null);
|
||||
}
|
||||
}
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(240, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app-a-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: app-a
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: app-a
|
||||
spec:
|
||||
containers:
|
||||
- name: app-a
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-a
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: SPRING_PROFILES_ACTIVE
|
||||
value: bus-kafka
|
||||
- name: spring.kafka.bootstrap-servers
|
||||
value: kafka:9092
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/readiness
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/liveness
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
@@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: app-a
|
||||
name: app-a
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: app-a
|
||||
type: ClusterIP
|
||||
@@ -1,42 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app-b-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: app-b
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: app-b
|
||||
spec:
|
||||
containers:
|
||||
- name: app-b
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-client-configuration-watcher-configmap-app-b
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: SPRING_PROFILES_ACTIVE
|
||||
value: bus-kafka
|
||||
- name: spring.kafka.bootstrap-servers
|
||||
value: kafka:9092
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8081
|
||||
path: /actuator/health/readiness
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8081
|
||||
path: /actuator/health/liveness
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
ports:
|
||||
- containerPort: 8081
|
||||
@@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: app-b
|
||||
name: app-b
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8081
|
||||
targetPort: 8081
|
||||
selector:
|
||||
app: app-b
|
||||
type: ClusterIP
|
||||
@@ -1,47 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spring-cloud-kubernetes-configuration-watcher-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spring-cloud-kubernetes-configuration-watcher
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-configuration-watcher
|
||||
spec:
|
||||
serviceAccountName: spring-cloud-kubernetes-serviceaccount
|
||||
containers:
|
||||
- name: spring-cloud-kubernetes-configuration-watcher
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-configuration-watcher
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: SPRING_PROFILES_ACTIVE
|
||||
value: bus-kafka
|
||||
- name: SPRING_CLOUD_BUS_DESTINATION
|
||||
value: multiple-apps
|
||||
- name: spring.kafka.bootstrap-servers
|
||||
value: kafka:9092
|
||||
- name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY
|
||||
value: 1
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8888
|
||||
path: /actuator/health/readiness
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8888
|
||||
path: /actuator/health/liveness
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
ports:
|
||||
- containerPort: 8888
|
||||
@@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-configuration-watcher
|
||||
name: spring-cloud-kubernetes-configuration-watcher
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8888
|
||||
targetPort: 8888
|
||||
selector:
|
||||
app: spring-cloud-kubernetes-configuration-watcher
|
||||
type: ClusterIP
|
||||
@@ -1,26 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: it-ingress-multiple-apps
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /app-a
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: app-a
|
||||
port:
|
||||
number: 8080
|
||||
|
||||
- http:
|
||||
paths:
|
||||
- path: /app-b
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: app-b
|
||||
port:
|
||||
number: 8081
|
||||
@@ -1,14 +0,0 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
<logger name="org.testcontainers" level="INFO"/>
|
||||
<logger name="com.github.dockerjava" level="WARN"/>
|
||||
</configuration>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-event-reload</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-client-config</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>4.0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-configmap-polling-reload</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-client-config</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter</artifactId>
|
||||
<version>4.0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-discovery-it</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<description>Integration tests where SCK applications are run inside a Kubernetes cluster</description>
|
||||
<url>https://cloud.spring.io/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it</url>
|
||||
<inceptionYear>2017</inceptionYear>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>https://www.spring.io</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dsyer</id>
|
||||
<name>Dave Syer</name>
|
||||
<email>dsyer at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>sgibb</id>
|
||||
<name>Spencer Gibb</name>
|
||||
<email>sgibb at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>lead</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mgrzejszczak</id>
|
||||
<name>Marcin Grzejszczak</name>
|
||||
<email>mgrzejszczak at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>rbaxter</id>
|
||||
<name>Ryan Baxter</name>
|
||||
<email>rbaxter at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>omaciaszeksharma</id>
|
||||
<name>Olga Maciaszek-Sharma</name>
|
||||
<email>omaciaszeksharma at pivotal.io</email>
|
||||
<organization>Pivotal Software, Inc.</organization>
|
||||
<organizationUrl>https://www.spring.io</organizationUrl>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-kubernetes.git/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-kubernetes/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it</url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-discovery</artifactId>
|
||||
<version>3.0.4-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,115 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-kubernetes-client-discovery-it</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-test-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<!-- build image in the 'package' phase, and ignore plain tests -->
|
||||
<!-- via maven-surefire-plugin::skipTests -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<configuration>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build-image</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- ignore plain tests (in the 'test' phase), so that we could build the image first, see above -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- run tests in the 'integration-tests' phase, one that is after 'package' (where we build the image) -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${testsToRun}</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class DiscoveryApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DiscoveryApp.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import io.kubernetes.client.openapi.models.V1Pod;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.log.LogAccessor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryClientHealthIndicatorInitializer.RegisteredEventSource;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@Component
|
||||
public class DiscoveryApplicationListener implements ApplicationListener<InstanceRegisteredEvent<?>> {
|
||||
|
||||
private static final LogAccessor LOG = new LogAccessor(LogFactory.getLog(DiscoveryApplicationListener.class));
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(InstanceRegisteredEvent<?> event) {
|
||||
V1Pod pod = (V1Pod) ((RegisteredEventSource) event.getSource()).pod();
|
||||
LOG.info(() -> "received InstanceRegisteredEvent from pod with 'app' label value : "
|
||||
+ pod.getMetadata().getLabels().get("app"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.kubernetes.client.discovery.KubernetesInformerDiscoveryClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@RestController
|
||||
public class DiscoveryController {
|
||||
|
||||
private final KubernetesInformerDiscoveryClient discoveryClient;
|
||||
|
||||
public DiscoveryController(ObjectProvider<KubernetesInformerDiscoveryClient> discoveryClient) {
|
||||
KubernetesInformerDiscoveryClient[] local = new KubernetesInformerDiscoveryClient[1];
|
||||
discoveryClient.ifAvailable(x -> local[0] = x);
|
||||
this.discoveryClient = local[0];
|
||||
}
|
||||
|
||||
@GetMapping("/services")
|
||||
public List<String> allServices() {
|
||||
return discoveryClient.getServices();
|
||||
}
|
||||
|
||||
@GetMapping("/service-instances/{serviceId}")
|
||||
public List<ServiceInstance> serviceInstances(@PathVariable("serviceId") String serviceId) {
|
||||
return discoveryClient.getInstances(serviceId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.kubernetes.client.discovery.reactive.KubernetesInformerReactiveDiscoveryClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@RestController
|
||||
public class ReactiveDiscoveryController {
|
||||
|
||||
private final KubernetesInformerReactiveDiscoveryClient reactiveDiscoveryClient;
|
||||
|
||||
public ReactiveDiscoveryController(
|
||||
ObjectProvider<KubernetesInformerReactiveDiscoveryClient> reactiveDiscoveryClient) {
|
||||
KubernetesInformerReactiveDiscoveryClient[] local = new KubernetesInformerReactiveDiscoveryClient[1];
|
||||
reactiveDiscoveryClient.ifAvailable(x -> local[0] = x);
|
||||
this.reactiveDiscoveryClient = local[0];
|
||||
}
|
||||
|
||||
@GetMapping("/reactive/services")
|
||||
public Mono<List<String>> allServices() {
|
||||
return reactiveDiscoveryClient.getServices().collectList();
|
||||
}
|
||||
|
||||
@GetMapping("reactive/service-instances/{serviceId}")
|
||||
public Mono<List<ServiceInstance>> serviceInstances(@PathVariable("serviceId") String serviceId) {
|
||||
return reactiveDiscoveryClient.getInstances(serviceId).collectList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
management:
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
@@ -1,405 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import io.kubernetes.client.openapi.models.V1Deployment;
|
||||
import io.kubernetes.client.openapi.models.V1EnvVar;
|
||||
import io.kubernetes.client.openapi.models.V1Ingress;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.DefaultKubernetesServiceInstance;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class KubernetesClientDiscoveryClientIT {
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final String NAMESPACE_A = "a";
|
||||
|
||||
private static final String NAMESPACE_B = "b";
|
||||
|
||||
private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-discovery-it";
|
||||
|
||||
private static final String DEPLOYMENT_NAME = "spring-cloud-kubernetes-client-discovery-deployment-it";
|
||||
|
||||
private static final String NAMESPACE_A_UAT = "a-uat";
|
||||
|
||||
private static final String NAMESPACE_B_UAT = "b-uat";
|
||||
|
||||
private static Util util;
|
||||
|
||||
private static final K3sContainer K3S = Commons.container();
|
||||
|
||||
@BeforeAll
|
||||
static void beforeAll() throws Exception {
|
||||
K3S.start();
|
||||
Commons.validateImage(IMAGE_NAME, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
|
||||
|
||||
util = new Util(K3S);
|
||||
util.setUp(NAMESPACE);
|
||||
manifests(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() throws Exception {
|
||||
manifests(Phase.DELETE);
|
||||
Commons.cleanUp(IMAGE_NAME, K3S);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
/**
|
||||
* Three services are deployed in the default namespace. We do not configure any
|
||||
* explicit namespace and 'default' must be picked-up.
|
||||
*/
|
||||
@Test
|
||||
@Order(1)
|
||||
void testSimple() {
|
||||
|
||||
util.busybox(NAMESPACE, Phase.CREATE);
|
||||
|
||||
Commons.waitForLogStatement("serviceSharedInformer will use namespace : default", K3S, IMAGE_NAME);
|
||||
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/services").build();
|
||||
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(servicesResult.size(), 3);
|
||||
Assertions.assertTrue(servicesResult.contains("kubernetes"));
|
||||
Assertions.assertTrue(servicesResult.contains("spring-cloud-kubernetes-client-discovery-it"));
|
||||
Assertions.assertTrue(servicesResult.contains("busybox-service"));
|
||||
|
||||
WebClient ourServiceClient = builder()
|
||||
.baseUrl("http://localhost/service-instances/spring-cloud-kubernetes-client-discovery-it").build();
|
||||
|
||||
List<DefaultKubernetesServiceInstance> ourServiceInstances = ourServiceClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(ourServiceInstances.size(), 1);
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstance = ourServiceInstances.get(0);
|
||||
Assertions.assertNotNull(serviceInstance.getInstanceId());
|
||||
Assertions.assertEquals(serviceInstance.getServiceId(), "spring-cloud-kubernetes-client-discovery-it");
|
||||
Assertions.assertNotNull(serviceInstance.getHost());
|
||||
Assertions.assertEquals(serviceInstance.getMetadata(),
|
||||
Map.of("app", "spring-cloud-kubernetes-client-discovery-it", "custom-spring-k8s", "spring-k8s", "http",
|
||||
"8080", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions.assertEquals(serviceInstance.getPort(), 8080);
|
||||
Assertions.assertEquals(serviceInstance.getNamespace(), "default");
|
||||
|
||||
WebClient busyBoxServiceClient = builder().baseUrl("http://localhost/service-instances/busybox-service")
|
||||
.build();
|
||||
List<DefaultKubernetesServiceInstance> busyBoxServiceInstances = busyBoxServiceClient.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(busyBoxServiceInstances.size(), 2);
|
||||
|
||||
// enforces this :
|
||||
// https://github.com/spring-cloud/spring-cloud-kubernetes/issues/1286
|
||||
WebClient clientForNonExistentService = builder().baseUrl("http://localhost/service-instances/non-existent")
|
||||
.build();
|
||||
List<ServiceInstance> resultForNonExistentService = clientForNonExistentService.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(new ParameterizedTypeReference<List<ServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(resultForNonExistentService.size(), 0);
|
||||
|
||||
// clean-up
|
||||
util.busybox(NAMESPACE, Phase.DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - config server is enabled for all namespaces
|
||||
* - wiremock service is deployed in namespace-a
|
||||
* - busybox service is deployed in namespace-b
|
||||
*
|
||||
* Our discovery searches in all namespaces, thus finds them both.
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Order(2)
|
||||
void testAllNamespaces() {
|
||||
util.createNamespace(NAMESPACE_A);
|
||||
util.createNamespace(NAMESPACE_B);
|
||||
util.setUpClusterWideClusterRoleBinding(NAMESPACE);
|
||||
util.wiremock(NAMESPACE_A, "/wiremock", Phase.CREATE, false);
|
||||
util.busybox(NAMESPACE_B, Phase.CREATE);
|
||||
|
||||
KubernetesClientDiscoveryClientUtils.patchForAllNamespaces(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
Commons.waitForLogStatement("serviceSharedInformer will use all-namespaces", K3S, IMAGE_NAME);
|
||||
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/services").build();
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
Assertions.assertEquals(servicesResult.size(), 7);
|
||||
Assertions.assertTrue(servicesResult.contains("kubernetes"));
|
||||
Assertions.assertTrue(servicesResult.contains("spring-cloud-kubernetes-client-discovery-it"));
|
||||
Assertions.assertTrue(servicesResult.contains("busybox-service"));
|
||||
Assertions.assertTrue(servicesResult.contains("service-wiremock"));
|
||||
|
||||
// enforces this :
|
||||
// https://github.com/spring-cloud/spring-cloud-kubernetes/issues/1286
|
||||
WebClient clientForNonExistentService = builder().baseUrl("http://localhost/service-instances/non-existent")
|
||||
.build();
|
||||
List<ServiceInstance> resultForNonExistentService = clientForNonExistentService.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(new ParameterizedTypeReference<List<ServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(resultForNonExistentService.size(), 0);
|
||||
|
||||
// do not remove wiremock in namespace a, it is required in the next test
|
||||
util.busybox(NAMESPACE_B, Phase.DELETE);
|
||||
util.deleteClusterWideClusterRoleBinding(NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - config server is enabled for namespace-a
|
||||
* - wiremock service is deployed in namespace-a
|
||||
* - wiremock service is deployed in namespace-b
|
||||
*
|
||||
* Only service in namespace-a is found.
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Order(3)
|
||||
void testSpecificNamespace() {
|
||||
util.setUpClusterWide(NAMESPACE, Set.of(NAMESPACE, NAMESPACE_A));
|
||||
util.wiremock(NAMESPACE_B, "/wiremock", Phase.CREATE, false);
|
||||
|
||||
KubernetesClientDiscoveryClientUtils.patchForSingleNamespace(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
// first check that wiremock service is present in both namespaces a and b
|
||||
assertServicePresentInNamespaces(List.of("a", "b"), "service-wiremock", "service-wiremock");
|
||||
|
||||
Commons.waitForLogStatement("using selective namespaces : [a]", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("reading pod in namespace : default", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : a", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : a", K3S, IMAGE_NAME);
|
||||
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/services").build();
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
Assertions.assertEquals(servicesResult.size(), 1);
|
||||
Assertions.assertTrue(servicesResult.contains("service-wiremock"));
|
||||
|
||||
WebClient wiremockInNamespaceAClient = builder().baseUrl("http://localhost/service-instances/service-wiremock")
|
||||
.build();
|
||||
|
||||
List<DefaultKubernetesServiceInstance> wiremockInNamespaceA = wiremockInNamespaceAClient.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(wiremockInNamespaceA.size(), 1);
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstance = wiremockInNamespaceA.get(0);
|
||||
Assertions.assertEquals(serviceInstance.getNamespace(), "a");
|
||||
|
||||
// enforces this :
|
||||
// https://github.com/spring-cloud/spring-cloud-kubernetes/issues/1286
|
||||
WebClient clientForNonExistentService = builder().baseUrl("http://localhost/service-instances/non-existent")
|
||||
.build();
|
||||
List<ServiceInstance> resultForNonExistentService = clientForNonExistentService.method(HttpMethod.GET)
|
||||
.retrieve().bodyToMono(new ParameterizedTypeReference<List<ServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(resultForNonExistentService.size(), 0);
|
||||
|
||||
util.wiremock(NAMESPACE_A, "/wiremock", Phase.DELETE, false);
|
||||
util.wiremock(NAMESPACE_B, "/wiremock", Phase.DELETE, false);
|
||||
util.deleteClusterWide(NAMESPACE, Set.of(NAMESPACE, NAMESPACE_A));
|
||||
util.deleteNamespace(NAMESPACE_A);
|
||||
util.deleteNamespace(NAMESPACE_B);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void testSimplePodMetadata() {
|
||||
util.setUp(NAMESPACE);
|
||||
String imageName = "docker.io/springcloud/spring-cloud-kubernetes-client-discovery-it:" + Commons.pomVersion();
|
||||
KubernetesClientDiscoveryClientUtils.patchForPodMetadata(imageName, DEPLOYMENT_NAME, NAMESPACE);
|
||||
new KubernetesClientDiscoveryPodMetadataITDelegate().testSimple();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void filterMatchesOneNamespaceViaThePredicate() {
|
||||
String imageName = "docker.io/springcloud/spring-cloud-kubernetes-client-discovery-it:" + Commons.pomVersion();
|
||||
KubernetesClientDiscoveryClientUtils.patchForUATNamespacesTests(imageName, DEPLOYMENT_NAME, NAMESPACE);
|
||||
new KubernetesClientDiscoveryFilterITDelegate().filterMatchesOneNamespaceViaThePredicate(util);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - service "wiremock" is present in namespace "a-uat"
|
||||
* - service "wiremock" is present in namespace "b-uat"
|
||||
*
|
||||
* - we search with a predicate : "#root.metadata.namespace matches '^uat.*$'"
|
||||
*
|
||||
* As such, both services are found via 'getInstances' call.
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Order(6)
|
||||
void filterMatchesBothNamespacesViaThePredicate() {
|
||||
|
||||
// patch the deployment to change what namespaces are take into account
|
||||
KubernetesClientDiscoveryClientUtils.patchForTwoNamespacesMatchViaThePredicate(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
new KubernetesClientDiscoveryFilterITDelegate().filterMatchesBothNamespacesViaThePredicate();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void testBlockingConfiguration() {
|
||||
|
||||
// filter tests are done, clean-up a bit to prepare everything for health tests
|
||||
deleteNamespacesAndWiremock();
|
||||
|
||||
String imageName = "docker.io/springcloud/spring-cloud-kubernetes-client-discovery-it:" + Commons.pomVersion();
|
||||
KubernetesClientDiscoveryClientUtils.patchForBlockingHealth(imageName, DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
new KubernetesClientDiscoveryHealthITDelegate().testBlockingConfiguration(K3S);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void testReactiveConfiguration() {
|
||||
|
||||
KubernetesClientDiscoveryClientUtils.patchForReactiveHealth(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
new KubernetesClientDiscoveryHealthITDelegate().testReactiveConfiguration(K3S);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void testDefaultConfiguration() {
|
||||
|
||||
KubernetesClientDiscoveryClientUtils.patchForBlockingAndReactiveHealth(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
new KubernetesClientDiscoveryHealthITDelegate().testDefaultConfiguration(K3S);
|
||||
}
|
||||
|
||||
private void deleteNamespacesAndWiremock() {
|
||||
util.wiremock(NAMESPACE_A_UAT, "/wiremock", Phase.DELETE, false);
|
||||
util.wiremock(NAMESPACE_B_UAT, "/wiremock", Phase.DELETE, false);
|
||||
util.deleteNamespace(NAMESPACE_A_UAT);
|
||||
util.deleteNamespace(NAMESPACE_B_UAT);
|
||||
}
|
||||
|
||||
private static void manifests(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util.yaml("kubernetes-discovery-deployment.yaml");
|
||||
V1Service service = (V1Service) util.yaml("kubernetes-discovery-service.yaml");
|
||||
V1Ingress ingress = (V1Ingress) util.yaml("kubernetes-discovery-ingress.yaml");
|
||||
|
||||
if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, ingress);
|
||||
return;
|
||||
}
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
|
||||
List<V1EnvVar> envVars = new ArrayList<>(
|
||||
Optional.ofNullable(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv())
|
||||
.orElse(List.of()));
|
||||
V1EnvVar debugLevel = new V1EnvVar()
|
||||
.name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY").value("DEBUG");
|
||||
|
||||
V1EnvVar debugLevelForClient = new V1EnvVar()
|
||||
.name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT").value("DEBUG");
|
||||
|
||||
envVars.add(debugLevel);
|
||||
envVars.add(debugLevelForClient);
|
||||
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(envVars);
|
||||
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, ingress, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
private void assertServicePresentInNamespaces(List<String> namespaces, String value, String serviceName) {
|
||||
namespaces.forEach(x -> {
|
||||
try {
|
||||
String service = K3S.execInContainer("sh", "-c",
|
||||
"kubectl get services -n " + x + " -l app=" + value + " -o=name --no-headers | tr -d '\n'")
|
||||
.getStdout();
|
||||
Assertions.assertEquals(service, "service/" + serviceName);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,408 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util.patchWithMerge;
|
||||
import static org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util.patchWithReplace;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
final class KubernetesClientDiscoveryClientUtils {
|
||||
|
||||
private static final Map<String, String> POD_LABELS = Map.of("app", "spring-cloud-kubernetes-client-discovery-it");
|
||||
|
||||
// patch the filter so that it matches both namespaces
|
||||
private static final String BODY_ONE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_FILTER",
|
||||
"value": "#root.metadata.namespace matches '^.*uat$'"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_TWO = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_DISCOVERY",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_CLIENT_DISCOVERY_HEALTH_REACTIVE",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY_REACTIVE",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_BLOCKING_ENABLED",
|
||||
"value": "FALSE"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED",
|
||||
"value": "TRUE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
// this one patches on top of BODY_TWO, so it essentially enables both blocking and
|
||||
// reactive implementations
|
||||
// and adds proper packages in DEBUG mode, so that we could assert logs.
|
||||
private static final String BODY_THREE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_BLOCKING_ENABLED",
|
||||
"value": "TRUE"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
// this one patches on top of BODY_TWO, so it essentially enables both blocking and
|
||||
// reactive implementations
|
||||
// and adds proper packages in DEBUG mode, so that we could assert logs.
|
||||
private static final String BODY_FOUR = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"image": "image_name_here",
|
||||
"env": [
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_DISCOVERY",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED",
|
||||
"value": "FALSE"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_CLIENT_DISCOVERY_HEALTH",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY",
|
||||
"value": "DEBUG"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
// patch to include all namespaces
|
||||
private static final String BODY_FIVE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_ALL_NAMESPACES",
|
||||
"value": "TRUE"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
// disable all namespaces and include a single namespace to be discoverable
|
||||
private static final String BODY_SIX = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_0",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_ALL_NAMESPACES",
|
||||
"value": "FALSE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_SEVEN = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"image": "image_name_here",
|
||||
"env": [
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_METADATA_ADDLABELS",
|
||||
"value": "TRUE"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_METADATA_LABELSPREFIX",
|
||||
"value": "label-"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_METADATA_ADDANNOTATIONS",
|
||||
"value": "TRUE"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_METADATA_ANNOTATIONSPREFIX",
|
||||
"value": "annotation-"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_EIGHT = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED",
|
||||
"value": "TRUE"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_BLOCKING_ENABLED",
|
||||
"value": "FALSE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_NINE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED",
|
||||
"value": "TRUE"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_BLOCKING_ENABLED",
|
||||
"value": "TRUE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_TEN = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_1",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED",
|
||||
"value": "FALSE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_ELEVEN = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_DISCOVERY_BLOCKING_ENABLED",
|
||||
"value": "TRUE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_TWELVE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-client-discovery",
|
||||
"image": "image_name_here",
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_0",
|
||||
"value": "a-uat"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_1",
|
||||
"value": "b-uat"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_DISCOVERY_FILTER",
|
||||
"value": "#root.metadata.namespace matches 'a-uat$'"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY",
|
||||
"value": "DEBUG"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private KubernetesClientDiscoveryClientUtils() {
|
||||
|
||||
}
|
||||
|
||||
static void patchForTwoNamespacesMatchViaThePredicate(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_ONE, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForReactiveHealth(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_TWO, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForBlockingAndReactiveHealth(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_THREE, POD_LABELS);
|
||||
}
|
||||
|
||||
// notice the usage of 'PATCH_FORMAT_JSON_MERGE_PATCH' here, it will not merge
|
||||
// env variables
|
||||
static void patchForBlockingHealth(String image, String deploymentName, String namespace) {
|
||||
patchWithReplace(image, deploymentName, namespace, BODY_FOUR, POD_LABELS);
|
||||
}
|
||||
|
||||
// add SPRING_CLOUD_KUBERNETES_DISCOVERY_ALL_NAMESPACES=TRUE
|
||||
static void patchForAllNamespaces(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_FIVE, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForSingleNamespace(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_SIX, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForPodMetadata(String imageName, String deploymentName, String namespace) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_SEVEN, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForReactiveOnly(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_EIGHT, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForBlockingAndReactive(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_NINE, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForTwoNamespacesBlockingOnly(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_TEN, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchToAddBlockingSupport(String deploymentName, String namespace) {
|
||||
patchWithMerge(deploymentName, namespace, BODY_ELEVEN, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchForUATNamespacesTests(String image, String deploymentName, String namespace) {
|
||||
patchWithReplace(image, deploymentName, namespace, BODY_TWELVE, POD_LABELS);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.DefaultKubernetesServiceInstance;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
class KubernetesClientDiscoveryFilterITDelegate {
|
||||
|
||||
private static final String NAMESPACE_A_UAT = "a-uat";
|
||||
|
||||
private static final String NAMESPACE_B_UAT = "b-uat";
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final String DEPLOYMENT_NAME = "spring-cloud-kubernetes-client-discovery-deployment-it";
|
||||
|
||||
void filterMatchesOneNamespaceViaThePredicate(Util util) {
|
||||
|
||||
// set-up for this test and the next one
|
||||
util.createNamespace(NAMESPACE_A_UAT);
|
||||
util.createNamespace(NAMESPACE_B_UAT);
|
||||
util.setUpClusterWide(NAMESPACE, Set.of(NAMESPACE, NAMESPACE_A_UAT, NAMESPACE_B_UAT));
|
||||
util.wiremock(NAMESPACE_A_UAT, "/wiremock", Phase.CREATE, false);
|
||||
util.wiremock(NAMESPACE_B_UAT, "/wiremock", Phase.CREATE, false);
|
||||
|
||||
WebClient clientServices = builder().baseUrl("http://localhost/services").build();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> services = (List<String>) clientServices.method(HttpMethod.GET).retrieve().bodyToMono(List.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(services.size(), 1);
|
||||
Assertions.assertTrue(services.contains("service-wiremock"));
|
||||
|
||||
WebClient client = builder().baseUrl("http://localhost/service-instances/service-wiremock").build();
|
||||
List<DefaultKubernetesServiceInstance> serviceInstances = client.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(serviceInstances.size(), 1);
|
||||
|
||||
DefaultKubernetesServiceInstance first = serviceInstances.get(0);
|
||||
Assertions.assertEquals(first.getServiceId(), "service-wiremock");
|
||||
Assertions.assertNotNull(first.getInstanceId());
|
||||
Assertions.assertEquals(first.getPort(), 8080);
|
||||
Assertions.assertEquals(first.getNamespace(), "a-uat");
|
||||
Assertions.assertEquals(first.getMetadata(),
|
||||
Map.of("app", "service-wiremock", "http", "8080", "k8s_namespace", "a-uat", "type", "ClusterIP"));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - service "wiremock" is present in namespace "a-uat"
|
||||
* - service "wiremock" is present in namespace "b-uat"
|
||||
*
|
||||
* - we search with a predicate : "#root.metadata.namespace matches '^uat.*$'"
|
||||
*
|
||||
* As such, both services are found via 'getInstances' call.
|
||||
* </pre>
|
||||
*/
|
||||
void filterMatchesBothNamespacesViaThePredicate() {
|
||||
|
||||
// patch the deployment to change what namespaces are take into account
|
||||
KubernetesClientDiscoveryClientUtils.patchForTwoNamespacesMatchViaThePredicate(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
WebClient clientServices = builder().baseUrl("http://localhost/services").build();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> services = (List<String>) clientServices.method(HttpMethod.GET).retrieve().bodyToMono(List.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(services.size(), 1);
|
||||
Assertions.assertTrue(services.contains("service-wiremock"));
|
||||
|
||||
WebClient client = builder().baseUrl("http://localhost/service-instances/service-wiremock").build();
|
||||
List<DefaultKubernetesServiceInstance> serviceInstances = client.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(serviceInstances.size(), 2);
|
||||
List<DefaultKubernetesServiceInstance> sorted = serviceInstances.stream()
|
||||
.sorted(Comparator.comparing(DefaultKubernetesServiceInstance::getNamespace)).toList();
|
||||
|
||||
DefaultKubernetesServiceInstance first = sorted.get(0);
|
||||
Assertions.assertEquals(first.getServiceId(), "service-wiremock");
|
||||
Assertions.assertNotNull(first.getInstanceId());
|
||||
Assertions.assertEquals(first.getPort(), 8080);
|
||||
Assertions.assertEquals(first.getNamespace(), "a-uat");
|
||||
Assertions.assertEquals(first.getMetadata(),
|
||||
Map.of("app", "service-wiremock", "http", "8080", "k8s_namespace", "a-uat", "type", "ClusterIP"));
|
||||
|
||||
DefaultKubernetesServiceInstance second = sorted.get(1);
|
||||
Assertions.assertEquals(second.getServiceId(), "service-wiremock");
|
||||
Assertions.assertNotNull(second.getInstanceId());
|
||||
Assertions.assertEquals(second.getPort(), 8080);
|
||||
Assertions.assertEquals(second.getNamespace(), "b-uat");
|
||||
Assertions.assertEquals(second.getMetadata(),
|
||||
Map.of("app", "service-wiremock", "http", "8080", "k8s_namespace", "b-uat", "type", "ClusterIP"));
|
||||
|
||||
}
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(2)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.testcontainers.containers.Container;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.boot.test.json.BasicJsonTester;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
class KubernetesClientDiscoveryHealthITDelegate {
|
||||
|
||||
private static final String REACTIVE_STATUS = "$.components.reactiveDiscoveryClients.components.['Kubernetes Reactive Discovery Client'].status";
|
||||
|
||||
private static final String BLOCKING_STATUS = "$.components.discoveryComposite.components.discoveryClient.status";
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-discovery-it";
|
||||
|
||||
private static final String DEPLOYMENT_NAME = "spring-cloud-kubernetes-client-discovery-deployment-it";
|
||||
|
||||
private static final BasicJsonTester BASIC_JSON_TESTER = new BasicJsonTester(
|
||||
KubernetesClientDiscoveryHealthITDelegate.class);
|
||||
|
||||
/**
|
||||
* Reactive is disabled, only blocking is active. As such,
|
||||
* KubernetesInformerDiscoveryClientAutoConfiguration::indicatorInitializer will post
|
||||
* an InstanceRegisteredEvent.
|
||||
*
|
||||
* We assert for logs and call '/health' endpoint to see that blocking discovery
|
||||
* client was initialized.
|
||||
*/
|
||||
void testBlockingConfiguration(K3sContainer container) {
|
||||
|
||||
assertLogStatement(container, "Will publish InstanceRegisteredEvent from blocking implementation");
|
||||
assertLogStatement(container, "publishing InstanceRegisteredEvent");
|
||||
assertLogStatement(container, "Discovery Client has been initialized");
|
||||
assertLogStatement(container,
|
||||
"received InstanceRegisteredEvent from pod with 'app' label value : spring-cloud-kubernetes-client-discovery-it");
|
||||
|
||||
WebClient healthClient = builder().baseUrl("http://localhost/actuator/health").build();
|
||||
|
||||
String healthResult = healthClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult))
|
||||
.extractingJsonPathStringValue("$.components.discoveryComposite.status").isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(BLOCKING_STATUS)
|
||||
.isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult))
|
||||
.extractingJsonPathArrayValue(
|
||||
"$.components.discoveryComposite.components.discoveryClient.details.services")
|
||||
.containsExactlyInAnyOrder("spring-cloud-kubernetes-client-discovery-it", "kubernetes");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).doesNotHaveJsonPath(REACTIVE_STATUS);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reactive is enabled, blocking is disabled. As such,
|
||||
* KubernetesInformerDiscoveryClientAutoConfiguration::indicatorInitializer will post
|
||||
* an InstanceRegisteredEvent.
|
||||
*
|
||||
* We assert for logs and call '/health' endpoint to see that blocking discovery
|
||||
* client was initialized.
|
||||
*/
|
||||
void testReactiveConfiguration(K3sContainer container) {
|
||||
|
||||
KubernetesClientDiscoveryClientUtils.patchForReactiveHealth(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
assertLogStatement(container, "Will publish InstanceRegisteredEvent from reactive implementation");
|
||||
assertLogStatement(container, "publishing InstanceRegisteredEvent");
|
||||
assertLogStatement(container, "Discovery Client has been initialized");
|
||||
assertLogStatement(container,
|
||||
"received InstanceRegisteredEvent from pod with 'app' label value : spring-cloud-kubernetes-client-discovery-it");
|
||||
|
||||
WebClient healthClient = builder().baseUrl("http://localhost/actuator/health").build();
|
||||
|
||||
String healthResult = healthClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult))
|
||||
.extractingJsonPathStringValue("$.components.reactiveDiscoveryClients.status").isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(REACTIVE_STATUS)
|
||||
.isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathArrayValue(
|
||||
"$.components.reactiveDiscoveryClients.components.['Kubernetes Reactive Discovery Client'].details.services")
|
||||
.containsExactlyInAnyOrder("spring-cloud-kubernetes-client-discovery-it", "kubernetes");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).doesNotHaveJsonPath(BLOCKING_STATUS);
|
||||
|
||||
// test for services also:
|
||||
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/reactive/services").build();
|
||||
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertThat(servicesResult).contains("spring-cloud-kubernetes-client-discovery-it");
|
||||
Assertions.assertThat(servicesResult).contains("kubernetes");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Both blocking and reactive are enabled.
|
||||
*/
|
||||
void testDefaultConfiguration(K3sContainer container) {
|
||||
|
||||
KubernetesClientDiscoveryClientUtils.patchForBlockingAndReactiveHealth(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
assertLogStatement(container, "Will publish InstanceRegisteredEvent from blocking implementation");
|
||||
assertLogStatement(container, "publishing InstanceRegisteredEvent");
|
||||
assertLogStatement(container, "Discovery Client has been initialized");
|
||||
assertLogStatement(container,
|
||||
"received InstanceRegisteredEvent from pod with 'app' label value : spring-cloud-kubernetes-client-discovery-it");
|
||||
|
||||
WebClient healthClient = builder().baseUrl("http://localhost/actuator/health").build();
|
||||
WebClient infoClient = builder().baseUrl("http://localhost/actuator/info").build();
|
||||
|
||||
String healthResult = healthClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
String infoResult = infoClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult))
|
||||
.extractingJsonPathStringValue("$.components.discoveryComposite.status").isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult))
|
||||
.extractingJsonPathStringValue("$.components.discoveryComposite.components.discoveryClient.status")
|
||||
.isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult))
|
||||
.extractingJsonPathArrayValue(
|
||||
"$.components.discoveryComposite.components.discoveryClient.details.services")
|
||||
.containsExactlyInAnyOrder("spring-cloud-kubernetes-client-discovery-it", "kubernetes");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult))
|
||||
.extractingJsonPathStringValue("$.components.reactiveDiscoveryClients.status").isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.reactiveDiscoveryClients.components.['Kubernetes Reactive Discovery Client'].status")
|
||||
.isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathArrayValue(
|
||||
"$.components.reactiveDiscoveryClients.components.['Kubernetes Reactive Discovery Client'].details.services")
|
||||
.containsExactlyInAnyOrder("spring-cloud-kubernetes-client-discovery-it", "kubernetes");
|
||||
|
||||
// assert health/info also
|
||||
assertHealth(healthResult);
|
||||
assertInfo(infoResult);
|
||||
}
|
||||
|
||||
private void assertHealth(String healthResult) {
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.kubernetes.status").isEqualTo("UP");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.kubernetes.details.hostIp").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathBooleanValue(
|
||||
"$.components.kubernetes.details.inside").isEqualTo(true);
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.kubernetes.details.labels.app").isEqualTo("spring-cloud-kubernetes-client-discovery-it");
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.kubernetes.details.namespace").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.kubernetes.details.nodeName").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.kubernetes.details.podIp").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.kubernetes.details.podName").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue(
|
||||
"$.components.kubernetes.details.serviceAccount").isNotEmpty();
|
||||
}
|
||||
|
||||
private void assertInfo(String infoResult) {
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue(
|
||||
"$.kubernetes.hostIp").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathBooleanValue(
|
||||
"$.kubernetes.inside").isEqualTo(true);
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue(
|
||||
"$.kubernetes.namespace").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue(
|
||||
"$.kubernetes.nodeName").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue(
|
||||
"$.kubernetes.podIp").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue(
|
||||
"$.kubernetes.podName").isNotEmpty();
|
||||
|
||||
Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue(
|
||||
"$.kubernetes.serviceAccount").isNotEmpty();
|
||||
}
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
private void assertLogStatement(K3sContainer container, String message) {
|
||||
try {
|
||||
String appPodName = container.execInContainer("sh", "-c",
|
||||
"kubectl get pods -l app=" + IMAGE_NAME + " -o=name --no-headers | tr -d '\n'").getStdout();
|
||||
|
||||
await().pollDelay(Duration.ofSeconds(4)).pollInterval(Duration.ofSeconds(1)).atMost(20, TimeUnit.SECONDS)
|
||||
.until(() -> {
|
||||
Container.ExecResult execResult = container.execInContainer("sh", "-c",
|
||||
"kubectl logs " + appPodName.trim());
|
||||
String ok = execResult.getStdout();
|
||||
return ok.contains(message);
|
||||
});
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.containers.Container;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.DefaultKubernetesServiceInstance;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
class KubernetesClientDiscoveryMultipleSelectiveNamespacesITDelegate {
|
||||
|
||||
private static final String BLOCKING_PUBLISH = "Will publish InstanceRegisteredEvent from blocking implementation";
|
||||
|
||||
private static final String REACTIVE_PUBLISH = "Will publish InstanceRegisteredEvent from reactive implementation";
|
||||
|
||||
private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-discovery-it";
|
||||
|
||||
/**
|
||||
* Deploy wiremock in 3 namespaces: default, a, b. Search in selective namespaces 'a'
|
||||
* and 'b' with blocking enabled and reactive disabled, as such find services and it's
|
||||
* instances.
|
||||
*/
|
||||
void testTwoNamespacesBlockingOnly(K3sContainer container) {
|
||||
|
||||
Commons.waitForLogStatement("using selective namespaces : [a, b]", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesMissing : found selective namespaces : [a, b]",
|
||||
container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesMissing : found selective namespaces : [a, b]",
|
||||
container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesPresent : found selective namespaces : [a, b]",
|
||||
container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : a", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : b", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : a", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : b", container, IMAGE_NAME);
|
||||
|
||||
// this tiny checks makes sure that blocking is enabled and reactive is disabled.
|
||||
Commons.waitForLogStatement(BLOCKING_PUBLISH, container, IMAGE_NAME);
|
||||
Assertions.assertFalse(logs(container).contains(REACTIVE_PUBLISH));
|
||||
|
||||
blockingCheck();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy wiremock in 3 namespaces: default, a, b. Search in selective namespaces 'a'
|
||||
* and 'b' with blocking disabled and reactive enabled, as such find services and it's
|
||||
* instances.
|
||||
*/
|
||||
void testTwoNamespaceReactiveOnly(K3sContainer container) {
|
||||
|
||||
Commons.waitForLogStatement("using selective namespaces : [a, b]", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesMissing : found selective namespaces : [a, b]",
|
||||
container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesPresent : found selective namespaces : [a, b]",
|
||||
container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : a", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : b", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : a", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : b", container, IMAGE_NAME);
|
||||
|
||||
// this tiny checks makes sure that blocking is disabled and reactive is enabled.
|
||||
Commons.waitForLogStatement(REACTIVE_PUBLISH, container, IMAGE_NAME);
|
||||
Assertions.assertFalse(logs(container).contains(BLOCKING_PUBLISH));
|
||||
|
||||
reactiveCheck();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy wiremock in 3 namespaces: default, a, b. Search in selective namespaces 'a'
|
||||
* and 'b' with blocking enabled and reactive enabled, as such find services and its
|
||||
* service instances.
|
||||
*/
|
||||
void testTwoNamespacesBothBlockingAndReactive(K3sContainer container) {
|
||||
|
||||
Commons.waitForLogStatement("using selective namespaces : [a, b]", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesMissing : found selective namespaces : [a, b]",
|
||||
container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesPresent : found selective namespaces : [a, b]",
|
||||
container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : a", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : b", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : a", container, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : b", container, IMAGE_NAME);
|
||||
|
||||
// this tiny checks makes sure that blocking is enabled and reactive is enabled.
|
||||
Commons.waitForLogStatement(BLOCKING_PUBLISH, container, IMAGE_NAME);
|
||||
Assertions.assertTrue(logs(container).contains(REACTIVE_PUBLISH));
|
||||
|
||||
blockingCheck();
|
||||
reactiveCheck();
|
||||
|
||||
}
|
||||
|
||||
private String logs(K3sContainer container) {
|
||||
try {
|
||||
String appPodName = container.execInContainer("sh", "-c",
|
||||
"kubectl get pods -l app=" + IMAGE_NAME + " -o=name --no-headers | tr -d '\n'").getStdout();
|
||||
|
||||
Container.ExecResult execResult = container.execInContainer("sh", "-c",
|
||||
"kubectl logs " + appPodName.trim());
|
||||
return execResult.getStdout();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void reactiveCheck() {
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/reactive/services").build();
|
||||
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
// we get two here, but since there is 'distinct' call, only 1 will be reported
|
||||
// but service instances will report 2 nevertheless
|
||||
Assertions.assertEquals(servicesResult.size(), 1);
|
||||
Assertions.assertTrue(servicesResult.contains("service-wiremock"));
|
||||
|
||||
WebClient ourServiceClient = builder().baseUrl("http://localhost/reactive/service-instances/service-wiremock")
|
||||
.build();
|
||||
|
||||
List<DefaultKubernetesServiceInstance> ourServiceInstances = ourServiceClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(ourServiceInstances.size(), 2);
|
||||
ourServiceInstances = ourServiceInstances.stream()
|
||||
.sorted(Comparator.comparing(DefaultKubernetesServiceInstance::namespace)).toList();
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstanceA = ourServiceInstances.get(0);
|
||||
// we only care about namespace here, as all other fields are tested in various
|
||||
// other tests.
|
||||
Assertions.assertEquals(serviceInstanceA.getNamespace(), "a");
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstanceB = ourServiceInstances.get(1);
|
||||
// we only care about namespace here, as all other fields are tested in various
|
||||
// other tests.
|
||||
Assertions.assertEquals(serviceInstanceB.getNamespace(), "b");
|
||||
}
|
||||
|
||||
private void blockingCheck() {
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/services").build();
|
||||
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
// we get two here, but since there is 'distinct' call, only 1 will be reported
|
||||
// but service instances will report 2 nevertheless
|
||||
Assertions.assertEquals(servicesResult.size(), 1);
|
||||
Assertions.assertTrue(servicesResult.contains("service-wiremock"));
|
||||
|
||||
WebClient ourServiceClient = builder().baseUrl("http://localhost/service-instances/service-wiremock").build();
|
||||
|
||||
List<DefaultKubernetesServiceInstance> ourServiceInstances = ourServiceClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(ourServiceInstances.size(), 2);
|
||||
ourServiceInstances = ourServiceInstances.stream()
|
||||
.sorted(Comparator.comparing(DefaultKubernetesServiceInstance::namespace)).toList();
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstanceA = ourServiceInstances.get(0);
|
||||
// we only care about namespace here, as all other fields are tested in various
|
||||
// other tests.
|
||||
Assertions.assertEquals(serviceInstanceA.getNamespace(), "a");
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstanceB = ourServiceInstances.get(1);
|
||||
// we only care about namespace here, as all other fields are tested in various
|
||||
// other tests.
|
||||
Assertions.assertEquals(serviceInstanceB.getNamespace(), "b");
|
||||
}
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.DefaultKubernetesServiceInstance;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
class KubernetesClientDiscoveryPodMetadataITDelegate {
|
||||
|
||||
/**
|
||||
* Three services are deployed in the default namespace. We do not configure any
|
||||
* explicit namespace and 'default' must be picked-up.
|
||||
*/
|
||||
void testSimple() {
|
||||
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/services").build();
|
||||
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(servicesResult.size(), 2);
|
||||
Assertions.assertTrue(servicesResult.contains("kubernetes"));
|
||||
Assertions.assertTrue(servicesResult.contains("spring-cloud-kubernetes-client-discovery-it"));
|
||||
|
||||
WebClient ourServiceClient = builder()
|
||||
.baseUrl("http://localhost//service-instances/spring-cloud-kubernetes-client-discovery-it").build();
|
||||
|
||||
List<DefaultKubernetesServiceInstance> ourServiceInstances = ourServiceClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(ourServiceInstances.size(), 1);
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstance = ourServiceInstances.get(0);
|
||||
Assertions.assertNotNull(serviceInstance.getInstanceId());
|
||||
Assertions.assertEquals(serviceInstance.getServiceId(), "spring-cloud-kubernetes-client-discovery-it");
|
||||
Assertions.assertNotNull(serviceInstance.getHost());
|
||||
Assertions.assertEquals(serviceInstance.getMetadata(),
|
||||
Map.of("http", "8080", "k8s_namespace", "default", "type", "ClusterIP", "label-app",
|
||||
"spring-cloud-kubernetes-client-discovery-it", "annotation-custom-spring-k8s", "spring-k8s"));
|
||||
Assertions.assertEquals(serviceInstance.getPort(), 8080);
|
||||
Assertions.assertEquals(serviceInstance.getNamespace(), "default");
|
||||
|
||||
}
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery.it;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import io.kubernetes.client.openapi.models.V1Deployment;
|
||||
import io.kubernetes.client.openapi.models.V1EnvVar;
|
||||
import io.kubernetes.client.openapi.models.V1Ingress;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.testcontainers.containers.Container;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.DefaultKubernetesServiceInstance;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class KubernetesClientDiscoverySelectiveNamespacesIT {
|
||||
|
||||
private static final String BLOCKING_PUBLISH = "Will publish InstanceRegisteredEvent from blocking implementation";
|
||||
|
||||
private static final String REACTIVE_PUBLISH = "Will publish InstanceRegisteredEvent from reactive implementation";
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final String NAMESPACE_A = "a";
|
||||
|
||||
private static final String NAMESPACE_B = "b";
|
||||
|
||||
private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-discovery-it";
|
||||
|
||||
private static final String DEPLOYMENT_NAME = "spring-cloud-kubernetes-client-discovery-deployment-it";
|
||||
|
||||
private static Util util;
|
||||
|
||||
private static final K3sContainer K3S = Commons.container();
|
||||
|
||||
@BeforeAll
|
||||
static void beforeAll() throws Exception {
|
||||
K3S.start();
|
||||
Commons.validateImage(IMAGE_NAME, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
|
||||
|
||||
util = new Util(K3S);
|
||||
|
||||
util.createNamespace(NAMESPACE_A);
|
||||
util.createNamespace(NAMESPACE_B);
|
||||
util.setUpClusterWide(NAMESPACE, Set.of(NAMESPACE, NAMESPACE_A, NAMESPACE_B));
|
||||
util.wiremock(NAMESPACE, "/wiremock", Phase.CREATE, false);
|
||||
util.wiremock(NAMESPACE_A, "/wiremock", Phase.CREATE, false);
|
||||
util.wiremock(NAMESPACE_B, "/wiremock", Phase.CREATE, false);
|
||||
manifests(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() throws Exception {
|
||||
Commons.cleanUp(IMAGE_NAME, K3S);
|
||||
|
||||
util.wiremock(NAMESPACE, "/wiremock", Phase.DELETE, false);
|
||||
util.wiremock(NAMESPACE_A, "/wiremock", Phase.DELETE, false);
|
||||
util.wiremock(NAMESPACE_B, "/wiremock", Phase.DELETE, false);
|
||||
util.deleteClusterWide(NAMESPACE, Set.of(NAMESPACE, NAMESPACE_A, NAMESPACE_B));
|
||||
util.deleteNamespace(NAMESPACE_A);
|
||||
util.deleteNamespace(NAMESPACE_B);
|
||||
manifests(Phase.DELETE);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy wiremock in 3 namespaces: default, a, b. Search only in selective namespace
|
||||
* 'a' with blocking enabled and reactive disabled, as such find a single service and
|
||||
* its service instance.
|
||||
*/
|
||||
@Test
|
||||
@Order(1)
|
||||
void testOneNamespaceBlockingOnly() {
|
||||
|
||||
Commons.waitForLogStatement("using selective namespaces : [a]", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesMissing : found selective namespaces : [a]", K3S,
|
||||
IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesPresent : found selective namespaces : [a]", K3S,
|
||||
IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : a", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : a", K3S, IMAGE_NAME);
|
||||
|
||||
// this tiny checks makes sure that blocking is enabled and reactive is disabled.
|
||||
Commons.waitForLogStatement(BLOCKING_PUBLISH, K3S, IMAGE_NAME);
|
||||
Assertions.assertFalse(logs().contains(REACTIVE_PUBLISH));
|
||||
|
||||
blockingCheck();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy wiremock in 3 namespaces: default, a, b. Search only in selective namespace
|
||||
* 'a' with blocking disabled and reactive enabled, as such find a single service and
|
||||
* its service instance.
|
||||
*/
|
||||
@Test
|
||||
@Order(2)
|
||||
void testOneNamespaceReactiveOnly() {
|
||||
|
||||
KubernetesClientDiscoveryClientUtils.patchForReactiveOnly(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
Commons.waitForLogStatement("using selective namespaces : [a]", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesMissing : found selective namespaces : [a]", K3S,
|
||||
IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : a", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : a", K3S, IMAGE_NAME);
|
||||
|
||||
// this tiny checks makes sure that reactive is enabled and blocking is disabled.
|
||||
Commons.waitForLogStatement(REACTIVE_PUBLISH, K3S, IMAGE_NAME);
|
||||
Assertions.assertFalse(logs().contains(BLOCKING_PUBLISH));
|
||||
|
||||
reactiveCheck();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy wiremock in 3 namespaces: default, a, b. Search only in selective namespace
|
||||
* 'a' with blocking enabled and reactive enabled, as such find a single service and
|
||||
* its service instance.
|
||||
*/
|
||||
@Test
|
||||
@Order(3)
|
||||
void testOneNamespaceBothBlockingAndReactive() {
|
||||
|
||||
KubernetesClientDiscoveryClientUtils.patchForBlockingAndReactive(DEPLOYMENT_NAME, NAMESPACE);
|
||||
|
||||
Commons.waitForLogStatement("using selective namespaces : [a]", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesMissing : found selective namespaces : [a]", K3S,
|
||||
IMAGE_NAME);
|
||||
Commons.waitForLogStatement("ConditionalOnSelectiveNamespacesPresent : found selective namespaces : [a]", K3S,
|
||||
IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for services) in namespace : a", K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement("registering lister (for endpoints) in namespace : a", K3S, IMAGE_NAME);
|
||||
|
||||
// this tiny checks makes sure that blocking and reactive is enabled.
|
||||
Commons.waitForLogStatement(BLOCKING_PUBLISH, K3S, IMAGE_NAME);
|
||||
Commons.waitForLogStatement(REACTIVE_PUBLISH, K3S, IMAGE_NAME);
|
||||
|
||||
blockingCheck();
|
||||
reactiveCheck();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* previous test already has: <pre>
|
||||
* - SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_0 = a
|
||||
* - SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED = TRUE
|
||||
* - SPRING_CLOUD_DISCOVERY_BLOCKING_ENABLED = TRUE
|
||||
*
|
||||
* All we need to patch for is:
|
||||
* - add one more namespace to track, via SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_1 = b
|
||||
* - disable reactive, via SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED = FALSE
|
||||
*
|
||||
* As such, two namespaces + blocking only, is achieved.
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Order(4)
|
||||
void testTwoNamespacesBlockingOnly() {
|
||||
KubernetesClientDiscoveryClientUtils.patchForTwoNamespacesBlockingOnly(DEPLOYMENT_NAME, NAMESPACE);
|
||||
new KubernetesClientDiscoveryMultipleSelectiveNamespacesITDelegate().testTwoNamespacesBlockingOnly(K3S);
|
||||
}
|
||||
|
||||
/**
|
||||
* previous test already has: <pre>
|
||||
* - SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_0 = a
|
||||
* - SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_1 = b
|
||||
* - SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED = FALSE
|
||||
* - SPRING_CLOUD_DISCOVERY_BLOCKING_ENABLED = TRUE
|
||||
*
|
||||
* We invert the reactive and blocking in this test via patching.
|
||||
*
|
||||
* As such, two namespaces + reactive only, is achieved.
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Order(5)
|
||||
void testTwoNamespacesReactiveOnly() {
|
||||
KubernetesClientDiscoveryClientUtils.patchForReactiveOnly(DEPLOYMENT_NAME, NAMESPACE);
|
||||
new KubernetesClientDiscoveryMultipleSelectiveNamespacesITDelegate().testTwoNamespaceReactiveOnly(K3S);
|
||||
}
|
||||
|
||||
/**
|
||||
* previous test already has: <pre>
|
||||
* - SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_0 = a
|
||||
* - SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_1 = b
|
||||
* - SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED = TRUE
|
||||
* - SPRING_CLOUD_DISCOVERY_BLOCKING_ENABLED = FALSE
|
||||
*
|
||||
* We invert the blocking support.
|
||||
*
|
||||
* As such, two namespaces + blocking and reactive, is achieved.
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
@Order(6)
|
||||
void testTwoNamespacesBothBlockingAndReactive() {
|
||||
KubernetesClientDiscoveryClientUtils.patchToAddBlockingSupport(DEPLOYMENT_NAME, NAMESPACE);
|
||||
new KubernetesClientDiscoveryMultipleSelectiveNamespacesITDelegate()
|
||||
.testTwoNamespacesBothBlockingAndReactive(K3S);
|
||||
}
|
||||
|
||||
private static void manifests(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util.yaml("kubernetes-discovery-deployment.yaml");
|
||||
V1Service service = (V1Service) util.yaml("kubernetes-discovery-service.yaml");
|
||||
V1Ingress ingress = (V1Ingress) util.yaml("kubernetes-discovery-ingress.yaml");
|
||||
|
||||
if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, ingress);
|
||||
return;
|
||||
}
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
List<V1EnvVar> envVars = new ArrayList<>(
|
||||
Optional.ofNullable(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv())
|
||||
.orElse(List.of()));
|
||||
V1EnvVar debugLevel = new V1EnvVar()
|
||||
.name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_DISCOVERY").value("DEBUG");
|
||||
V1EnvVar selectiveNamespaceA = new V1EnvVar().name("SPRING_CLOUD_KUBERNETES_DISCOVERY_NAMESPACES_0")
|
||||
.value(NAMESPACE_A);
|
||||
|
||||
V1EnvVar disableReactiveEnvVar = new V1EnvVar().name("SPRING_CLOUD_DISCOVERY_REACTIVE_ENABLED")
|
||||
.value("FALSE");
|
||||
envVars.add(disableReactiveEnvVar);
|
||||
|
||||
envVars.add(debugLevel);
|
||||
envVars.add(selectiveNamespaceA);
|
||||
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(envVars);
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, ingress, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void reactiveCheck() {
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/reactive/services").build();
|
||||
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(servicesResult.size(), 1);
|
||||
Assertions.assertTrue(servicesResult.contains("service-wiremock"));
|
||||
|
||||
WebClient ourServiceClient = builder().baseUrl("http://localhost/reactive/service-instances/service-wiremock")
|
||||
.build();
|
||||
|
||||
List<DefaultKubernetesServiceInstance> ourServiceInstances = ourServiceClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(ourServiceInstances.size(), 1);
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstance = ourServiceInstances.get(0);
|
||||
// we only care about namespace here, as all other fields are tested in various
|
||||
// other tests.
|
||||
Assertions.assertEquals(serviceInstance.getNamespace(), "a");
|
||||
}
|
||||
|
||||
private void blockingCheck() {
|
||||
WebClient servicesClient = builder().baseUrl("http://localhost/services").build();
|
||||
|
||||
List<String> servicesResult = servicesClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<String>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(servicesResult.size(), 1);
|
||||
Assertions.assertTrue(servicesResult.contains("service-wiremock"));
|
||||
|
||||
WebClient ourServiceClient = builder().baseUrl("http://localhost/service-instances/service-wiremock").build();
|
||||
|
||||
List<DefaultKubernetesServiceInstance> ourServiceInstances = ourServiceClient.method(HttpMethod.GET).retrieve()
|
||||
.bodyToMono(new ParameterizedTypeReference<List<DefaultKubernetesServiceInstance>>() {
|
||||
|
||||
}).retryWhen(retrySpec()).block();
|
||||
|
||||
Assertions.assertEquals(ourServiceInstances.size(), 1);
|
||||
|
||||
DefaultKubernetesServiceInstance serviceInstance = ourServiceInstances.get(0);
|
||||
// we only care about namespace here, as all other fields are tested in various
|
||||
// other tests.
|
||||
Assertions.assertEquals(serviceInstance.getNamespace(), "a");
|
||||
}
|
||||
|
||||
private String logs() {
|
||||
try {
|
||||
String appPodName = K3S.execInContainer("sh", "-c",
|
||||
"kubectl get pods -l app=" + IMAGE_NAME + " -o=name --no-headers | tr -d '\n'").getStdout();
|
||||
|
||||
Container.ExecResult execResult = K3S.execInContainer("sh", "-c", "kubectl logs " + appPodName.trim());
|
||||
return execResult.getStdout();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spring-cloud-kubernetes-client-discovery-deployment-it
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spring-cloud-kubernetes-client-discovery-it
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-client-discovery-it
|
||||
spec:
|
||||
serviceAccountName: spring-cloud-kubernetes-serviceaccount
|
||||
containers:
|
||||
- name: spring-cloud-kubernetes-client-discovery
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-client-discovery-it
|
||||
imagePullPolicy: IfNotPresent
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/readiness
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 2
|
||||
failureThreshold: 5
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/liveness
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 2
|
||||
failureThreshold: 5
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: spring-cloud-kubernetes-client-discovery-ingress-it
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: spring-cloud-kubernetes-client-discovery-it
|
||||
port:
|
||||
number: 8080
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-client-discovery-it
|
||||
annotations:
|
||||
custom-spring-k8s: spring-k8s
|
||||
name: spring-cloud-kubernetes-client-discovery-it
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: spring-cloud-kubernetes-client-discovery-it
|
||||
type: ClusterIP
|
||||
@@ -1,14 +0,0 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
<logger name="org.testcontainers" level="INFO"/>
|
||||
<logger name="com.github.dockerjava" level="INFO"/>
|
||||
</configuration>
|
||||
@@ -1,115 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-integration-tests</artifactId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-cloud-kubernetes-client-event-and-polling-reload</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-client-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- not bootstrap starter, because we want to be able to disable bootstrap per-test -->
|
||||
<!-- and ConditionalOnBootstrapEnabled has a @ConditionalOnClass on a Marker -->
|
||||
<!-- that is present in bootstrap-starter, but not in this one -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-test-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<!-- build image in the 'package' phase, and ignore plain tests -->
|
||||
<!-- via maven-surefire-plugin::skipTests -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<configuration>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build-image</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- ignore plain tests (in the 'test' phase), so that we could build the image first, see above -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- run tests in the 'integration-tests' phase, one that is after 'package' (where we build the image) -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${testsToRun}</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.reload;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties({ LeftProperties.class, RightProperties.class, RightWithLabelsProperties.class,
|
||||
ConfigMapProperties.class, SecretsProperties.class })
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(App.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.reload;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@ConfigurationProperties("from.properties")
|
||||
public class ConfigMapProperties {
|
||||
|
||||
private String key;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key1) {
|
||||
this.key = key1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.reload;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@RestController
|
||||
public class Controller {
|
||||
|
||||
private final LeftProperties leftProperties;
|
||||
|
||||
private final RightProperties rightProperties;
|
||||
|
||||
private final RightWithLabelsProperties rightWithLabelsProperties;
|
||||
|
||||
private final ConfigMapProperties configMapProperties;
|
||||
|
||||
public Controller(LeftProperties leftProperties, RightProperties rightProperties,
|
||||
RightWithLabelsProperties rightWithLabelsProperties, ConfigMapProperties configMapProperties) {
|
||||
this.leftProperties = leftProperties;
|
||||
this.rightProperties = rightProperties;
|
||||
this.rightWithLabelsProperties = rightWithLabelsProperties;
|
||||
this.configMapProperties = configMapProperties;
|
||||
}
|
||||
|
||||
@GetMapping("/left")
|
||||
public String left() {
|
||||
return leftProperties.getValue();
|
||||
}
|
||||
|
||||
@GetMapping("/right")
|
||||
public String right() {
|
||||
return rightProperties.getValue();
|
||||
}
|
||||
|
||||
@GetMapping("/with-label")
|
||||
public String witLabel() {
|
||||
return rightWithLabelsProperties.getValue();
|
||||
}
|
||||
|
||||
@GetMapping("/mount")
|
||||
public String key() {
|
||||
return configMapProperties.getKey();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.reload;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@ConfigurationProperties("left")
|
||||
public class LeftProperties {
|
||||
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.reload;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@ConfigurationProperties("right")
|
||||
public class RightProperties {
|
||||
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.reload;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@ConfigurationProperties("right.with.label")
|
||||
public class RightWithLabelsProperties {
|
||||
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.reload;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@RestController
|
||||
public class SecretsController {
|
||||
|
||||
private final SecretsProperties properties;
|
||||
|
||||
public SecretsController(SecretsProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@GetMapping("/key")
|
||||
public String key() {
|
||||
return properties.getKey();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.reload;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@ConfigurationProperties("from.properties")
|
||||
public class SecretsProperties {
|
||||
|
||||
private String key;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
spring:
|
||||
application:
|
||||
name: poll-reload-mount
|
||||
cloud:
|
||||
kubernetes:
|
||||
reload:
|
||||
enabled: true
|
||||
monitoring-config-maps: true
|
||||
strategy: shutdown
|
||||
mode: polling
|
||||
period: 5000
|
||||
config:
|
||||
paths:
|
||||
- /tmp/application.properties
|
||||
config:
|
||||
import: "kubernetes:"
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
logging:
|
||||
level:
|
||||
root: DEBUG
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: event-reload
|
||||
cloud:
|
||||
kubernetes:
|
||||
reload:
|
||||
enabled: true
|
||||
strategy: shutdown
|
||||
mode: event
|
||||
namespaces:
|
||||
- left
|
||||
monitoring-config-maps: true
|
||||
@@ -1,17 +0,0 @@
|
||||
logging:
|
||||
level:
|
||||
root: DEBUG
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: event-reload
|
||||
cloud:
|
||||
kubernetes:
|
||||
reload:
|
||||
enabled: true
|
||||
strategy: shutdown
|
||||
mode: event
|
||||
namespaces:
|
||||
- right
|
||||
monitoring-config-maps: true
|
||||
enable-reload-filtering: true
|
||||
@@ -1,16 +0,0 @@
|
||||
logging:
|
||||
level:
|
||||
root: DEBUG
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: event-reload
|
||||
cloud:
|
||||
kubernetes:
|
||||
reload:
|
||||
enabled: true
|
||||
strategy: shutdown
|
||||
mode: event
|
||||
namespaces:
|
||||
- right
|
||||
monitoring-config-maps: true
|
||||
@@ -1,12 +0,0 @@
|
||||
spring:
|
||||
application:
|
||||
name: poll-reload-mount-boostrap
|
||||
cloud:
|
||||
kubernetes:
|
||||
reload:
|
||||
enabled: true
|
||||
monitoring-config-maps: true
|
||||
strategy: shutdown
|
||||
mode: polling
|
||||
period: 5000
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
logging:
|
||||
level:
|
||||
root: DEBUG
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: event-reload
|
||||
config:
|
||||
import: "kubernetes:"
|
||||
cloud:
|
||||
kubernetes:
|
||||
reload:
|
||||
enabled: true
|
||||
strategy: shutdown
|
||||
mode: event
|
||||
monitoring-secrets: true
|
||||
monitoring-configMaps: false
|
||||
secrets:
|
||||
enabled: true
|
||||
enable-api: true
|
||||
@@ -1,13 +0,0 @@
|
||||
logging:
|
||||
level:
|
||||
root: DEBUG
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
kubernetes:
|
||||
config:
|
||||
sources:
|
||||
- namespace: left
|
||||
name: left-configmap
|
||||
- namespace: right
|
||||
name: right-configmap
|
||||
@@ -1,15 +0,0 @@
|
||||
logging:
|
||||
level:
|
||||
root: DEBUG
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
kubernetes:
|
||||
config:
|
||||
sources:
|
||||
- namespace: left
|
||||
name: left-configmap
|
||||
- namespace: right
|
||||
name: right-configmap
|
||||
- namespace: right
|
||||
name: right-configmap-with-label
|
||||
@@ -1,13 +0,0 @@
|
||||
logging:
|
||||
level:
|
||||
root: DEBUG
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
kubernetes:
|
||||
config:
|
||||
sources:
|
||||
- namespace: left
|
||||
name: left-configmap
|
||||
- namespace: right
|
||||
name: right-configmap
|
||||
@@ -1,6 +0,0 @@
|
||||
spring:
|
||||
cloud:
|
||||
kubernetes:
|
||||
config:
|
||||
paths:
|
||||
- /tmp/application.properties
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.configmap.reload;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import io.kubernetes.client.openapi.models.V1ConfigMap;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
final class BootstrapEnabledPollingReloadConfigMapMountDelegate {
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - we have bootstrap enabled, which means we will 'locate' property sources
|
||||
* from config maps.
|
||||
* - there are no explicit config maps to search for, but what we will also read,
|
||||
* is 'spring.cloud.kubernetes.config.paths', which we have set to
|
||||
* '/tmp/application.properties'
|
||||
* in this test. That is populated by the volumeMounts (see deployment-mount.yaml)
|
||||
* - we first assert that we are actually reading the path based source via (1), (2) and (3).
|
||||
*
|
||||
* - we then change the config map content, wait for k8s to pick it up and replace them
|
||||
* - our polling will then detect that change, and trigger a reload.
|
||||
* </pre>
|
||||
*/
|
||||
static void testBootstrapEnabledPollingReloadConfigMapMount(String deploymentName, K3sContainer k3sContainer,
|
||||
Util util, String imageName) throws Exception {
|
||||
|
||||
recreateMountConfigMap(util);
|
||||
K8sClientConfigMapReloadITUtil.patchSix(deploymentName, "default", imageName);
|
||||
|
||||
// (1)
|
||||
Commons.waitForLogStatement("paths property sources : [/tmp/application.properties]", k3sContainer,
|
||||
deploymentName);
|
||||
|
||||
// (2)
|
||||
Commons.waitForLogStatement("will add file-based property source : /tmp/application.properties", k3sContainer,
|
||||
deploymentName);
|
||||
|
||||
// (3)
|
||||
WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/mount").build();
|
||||
String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block();
|
||||
|
||||
// we first read the initial value from the configmap
|
||||
Assertions.assertEquals("as-mount-initial", result);
|
||||
|
||||
// replace data in configmap and wait for k8s to pick it up
|
||||
// our polling will detect that and restart the app
|
||||
V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml");
|
||||
configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed"));
|
||||
new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", NAMESPACE, configMap, null, null, null,
|
||||
null);
|
||||
|
||||
await().timeout(Duration.ofSeconds(180))
|
||||
.until(() -> webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block().equals("as-mount-changed"));
|
||||
|
||||
}
|
||||
|
||||
private static void recreateMountConfigMap(Util util) {
|
||||
V1ConfigMap mountConfigMap = (V1ConfigMap) util.yaml("configmap-mount.yaml");
|
||||
|
||||
util.deleteAndWait("default", mountConfigMap, null);
|
||||
util.createAndWait("default", mountConfigMap, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.configmap.reload;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import io.kubernetes.client.openapi.ApiException;
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import io.kubernetes.client.openapi.models.V1ConfigMap;
|
||||
import io.kubernetes.client.openapi.models.V1ConfigMapBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ObjectMetaBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
final class DataChangesInConfigMapReloadDelegate {
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final String LEFT_NAMESPACE = "left";
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - configMap with no labels and data: left.value = left-initial exists in namespace left
|
||||
* - we assert that we can read it correctly first, by invoking localhost/left
|
||||
*
|
||||
* - then we change the configmap by adding a label, this in turn does not
|
||||
* change the result of localhost/left, because the data has not changed.
|
||||
*
|
||||
* - then we change data inside the config map, and we must see the updated value
|
||||
* </pre>
|
||||
*/
|
||||
static void testSimple(String dockerImage, String deploymentName, K3sContainer k3sContainer) {
|
||||
|
||||
K8sClientConfigMapReloadITUtil.patchFour(deploymentName, NAMESPACE, dockerImage);
|
||||
Commons.assertReloadLogStatements("added configmap informer for namespace",
|
||||
"added secret informer for namespace", deploymentName);
|
||||
|
||||
WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/" + LEFT_NAMESPACE)
|
||||
.build();
|
||||
String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block();
|
||||
|
||||
// we first read the initial value from the left-configmap
|
||||
Assertions.assertEquals("left-initial", result);
|
||||
|
||||
// then deploy a new version of left-configmap, but without changing its data,
|
||||
// only add a label
|
||||
V1ConfigMap configMap = new V1ConfigMapBuilder().withMetadata(new V1ObjectMetaBuilder()
|
||||
.withLabels(Map.of("new-label", "abc")).withNamespace("left").withName("left-configmap").build())
|
||||
.withData(Map.of("left.value", "left-initial")).build();
|
||||
|
||||
replaceConfigMap(configMap);
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> {
|
||||
WebClient innerWebClient = K8sClientConfigMapReloadITUtil.builder()
|
||||
.baseUrl("http://localhost/" + LEFT_NAMESPACE).build();
|
||||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block();
|
||||
return "left-initial".equals(innerResult);
|
||||
});
|
||||
|
||||
String logs = K8sClientConfigMapReloadITUtil.logs(deploymentName, k3sContainer);
|
||||
Assertions.assertTrue(logs.contains("ConfigMap left-configmap was updated in namespace left"));
|
||||
Assertions.assertTrue(logs.contains("data in configmap has not changed, will not reload"));
|
||||
|
||||
// change data
|
||||
configMap = new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMetaBuilder().withLabels(Map.of("new-label", "abc")).withNamespace("left")
|
||||
.withName("left-configmap").build())
|
||||
.withData(Map.of("left.value", "left-after-change")).build();
|
||||
|
||||
replaceConfigMap(configMap);
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> {
|
||||
WebClient innerWebClient = K8sClientConfigMapReloadITUtil.builder()
|
||||
.baseUrl("http://localhost/" + LEFT_NAMESPACE).build();
|
||||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block();
|
||||
return "left-after-change".equals(innerResult);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static void replaceConfigMap(V1ConfigMap configMap) {
|
||||
try {
|
||||
new CoreV1Api().replaceNamespacedConfigMap("left-configmap", LEFT_NAMESPACE, configMap, null, null, null,
|
||||
null);
|
||||
}
|
||||
catch (ApiException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,352 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.configmap.reload;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
import io.kubernetes.client.openapi.ApiException;
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import io.kubernetes.client.openapi.models.V1ConfigMap;
|
||||
import io.kubernetes.client.openapi.models.V1ConfigMapBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1Deployment;
|
||||
import io.kubernetes.client.openapi.models.V1Ingress;
|
||||
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.springframework.cloud.kubernetes.client.configmap.reload.BootstrapEnabledPollingReloadConfigMapMountDelegate.testBootstrapEnabledPollingReloadConfigMapMount;
|
||||
import static org.springframework.cloud.kubernetes.client.configmap.reload.DataChangesInConfigMapReloadDelegate.testSimple;
|
||||
import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.builder;
|
||||
import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchOne;
|
||||
import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchThree;
|
||||
import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchTwo;
|
||||
import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.retrySpec;
|
||||
import static org.springframework.cloud.kubernetes.client.configmap.reload.PollingReloadConfigMapMountDelegate.testPollingReloadConfigMapMount;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
class K8sClientConfigMapReloadIT {
|
||||
|
||||
private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-event-and-polling-reload";
|
||||
|
||||
private static final String DEPLOYMENT_NAME = "spring-k8s-client-reload";
|
||||
|
||||
private static final String DOCKER_IMAGE = "docker.io/springcloud/" + IMAGE_NAME + ":" + Commons.pomVersion();
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final K3sContainer K3S = Commons.container();
|
||||
|
||||
private static Util util;
|
||||
|
||||
private static CoreV1Api api;
|
||||
|
||||
@BeforeAll
|
||||
static void beforeAll() throws Exception {
|
||||
K3S.start();
|
||||
Commons.validateImage(IMAGE_NAME, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
|
||||
util = new Util(K3S);
|
||||
util.createNamespace("left");
|
||||
util.createNamespace("right");
|
||||
util.setUpClusterWide(NAMESPACE, Set.of("left", "right"));
|
||||
util.setUp(NAMESPACE);
|
||||
api = new CoreV1Api();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() throws Exception {
|
||||
util.deleteClusterWide(NAMESPACE, Set.of("left", "right"));
|
||||
manifests(Phase.DELETE);
|
||||
util.deleteNamespace("left");
|
||||
util.deleteNamespace("right");
|
||||
Commons.cleanUp(IMAGE_NAME, K3S);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - there are two namespaces : left and right
|
||||
* - each of the namespaces has one configmap
|
||||
* - we watch the "left" namespace, but make a change in the configmap in the right namespace
|
||||
* - as such, no event is triggered and "left-configmap" stays as-is
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
void testInformFromOneNamespaceEventNotTriggered() throws Exception {
|
||||
manifests(Phase.CREATE);
|
||||
Commons.assertReloadLogStatements("added configmap informer for namespace",
|
||||
"added secret informer for namespace", "spring-k8s-client-reload");
|
||||
|
||||
WebClient webClient = builder().baseUrl("http://localhost/left").build();
|
||||
String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
|
||||
// we first read the initial value from the left-configmap
|
||||
Assertions.assertEquals("left-initial", result);
|
||||
|
||||
// then read the value from the right-configmap
|
||||
webClient = builder().baseUrl("http://localhost/right").build();
|
||||
result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()).block();
|
||||
Assertions.assertEquals("right-initial", result);
|
||||
|
||||
// then deploy a new version of right-configmap
|
||||
V1ConfigMap rightConfigMapAfterChange = new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMeta().namespace("right").name("right-configmap"))
|
||||
.withData(Map.of("right.value", "right-after-change")).build();
|
||||
|
||||
replaceConfigMap(rightConfigMapAfterChange, "right-configmap");
|
||||
|
||||
// wait dummy for 5 seconds
|
||||
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5));
|
||||
|
||||
webClient = builder().baseUrl("http://localhost/left").build();
|
||||
result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()).block();
|
||||
// left configmap has not changed, no restart of app has happened
|
||||
Assertions.assertEquals("left-initial", result);
|
||||
|
||||
testAllOther();
|
||||
|
||||
}
|
||||
|
||||
// since we patch each deployment with "replace" strategy, any of the above can be
|
||||
// commented out and debugged individually.
|
||||
private void testAllOther() throws Exception {
|
||||
testInformFromOneNamespaceEventTriggered();
|
||||
testInform();
|
||||
testInformFromOneNamespaceEventTriggeredSecretsDisabled();
|
||||
testSimple(DOCKER_IMAGE, DEPLOYMENT_NAME, K3S);
|
||||
testPollingReloadConfigMapMount(DEPLOYMENT_NAME, K3S, util, DOCKER_IMAGE);
|
||||
testBootstrapEnabledPollingReloadConfigMapMount(DEPLOYMENT_NAME, K3S, util, DOCKER_IMAGE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - there are two namespaces : left and right
|
||||
* - each of the namespaces has one configmap
|
||||
* - we watch the "right" namespace and make a change in the configmap in the same namespace
|
||||
* - as such, event is triggered and we see the updated value
|
||||
* </pre>
|
||||
*/
|
||||
void testInformFromOneNamespaceEventTriggered() throws Exception {
|
||||
recreateConfigMaps();
|
||||
patchOne(DEPLOYMENT_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
Commons.assertReloadLogStatements("added configmap informer for namespace",
|
||||
"added secret informer for namespace", DEPLOYMENT_NAME);
|
||||
|
||||
// read the value from the right-configmap
|
||||
WebClient webClient = builder().baseUrl("http://localhost/right").build();
|
||||
String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
Assertions.assertEquals("right-initial", result);
|
||||
|
||||
// then deploy a new version of right-configmap
|
||||
V1ConfigMap rightConfigMapAfterChange = new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMeta().namespace("right").name("right-configmap"))
|
||||
.withData(Map.of("right.value", "right-after-change")).build();
|
||||
|
||||
replaceConfigMap(rightConfigMapAfterChange, "right-configmap");
|
||||
|
||||
String[] resultAfterChange = new String[1];
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> {
|
||||
WebClient innerWebClient = builder().baseUrl("http://localhost/right").build();
|
||||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
resultAfterChange[0] = innerResult;
|
||||
return innerResult != null;
|
||||
});
|
||||
Assertions.assertEquals("right-after-change", resultAfterChange[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - there are two namespaces : left and right (though we do not care about the left one)
|
||||
* - left has one configmap : left-configmap
|
||||
* - right has two configmaps: right-configmap, right-configmap-with-label
|
||||
* - we watch the "right" namespace, but enable tagging; which means that only
|
||||
* right-configmap-with-label triggers changes.
|
||||
* </pre>
|
||||
*/
|
||||
void testInform() throws Exception {
|
||||
recreateConfigMaps();
|
||||
V1ConfigMap rightWithLabelConfigMap = (V1ConfigMap) util.yaml("right-configmap-with-label.yaml");
|
||||
util.createAndWait("right", rightWithLabelConfigMap, null);
|
||||
patchTwo(DEPLOYMENT_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
|
||||
Commons.assertReloadLogStatements("added configmap informer for namespace",
|
||||
"added secret informer for namespace", DEPLOYMENT_NAME);
|
||||
|
||||
// read the initial value from the right-configmap
|
||||
WebClient rightWebClient = builder().baseUrl("http://localhost/right").build();
|
||||
String rightResult = rightWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
Assertions.assertEquals("right-initial", rightResult);
|
||||
|
||||
// then read the initial value from the right-with-label-configmap
|
||||
WebClient rightWithLabelWebClient = builder().baseUrl("http://localhost/with-label").build();
|
||||
String rightWithLabelResult = rightWithLabelWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
Assertions.assertEquals("right-with-label-initial", rightWithLabelResult);
|
||||
|
||||
// then deploy a new version of right-configmap
|
||||
V1ConfigMap rightConfigMapAfterChange = new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMeta().namespace("right").name("right-configmap"))
|
||||
.withData(Map.of("right.value", "right-after-change")).build();
|
||||
|
||||
replaceConfigMap(rightConfigMapAfterChange, "right-configmap");
|
||||
|
||||
// sleep for 5 seconds
|
||||
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5));
|
||||
|
||||
// nothing changes in our app, because we are watching only labeled configmaps
|
||||
rightResult = rightWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
Assertions.assertEquals("right-initial", rightResult);
|
||||
|
||||
// then deploy a new version of right-with-label-configmap
|
||||
V1ConfigMap rightWithLabelConfigMapAfterChange = new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMeta().namespace("right").name("right-configmap-with-label"))
|
||||
.withData(Map.of("right.with.label.value", "right-with-label-after-change")).build();
|
||||
|
||||
replaceConfigMap(rightWithLabelConfigMapAfterChange, "right-configmap-with-label");
|
||||
|
||||
// since we have changed a labeled configmap, app will restart and pick up the new
|
||||
// value
|
||||
String[] resultAfterChange = new String[1];
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> {
|
||||
WebClient innerWebClient = builder().baseUrl("http://localhost/with-label").build();
|
||||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
resultAfterChange[0] = innerResult;
|
||||
return innerResult != null;
|
||||
});
|
||||
Assertions.assertEquals("right-with-label-after-change", resultAfterChange[0]);
|
||||
|
||||
// right-configmap now will see the new value also, but only because the other
|
||||
// configmap has triggered the restart
|
||||
rightResult = rightWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
Assertions.assertEquals("right-after-change", rightResult);
|
||||
util.deleteAndWait("right", rightWithLabelConfigMap, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - there are two namespaces : left and right
|
||||
* - each of the namespaces has one configmap
|
||||
* - we watch the "right" namespace and make a change in the configmap in the same namespace
|
||||
* - as such, event is triggered and we see the updated value
|
||||
* </pre>
|
||||
*/
|
||||
void testInformFromOneNamespaceEventTriggeredSecretsDisabled() throws Exception {
|
||||
recreateConfigMaps();
|
||||
patchThree(DEPLOYMENT_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
Commons.assertReloadLogStatements("added configmap informer for namespace",
|
||||
"added secret informer for namespace", DEPLOYMENT_NAME);
|
||||
|
||||
// read the value from the right-configmap
|
||||
WebClient webClient = builder().baseUrl("http://localhost/right").build();
|
||||
String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
Assertions.assertEquals("right-initial", result);
|
||||
|
||||
// then deploy a new version of right-configmap
|
||||
V1ConfigMap rightConfigMapAfterChange = new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMeta().namespace("right").name("right-configmap"))
|
||||
.withData(Map.of("right.value", "right-after-change")).build();
|
||||
|
||||
replaceConfigMap(rightConfigMapAfterChange, "right-configmap");
|
||||
|
||||
String[] resultAfterChange = new String[1];
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> {
|
||||
WebClient innerWebClient = builder().baseUrl("http://localhost/right").build();
|
||||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
|
||||
resultAfterChange[0] = innerResult;
|
||||
return innerResult != null;
|
||||
});
|
||||
Assertions.assertEquals("right-after-change", resultAfterChange[0]);
|
||||
}
|
||||
|
||||
private void recreateConfigMaps() {
|
||||
V1ConfigMap leftConfigMap = (V1ConfigMap) util.yaml("left-configmap.yaml");
|
||||
V1ConfigMap rightConfigMap = (V1ConfigMap) util.yaml("right-configmap.yaml");
|
||||
|
||||
util.deleteAndWait("left", leftConfigMap, null);
|
||||
util.deleteAndWait("right", rightConfigMap, null);
|
||||
|
||||
util.createAndWait("left", leftConfigMap, null);
|
||||
util.createAndWait("right", rightConfigMap, null);
|
||||
}
|
||||
|
||||
private static void manifests(Phase phase) {
|
||||
|
||||
try {
|
||||
|
||||
V1ConfigMap leftConfigMap = (V1ConfigMap) util.yaml("left-configmap.yaml");
|
||||
V1ConfigMap rightConfigMap = (V1ConfigMap) util.yaml("right-configmap.yaml");
|
||||
V1ConfigMap mountConfigMap = (V1ConfigMap) util.yaml("configmap-mount.yaml");
|
||||
|
||||
V1Deployment deployment = (V1Deployment) util.yaml("deployment.yaml");
|
||||
V1Service service = (V1Service) util.yaml("service.yaml");
|
||||
V1Ingress ingress = (V1Ingress) util.yaml("ingress.yaml");
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
util.createAndWait(NAMESPACE, mountConfigMap, null);
|
||||
util.createAndWait("left", leftConfigMap, null);
|
||||
util.createAndWait("right", rightConfigMap, null);
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, ingress, true);
|
||||
}
|
||||
|
||||
if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, mountConfigMap, null);
|
||||
util.deleteAndWait("left", leftConfigMap, null);
|
||||
util.deleteAndWait("right", rightConfigMap, null);
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, ingress);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void replaceConfigMap(V1ConfigMap configMap, String name) throws ApiException {
|
||||
api.replaceNamespacedConfigMap(name, "right", configMap, null, null, null, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,453 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.configmap.reload;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.testcontainers.containers.Container;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util.patchWithReplace;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
final class K8sClientConfigMapReloadITUtil {
|
||||
|
||||
private static final Map<String, String> POD_LABELS = Map.of("app", "spring-k8s-client-reload");
|
||||
|
||||
private K8sClientConfigMapReloadITUtil() {
|
||||
}
|
||||
|
||||
private static final String BODY_ONE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-k8s-client-reload",
|
||||
"image": "image_name_here",
|
||||
"livenessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/liveness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"readinessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/readiness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_PROFILES_ACTIVE",
|
||||
"value": "two"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_CONFIG_RELOAD",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_BOOTSTRAP_ENABLED",
|
||||
"value": "TRUE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_TWO = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-k8s-client-reload",
|
||||
"image": "image_name_here",
|
||||
"livenessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/liveness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"readinessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/readiness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_PROFILES_ACTIVE",
|
||||
"value": "three"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_CONFIG_RELOAD",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_BOOTSTRAP_ENABLED",
|
||||
"value": "TRUE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_THREE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-k8s-client-reload",
|
||||
"image": "image_name_here",
|
||||
"livenessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/liveness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"readinessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/readiness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_PROFILES_ACTIVE",
|
||||
"value": "two"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_CONFIG_RELOAD",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_SECRETS_ENABLED",
|
||||
"value": "FALSE"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_BOOTSTRAP_ENABLED",
|
||||
"value": "TRUE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_FOUR = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-k8s-client-reload",
|
||||
"image": "image_name_here",
|
||||
"livenessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/liveness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"readinessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/readiness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_PROFILES_ACTIVE",
|
||||
"value": "one"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_CONFIG_RELOAD",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_SECRETS_ENABLED",
|
||||
"value": "FALSE"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_BOOTSTRAP_ENABLED",
|
||||
"value": "TRUE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_FIVE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"volumes": [
|
||||
{
|
||||
"configMap": {
|
||||
"defaultMode": 420,
|
||||
"name": "poll-reload-as-mount"
|
||||
},
|
||||
"name": "config-map-volume"
|
||||
}
|
||||
],
|
||||
"containers": [{
|
||||
"name": "spring-k8s-client-reload",
|
||||
"image": "image_name_here",
|
||||
"volumeMounts": [
|
||||
{
|
||||
"mountPath": "/tmp",
|
||||
"name": "config-map-volume"
|
||||
}
|
||||
],
|
||||
"livenessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/liveness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"readinessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/readiness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_PROFILES_ACTIVE",
|
||||
"value": "mount"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_BOOTSTRAP_ENABLED",
|
||||
"value": "FALSE"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS",
|
||||
"value": "DEBUG"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String BODY_SIX = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"volumes": [
|
||||
{
|
||||
"configMap": {
|
||||
"defaultMode": 420,
|
||||
"name": "poll-reload-as-mount"
|
||||
},
|
||||
"name": "config-map-volume"
|
||||
}
|
||||
],
|
||||
"containers": [{
|
||||
"name": "spring-k8s-client-reload",
|
||||
"image": "image_name_here",
|
||||
"volumeMounts": [
|
||||
{
|
||||
"mountPath": "/tmp",
|
||||
"name": "config-map-volume"
|
||||
}
|
||||
],
|
||||
"livenessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/liveness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"readinessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/readiness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_PROFILES_ACTIVE",
|
||||
"value": "with-bootstrap"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_BOOTSTRAP_ENABLED",
|
||||
"value": "TRUE"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS",
|
||||
"value": "DEBUG"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
static void patchOne(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_ONE, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchTwo(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_TWO, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchThree(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_THREE, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchFour(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_FOUR, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchFive(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_FIVE, POD_LABELS);
|
||||
}
|
||||
|
||||
static void patchSix(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_SIX, POD_LABELS);
|
||||
}
|
||||
|
||||
static WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
static RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(120, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
static String logs(String appLabelValue, K3sContainer k3sContainer) {
|
||||
try {
|
||||
String appPodName = k3sContainer
|
||||
.execInContainer("sh", "-c",
|
||||
"kubectl get pods -l app=" + appLabelValue + " -o=name --no-headers | tr -d '\n'")
|
||||
.getStdout();
|
||||
|
||||
Container.ExecResult execResult = k3sContainer.execInContainer("sh", "-c",
|
||||
"kubectl logs " + appPodName.trim());
|
||||
return execResult.getStdout();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.configmap.reload;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import io.kubernetes.client.openapi.models.V1ConfigMap;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
final class PollingReloadConfigMapMountDelegate {
|
||||
|
||||
private PollingReloadConfigMapMountDelegate() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - we have "spring.config.import: kubernetes", which means we will 'locate' property sources
|
||||
* from config maps.
|
||||
* - the property above means that at the moment we will be searching for config maps that only
|
||||
* match the application name, in this specific test there is no such config map.
|
||||
* - what we will also read, is 'spring.cloud.kubernetes.config.paths', which we have set to
|
||||
* '/tmp/application.properties'
|
||||
* in this test. That is populated by the volumeMounts (see BODY_FIVE)
|
||||
* - we first assert that we are actually reading the path based source via (1), (2) and (3).
|
||||
*
|
||||
* - we then change the config map content, wait for k8s to pick it up and replace them
|
||||
* - our polling will then detect that change, and trigger a reload.
|
||||
* </pre>
|
||||
*/
|
||||
static void testPollingReloadConfigMapMount(String deploymentName, K3sContainer k3sContainer, Util util,
|
||||
String imageName) throws Exception {
|
||||
|
||||
K8sClientConfigMapReloadITUtil.patchFive(deploymentName, "default", imageName);
|
||||
|
||||
// (1)
|
||||
Commons.waitForLogStatement("paths property sources : [/tmp/application.properties]", k3sContainer,
|
||||
deploymentName);
|
||||
|
||||
// (2)
|
||||
Commons.waitForLogStatement("will add file-based property source : /tmp/application.properties", k3sContainer,
|
||||
deploymentName);
|
||||
|
||||
// (3)
|
||||
WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/mount").build();
|
||||
String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block();
|
||||
|
||||
// we first read the initial value from the configmap
|
||||
Assertions.assertEquals("as-mount-initial", result);
|
||||
|
||||
// replace data in configmap and wait for k8s to pick it up
|
||||
// our polling will detect that and restart the app
|
||||
V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml");
|
||||
configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed"));
|
||||
new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", "default", configMap, null, null, null,
|
||||
null);
|
||||
|
||||
await().timeout(Duration.ofSeconds(180))
|
||||
.until(() -> webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block().equals("as-mount-changed"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.secrets.reload;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import io.kubernetes.client.openapi.ApiException;
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import io.kubernetes.client.openapi.models.V1ObjectMetaBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1Secret;
|
||||
import io.kubernetes.client.openapi.models.V1SecretBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.springframework.cloud.kubernetes.client.secrets.reload.K8sClientSecretsReloadITUtil.builder;
|
||||
import static org.springframework.cloud.kubernetes.client.secrets.reload.K8sClientSecretsReloadITUtil.retrySpec;
|
||||
|
||||
final class DataChangesInSecretsReloadDelegate {
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - secret with no labels and data: from.properties.key = initial exists in namespace default
|
||||
* - we assert that we can read it correctly first, by invoking localhost/key.
|
||||
*
|
||||
* - then we change the secret by adding a label, this in turn does not
|
||||
* change the result of localhost/key, because the data has not changed.
|
||||
*
|
||||
* - then we change data inside the secret, and we must see the updated value.
|
||||
* </pre>
|
||||
*/
|
||||
static void testDataChangesInSecretsReload(K3sContainer k3sContainer, String deploymentName) {
|
||||
Commons.assertReloadLogStatements("added secret informer for namespace",
|
||||
"added configmap informer for namespace", deploymentName);
|
||||
|
||||
WebClient webClient = builder().baseUrl("http://localhost/key").build();
|
||||
String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
|
||||
// we first read the initial value from the secret
|
||||
Assertions.assertEquals("initial", result);
|
||||
|
||||
// then deploy a new version of left-configmap, but without changing its data,
|
||||
// only add a label
|
||||
V1Secret secret = new V1SecretBuilder()
|
||||
.withMetadata(new V1ObjectMetaBuilder().withLabels(Map.of("new-label", "abc")).withNamespace(NAMESPACE)
|
||||
.withName("event-reload").build())
|
||||
.withData(Map.of("application.properties", "from.properties.key=initial".getBytes())).build();
|
||||
|
||||
replaceSecret(secret, "event-reload");
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> {
|
||||
WebClient innerWebClient = builder().baseUrl("http://localhost/key").build();
|
||||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
return "initial".equals(innerResult);
|
||||
});
|
||||
|
||||
Commons.waitForLogStatement("Secret event-reload was updated in namespace default", k3sContainer,
|
||||
deploymentName);
|
||||
Commons.waitForLogStatement("data in secret has not changed, will not reload", k3sContainer, deploymentName);
|
||||
|
||||
// change data
|
||||
secret = new V1SecretBuilder()
|
||||
.withMetadata(new V1ObjectMetaBuilder().withLabels(Map.of("new-label", "abc")).withNamespace(NAMESPACE)
|
||||
.withName("event-reload").build())
|
||||
.withData(Map.of("application.properties", "from.properties.key=change-initial".getBytes())).build();
|
||||
|
||||
replaceSecret(secret, "event-reload");
|
||||
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> {
|
||||
WebClient innerWebClient = builder().baseUrl("http://localhost/key").build();
|
||||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block();
|
||||
return "change-initial".equals(innerResult);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static void replaceSecret(V1Secret secret, String name) {
|
||||
try {
|
||||
new CoreV1Api().replaceNamespacedSecret(name, NAMESPACE, secret, null, null, null, null);
|
||||
}
|
||||
catch (ApiException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.secrets.reload;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import io.kubernetes.client.openapi.models.V1Deployment;
|
||||
import io.kubernetes.client.openapi.models.V1Ingress;
|
||||
import io.kubernetes.client.openapi.models.V1Secret;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.springframework.cloud.kubernetes.client.secrets.reload.DataChangesInSecretsReloadDelegate.testDataChangesInSecretsReload;
|
||||
import static org.springframework.cloud.kubernetes.client.secrets.reload.K8sClientSecretsReloadITUtil.builder;
|
||||
import static org.springframework.cloud.kubernetes.client.secrets.reload.K8sClientSecretsReloadITUtil.patchOne;
|
||||
import static org.springframework.cloud.kubernetes.client.secrets.reload.K8sClientSecretsReloadITUtil.retrySpec;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
class K8sClientSecretsReloadIT {
|
||||
|
||||
private static final String PROPERTY_URL = "http://localhost:80/key";
|
||||
|
||||
private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-event-and-polling-reload";
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final String DEPLOYMENT_NAME = "spring-k8s-client-reload";
|
||||
|
||||
private static final String DOCKER_IMAGE = "docker.io/springcloud/" + IMAGE_NAME + ":" + Commons.pomVersion();
|
||||
|
||||
private static final K3sContainer K3S = Commons.container();
|
||||
|
||||
private static Util util;
|
||||
|
||||
private static CoreV1Api coreV1Api;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() throws Exception {
|
||||
K3S.start();
|
||||
Commons.validateImage(IMAGE_NAME, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
|
||||
util = new Util(K3S);
|
||||
coreV1Api = new CoreV1Api();
|
||||
util.setUp(NAMESPACE);
|
||||
configK8sClientIt(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() throws Exception {
|
||||
configK8sClientIt(Phase.DELETE);
|
||||
Commons.cleanUp(IMAGE_NAME, K3S);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSecretReload() throws Exception {
|
||||
Commons.assertReloadLogStatements("added secret informer for namespace",
|
||||
"added configmap informer for namespace", DEPLOYMENT_NAME);
|
||||
testSecretEventReload();
|
||||
|
||||
testAllOther();
|
||||
}
|
||||
|
||||
private void testAllOther() throws Exception {
|
||||
recreateSecret();
|
||||
patchOne(DEPLOYMENT_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
testSecretReloadConfigDisabled();
|
||||
|
||||
recreateSecret();
|
||||
patchOne(DEPLOYMENT_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
testDataChangesInSecretsReload(K3S, DEPLOYMENT_NAME);
|
||||
}
|
||||
|
||||
void testSecretReloadConfigDisabled() throws Exception {
|
||||
Commons.assertReloadLogStatements("added secret informer for namespace",
|
||||
"added configmap informer for namespace", DEPLOYMENT_NAME);
|
||||
testSecretEventReload();
|
||||
}
|
||||
|
||||
void testSecretEventReload() throws Exception {
|
||||
|
||||
WebClient.Builder builder = builder();
|
||||
WebClient secretClient = builder.baseUrl(PROPERTY_URL).build();
|
||||
|
||||
await().timeout(Duration.ofSeconds(120)).pollInterval(Duration.ofSeconds(2))
|
||||
.until(() -> secretClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block().equals("initial"));
|
||||
|
||||
V1Secret v1Secret = (V1Secret) util.yaml("secret.yaml");
|
||||
Map<String, byte[]> secretData = v1Secret.getData();
|
||||
secretData.replace("application.properties", "from.properties.key: after-change".getBytes());
|
||||
v1Secret.setData(secretData);
|
||||
coreV1Api.replaceNamespacedSecret("event-reload", NAMESPACE, v1Secret, null, null, null, null);
|
||||
|
||||
await().timeout(Duration.ofSeconds(120)).pollInterval(Duration.ofSeconds(2))
|
||||
.until(() -> secretClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class)
|
||||
.retryWhen(retrySpec()).block().equals("after-change"));
|
||||
}
|
||||
|
||||
private void recreateSecret() {
|
||||
V1Secret secret = (V1Secret) util.yaml("secret.yaml");
|
||||
util.deleteAndWait(NAMESPACE, null, secret);
|
||||
util.createAndWait(NAMESPACE, null, secret);
|
||||
}
|
||||
|
||||
private static void configK8sClientIt(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util.yaml("deployment-with-secret.yaml");
|
||||
V1Service service = (V1Service) util.yaml("service.yaml");
|
||||
V1Ingress ingress = (V1Ingress) util.yaml("ingress.yaml");
|
||||
V1Secret secret = (V1Secret) util.yaml("secret.yaml");
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, ingress, true);
|
||||
util.createAndWait(NAMESPACE, null, secret);
|
||||
}
|
||||
else if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, ingress);
|
||||
util.deleteAndWait(NAMESPACE, null, secret);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.secrets.reload;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.util.retry.Retry;
|
||||
import reactor.util.retry.RetryBackoffSpec;
|
||||
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util.patchWithReplace;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
final class K8sClientSecretsReloadITUtil {
|
||||
|
||||
private static final Map<String, String> POD_LABELS = Map.of("app", "spring-k8s-client-reload");
|
||||
|
||||
private static final String BODY_ONE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-k8s-client-reload",
|
||||
"image": "image_name_here",
|
||||
"livenessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/liveness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"readinessProbe": {
|
||||
"failureThreshold": 3,
|
||||
"httpGet": {
|
||||
"path": "/actuator/health/readiness",
|
||||
"port": 8080,
|
||||
"scheme": "HTTP"
|
||||
},
|
||||
"periodSeconds": 10,
|
||||
"successThreshold": 1,
|
||||
"timeoutSeconds": 1
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_CONFIG_ENABLED",
|
||||
"value": "FALSE"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_PROFILES_ACTIVE",
|
||||
"value": "with-secret"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private K8sClientSecretsReloadITUtil() {
|
||||
|
||||
}
|
||||
|
||||
static WebClient.Builder builder() {
|
||||
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create()));
|
||||
}
|
||||
|
||||
static RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(60, Duration.ofSeconds(2)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
static void patchOne(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_ONE, POD_LABELS);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: poll-reload-as-mount
|
||||
namespace: default
|
||||
data:
|
||||
application.properties: |
|
||||
from.properties.key=as-mount-initial
|
||||
@@ -1,33 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spring-k8s-client-reload
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spring-k8s-client-reload
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-k8s-client-reload
|
||||
spec:
|
||||
serviceAccountName: spring-cloud-kubernetes-serviceaccount
|
||||
containers:
|
||||
- name: spring-k8s-client-reload
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-client-event-and-polling-reload
|
||||
imagePullPolicy: IfNotPresent
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/readiness
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/liveness
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
env:
|
||||
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_CONFIG_RELOAD
|
||||
value: DEBUG
|
||||
- name: SPRING_PROFILES_ACTIVE
|
||||
value: "with-secret"
|
||||
@@ -1,35 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spring-k8s-client-reload
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spring-k8s-client-reload
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-k8s-client-reload
|
||||
spec:
|
||||
serviceAccountName: spring-cloud-kubernetes-serviceaccount
|
||||
containers:
|
||||
- name: spring-k8s-client-reload
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-client-event-and-polling-reload
|
||||
imagePullPolicy: IfNotPresent
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/readiness
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/liveness
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
env:
|
||||
- name: SPRING_PROFILES_ACTIVE
|
||||
value: one
|
||||
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_CONFIG_RELOAD
|
||||
value: DEBUG
|
||||
- name: SPRING_CLOUD_BOOTSTRAP_ENABLED
|
||||
value: "TRUE"
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: spring-k8s-client-ingress-reload
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: spring-k8s-client-reload
|
||||
port:
|
||||
number: 8080
|
||||
@@ -1,7 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: left-configmap
|
||||
namespace: left
|
||||
data:
|
||||
left.value: "left-initial"
|
||||
@@ -1,14 +0,0 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
<logger name="org.testcontainers" level="INFO"/>
|
||||
<logger name="com.github.dockerjava" level="WARN"/>
|
||||
</configuration>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user