-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Attila Mészáros <[email protected]>
- Loading branch information
Showing
15 changed files
with
278 additions
and
16 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ jobs: | |
QUARKUS_CONTAINER_IMAGE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
./mvnw versions:set -DnewVersion="${RELEASE_VERSION}" versions:commit | ||
./mvnw clean install -DskipTests -Dquarkus.container-image.build=true -Dquarkus.kubernetes.namespace=default -Dquarkus.container-image.push=true | ||
./mvnw clean install -DskipTests -Dquarkus.container-image.build=true -Dquarkus.container-image.push=true | ||
./mvnw ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
|
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
6 changes: 3 additions & 3 deletions
6
...lue/condition/PodsReadyConditionSpec.java → ...ce/glue/condition/ReadyConditionSpec.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
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
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
73 changes: 73 additions & 0 deletions
73
...st/java/io/csviri/operator/resourceglue/sample/mutation/MutationWebhookDeploymentE2E.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,73 @@ | ||
package io.csviri.operator.resourceglue.sample.mutation; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.time.Duration; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.csviri.operator.resourceglue.TestUtils; | ||
import io.csviri.operator.resourceglue.customresource.glue.Glue; | ||
import io.csviri.operator.resourceglue.customresource.operator.GlueOperator; | ||
import io.fabric8.kubernetes.api.model.*; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.KubernetesClientBuilder; | ||
import io.fabric8.kubernetes.client.dsl.NonDeletingOperation; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.awaitility.Awaitility.await; | ||
|
||
public class MutationWebhookDeploymentE2E { | ||
|
||
public static final String TEST_POD_NAME = "testpod"; | ||
private final KubernetesClient client = new KubernetesClientBuilder().build(); | ||
|
||
@BeforeEach | ||
void applyCRDs() throws MalformedURLException, URISyntaxException { | ||
TestUtils.applyCrd(client, Glue.class, GlueOperator.class); | ||
TestUtils.applyAndWait(client, | ||
new URI( | ||
"https://github.com/cert-manager/cert-manager/releases/download/v1.14.4/cert-manager.yaml") | ||
.toURL()); | ||
TestUtils.applyAndWait(client, "target/kubernetes/kubernetes.yml"); | ||
TestUtils.applyAndWait(client, "src/test/resources/sample/mutation/related.resource.yaml"); | ||
} | ||
|
||
@Test | ||
void testMutationHookDeployment() { | ||
client.resource(TestUtils.load("/sample/mutation/mutation.glue.yaml")) | ||
.createOr(NonDeletingOperation::update); | ||
|
||
await().atMost(Duration.ofMinutes(5)).untilAsserted(() -> { | ||
var conf = client.admissionRegistration().v1().mutatingWebhookConfigurations() | ||
.withName("pod-mutating-webhook").get(); | ||
var deployment = client.apps().deployments().withName("pod-mutating-hook").get(); | ||
assertThat(conf).isNotNull(); | ||
assertThat(deployment.getStatus().getReadyReplicas()).isGreaterThan(0); | ||
}); | ||
|
||
var pod = client.resource(testPod()).create(); | ||
assertThat(pod.getMetadata().getAnnotations()).containsEntry("sample.annotation.present", | ||
"true"); | ||
} | ||
|
||
Pod testPod() { | ||
return new PodBuilder() | ||
.withNewMetadata() | ||
.withName(TEST_POD_NAME) | ||
.endMetadata() | ||
.withNewSpec() | ||
.withContainers(new ContainerBuilder() | ||
.withName("nginx") | ||
.withImage("nginx:1.14.2") | ||
.withPorts(new ContainerPortBuilder() | ||
.withContainerPort(80) | ||
.build()) | ||
.build()) | ||
.endSpec() | ||
.build(); | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
apiVersion: io.csviri.operator.resourceglue/v1beta1 | ||
kind: Glue | ||
metadata: | ||
name: mutation-webhook-deployment | ||
spec: | ||
resources: | ||
- name: service | ||
resource: | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: pod-mutating-hook | ||
spec: | ||
ports: | ||
- name: https | ||
port: 443 | ||
protocol: TCP | ||
targetPort: 443 | ||
selector: | ||
app.kubernetes.io/name: pod-mutating-hook | ||
app.kubernetes.io/version: 0.1.0 | ||
type: NodePort | ||
- name: deployment | ||
readyPostCondition: | ||
type: ReadyCondition | ||
resource: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: pod-mutating-hook | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: pod-mutating-hook | ||
app.kubernetes.io/version: 0.1.0 | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: pod-mutating-hook | ||
app.kubernetes.io/version: 0.1.0 | ||
namespace: default | ||
spec: | ||
containers: | ||
- env: | ||
- name: KUBERNETES_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: QUARKUS_HTTP_SSL_CERTIFICATE_KEY_STORE_FILE | ||
value: /etc/certs/keystore.p12 | ||
- name: QUARKUS_HTTP_SSL_CERTIFICATE_KEY_STORE_FILE_TYPE | ||
value: PKCS12 | ||
- name: QUARKUS_HTTP_SSL_CERTIFICATE_KEY_STORE_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
key: password | ||
name: pkcs12-pass | ||
image: ghcr.io/csviri/sample-pod-mutating-webhook:0.1.0 | ||
imagePullPolicy: IfNotPresent | ||
name: pod-mutating-hook | ||
ports: | ||
- containerPort: 443 | ||
name: https | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /etc/certs | ||
name: sample-pod-mutating-webhook | ||
readOnly: true | ||
serviceAccountName: pod-mutating-hook | ||
volumes: | ||
- name: sample-pod-mutating-webhook | ||
secret: | ||
optional: false | ||
secretName: tls-secret | ||
- name: mutation_hook_config | ||
dependsOn: | ||
- deployment | ||
- service | ||
resource: | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: MutatingWebhookConfiguration | ||
metadata: | ||
annotations: | ||
cert-manager.io/inject-ca-from: default/sample-pod-mutating-webhook | ||
name: pod-mutating-webhook | ||
webhooks: | ||
- admissionReviewVersions: | ||
- v1 | ||
clientConfig: | ||
service: | ||
name: pod-mutating-hook | ||
namespace: default | ||
path: /mutate | ||
failurePolicy: Fail | ||
name: sample.mutating.webhook | ||
rules: | ||
- apiGroups: | ||
- "" | ||
apiVersions: | ||
- v1 | ||
operations: | ||
- UPDATE | ||
- CREATE | ||
resources: | ||
- pods | ||
sideEffects: None | ||
timeoutSeconds: 5 | ||
|
Oops, something went wrong.