Search code examples
dockerkubernetesopenshiftopen-liberty

OpenLibertyApplication in Openshift cloud cluster


Problem

Deploying OpenLibertyApplication rewrites the /config/server.xml specified in the container image

What did you do?

  1. Deployed OpenLibertyApplication with initial configuration in src/main/liberty/config/server.xml:
    <httpEndpoint id="defaultHttpEndpointss"
                  host="*"
                  httpPort="8080"
                  httpsPort="9443" />
  1. Changed port above to
    <httpEndpoint id="defaultHttpEndpointssssssssss"
                  host="*"
                  httpPort="8080"
                  httpsPort="8083" />
  1. Docker build copies this server.xml to /config/server.xml (Docker pull-ing the image to my local shows the correct updated /config/server.xml)
  2. Deployed the new image using the OpenLibertyApplication supported by Open Liberty Operator from OperatorHub version 0.7.0 using oc apply -f openlibertyapplication.yaml:
apiVersion: openliberty.io/v1beta1
kind: OpenLibertyApplication
metadata:
  name: vehicle
  labels:
    app: vehicle
    name: vehicle
    service: vehicle
    version: v2
spec:
  applicationImage: quay.io/xxxx/xxxxx:latest
  createAppDefinition: false
  version: v2
  service:
    port: 8080
    portName: http
  expose: true

server.xml:

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

    <featureManager>
        <feature>servlet-4.0</feature>
        <feature>springBoot-2.0</feature>
    </featureManager>

    <httpEndpoint id="defaultHttpEndpointssssssssss"
                  host="*"
                  httpPort="8080"
                  httpsPort="8083" />

    <springBootApplication id="vehicle"
                           location="thin-vehicle-0.0.1-SNAPSHOT.jar"
                           name="vehicle" />

</server>

What did you expect to see?

/config/server.xml in the Openshift pod showing the correct updated port for httpEndpoint http: 8080, https: 8083

What did you see instead? Under which circumstances?

Instead, I'm seeing the old port values on the Pod /config/server.xml, http: 8080, https: 9443. Id remains the old value too: id="defaultHttpEndpointss"

Environment

  • Kubernetes version information:
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.7", GitCommit:"1dd5338295409edcfff11505e7bb246f0d325d15", GitTreeState:"clean", BuildDate:"2021-01-13T13:23:52Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0+2817867", GitCommit:"2817867655bb7b68215b4e77873a8facf82bee06", GitTreeState:"clean", BuildDate:"2021-06-02T22:14:22Z", GoVersion:"go1.15.7", Compiler:"gc", Platform:"linux/amd64"}
  • OpenShift version information (if applicable):
Client Version: 4.7.0-202104250659.p0-95881af
Server Version: 4.7.16
Kubernetes Version: v1.20.0+2817867

Thanks in advance!


Solution

  • The problem in this case was cached image with the latest tag. If the application is created without specifying policy, it is set to pullPolicy: IfNotPresent to optimize creating container. Since the OP first created image with incorrect settings, and then overwrite image with the same tag, OCP used cached version.

    To ensure that you are using correct image either:

    • change the tag name
    • set pullPolicy: Always in your application definition