diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000000..0b0b74ff42 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,142 @@ +name: Kubernetes Testing + +on: + - push + - pull_request + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + + - name: Install Helm + uses: azure/setup-helm@v3 + with: + version: v3.12.1 + + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1.5.0 + with: + node_image: "kindest/node:v1.27.3" + config: ./test-setup/kind-config.yaml + + - name: Setup Image registry & ingress controller + run: |- + ./test-setup/setup-image-registry.sh + ./test-setup/setup-nginx-ingress-controller.sh + sudo echo "127.0.0.1 wildfly.local" | sudo tee -a /etc/hosts + + - name: Run helloworld test + run: |- + cd helloworld + mvn -B -Popenshift package wildfly:image + docker tag helloworld localhost:5001/helloworld + docker push localhost:5001/helloworld + + cat << EOF > override.yaml + image: + name: localhost:5001/helloworld + build: + enabled: false + deploy: + route: + enabled: false + EOF + + helm install helloworld \ + --repo https://docs.wildfly.org/wildfly-charts wildfly \ + --wait --timeout=90s \ + -f charts/helm.yaml -f override.yaml + + cat << EOF | kubectl create -f - + apiVersion: networking.k8s.io/v1 + kind: Ingress + metadata: + name: helloworld-ingress + spec: + rules: + - host: wildfly.local + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: helloworld + port: + number: 8080 + EOF + sleep 5 + + SERVER_HOST=http://wildfly.local/ mvn -B -P integration-testing verify + + helm delete helloworld + kubectl delete ingress helloworld-ingress + + echo " * :white_check_mark: Helloworld" >> $GITHUB_STEP_SUMMARY + + - name: Run todo-backend test + run: |- + cd todo-backend + mvn -B -Popenshift package wildfly:image + docker tag todo-backend localhost:5001/todo-backend + docker push localhost:5001/todo-backend + + cat << EOF > override.yaml + wildfly: + image: + name: localhost:5001/todo-backend + build: + enabled: false + deploy: + route: + enabled: false + EOF + + helm dependency update todo-backend-chart/ + echo install todo-backend helm chart + helm install todo-backend todo-backend-chart \ + -f override.yaml + + kubectl wait \ + --for=condition=ready pod \ + --selector=app.kubernetes.io/name=todo-backend \ + --timeout=120s + + cat << EOF | kubectl create -f - + apiVersion: networking.k8s.io/v1 + kind: Ingress + metadata: + name: todo-backend-ingress + spec: + rules: + - host: wildfly.local + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: todo-backend + port: + number: 8080 + EOF + sleep 5 + + SERVER_HOST=http://wildfly.local/ mvn -B -P arq-remote verify + + helm delete todo-backend + kubectl delete ingress todo-backend-ingress + + echo " * :white_check_mark: TODO Backend" >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/test-setup/kind-config.yaml b/test-setup/kind-config.yaml new file mode 100644 index 0000000000..e98f806221 --- /dev/null +++ b/test-setup/kind-config.yaml @@ -0,0 +1,21 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +containerdConfigPatches: +- |- + [plugins."io.containerd.grpc.v1.cri".registry] + config_path = "/etc/containerd/certs.d" +nodes: +- role: control-plane + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 80 + hostPort: 80 + protocol: TCP + - containerPort: 443 + hostPort: 443 + protocol: TCP \ No newline at end of file diff --git a/test-setup/setup-image-registry.sh b/test-setup/setup-image-registry.sh new file mode 100755 index 0000000000..0208a4f493 --- /dev/null +++ b/test-setup/setup-image-registry.sh @@ -0,0 +1,49 @@ +#!/bin/sh +set -o errexit + +echo 1. Create registry container unless it already exists +reg_name='kind-registry' +reg_port='5001' +if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then + docker run \ + -d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \ + registry:2 +fi + +echo 2. Add the registry config to the nodes + +# This is necessary because localhost resolves to loopback addresses that are +# network-namespace local. +# In other words: localhost in the container is not localhost on the host. +# +# We want a consistent name that works from both ends, so we tell containerd to +# alias localhost:${reg_port} to the registry container when pulling images +kind get nodes --name chart-testing +REGISTRY_DIR="/etc/containerd/certs.d/localhost:${reg_port}" +for node in $(kind get nodes --name chart-testing); do + docker exec "${node}" mkdir -p "${REGISTRY_DIR}" + cat <wildfly-datasources-galleon-pack ${version.wildfly-datasources-galleon-pack} + + org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.cloud.fp} + cloud-server diff --git a/todo-backend/todo-backend-chart/values.yaml b/todo-backend/todo-backend-chart/values.yaml index 0ccdf6778e..6c782fa2b0 100644 --- a/todo-backend/todo-backend-chart/values.yaml +++ b/todo-backend/todo-backend-chart/values.yaml @@ -31,7 +31,6 @@ postgresql: enabled: false securityContext: runAsUser: "auto" - wildfly: build: uri: https://github.com/wildfly/quickstart.git @@ -53,41 +52,17 @@ wildfly: value: todo-backend-postgresql - name: POSTGRESQL_SERVICE_PORT value: "5432" - # Env vars to configure CORS filter - - name: FILTERS - value: acao, acam, acah, acac, acma - - name: acao_FILTER_RESPONSE_HEADER_NAME - value: Access-Control-Allow-Origin - - name: acao_FILTER_RESPONSE_HEADER_VALUE - value: "*" - - name: acao_FILTER_REF_NAME - value: Access-Control-Allow-Origin - - name: acam_FILTER_RESPONSE_HEADER_NAME - value: Access-Control-Allow-Methods - - name: acam_FILTER_RESPONSE_HEADER_VALUE - value: GET, POST, OPTION, PUT, DELETE, PATCH - - name: acam_FILTER_REF_NAME - value: Access-Control-Allow-Methods - - name: acah_FILTER_RESPONSE_HEADER_NAME - value: Access-Control-Allow-Headers - - name: acah_FILTER_RESPONSE_HEADER_VALUE - value: accept, authorization, content-type, x-requested-with - - name: acah_FILTER_REF_NAME - value: Access-Control-Allow-Headers - - name: acac_FILTER_RESPONSE_HEADER_NAME - value: Access-Control-Allow-Credentials - - name: acac_FILTER_RESPONSE_HEADER_VALUE - value: "true" - - name: acac_FILTER_REF_NAME - value: Access-Control-Allow-Credentials - - name: acma_FILTER_RESPONSE_HEADER_NAME - value: Access-Control-Max-Age - - name: acma_FILTER_RESPONSE_HEADER_VALUE - value: "1" - - name: acma_FILTER_REF_NAME - value: Access-Control-Max-Age - # Env to avoid OOME - - name: GC_MAX_METASPACE_SIZE - value: "256" - - name: GC_METASPACE_SIZE - value: "96" + startupProbe: + httpGet: + path: /health/ready + port: 9990 + initialDelaySeconds: 20 + failureThreshold: 5 + periodSeconds: 10 + livenessProbe: + httpGet: + path: /health/ready + port: 9990 + initialDelaySeconds: 20 + failureThreshold: 5 + periodSeconds: 10 \ No newline at end of file