-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (#12121) fix volume,sidecar and hostalias support for knative
- Loading branch information
Showing
4 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...s/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KnativeWithVolumesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package io.quarkus.it.kubernetes; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import org.assertj.core.api.Condition; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.fabric8.knative.serving.v1.Service; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.Volume; | ||
import io.fabric8.kubernetes.api.model.VolumeMount; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class KnativeWithVolumesTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses(GreetingResource.class)) | ||
.setApplicationName("knative-with-volumes-properties") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.withConfigurationResource("knative-with-volumes.properties"); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@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 secert 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"); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...-tests/kubernetes/quarkus-standard-way/src/test/resources/knative-with-volumes.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Configuration file | ||
quarkus.kubernetes.deployment-target=knative | ||
|
||
quarkus.knative.mounts.client-crts.path=/mnt/clientcerts | ||
quarkus.knative.secret-volumes.client-crts.secret-name=clientcerts | ||
|
||
quarkus.knative.mounts.client-cfg.path=/mnt/clientconfig | ||
quarkus.knative.config-map-volumes.client-cfg.config-map-name=clientconfig |