q-shift / openshift-vm-playground

0 stars 1 forks source link

The test pipeline should also perform deployment #15

Open iocanel opened 11 months ago

iocanel commented 11 months ago

The pipeline currently performs a simple maven build. It would be create if we had a deployment step.

The deployment step could just use ./mvnw quarkus:deploy -Dquarkus.openshift.deploy=true or something like this.

cmoulliard commented 11 months ago

The deployment step could just use ./mvnw quarkus:deploy -Dquarkus.openshift.deploy=true or something like this.

So it will be needed that we set different values such as:

NOTE: Pod created could fail if the backend system required (postgresql, etc) is not available. So do we plan to also manage the binding and/or binding + deployment of the backend ? @iocanel

cmoulliard commented 11 months ago

Test 1

I don t see a deployment yaml created within the namespace running the tekton task "deploy". Log just reports

[maven-deploy : mvn-goals] [INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 696ms
[maven-deploy : mvn-goals] [INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Selecting target 'openshift' since it has the highest priority among the implicitly enabled deployment targets
[maven-deploy : mvn-goals] [INFO] [io.quarkus.kubernetes.deployment.PropertyUtil] Openshift manifests are generated with 'The container port http' having default value '8080'. The app and manifests will get out of sync if the property 'quarkus.http.port' is changed at runtime.
[maven-deploy : mvn-goals] [INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 4084ms
[maven-deploy : mvn-goals] [INFO] ------------------------------------------------------------------------

Test 2

I executed a new pipelineRun and now I can see the resources deployed. FYI: I passed as param -Dquarkus.log.level=DEBUG which helps to see what it is populated and deployed

[maven-deploy : mvn-goals] [INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Deploying to openshift server: https://172.30.0.1:443/ in namespace: test2.
[maven-deploy : mvn-goals] [INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Applied: Service quarkus-helloworld.
[maven-deploy : mvn-goals] [INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Applied: ImageStream openjdk-11.
[maven-deploy : mvn-goals] [INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Applied: ImageStream quarkus-helloworld.
[maven-deploy : mvn-goals] [INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Applied: BuildConfig quarkus-helloworld.
[maven-deploy : mvn-goals] [INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Applied: DeploymentConfig quarkus-helloworld.
[maven-deploy : mvn-goals] [INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 4675ms
[maven-deploy : mvn-goals] [INFO] ------------------------------------------------------------------------
...
k get svc,deploymentconfig,imagestream,buildconfig
Warning: apps.openshift.io/v1 DeploymentConfig is deprecated in v4.14+, unavailable in v4.10000+
NAME                         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
service/quarkus-helloworld   ClusterIP   172.30.35.99   <none>        80/TCP    3m35s

NAME                                                    REVISION   DESIRED   CURRENT   TRIGGERED BY
deploymentconfig.apps.openshift.io/quarkus-helloworld   0          1         0         image(quarkus-helloworld:1.0-SNAPSHOT)

NAME                                                IMAGE REPOSITORY                                                            TAGS                                                       UPDATED
imagestream.image.openshift.io/openjdk-11           registry.access.redhat.com/ubi8/openjdk-11                                  1.10,1.10-1,1.10-1-source,1.10-1.1634738701 + 46 more...   2 minutes ago
imagestream.image.openshift.io/quarkus-helloworld   image-registry.openshift-image-registry.svc:5000/test2/quarkus-helloworld                                                              

NAME                                                TYPE     FROM     LATEST
buildconfig.build.openshift.io/quarkus-helloworld   Source   Binary   0
cmoulliard commented 11 months ago

Question: As quarkus.openshift.deploy=true generates ocp resources like buildconfig.build.openshift.io. Should we in a next step/task launch the build if the deployment was successfull ? @iocanel

cmoulliard commented 11 months ago

FYI. If we trigger a build - https://console-openshift-console.apps.qshift.snowdrop.dev/k8s/ns/test2/builds/quarkus-helloworld-1 the resulting image build fails to start from the pod

Starting the Java application using /opt/jboss/container/java/run/run-java.sh ...
ERROR No such file /deployments/quarkus-run.jar
INFO exec -a "java" java -javaagent:/usr/share/java/jolokia-jvm-agent/jolokia-jvm.jar=config=/opt/jboss/container/jolokia/etc/jolokia.properties -XX:MaxRAMPercentage=80.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -cp "." -jar
INFO running in /deployments
Error: -jar requires jar file specification
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)

Screenshot 2023-11-22 at 17 49 58

Here is the log of the s2i build

Generating dockerfile with builder image registry.access.redhat.com/ubi8/openjdk-11@sha256:67fee4b64b269f5666a1051d806635b675903ef56d07b7cc019d3d59ff1aa97c
Adding transient rw bind mount for /run/secrets/rhsm
STEP 1/9: FROM registry.access.redhat.com/ubi8/openjdk-11@sha256:67fee4b64b269f5666a1051d806635b675903ef56d07b7cc019d3d59ff1aa97c
STEP 2/9: LABEL "io.openshift.build.image"="registry.access.redhat.com/ubi8/openjdk-11@sha256:67fee4b64b269f5666a1051d806635b675903ef56d07b7cc019d3d59ff1aa97c" "io.openshift.build.source-location"="/tmp/build/inputs" "io.openshift.s2i.destination"="/tmp"
STEP 3/9: ENV OPENSHIFT_BUILD_NAME="quarkus-helloworld-1" OPENSHIFT_BUILD_NAMESPACE="test2"
STEP 4/9: USER root
STEP 5/9: COPY upload/src /tmp/src
STEP 6/9: RUN chown -R 185:0 /tmp/src
STEP 7/9: USER 185
STEP 8/9: RUN /usr/local/s2i/assemble
INFO S2I source build with plain binaries detected
INFO Copying binaries from /tmp/src to /deployments ...
STEP 9/9: CMD /usr/local/s2i/run
COMMIT temp.builder.openshift.io/test2/quarkus-helloworld-1:27e98fd4
Getting image source signatures
Copying blob sha256:1053d00b8e292c8a36bef630a0f4977b29da4e2fd60ac9425e0fcd1f7c1108d5
Copying blob sha256:b30496cd9d7b7402019d1bb2893cb544b3a20ec2b1c42e891ccedcdb7e7fe606
Copying blob sha256:a8e7738568a708ad2fdddce8e33dc850e7c6837aa50e089e5f7f47b0781a24af
Copying config sha256:ddd0ccced9b49a8b2b6fc2303de2a00a3c045518ed5d8b38275196d6fce21b22
Writing manifest to image destination
--> ddd0ccced9b4
Successfully tagged temp.builder.openshift.io/test2/quarkus-helloworld-1:27e98fd4
ddd0ccced9b49a8b2b6fc2303de2a00a3c045518ed5d8b38275196d6fce21b22
Pushing image image-registry.openshift-image-registry.svc:5000/test2/quarkus-helloworld:1.0-SNAPSHOT ...
Getting image source signatures
Copying blob sha256:a8e7738568a708ad2fdddce8e33dc850e7c6837aa50e089e5f7f47b0781a24af
Copying blob sha256:dc35b837139a95d1b9f7f7b0435a024a74ab972416bdc248f3f608c9f917a753
Copying blob sha256:4009473c181390dadf086f42ecb4b10fb87f5e79de8d0195f6c22239985b2da0
Copying config sha256:ddd0ccced9b49a8b2b6fc2303de2a00a3c045518ed5d8b38275196d6fce21b22
Writing manifest to image destination
Successfully pushed image-registry.openshift-image-registry.svc:5000/test2/quarkus-helloworld@sha256:feb19828c0594b1192b5282995ec2efc7e5cb588e83fbcfb998e8d44841a1be7
Push successful

NOTE: Red Hat documentation don't use -Ddeploy.openshift but instead -Ddeploy.kubernetes by the way -> https://access.redhat.com/documentation/en-us/red_hat_build_of_quarkus/quarkus-3.2/guide/85e494b4-4e47-4831-8294-212c4c838c7b !

@iocanel

cmoulliard commented 11 months ago

Build issue fixed after I changed the maven parameters to perform the build using docker and not s2i

    - name: maven-build
      runAfter:
        - virtualmachine
      taskRef:
        name: maven
      params:
        - name: DOCKER_HOST
          value: "tcp://$(tasks.virtualmachine.results.ip):2376"
        - name: GOALS
          value:
          - package
          - -Dquarkus.openshift.build-strategy=docker
          - -Dquarkus.container-image.build=true
          - -Dquarkus.container-image.push=true
iocanel commented 11 months ago

We could possibly live without the registry and credentials and default to the internal registry for now (unless it requires very low effort).

Reagrding quarkus.kubernetes.deploy vs quarkus.opesnhift.deploy both are meant to work. The later is a bit more specific and is meant to bring in the openshift extension.

cmoulliard commented 11 months ago

We could possibly live without the registry and credentials and default to the internal registry for now (unless it requires very low effort).

I agree with you as tekton task (= mvn package -Dquarkus.container-image.push=true) works using internal registry ;-)

cmoulliard commented 11 months ago

Can we close this issue ? @iocanel