Search code examples
kuberneteswebspherekubernetes-ingressnginx-ingress

Problem configuring websphere application server behind ingress


I am running websphere application server deployment and service (type LoadBalancer). The websphere admin console works fine at 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

But if i configure that websphere service behind ingress using ingress file like:

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

The url https://ingressip//ibm/console/logon.jsp doesn't works. I have tried the rewrite annotation too.

Can anyone help to just deploy the ibmcom/websphere-traditional docker image in kubernetes using deployment and service. With the service mapped behind the ingress and the websphere admin console should somehow be opened from ingress


Solution

  • There is a helm chart available from IBM team which has the ingress resource as well. In your code snippet, you are missing SSL related annotations as well.

    I have added the Virtual Host configuration for admin console to work with port 443 in the following code sample.

    Please Note: Exposing admin console on the ingress is not a good practice. Configuration should be done via wsadmin or by extending the base Dockerfile. Any changes done through the console will be lost when the container restarts.

    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