Search in sources :

Example 1 with PodSpec

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.PodSpec in project yakc by manusa.

the class PodIT method replaceNamespacedPod.

@Test
@DisplayName("replaceNamespacedPod, should replace existing Pod's image")
void replaceNamespacedPod() throws IOException {
    // Given
    awaitPodReady();
    final Pod existingPod = KC.create(CoreV1Api.class).readNamespacedPod(podName, NAMESPACE).get();
    existingPod.getMetadata().setResourceVersion(null);
    existingPod.getSpec().getContainers().get(0).setImage("nginxdemos/hello");
    // When
    final Pod result = KC.create(CoreV1Api.class).replaceNamespacedPod(podName, NAMESPACE, existingPod).get();
    // Then
    assertThat(result).isNotNull().hasFieldOrPropertyWithValue("metadata.name", podName).extracting(Pod::getSpec).extracting(PodSpec::getContainers).asList().hasSize(1).element(0).hasFieldOrPropertyWithValue("image", "nginxdemos/hello");
}
Also used : Pod(com.marcnuri.yakc.model.io.k8s.api.core.v1.Pod) PodSpec(com.marcnuri.yakc.model.io.k8s.api.core.v1.PodSpec) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Pod (com.marcnuri.yakc.model.io.k8s.api.core.v1.Pod)1 PodSpec (com.marcnuri.yakc.model.io.k8s.api.core.v1.PodSpec)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1