Configure HAProxy and Public Cloud to expose Watson Query ports
Expose Watson Query NodePort for external JDBC access and remote agent connection on Amazon Web Services (AWS) self-managed Kubernetes clusters.
About this task
Watson Query NodePort service enables an external connection to Watson Query components running in the Watson Query head pod. To configure the network, you must have access to the AWS Console and the Red Hat® OpenShift® command-line interface (oc).
Procedure
-
Use the oc login command to log in to the AWS self-managed Kubernetes cluster, and then run the
following command to list the Watson
Query NodePort service and the port values. Replace
<DV_INSTANCE_NAMESPACE> with the namespace where the Watson
Query
instance runs.
oc -n <DV_INSTANCE_NAMESPACE> get svc c-db2u-dv-db2u-engn-svc
Example: Theport:nodeport
result displays 3 ports in this example. The internal port, NodePort port and protocol are displayed in that order for each port. For example,50001
is the internal port,31966
is the NodePort port, andTCP
is the protocol.user@host:~# oc get svc c-db2u-dv-db2u-engn-svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE c-db2u-dv-db2u-engn-svc NodePort 1.2.3.4 <none> 50001:31966/TCP,50000:32121/TCP,7777:31164/TCP 1d
- Use the following command to create a network policy if a network policy with the same
contents has not already been created. Replace <DV_INSTANCE_NAMESPACE> with
the namespace where the Watson
Query instance runs.
cat << EOF | oc -n <DV_INSTANCE_NAMESPACE> apply -f - apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: dv-nodeport-ext namespace: <DV_INSTANCE_NAMESPACE> spec: ingress: - ports: - port: 50000 protocol: TCP - port: 50001 protocol: TCP - port: 7777 protocol: TCP podSelector: matchLabels: component: db2dv formation_id: db2u-dv icpdsupport/app: dv role: db type: engine policyTypes: - Ingress EOF
- Log in to the AWS Console and create one target group for each NodePort port to be
exposed externally. Note: Do not group all the NodePort ports into one target group, as AWS will not know which port to route the inbound network traffic.
- In the Specify group details page, set the following configurations.
- Set the target type to Instances
- Set the Protocol to Port pair to TCP:<NodePort port>. Replace <Nodeport port> with the NodePort port value from step 1.
- Set the IP address type to IPv4.
- Select external VPC.
- Set the Health check protocol to TCP.
- On the Register targets page, add all the master nodes to target the
group's Targets list, and then specify the NodePort port value in the
Ports for the selected instances field.
For example, if the target group is to expose the Db2® SSL port, the Ports for the selected instances field should have the NodePort port corresponding to the internal Db2 port 50001.
- In the Specify group details page, set the following configurations.
- Create a new security group to allow inbound traffic from each NodePort port.
- Navigate to Create security group > Inbound
rules and then complete these steps.
- For CIDR blocks 0.0.0.0/0 and 10.0.0.0/16, add one rule for each block against the internal Watson Query port.
- Add another rule against the NodePort port.
- For each rule you created, enter the following specifications.
- Type: Custom TCP.
- Port range: For the rules for each block against the internal Watson Query port, enter the Watson Query internal port from step 1. For the rule against the NodePort ports, enter the corresponding NodePort port.
- Source: Custom.
- Select 0.0.0.0/0 CIDR blocks.
- Create a network load balancer against the public or external VPC. Ensure that the load
balancer displays the following properties when it is created.
Scheme Internet-facing Load balancer IP address type IPv4 Load balancer type Network
- Add one listener per NodePort to be exposed externally. Make sure that each listener is
connected to a target group that only has a single port, and then set the following
specifications.
- Protocol: Port pair: TCP: <Internal port>. Replace <Internal port> with the internal port value from step 1.
- Select the corresponding target group that you created in step 3.
For example, to expose the Watson Query internal 50001 Db2 SSL port, ensure you specify TCP: 50001, then select the corresponding target group when you add the listener. The external client connection still uses port 50001, and the AWS side will be mapped to the NodePort opened on the OpenShift master nodes, which in turn is routed to the Watson Query head pod.
After you add the listeners to the load balancer, the target group starts running a health check. The status of the health check should beHealthy
, indicating that the NodePort port is reachable from the load balancer.Optional: You can view the listener to target group mapping under the Resource map - new tab of the network load balancer you created in this step.
- Add the security group that you created in step 5 to the load balancer.