Openshift 云集群中的 OpenLibertyApplication
OpenLibertyApplication in Openshift cloud cluster
问题
部署 OpenLibertyApplication 会重写容器映像中指定的 /config/server.xml
你做了什么?
- 已在 src/main/liberty 中使用初始配置部署 OpenLibertyApplication/config/server。xml:
<httpEndpoint id="defaultHttpEndpointss"
host="*"
httpPort="8080"
httpsPort="9443" />
- 将上面的端口更改为
<httpEndpoint id="defaultHttpEndpointssssssssss"
host="*"
httpPort="8080"
httpsPort="8083" />
- Docker 构建将此 server.xml 复制到 /config/server.xml(Docker 将图像拉到我的本地显示正确的更新 /config/server.xml)
- 使用 oc apply -f openlibertyapplication.yaml:
从 OperatorHub 版本 0.7.0 使用 Open Liberty Operator 支持的 OpenLibertyApplication 部署了新映像
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>
您希望看到什么?
/config/server.xml 在 Openshift pod 中显示了 httpEndpoint 的正确更新端口 http: 8080, https: 8083
你看到了什么?在什么情况下?
相反,我在 Pod /config/server.xml、http: 8080、https: 9443 上看到旧端口值。ID 也保持旧值:id="defaultHttpEndpointss"
环境
- Kubernetes 版本信息:
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 版本信息(如果适用):
Client Version: 4.7.0-202104250659.p0-95881af
Server Version: 4.7.16
Kubernetes Version: v1.20.0+2817867
提前致谢!
本例中的问题是带有 latest
标记的缓存图像。如果在没有指定策略的情况下创建应用程序,则将其设置为 pullPolicy: IfNotPresent
以优化创建容器。由于OP首先使用错误设置创建图像,然后使用相同标签覆盖图像,OCP使用缓存版本。
为确保您使用的图片正确:
- 更改标签名称
- 在您的应用程序定义中设置
pullPolicy: Always
问题
部署 OpenLibertyApplication 会重写容器映像中指定的 /config/server.xml
你做了什么?
- 已在 src/main/liberty 中使用初始配置部署 OpenLibertyApplication/config/server。xml:
<httpEndpoint id="defaultHttpEndpointss"
host="*"
httpPort="8080"
httpsPort="9443" />
- 将上面的端口更改为
<httpEndpoint id="defaultHttpEndpointssssssssss"
host="*"
httpPort="8080"
httpsPort="8083" />
- Docker 构建将此 server.xml 复制到 /config/server.xml(Docker 将图像拉到我的本地显示正确的更新 /config/server.xml)
- 使用 oc apply -f openlibertyapplication.yaml: 从 OperatorHub 版本 0.7.0 使用 Open Liberty Operator 支持的 OpenLibertyApplication 部署了新映像
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>
您希望看到什么?
/config/server.xml 在 Openshift pod 中显示了 httpEndpoint 的正确更新端口 http: 8080, https: 8083
你看到了什么?在什么情况下?
相反,我在 Pod /config/server.xml、http: 8080、https: 9443 上看到旧端口值。ID 也保持旧值:id="defaultHttpEndpointss"
环境
- Kubernetes 版本信息:
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 版本信息(如果适用):
Client Version: 4.7.0-202104250659.p0-95881af
Server Version: 4.7.16
Kubernetes Version: v1.20.0+2817867
提前致谢!
本例中的问题是带有 latest
标记的缓存图像。如果在没有指定策略的情况下创建应用程序,则将其设置为 pullPolicy: IfNotPresent
以优化创建容器。由于OP首先使用错误设置创建图像,然后使用相同标签覆盖图像,OCP使用缓存版本。
为确保您使用的图片正确:
- 更改标签名称
- 在您的应用程序定义中设置
pullPolicy: Always