use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project kubernetes-client by fabric8io.
the class ServiceCrudTest method shouldDeleteAService.
@Test
void shouldDeleteAService() {
Service service3 = new ServiceBuilder().withNewMetadata().withName("service3").endMetadata().build();
client.services().inNamespace("ns3").create(service3);
Boolean deleted = client.services().inNamespace("ns3").withName("service3").delete();
assertTrue(deleted);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project quarkus by quarkusio.
the class KnativeWithHealthTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getSpec()).satisfies(spec -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getNamespace()).isNull();
});
assertThat(spec.getTemplate()).satisfies(template -> {
assertThat(template.getSpec()).satisfies(templateSpec -> {
assertThat(templateSpec.getContainers()).hasSize(1).singleElement().satisfies(c -> {
assertThat(c.getPorts()).hasSize(1).singleElement().satisfies(p -> {
assertThat(p.getName()).isEqualTo("http1");
});
assertThat(c.getReadinessProbe()).isNotNull().satisfies(p -> {
assertThat(p.getInitialDelaySeconds()).isEqualTo(0);
assertProbePath(p, "/q/health/ready");
assertNotNull(p.getHttpGet());
assertNull(p.getHttpGet().getPort());
});
assertThat(c.getLivenessProbe()).isNotNull().satisfies(p -> {
assertThat(p.getInitialDelaySeconds()).isEqualTo(20);
assertProbePath(p, "/q/health/live");
assertNotNull(p.getHttpGet());
assertNull(p.getHttpGet().getPort());
});
});
});
});
});
});
});
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project quarkus by quarkusio.
the class KnativeWithVolumesTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getSpec()).satisfies(spec -> {
assertThat(spec.getTemplate()).satisfies(template -> {
assertThat(template.getSpec()).satisfies(revisionSpec -> {
assertThat(revisionSpec.getVolumes()).haveAtLeastOne(new Condition<Volume>(v -> v.getName().equals("client-crts") && v.getSecret().getSecretName().equals("clientcerts"), "Has secret volume named client-crts referencing secret clientcerts"));
assertThat(revisionSpec.getVolumes()).haveAtLeastOne(new Condition<Volume>(v -> v.getName().equals("client-cfg") && v.getConfigMap().getName().equals("clientconfig"), "Has config-map named client-cfg referencing configmap clientconfig"));
assertThat(revisionSpec.getContainers()).hasSize(1).singleElement().satisfies(c -> {
assertThat(c.getVolumeMounts()).haveAtLeastOne(new Condition<VolumeMount>(m -> m.getName().equals("client-crts"), "Has client-crts mount"));
assertThat(c.getVolumeMounts()).haveAtLeastOne(new Condition<VolumeMount>(m -> m.getName().equals("client-cfg"), "Has client-cfg mount"));
assertThat(c.getPorts()).hasSize(1).singleElement().satisfies(p -> {
assertThat(p.getName()).isEqualTo("http1");
});
});
});
});
});
});
});
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project quarkus by quarkusio.
the class KnativeTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getSpec()).satisfies(spec -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getNamespace()).isNull();
});
assertThat(spec.getTemplate()).satisfies(template -> {
assertThat(template.getSpec()).satisfies(templateSpec -> {
assertThat(templateSpec.getContainers()).hasSize(1).singleElement().satisfies(c -> {
assertThat(c.getPorts()).hasSize(1).singleElement().satisfies(p -> {
assertThat(p.getName()).isEqualTo("http1");
});
});
});
});
});
});
});
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project quarkus by quarkusio.
the class KnativeWithImagePullSecretTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
final Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml"));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("knative-with-image-pull-secret");
});
assertThat(s.getSpec()).satisfies(serviceSpec -> {
assertThat(serviceSpec.getTemplate()).satisfies(t -> {
assertThat(t.getSpec()).satisfies(r -> {
assertThat(r.getServiceAccountName()).isEqualTo("knative-with-image-pull-secret");
});
});
});
});
});
assertThat(kubernetesList).filteredOn(i -> "ServiceAccount".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(ServiceAccount.class, s -> {
assertTrue(s.getImagePullSecrets().stream().anyMatch(r -> r.getName().equals("my-secret")));
});
});
}
Aggregations