在入口后面配置 websphere 应用程序服务器时出现问题
Problem configuring websphere application server behind ingress
我是 运行 websphere 应用程序服务器部署和服务(类型 LoadBalancer)。 Websphere 管理控制台在 URL https://svcloadbalancerip:9043/ibm/console/logon.jsp
下运行良好
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
was-svc LoadBalancer x.x.x.x x.x.x.x 9080:30810/TCP,9443:30095/TCP,9043:31902/TCP,7777:32123/TCP,31199:30225/TCP,8880:31027/TCP,9100:30936/TCP,9403:32371/TCP 2d5h
但是如果我使用 ingress 文件在 ingress 后面配置该 websphere 服务,例如:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: nginx-ingress-check
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- http:
paths:
- path: /ibm/console/logon.jsp
backend:
serviceName: was-svc
servicePort: 9043
- path: /v1
backend:
serviceName: web
servicePort: 8080
url https://ingressip//ibm/console/logon.jsp
不起作用。
我也尝试过重写注释。
任何人都可以帮助使用部署和服务在 kubernetes 中部署 ibmcom/websphere-traditional docker 图像。服务映射在入口后面,websphere 管理控制台应该以某种方式从入口打开
IBM 团队提供了一个 helm chart,它也有入口资源。在您的代码片段中,您也缺少与 SSL 相关的注释。
- https://hub.helm.sh/charts/ibm-charts/ibm-websphere-traditional
- https://github.com/IBM/charts/tree/master/stable/ibm-websphere-traditional
我在以下代码示例中添加了管理控制台的虚拟主机配置以使用端口 443。
请注意:在入口处公开管理控制台不是一个好习惯。配置应通过 wsadmin
或扩展基本 Dockerfile 来完成。当容器重新启动时,通过控制台完成的任何更改都将丢失。
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
name: websphere
spec:
type: NodePort
ports:
- name: admin
port: 9043
protocol: TCP
targetPort: 9043
nodePort: 30510
- name: app
port: 9443
protocol: TCP
targetPort: 9443
nodePort: 30511
selector:
run: websphere
status:
loadBalancer: {}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: websphere-admin-vh
namespace: default
data:
ingress_vh.props: |+
#
# Header
#
ResourceType=VirtualHost
ImplementingResourceType=VirtualHost
ResourceId=Cell=!{cellName}:VirtualHost=admin_host
AttributeInfo=aliases(port,hostname)
#
#
#Properties
#
443=*
EnvironmentVariablesSection
#
#
#Environment Variables
cellName=DefaultCell01
---
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: websphere
name: websphere
spec:
containers:
- image: ibmcom/websphere-traditional
name: websphere
volumeMounts:
- name: admin-vh
mountPath: /etc/websphere/
ports:
- name: app
containerPort: 9443
- name: admin
containerPort: 9043
volumes:
- name: admin-vh
configMap:
name: websphere-admin-vh
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: nginx-ingress-check
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
rules:
- http:
paths:
- path: /ibm/console
backend:
serviceName: websphere
servicePort: 9043
不可能通过入口暴露 adminhost 和 defaulthost,或者至少我从来没有想出如何完成它。问题的症结在于ingress监听80端口或者443端口,将你的请求转发到容器上对应的端口。因此,您请求的 Host header 包含该端口。我对 WAS channels/virtualhosts 了解不够,无法理解其具体工作原理,但为了通过 WAS 配置中列出的端点以外的任何端口访问 WAS 端点,websphere-traditional image 必须设置 属性 来提取端口,它应该用于检查 virtualhost hostalias 条目和从主机发出重定向 header (com.ibm.ws.webcontainer.extractHostHeaderPort
).
问题是,当它使用该端口时,需要将该端口列为虚拟主机的主机别名,以便让流量通过应用程序。并且由于通配符主机和特定端口的组合一次只能是一个虚拟主机上的主机别名,因此它们被设置为 defaulthost 上的主机别名,以便 Web 应用程序将通过入口运行,但这使得无法同时访问管理控制台,因为它是通过一个单独的虚拟主机提供服务的,该虚拟主机没有(据我所知不能)设置主机别名条目以允许其主机 header 中端口 443 的流量通过。我不必弄清楚如何让它工作,因为 kubectl port-forward
已经足以让我在需要咨询某些东西的时候进入管理控制台,而且你无论如何也无法进行更改,因为它们'当 pod 重新启动并且从相同(未更改的)图像启动新的 pod 时,它会消失。
我是 运行 websphere 应用程序服务器部署和服务(类型 LoadBalancer)。 Websphere 管理控制台在 URL https://svcloadbalancerip:9043/ibm/console/logon.jsp
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
was-svc LoadBalancer x.x.x.x x.x.x.x 9080:30810/TCP,9443:30095/TCP,9043:31902/TCP,7777:32123/TCP,31199:30225/TCP,8880:31027/TCP,9100:30936/TCP,9403:32371/TCP 2d5h
但是如果我使用 ingress 文件在 ingress 后面配置该 websphere 服务,例如:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: nginx-ingress-check
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- http:
paths:
- path: /ibm/console/logon.jsp
backend:
serviceName: was-svc
servicePort: 9043
- path: /v1
backend:
serviceName: web
servicePort: 8080
url https://ingressip//ibm/console/logon.jsp
不起作用。
我也尝试过重写注释。
任何人都可以帮助使用部署和服务在 kubernetes 中部署 ibmcom/websphere-traditional docker 图像。服务映射在入口后面,websphere 管理控制台应该以某种方式从入口打开
IBM 团队提供了一个 helm chart,它也有入口资源。在您的代码片段中,您也缺少与 SSL 相关的注释。
- https://hub.helm.sh/charts/ibm-charts/ibm-websphere-traditional
- https://github.com/IBM/charts/tree/master/stable/ibm-websphere-traditional
我在以下代码示例中添加了管理控制台的虚拟主机配置以使用端口 443。
请注意:在入口处公开管理控制台不是一个好习惯。配置应通过 wsadmin
或扩展基本 Dockerfile 来完成。当容器重新启动时,通过控制台完成的任何更改都将丢失。
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
name: websphere
spec:
type: NodePort
ports:
- name: admin
port: 9043
protocol: TCP
targetPort: 9043
nodePort: 30510
- name: app
port: 9443
protocol: TCP
targetPort: 9443
nodePort: 30511
selector:
run: websphere
status:
loadBalancer: {}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: websphere-admin-vh
namespace: default
data:
ingress_vh.props: |+
#
# Header
#
ResourceType=VirtualHost
ImplementingResourceType=VirtualHost
ResourceId=Cell=!{cellName}:VirtualHost=admin_host
AttributeInfo=aliases(port,hostname)
#
#
#Properties
#
443=*
EnvironmentVariablesSection
#
#
#Environment Variables
cellName=DefaultCell01
---
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: websphere
name: websphere
spec:
containers:
- image: ibmcom/websphere-traditional
name: websphere
volumeMounts:
- name: admin-vh
mountPath: /etc/websphere/
ports:
- name: app
containerPort: 9443
- name: admin
containerPort: 9043
volumes:
- name: admin-vh
configMap:
name: websphere-admin-vh
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: nginx-ingress-check
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
rules:
- http:
paths:
- path: /ibm/console
backend:
serviceName: websphere
servicePort: 9043
不可能通过入口暴露 adminhost 和 defaulthost,或者至少我从来没有想出如何完成它。问题的症结在于ingress监听80端口或者443端口,将你的请求转发到容器上对应的端口。因此,您请求的 Host header 包含该端口。我对 WAS channels/virtualhosts 了解不够,无法理解其具体工作原理,但为了通过 WAS 配置中列出的端点以外的任何端口访问 WAS 端点,websphere-traditional image 必须设置 属性 来提取端口,它应该用于检查 virtualhost hostalias 条目和从主机发出重定向 header (com.ibm.ws.webcontainer.extractHostHeaderPort
).
问题是,当它使用该端口时,需要将该端口列为虚拟主机的主机别名,以便让流量通过应用程序。并且由于通配符主机和特定端口的组合一次只能是一个虚拟主机上的主机别名,因此它们被设置为 defaulthost 上的主机别名,以便 Web 应用程序将通过入口运行,但这使得无法同时访问管理控制台,因为它是通过一个单独的虚拟主机提供服务的,该虚拟主机没有(据我所知不能)设置主机别名条目以允许其主机 header 中端口 443 的流量通过。我不必弄清楚如何让它工作,因为 kubectl port-forward
已经足以让我在需要咨询某些东西的时候进入管理控制台,而且你无论如何也无法进行更改,因为它们'当 pod 重新启动并且从相同(未更改的)图像启动新的 pod 时,它会消失。