diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8b40b89dc..fa9e45aba 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -95,8 +95,6 @@ jobs: run: systemctl --user enable --now podman.socket - name: Set DOCKER_HOST environment variable run: echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV" - - name: Build db image - run: sh db/build.sh - name: Run tests run: ./mvnw -B -U clean verify continue-on-error: ${{ matrix.java != '17' }} diff --git a/README.md b/README.md index ab82d47ac..a6b025cf1 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Build Requirements: Run Requirements: - [`yq`](https://github.com/mikefarah/yq) v4.35.1+ -- [`kompose`](https://kompose.io/installation/) v1.30.0+ +- [`kompose`](https://kompose.io/installation/) v1.31.2+ - [docker-compose](https://docs.docker.com/compose/install/) v1.29.2 - [podman-docker](https://packages.fedoraproject.org/pkgs/podman/podman-docker/) (Optional) - [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) / [oc](https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/getting-started-cli.html) @@ -51,12 +51,6 @@ $ yarn install && yarn yarn:frzinstall $ cd - ``` -### Build the custom database container image - -```bash -$ sh db/build.sh -``` - ### Build the application container image The application image can be created using: diff --git a/db/Dockerfile b/db/Dockerfile deleted file mode 100644 index d9b41142e..000000000 --- a/db/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM quay.io/sclorg/postgresql-15-c8s:latest - -ENTRYPOINT ["/usr/local/bin/cryostat-db-entrypoint.bash"] - -ENV POSTGRESQL_LOG_DESTINATION=/dev/stderr - -COPY ./entrypoint.bash /usr/local/bin/cryostat-db-entrypoint.bash -COPY ./include /opt/app-root/src/ diff --git a/db/build.sh b/db/build.sh deleted file mode 100755 index a01439def..000000000 --- a/db/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -DIR="$(dirname "$(readlink -f "$0")")" - -if [ -z "${BUILDER}" ]; then - BUILDER=podman -fi - -${BUILDER} build --pull -t quay.io/cryostat/cryostat3-db:latest -f "${DIR}/Dockerfile" "${DIR}" -${BUILDER} tag quay.io/cryostat/cryostat3-db:latest quay.io/cryostat/cryostat3-db:dev diff --git a/db/entrypoint.bash b/db/entrypoint.bash deleted file mode 100755 index 1806c58d2..000000000 --- a/db/entrypoint.bash +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -if [ "$1" = "postgres" ]; then - shift -fi - -exec /usr/bin/run-postgresql \ - -c encrypt.key="${PG_ENCRYPT_KEY?:\$PG_ENCRYPT_KEY must be set and non-empty}" \ - "$@" diff --git a/db/include/postgresql-cfg/pgcrypto.conf b/db/include/postgresql-cfg/pgcrypto.conf deleted file mode 100644 index 47109c0c9..000000000 --- a/db/include/postgresql-cfg/pgcrypto.conf +++ /dev/null @@ -1 +0,0 @@ -shared_preload_libraries='pgcrypto' diff --git a/db/include/postgresql-init/pgcrypto.sh b/db/include/postgresql-init/pgcrypto.sh deleted file mode 100755 index b549fe51a..000000000 --- a/db/include/postgresql-init/pgcrypto.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public CASCADE;" diff --git a/smoketest.bash b/smoketest.bash index d8fa29650..ab0245d90 100755 --- a/smoketest.bash +++ b/smoketest.bash @@ -82,6 +82,8 @@ for file in "${FILES[@]}"; do CMD+=(-f "${file}") done +HOSTSFILE="${HOSTSFILE:-$HOME/.hosts}" + cleanup() { DOWN_FLAGS=('--remove-orphans') if [ "${KEEP_VOLUMES}" != "true" ]; then @@ -91,7 +93,7 @@ cleanup() { "${CMD[@]}" \ down "${DOWN_FLAGS[@]}" # podman kill hoster || true - > ~/.hosts + truncate -s 0 "${HOSTSFILE}" } trap cleanup EXIT cleanup @@ -109,16 +111,15 @@ setupUserHosts() { # -v "${XDG_RUNTIME_DIR}/podman/podman.sock:/tmp/docker.sock:Z" \ # -v "${HOME}/.hosts:/tmp/hosts" \ # dvdarias/docker-hoster - > ~/.hosts + truncate -s 0 "${HOSTSFILE}" for file in "${FILES[@]}" ; do hosts="$(yq '.services.*.hostname' "${file}" | grep -v null | sed -e 's/^/localhost /')" - echo "${hosts}" >> ~/.hosts + echo "${hosts}" >> "${HOSTSFILE}" done } setupUserHosts if [ "${PULL_IMAGES}" = "true" ]; then - sh db/build.sh IMAGES=() for file in "${FILES[@]}" ; do images="$(yq '.services.*.image' "${file}" | grep -v null)" diff --git a/smoketest/compose/db.yml b/smoketest/compose/db.yml index 33bd8ed58..e28579e63 100644 --- a/smoketest/compose/db.yml +++ b/smoketest/compose/db.yml @@ -7,8 +7,7 @@ services: QUARKUS_DATASOURCE_PASSWORD: cryostat3 QUARKUS_DATASOURCE_JDBC_URL: jdbc:postgresql://db:5432/cryostat3 db: - image: quay.io/cryostat/cryostat3-db:dev - build: ../../db + image: quay.io/andrewazores/cryostat-db:latest hostname: db expose: - "5432" diff --git a/smoketest/compose/db_k8s.yml b/smoketest/compose/db_k8s.yml index 63c9b0df6..0fc25b7c8 100644 --- a/smoketest/compose/db_k8s.yml +++ b/smoketest/compose/db_k8s.yml @@ -8,23 +8,17 @@ services: QUARKUS_DATASOURCE_PASSWORD: cryostat3 QUARKUS_DATASOURCE_JDBC_URL: jdbc:postgresql://db:5432/cryostat3 db: - image: quay.io/cryostat/cryostat3-db:dev - build: ../../db - entrypoint: - - /usr/local/bin/docker-entrypoint.sh - command: - - postgres - - -c - - encrypt.key=REPLACEME + image: quay.io/cryostat/cryostat-db:latest hostname: db expose: - "5432" environment: - POSTGRES_USER: cryostat3 - POSTGRES_PASSWORD: cryostat3 + POSTGRESQL_USER: cryostat3 + POSTGRESQL_PASSWORD: cryostat3 + POSTGRESQL_DATABASE: cryostat3 PG_ENCRYPT_KEY: REPLACEME volumes: - - postgresql:/var/lib/postgresql/data + - postgresql:/var/lib/pgsql/data restart: always healthcheck: test: pg_isready -U cryostat3 -d cryostat3 || exit 1 diff --git a/smoketest/containers/smoketest_pod.bash b/smoketest/containers/smoketest_pod.bash index eea4fcdaf..4bddfe954 100755 --- a/smoketest/containers/smoketest_pod.bash +++ b/smoketest/containers/smoketest_pod.bash @@ -3,7 +3,7 @@ set -x set -e -HOSTSFILE="${HOSTSFILE:-~/.hosts}" +HOSTSFILE="${HOSTSFILE:-$HOME/.hosts}" cleanup() { podman-compose --in-pod=1 \ @@ -30,7 +30,7 @@ cleanup # --user=0 \ # --security-opt label=disable \ # -v "${XDG_RUNTIME_DIR}/podman/podman.sock:/tmp/docker.sock:Z" \ -# -v "${HOME}/.hosts:/tmp/hosts" \ +# -v "${HOSTSFILE}:/tmp/hosts" \ # dvdarias/docker-hoster setupUserHosts() { diff --git a/smoketest/k8s/compose-default-networkpolicy.yaml b/smoketest/k8s/compose-default-networkpolicy.yaml new file mode 100644 index 000000000..d78a9fa1a --- /dev/null +++ b/smoketest/k8s/compose-default-networkpolicy.yaml @@ -0,0 +1,14 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + creationTimestamp: null + name: compose-default +spec: + ingress: + - from: + - podSelector: + matchLabels: + io.kompose.network/compose-default: "true" + podSelector: + matchLabels: + io.kompose.network/compose-default: "true" diff --git a/smoketest/k8s/cryostat-deployment.yaml b/smoketest/k8s/cryostat-deployment.yaml index 45bad93f1..2db623091 100644 --- a/smoketest/k8s/cryostat-deployment.yaml +++ b/smoketest/k8s/cryostat-deployment.yaml @@ -11,7 +11,6 @@ metadata: labels: io.kompose.service: cryostat name: cryostat - namespace: default spec: replicas: 1 selector: @@ -82,7 +81,6 @@ spec: hostPort: 8181 protocol: TCP - containerPort: 9091 - hostPort: 9091 protocol: TCP resources: {} securityContext: diff --git a/smoketest/k8s/cryostat-ingress.yaml b/smoketest/k8s/cryostat-ingress.yaml index 38104f835..a750c23bf 100644 --- a/smoketest/k8s/cryostat-ingress.yaml +++ b/smoketest/k8s/cryostat-ingress.yaml @@ -11,7 +11,6 @@ metadata: labels: io.kompose.service: cryostat name: cryostat - namespace: default spec: rules: - host: cryostat3 diff --git a/smoketest/k8s/cryostat-service.yaml b/smoketest/k8s/cryostat-service.yaml index bb7c3d2df..ba686ca30 100644 --- a/smoketest/k8s/cryostat-service.yaml +++ b/smoketest/k8s/cryostat-service.yaml @@ -11,7 +11,6 @@ metadata: labels: io.kompose.service: cryostat name: cryostat - namespace: default spec: ports: - name: "8181" diff --git a/smoketest/k8s/db-deployment.yaml b/smoketest/k8s/db-deployment.yaml index fbdced1bc..28e82c4b7 100644 --- a/smoketest/k8s/db-deployment.yaml +++ b/smoketest/k8s/db-deployment.yaml @@ -5,7 +5,6 @@ metadata: labels: io.kompose.service: db name: db - namespace: default spec: replicas: 1 selector: @@ -21,20 +20,16 @@ spec: io.kompose.service: db spec: containers: - - args: - - postgres - - -c - - encrypt.key=REPLACEME - command: - - /usr/local/bin/docker-entrypoint.sh - env: + - env: - name: PG_ENCRYPT_KEY value: REPLACEME - - name: POSTGRES_PASSWORD + - name: POSTGRESQL_DATABASE value: cryostat3 - - name: POSTGRES_USER + - name: POSTGRESQL_PASSWORD value: cryostat3 - image: quay.io/cryostat/cryostat3-db:dev + - name: POSTGRESQL_USER + value: cryostat3 + image: quay.io/cryostat/cryostat-db:latest livenessProbe: exec: command: @@ -46,11 +41,10 @@ spec: name: db ports: - containerPort: 5432 - hostPort: 5432 protocol: TCP resources: {} volumeMounts: - - mountPath: /var/lib/postgresql/data + - mountPath: /var/lib/pgsql/data name: postgresql hostname: db restartPolicy: Always diff --git a/smoketest/k8s/db-service.yaml b/smoketest/k8s/db-service.yaml index 43f49d892..f80320777 100644 --- a/smoketest/k8s/db-service.yaml +++ b/smoketest/k8s/db-service.yaml @@ -5,7 +5,6 @@ metadata: labels: io.kompose.service: db name: db - namespace: default spec: ports: - name: "5432" diff --git a/smoketest/k8s/db-viewer-deployment.yaml b/smoketest/k8s/db-viewer-deployment.yaml index 2c35dcbda..957149891 100644 --- a/smoketest/k8s/db-viewer-deployment.yaml +++ b/smoketest/k8s/db-viewer-deployment.yaml @@ -7,7 +7,6 @@ metadata: labels: io.kompose.service: db-viewer name: db-viewer - namespace: default spec: replicas: 1 selector: diff --git a/smoketest/k8s/db-viewer-ingress.yaml b/smoketest/k8s/db-viewer-ingress.yaml index eecacffc4..7be901f0c 100644 --- a/smoketest/k8s/db-viewer-ingress.yaml +++ b/smoketest/k8s/db-viewer-ingress.yaml @@ -7,7 +7,6 @@ metadata: labels: io.kompose.service: db-viewer name: db-viewer - namespace: default spec: rules: - host: pgadmin diff --git a/smoketest/k8s/db-viewer-service.yaml b/smoketest/k8s/db-viewer-service.yaml index 4ea3da961..4e2e3fddc 100644 --- a/smoketest/k8s/db-viewer-service.yaml +++ b/smoketest/k8s/db-viewer-service.yaml @@ -7,7 +7,6 @@ metadata: labels: io.kompose.service: db-viewer name: db-viewer - namespace: default spec: ports: - name: "8989" diff --git a/smoketest/k8s/minio-certs-persistentvolumeclaim.yaml b/smoketest/k8s/minio-certs-persistentvolumeclaim.yaml index 0076ff3b8..64974d8f2 100644 --- a/smoketest/k8s/minio-certs-persistentvolumeclaim.yaml +++ b/smoketest/k8s/minio-certs-persistentvolumeclaim.yaml @@ -5,7 +5,6 @@ metadata: labels: io.kompose.service: minio-certs name: minio-certs - namespace: default spec: accessModes: - ReadWriteOnce diff --git a/smoketest/k8s/minio-data-persistentvolumeclaim.yaml b/smoketest/k8s/minio-data-persistentvolumeclaim.yaml index 5489b68f7..75ade51f7 100644 --- a/smoketest/k8s/minio-data-persistentvolumeclaim.yaml +++ b/smoketest/k8s/minio-data-persistentvolumeclaim.yaml @@ -5,7 +5,6 @@ metadata: labels: io.kompose.service: minio-data name: minio-data - namespace: default spec: accessModes: - ReadWriteOnce diff --git a/smoketest/k8s/pgadmin-persistentvolumeclaim.yaml b/smoketest/k8s/pgadmin-persistentvolumeclaim.yaml index b84cb1446..e97ee87fb 100644 --- a/smoketest/k8s/pgadmin-persistentvolumeclaim.yaml +++ b/smoketest/k8s/pgadmin-persistentvolumeclaim.yaml @@ -5,7 +5,6 @@ metadata: labels: io.kompose.service: pgadmin name: pgadmin - namespace: default spec: accessModes: - ReadWriteOnce diff --git a/smoketest/k8s/postgresql-persistentvolumeclaim.yaml b/smoketest/k8s/postgresql-persistentvolumeclaim.yaml index 7430c131a..39c8e7e10 100644 --- a/smoketest/k8s/postgresql-persistentvolumeclaim.yaml +++ b/smoketest/k8s/postgresql-persistentvolumeclaim.yaml @@ -5,7 +5,6 @@ metadata: labels: io.kompose.service: postgresql name: postgresql - namespace: default spec: accessModes: - ReadWriteOnce diff --git a/smoketest/k8s/quarkus-test-agent-deployment.yaml b/smoketest/k8s/quarkus-test-agent-deployment.yaml index 4f6daca45..9007361b8 100644 --- a/smoketest/k8s/quarkus-test-agent-deployment.yaml +++ b/smoketest/k8s/quarkus-test-agent-deployment.yaml @@ -5,7 +5,6 @@ metadata: labels: io.kompose.service: quarkus-test-agent name: quarkus-test-agent - namespace: default spec: replicas: 1 selector: diff --git a/smoketest/k8s/quarkus-test-agent-service.yaml b/smoketest/k8s/quarkus-test-agent-service.yaml index 051c16298..16c319579 100644 --- a/smoketest/k8s/quarkus-test-agent-service.yaml +++ b/smoketest/k8s/quarkus-test-agent-service.yaml @@ -5,7 +5,6 @@ metadata: labels: io.kompose.service: quarkus-test-agent name: quarkus-test-agent - namespace: default spec: ports: - name: "9977" diff --git a/smoketest/k8s/s3-deployment.yaml b/smoketest/k8s/s3-deployment.yaml index a6ebdc8b9..fb76382ed 100644 --- a/smoketest/k8s/s3-deployment.yaml +++ b/smoketest/k8s/s3-deployment.yaml @@ -7,7 +7,6 @@ metadata: labels: io.kompose.service: s3 name: s3 - namespace: default spec: replicas: 1 selector: diff --git a/smoketest/k8s/s3-ingress.yaml b/smoketest/k8s/s3-ingress.yaml index c2958931f..dad6f969f 100644 --- a/smoketest/k8s/s3-ingress.yaml +++ b/smoketest/k8s/s3-ingress.yaml @@ -7,7 +7,6 @@ metadata: labels: io.kompose.service: s3 name: s3 - namespace: default spec: rules: - host: minio diff --git a/smoketest/k8s/s3-service.yaml b/smoketest/k8s/s3-service.yaml index aa9a2ff03..befd770da 100644 --- a/smoketest/k8s/s3-service.yaml +++ b/smoketest/k8s/s3-service.yaml @@ -7,7 +7,6 @@ metadata: labels: io.kompose.service: s3 name: s3 - namespace: default spec: ports: - name: "9001" diff --git a/smoketest/k8s/sample-app-deployment.yaml b/smoketest/k8s/sample-app-deployment.yaml index bddac5667..53c2baf3c 100644 --- a/smoketest/k8s/sample-app-deployment.yaml +++ b/smoketest/k8s/sample-app-deployment.yaml @@ -9,7 +9,6 @@ metadata: labels: io.kompose.service: sample-app name: sample-app - namespace: default spec: replicas: 1 selector: diff --git a/smoketest/k8s/sample-app-service.yaml b/smoketest/k8s/sample-app-service.yaml index ed342d863..323741f45 100644 --- a/smoketest/k8s/sample-app-service.yaml +++ b/smoketest/k8s/sample-app-service.yaml @@ -9,7 +9,6 @@ metadata: labels: io.kompose.service: sample-app name: sample-app - namespace: default spec: ports: - name: "8081" diff --git a/smoketest/k8s/smoketest.bash b/smoketest/k8s/smoketest.bash index da42928e0..641a3a478 100755 --- a/smoketest/k8s/smoketest.bash +++ b/smoketest/k8s/smoketest.bash @@ -18,13 +18,11 @@ while [ "$#" -ne 0 ]; do cleanKind kind create cluster kind load docker-image "quay.io/${IMAGE_REPOSITORY}/cryostat3:dev" - kind load docker-image "quay.io/${IMAGE_REPOSITORY}/cryostat3-db:dev" ;; unkind) cleanKind ;; generate) - sh "${DIR}/../../db/build.sh" kompose convert \ --with-kompose-annotation=false \ -o "${DIR}" \ @@ -36,8 +34,8 @@ while [ "$#" -ne 0 ]; do bash "${DIR}/generate.bash" ;; apply) - kubectl apply -f "./*.yaml" - kubectl patch -p "{\"spec\":{\"template\":{\"spec\":{\"\$setElementOrder/containers\":[{\"name\":\"db\"}],\"containers\":[{\"image\":\"quay.io/$IMAGE_REPOSITORY/cryostat3-db:dev\",\"name\":\"db\"}]}}}}" deployment/db + kubectl apply -f "${DIR}/*.yaml" + kubectl patch -p "{\"spec\":{\"template\":{\"spec\":{\"\$setElementOrder/containers\":[{\"name\":\"db\"}],\"containers\":[{\"image\":\"quay.io/$IMAGE_REPOSITORY/cryostat-db:latest\",\"name\":\"db\"}]}}}}" deployment/db kubectl wait \ --for condition=available \ --timeout=5m \ @@ -53,7 +51,7 @@ while [ "$#" -ne 0 ]; do ;; forward) sh -c '(sleep 1 ; xdg-open http://localhost:9001 ; xdg-open http://localhost:8181 ; xdg-open http://localhost:8989)&' - if ! kubectl multiforward smoketest; then + if ! ( pushd "${DIR}" ; sc=$(kubectl multiforward smoketest) ; popd ; exit "${sc}" ); then echo "Run the following to expose the applications:" echo "kubectl port-forward svc/cryostat 8181" echo "kubectl port-forward svc/s3 9001" diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 87642863f..08e564fbe 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -19,7 +19,7 @@ cryostat.discovery.podman.enabled=true cryostat.discovery.docker.enabled=true quarkus.datasource.devservices.enabled=true -quarkus.datasource.devservices.image-name=quay.io/cryostat/cryostat3-db +quarkus.datasource.devservices.image-name=quay.io/cryostat/cryostat-db # !!! prod databases must set this configuration parameter some other way via a secret !!! quarkus.datasource.devservices.container-env.PG_ENCRYPT_KEY=examplekey diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties index d2fc74d6b..ac558246d 100644 --- a/src/main/resources/application-test.properties +++ b/src/main/resources/application-test.properties @@ -11,7 +11,7 @@ grafana-datasource.url=http://jfr-datasource:8080 quarkus.test.env.JAVA_OPTS_APPEND=-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dcom.sun.management.jmxremote.autodiscovery=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9091 -Dcom.sun.management.jmxremote.rmi.port=9091 -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false quarkus.datasource.devservices.enabled=true -quarkus.datasource.devservices.image-name=quay.io/cryostat/cryostat3-db +quarkus.datasource.devservices.image-name=quay.io/cryostat/cryostat-db # !!! prod databases must set this configuration parameter some other way via a secret !!! quarkus.datasource.devservices.container-env.PG_ENCRYPT_KEY=examplekey