Merge branch '3.0.x'
This commit is contained in:
@@ -65,10 +65,12 @@
|
||||
<!-- since discovery controller is based on k8s-client, we do not have a fabric8 module -->
|
||||
<module>spring-cloud-kubernetes-k8s-client-discovery-server</module>
|
||||
|
||||
<!-- configuration watcher is based on k8s-client, there's no fabric8 counterpart -->
|
||||
<module>spring-cloud-kubernetes-k8s-client-configuration-watcher</module>
|
||||
|
||||
<module>spring-cloud-kubernetes-fabric8-istio-it</module>
|
||||
|
||||
<module>spring-cloud-kubernetes-client-loadbalancer-it</module>
|
||||
<module>spring-cloud-kubernetes-configuration-watcher-it</module>
|
||||
<module>spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps</module>
|
||||
<module>spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps</module>
|
||||
</modules>
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2020 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;
|
||||
|
||||
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;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class ConfigWatcherTestApplication implements ApplicationListener<RefreshRemoteApplicationEvent> {
|
||||
|
||||
protected Log log = LogFactory.getLog(getClass());
|
||||
|
||||
private boolean value = false;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfigWatcherTestApplication.class, args);
|
||||
}
|
||||
|
||||
@GetMapping("/it")
|
||||
public boolean index() {
|
||||
log.info("Current value: " + value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(RefreshRemoteApplicationEvent refreshRemoteApplicationEvent) {
|
||||
log.info("Received remote refresh event");
|
||||
this.value = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
spring:
|
||||
application:
|
||||
name: spring-cloud-kubernetes-configuration-watcher-it
|
||||
cloud:
|
||||
bus:
|
||||
refresh:
|
||||
enabled: false #disable this because we are going to provide our own refresh listener for testing purposes
|
||||
enabled: false
|
||||
autoconfigure:
|
||||
exclude: org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration
|
||||
management:
|
||||
endpoint:
|
||||
health:
|
||||
probes:
|
||||
enabled: true
|
||||
---
|
||||
spring:
|
||||
cloud:
|
||||
bus:
|
||||
enabled: true
|
||||
stream:
|
||||
default-binder: rabbit
|
||||
config:
|
||||
activate:
|
||||
on-profile: bus-amqp
|
||||
---
|
||||
spring:
|
||||
cloud:
|
||||
bus:
|
||||
enabled: true
|
||||
stream:
|
||||
default-binder: kafka
|
||||
config:
|
||||
activate:
|
||||
on-profile: bus-kafka
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2020 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;
|
||||
|
||||
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 Kris Iyer
|
||||
*/
|
||||
class ActuatorRefreshKafkaIT {
|
||||
|
||||
private static final String CONFIG_WATCHER_IT_IMAGE = "spring-cloud-kubernetes-configuration-watcher-it";
|
||||
|
||||
private static final String SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME = "spring-cloud-kubernetes-configuration-watcher";
|
||||
|
||||
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();
|
||||
|
||||
Commons.validateImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
|
||||
Commons.validateImage(CONFIG_WATCHER_IT_IMAGE, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(CONFIG_WATCHER_IT_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_IT_IMAGE, K3S);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
util.zookeeper(NAMESPACE, Phase.CREATE);
|
||||
util.kafka(NAMESPACE, Phase.CREATE);
|
||||
testApp(Phase.CREATE);
|
||||
configWatcher(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void after() {
|
||||
util.zookeeper(NAMESPACE, Phase.DELETE);
|
||||
util.kafka(NAMESPACE, Phase.DELETE);
|
||||
testApp(Phase.DELETE);
|
||||
configWatcher(Phase.DELETE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRefresh() {
|
||||
// Create new configmap to trigger controller to signal app to refresh
|
||||
V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName(CONFIG_WATCHER_IT_IMAGE)
|
||||
.addToLabels("spring.cloud.kubernetes.config", "true").endMetadata().addToData("foo", "hello world")
|
||||
.build();
|
||||
util.createAndWait(NAMESPACE, configMap, null);
|
||||
|
||||
WebClient.Builder builder = builder();
|
||||
WebClient serviceClient = builder.baseUrl("http://localhost:80/it").build();
|
||||
|
||||
Boolean[] value = new Boolean[1];
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(240)).until(() -> {
|
||||
value[0] = serviceClient.method(HttpMethod.GET).retrieve().bodyToMono(Boolean.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
return value[0];
|
||||
});
|
||||
|
||||
Assertions.assertTrue(value[0]);
|
||||
|
||||
util.deleteAndWait(NAMESPACE, configMap, null);
|
||||
}
|
||||
|
||||
private void testApp(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util
|
||||
.yaml("app/spring-cloud-kubernetes-configuration-watcher-it-bus-kafka-deployment.yaml");
|
||||
V1Service service = (V1Service) util.yaml("app/spring-cloud-kubernetes-configuration-watcher-it-service.yaml");
|
||||
V1Ingress ingress = (V1Ingress) util.yaml("app/spring-cloud-kubernetes-configuration-watcher-it-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 configWatcher(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util
|
||||
.yaml("app-watcher/spring-cloud-kubernetes-configuration-watcher-bus-kafka-deployment.yaml");
|
||||
V1Service service = (V1Service) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-service.yaml");
|
||||
|
||||
V1ConfigMap configMap = (V1ConfigMap) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-configmap.yaml");
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, null, true);
|
||||
util.createAndWait(NAMESPACE, configMap, null);
|
||||
}
|
||||
else if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, null);
|
||||
util.deleteAndWait(NAMESPACE, configMap, 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,158 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2020 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;
|
||||
|
||||
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 Ryan Baxter
|
||||
*/
|
||||
class ActuatorRefreshRabbitMQIT {
|
||||
|
||||
private static final String CONFIG_WATCHER_IT_IMAGE = "spring-cloud-kubernetes-configuration-watcher-it";
|
||||
|
||||
private static final String SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME = "spring-cloud-kubernetes-configuration-watcher";
|
||||
|
||||
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();
|
||||
|
||||
Commons.validateImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
|
||||
Commons.validateImage(CONFIG_WATCHER_IT_IMAGE, K3S);
|
||||
Commons.loadSpringCloudKubernetesImage(CONFIG_WATCHER_IT_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_IT_IMAGE, K3S);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
util.rabbitMq(NAMESPACE, Phase.CREATE);
|
||||
app(Phase.CREATE);
|
||||
configWatcher(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
util.rabbitMq(NAMESPACE, Phase.DELETE);
|
||||
app(Phase.DELETE);
|
||||
configWatcher(Phase.DELETE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRefresh() {
|
||||
// Create new configmap to trigger controller to signal app to refresh
|
||||
V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName(CONFIG_WATCHER_IT_IMAGE)
|
||||
.addToLabels("spring.cloud.kubernetes.config", "true").endMetadata().addToData("foo", "hello world")
|
||||
.build();
|
||||
util.createAndWait(NAMESPACE, configMap, null);
|
||||
|
||||
WebClient.Builder builder = builder();
|
||||
WebClient serviceClient = builder.baseUrl("http://localhost:80/it").build();
|
||||
|
||||
Boolean[] value = new Boolean[1];
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(180)).until(() -> {
|
||||
value[0] = serviceClient.method(HttpMethod.GET).retrieve().bodyToMono(Boolean.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
return value[0];
|
||||
});
|
||||
|
||||
Assertions.assertTrue(value[0]);
|
||||
util.deleteAndWait(NAMESPACE, configMap, null);
|
||||
}
|
||||
|
||||
private void app(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util
|
||||
.yaml("app-watcher/spring-cloud-kubernetes-configuration-watcher-it-bus-amqp-deployment.yaml");
|
||||
V1Service service = (V1Service) util.yaml("app/spring-cloud-kubernetes-configuration-watcher-it-service.yaml");
|
||||
V1Ingress ingress = (V1Ingress) util.yaml("app/spring-cloud-kubernetes-configuration-watcher-it-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 configWatcher(Phase phase) {
|
||||
V1Deployment deployment = (V1Deployment) util
|
||||
.yaml("app-watcher/spring-cloud-kubernetes-configuration-watcher-bus-amqp-deployment.yaml");
|
||||
V1Service service = (V1Service) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-service.yaml");
|
||||
V1ConfigMap configMap = (V1ConfigMap) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-configmap.yaml");
|
||||
|
||||
if (phase.equals(Phase.CREATE)) {
|
||||
util.createAndWait(NAMESPACE, null, deployment, service, null, true);
|
||||
util.createAndWait(NAMESPACE, configMap, null);
|
||||
}
|
||||
else if (phase.equals(Phase.DELETE)) {
|
||||
util.deleteAndWait(NAMESPACE, deployment, service, null);
|
||||
util.deleteAndWait(NAMESPACE, configMap, null);
|
||||
}
|
||||
}
|
||||
|
||||
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,33 +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-amqp
|
||||
- name: SPRING_RABBITMQ_HOST
|
||||
value: rabbitmq-service
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8888
|
||||
path: /actuator/health/readiness
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8888
|
||||
path: /actuator/health/liveness
|
||||
ports:
|
||||
- containerPort: 8888
|
||||
@@ -1,43 +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.kafka.bootstrap-servers
|
||||
value: kafka:9092
|
||||
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,32 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spring-cloud-kubernetes-configuration-watcher-it-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spring-cloud-kubernetes-configuration-watcher-it
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-configuration-watcher-it
|
||||
spec:
|
||||
containers:
|
||||
- name: spring-cloud-kubernetes-configuration-watcher-it
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-configuration-watcher-it
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: SPRING_PROFILES_ACTIVE
|
||||
value: bus-amqp
|
||||
- name: SPRING_RABBITMQ_HOST
|
||||
value: rabbitmq-service
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/readiness
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
port: 8080
|
||||
path: /actuator/health/liveness
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
@@ -1,42 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spring-cloud-kubernetes-configuration-watcher-it-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spring-cloud-kubernetes-configuration-watcher-it
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-configuration-watcher-it
|
||||
spec:
|
||||
containers:
|
||||
- name: spring-cloud-kubernetes-configuration-watcher-it
|
||||
image: docker.io/springcloud/spring-cloud-kubernetes-configuration-watcher-it
|
||||
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,16 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: it-ingress
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /it
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: spring-cloud-kubernetes-configuration-watcher-it
|
||||
port:
|
||||
number: 8080
|
||||
@@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-cloud-kubernetes-configuration-watcher-it
|
||||
name: spring-cloud-kubernetes-configuration-watcher-it
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: spring-cloud-kubernetes-configuration-watcher-it
|
||||
type: ClusterIP
|
||||
@@ -9,7 +9,7 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-kubernetes-configuration-watcher-it</artifactId>
|
||||
<artifactId>spring-cloud-kubernetes-k8s-client-configuration-watcher</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
@@ -69,34 +69,6 @@
|
||||
</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>
|
||||
@@ -16,16 +16,13 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.configuration.watcher;
|
||||
|
||||
import java.net.SocketException;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||
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.V1EnvVar;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@@ -57,6 +54,9 @@ class ActuatorRefreshIT {
|
||||
|
||||
private static final String NAMESPACE = "default";
|
||||
|
||||
private static final String DOCKER_IMAGE = "docker.io/springcloud/" + SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME + ":"
|
||||
+ Commons.pomVersion();
|
||||
|
||||
private static final K3sContainer K3S = Commons.container();
|
||||
|
||||
private static Util util;
|
||||
@@ -68,22 +68,25 @@ class ActuatorRefreshIT {
|
||||
Commons.loadSpringCloudKubernetesImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
util = new Util(K3S);
|
||||
util.setUp(NAMESPACE);
|
||||
|
||||
configWatcher(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() throws Exception {
|
||||
configWatcher(Phase.DELETE);
|
||||
Commons.cleanUp(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S);
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
util.wiremock(NAMESPACE, "/", Phase.CREATE);
|
||||
util.wiremock(NAMESPACE, WIREMOCK_PATH, Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void after() {
|
||||
util.wiremock(NAMESPACE, "/", Phase.DELETE);
|
||||
util.wiremock(NAMESPACE, WIREMOCK_PATH, Phase.DELETE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -96,36 +99,34 @@ class ActuatorRefreshIT {
|
||||
// curl <WIREMOCK_POD_IP>:8080/__admin/mappings
|
||||
@Test
|
||||
void testActuatorRefresh() {
|
||||
configWatcher(Phase.CREATE, false);
|
||||
|
||||
WireMock.configureFor(WIREMOCK_HOST, WIREMOCK_PORT, WIREMOCK_PATH);
|
||||
await().timeout(Duration.ofSeconds(60))
|
||||
await().timeout(Duration.ofSeconds(60)).ignoreException(SocketException.class)
|
||||
.until(() -> WireMock
|
||||
.stubFor(WireMock.post(WireMock.urlEqualTo("/actuator/refresh"))
|
||||
.willReturn(WireMock.aResponse().withBody("{}").withStatus(200)))
|
||||
.getResponse().wasConfigured());
|
||||
|
||||
// Create new configmap to trigger controller to signal app to refresh
|
||||
V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName("service-wiremock")
|
||||
.addToLabels("spring.cloud.kubernetes.config", "true").endMetadata().addToData("foo", "bar").build();
|
||||
util.createAndWait(NAMESPACE, configMap, null);
|
||||
createConfigMap();
|
||||
|
||||
// Wait a bit before we verify
|
||||
await().atMost(Duration.ofSeconds(30)).until(
|
||||
() -> !WireMock.findAll(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh"))).isEmpty());
|
||||
|
||||
WireMock.verify(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh")));
|
||||
util.deleteAndWait(NAMESPACE, configMap, null);
|
||||
|
||||
configWatcher(Phase.DELETE, false);
|
||||
deleteConfigMap();
|
||||
|
||||
// the other test
|
||||
testActuatorRefreshReloadDisabled();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* same test as above, but reload is disabled.
|
||||
*/
|
||||
@Test
|
||||
void testActuatorRefreshReloadDisabled() {
|
||||
configWatcher(Phase.CREATE, true);
|
||||
|
||||
TestUtil.patchForDisabledReload(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, NAMESPACE, DOCKER_IMAGE);
|
||||
|
||||
WireMock.configureFor(WIREMOCK_HOST, WIREMOCK_PORT, WIREMOCK_PATH);
|
||||
await().timeout(Duration.ofSeconds(60))
|
||||
@@ -134,50 +135,29 @@ class ActuatorRefreshIT {
|
||||
.willReturn(WireMock.aResponse().withBody("{}").withStatus(200)))
|
||||
.getResponse().wasConfigured());
|
||||
|
||||
// Create new configmap to trigger controller to signal app to refresh
|
||||
V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName("service-wiremock")
|
||||
.addToLabels("spring.cloud.kubernetes.config", "true").endMetadata().addToData("foo", "bar").build();
|
||||
util.createAndWait(NAMESPACE, configMap, null);
|
||||
createConfigMap();
|
||||
|
||||
// Wait a bit before we verify
|
||||
await().atMost(Duration.ofSeconds(30)).until(
|
||||
() -> !WireMock.findAll(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh"))).isEmpty());
|
||||
|
||||
Assertions.assertTrue(logs().contains("creating NOOP strategy because reload is disabled"));
|
||||
Commons.waitForLogStatement("creating NOOP strategy because reload is disabled", K3S,
|
||||
SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME);
|
||||
|
||||
// nothing related to 'ConfigReloadUtil' is present in logs
|
||||
// this proves that once we disable reload everything still works
|
||||
Assertions.assertFalse(logs().contains("ConfigReloadUtil"));
|
||||
|
||||
WireMock.verify(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh")));
|
||||
util.deleteAndWait(NAMESPACE, configMap, null);
|
||||
|
||||
configWatcher(Phase.DELETE, true);
|
||||
deleteConfigMap();
|
||||
|
||||
}
|
||||
|
||||
private void configWatcher(Phase phase, boolean disableReload) {
|
||||
private static void configWatcher(Phase phase) {
|
||||
V1ConfigMap configMap = (V1ConfigMap) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-configmap.yaml");
|
||||
V1Deployment deployment = (V1Deployment) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-http-deployment.yaml");
|
||||
|
||||
List<V1EnvVar> envVars = new ArrayList<>(
|
||||
Optional.ofNullable(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv())
|
||||
.orElse(new ArrayList<>()));
|
||||
|
||||
V1EnvVar commonsDebug = new V1EnvVar()
|
||||
.name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD").value("DEBUG");
|
||||
V1EnvVar watcherDebug = new V1EnvVar()
|
||||
.name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CONFIGURATION_WATCHER").value("DEBUG");
|
||||
|
||||
envVars.add(commonsDebug);
|
||||
envVars.add(watcherDebug);
|
||||
|
||||
if (disableReload) {
|
||||
V1EnvVar disableReloadEnvVar = new V1EnvVar().name("SPRING_CLOUD_KUBERNETES_RELOAD_ENABLED").value("FALSE");
|
||||
envVars.add(disableReloadEnvVar);
|
||||
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(envVars);
|
||||
}
|
||||
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-deployment.yaml");
|
||||
V1Service service = (V1Service) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-service.yaml");
|
||||
|
||||
@@ -192,6 +172,19 @@ class ActuatorRefreshIT {
|
||||
|
||||
}
|
||||
|
||||
// Create new configmap to trigger controller to signal app to refresh
|
||||
private void createConfigMap() {
|
||||
V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName("service-wiremock")
|
||||
.addToLabels("spring.cloud.kubernetes.config", "true").endMetadata().addToData("foo", "bar").build();
|
||||
util.createAndWait(NAMESPACE, configMap, null);
|
||||
}
|
||||
|
||||
private void deleteConfigMap() {
|
||||
V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName("service-wiremock")
|
||||
.addToLabels("spring.cloud.kubernetes.config", "true").endMetadata().addToData("foo", "bar").build();
|
||||
util.deleteAndWait(NAMESPACE, configMap, null);
|
||||
}
|
||||
|
||||
private String logs() {
|
||||
try {
|
||||
String appPodName = K3S.execInContainer("sh", "-c", "kubectl get pods -l app="
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.configuration.watcher;
|
||||
|
||||
import java.net.SocketException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.Base64;
|
||||
@@ -32,9 +33,7 @@ import io.kubernetes.client.openapi.models.V1Secret;
|
||||
import io.kubernetes.client.openapi.models.V1SecretBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
@@ -72,11 +71,15 @@ class ActuatorRefreshMultipleNamespacesIT {
|
||||
util = new Util(K3S);
|
||||
util.createNamespace(LEFT_NAMESPACE);
|
||||
util.createNamespace(RIGHT_NAMESPACE);
|
||||
util.wiremock(DEFAULT_NAMESPACE, "/", Phase.CREATE);
|
||||
util.setUpClusterWide(DEFAULT_NAMESPACE, Set.of(DEFAULT_NAMESPACE, LEFT_NAMESPACE, RIGHT_NAMESPACE));
|
||||
configWatcher(Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void afterAll() throws Exception {
|
||||
configWatcher(Phase.DELETE);
|
||||
util.wiremock(DEFAULT_NAMESPACE, "/", Phase.DELETE);
|
||||
util.deleteClusterWide(DEFAULT_NAMESPACE, Set.of(DEFAULT_NAMESPACE, LEFT_NAMESPACE, RIGHT_NAMESPACE));
|
||||
util.deleteNamespace(LEFT_NAMESPACE);
|
||||
util.deleteNamespace(RIGHT_NAMESPACE);
|
||||
@@ -84,18 +87,6 @@ class ActuatorRefreshMultipleNamespacesIT {
|
||||
Commons.systemPrune();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
configWatcher(Phase.CREATE);
|
||||
util.wiremock(DEFAULT_NAMESPACE, "/", Phase.CREATE);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void after() {
|
||||
configWatcher(Phase.DELETE);
|
||||
util.wiremock(DEFAULT_NAMESPACE, "/", Phase.DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* - deploy config-watcher in default namespace
|
||||
@@ -139,8 +130,8 @@ class ActuatorRefreshMultipleNamespacesIT {
|
||||
() -> !WireMock.findAll(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh"))).isEmpty());
|
||||
WireMock.verify(WireMock.exactly(2), WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh")));
|
||||
|
||||
util.deleteAndWait(LEFT_NAMESPACE, leftConfigMap, null);
|
||||
util.deleteAndWait(RIGHT_NAMESPACE, rightConfigMap, null);
|
||||
testSecretActuatorRefreshMultipleNamespaces();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,10 +144,8 @@ class ActuatorRefreshMultipleNamespacesIT {
|
||||
* - same as above for the secret-right.
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
void testSecretActuatorRefreshMultipleNamespaces() {
|
||||
WireMock.configureFor(WIREMOCK_HOST, WIREMOCK_PORT, WIREMOCK_PATH);
|
||||
await().timeout(Duration.ofSeconds(60))
|
||||
await().timeout(Duration.ofSeconds(60)).ignoreException(SocketException.class)
|
||||
.until(() -> WireMock
|
||||
.stubFor(WireMock.post(WireMock.urlEqualTo("/actuator/refresh"))
|
||||
.willReturn(WireMock.aResponse().withBody("{}").withStatus(200)))
|
||||
@@ -186,18 +175,15 @@ class ActuatorRefreshMultipleNamespacesIT {
|
||||
|
||||
await().atMost(Duration.ofSeconds(30)).until(
|
||||
() -> !WireMock.findAll(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh"))).isEmpty());
|
||||
WireMock.verify(WireMock.exactly(2), WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh")));
|
||||
|
||||
util.deleteAndWait(LEFT_NAMESPACE, null, leftSecret);
|
||||
util.deleteAndWait(RIGHT_NAMESPACE, null, rightSecret);
|
||||
WireMock.verify(WireMock.exactly(4), WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh")));
|
||||
|
||||
}
|
||||
|
||||
private void configWatcher(Phase phase) {
|
||||
private static void configWatcher(Phase phase) {
|
||||
V1ConfigMap configMap = (V1ConfigMap) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-configmap.yaml");
|
||||
V1Deployment deployment = (V1Deployment) util
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-http-deployment.yaml");
|
||||
.yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-deployment.yaml");
|
||||
|
||||
List<V1EnvVar> envVars = List.of(
|
||||
new V1EnvVar().name("SPRING_CLOUD_KUBERNETES_RELOAD_NAMESPACES_0").value(LEFT_NAMESPACE),
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.configuration.watcher;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util.patchWithReplace;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
final class TestUtil {
|
||||
|
||||
private TestUtil() {
|
||||
|
||||
}
|
||||
|
||||
private static final Map<String, String> POD_LABELS = Map.of("app",
|
||||
"spring-cloud-kubernetes-configuration-watcher");
|
||||
|
||||
private static final String BODY_ONE = """
|
||||
{
|
||||
"spec": {
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "spring-cloud-kubernetes-configuration-watcher",
|
||||
"image": "image_name_here",
|
||||
"env": [
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CONFIGURATION_WATCHER",
|
||||
"value": "DEBUG"
|
||||
},
|
||||
{
|
||||
"name": "SPRING_CLOUD_KUBERNETES_RELOAD_ENABLED",
|
||||
"value": "FALSE"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
static void patchForDisabledReload(String deploymentName, String namespace, String imageName) {
|
||||
patchWithReplace(imageName, deploymentName, namespace, BODY_ONE, POD_LABELS);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: spring-cloud-kubernetes-configuration-watcher-deployment
|
||||
name: spring-cloud-kubernetes-configuration-watcher
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
@@ -240,13 +240,13 @@ public final class Commons {
|
||||
/**
|
||||
* the assumption is that there is only a single pod that is 'Running'.
|
||||
*/
|
||||
public static void waitForLogStatement(String message, K3sContainer k3sContainer, String imageName) {
|
||||
public static void waitForLogStatement(String message, K3sContainer k3sContainer, String appLabelValue) {
|
||||
try {
|
||||
|
||||
await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(4)).until(() -> {
|
||||
|
||||
String appPodName = k3sContainer.execInContainer("sh", "-c",
|
||||
"kubectl get pods -l app=" + imageName
|
||||
"kubectl get pods -l app=" + appLabelValue
|
||||
+ " -o custom-columns=POD:metadata.name,STATUS:status.phase"
|
||||
+ " | grep -i 'running' | awk '{print $1}' | tr -d '\n' ")
|
||||
.getStdout();
|
||||
|
||||
Reference in New Issue
Block a user