How to expose a Kubernetes-deployed LiveView Web application to external clients using an Ingress Controller

How to expose a Kubernetes-deployed LiveView Web application to external clients using an Ingress Controller

book

Article ID: KB0072906

calendar_today

Updated On:

Products Versions
TIBCO LiveView Web 1.6.2 and later

Description

How can I deploy a LiveView Web application in Kubernetes, and expose it to clients as a tcp service?
 

Issue/Introduction

Outlines the steps needed to expose a Kubernetes-deployed LiveView Web application to external clients using an Ingress Controller. Examples using Kind Kubernetes and NGINX Ingress are provided.

Resolution

NOTE: The guidance shown below assumes you have already built a docker image of your LiveView application. If you haven't yet reached this step, please refer to the Help under Home > StreamBase Admin Guide > Using Docker > LiveView: Creating Docker Images.

To expose your Kubernetes-deployed LiveView application to external tcp clients, use an Ingress Controller:

First, deploy (for example) a Kind Kubernetes cluster using a *.yaml file with the following contents:
 
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP

To start the Kubernetes cluster, run:
 
$ cat kind-ingress.yaml | kind create cluster --config=-

Next, deploy (for example) a NGINX ingress controller:
 
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml

Then wait for the ingress to initialize:
 
$ kubectl wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=90s

(wait for the 'condition met' message)

Next, load your docker image into the Kind Kubernetes cluster. For example: 
 
$ kind load docker-image sample_lv_sample_lvweb_app:0.0.1-SNAPSHOT

Next, create a *.yaml file to deploy your LiveView application. In this *.yaml, add the Ingress controller as shown below:
 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: lvweb-app-deployment
  labels:
    app: lvweb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: lvweb
  template:
    metadata:
      labels:
        app: lvweb
    spec:
     containers:
      - name: lvweb-app
        image: sample_lv_sample_lvweb_app:0.0.1-SNAPSHOT
        imagePullPolicy: Never
        ports:
        - containerPort: 11080
        env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: APPNAME
            value: samplelvsamplelvwebapp
          - name: STREAMING_NODENAME
            value: "$(POD_NAME).$(APPNAME)"
---
kind: Service
apiVersion: v1
metadata:
  name: lvweb-service
spec:
  selector:
    app: lvweb
  ports:
    - port: 11880
      targetPort: 11080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: lvweb-ingress
spec:
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: lvweb-service
            port:
              number: 11880
---

Finally, deploy your LiveView application:
 
$ kubectl apply -f lvweb.yaml

External tcp clients should now be able to access the LiveView Web service over port 80.