Diameter Server Inside Kubernetes Cluster and Diameter Client Outside Kubernetes Cluster(3.0)
The instructions for a Diameter server inside Kubernetes cluster (also referred as cluster here) and Diameter client outside of Kubernetes cluster also applies to the Diameter client inside Kubernetes cluster and Diameter server outside Kubernetes cluster.
If the Diameter server (assuming Usage Engine is the server) is inside the cluster and the Diameter client is outside the cluster, some things need to be done to enable proper Diameter communication.
- The pod running the Diameter Server workflow should be connected to a specific host, instead of being able to run on any host. This is because the hostname used (Diameter Identity/Host) should be connected to the external IP of that node. This is done by adding the parameter
nodeHost: nodename
to the parameterspec:
in the ECD yaml (a full example appears further down). In addition, the hostname used for the server must be added to the
/etc/hosts
file on the client and accordingly the hostname of the client needs to be added to the/etc/hosts
file of the server. The latter is done through another addition to the ECD yaml, namely hostAliases. The hostname must be mapped to the external IP of the cluster node. In addition, the port that the server listens to must be mapped to an externally available port (nodePort in the example below).
Since the default hostname of the pod will change on each restart, the server hostname also needs to be entered as a hostAlias so that the Diameter stack agent can bind to that hostname, this is the reason that the server is also part of the example below.Example
services:
 - name: "diameter-server-nodeport-1"
  spec:
   externalTrafficPolicy: "Local"
   type: "NodePort"
   ports:
   - protocol: "TCP"
    port: 3868
    targetPort: 3868
    nodePort: 31868
 hostAliases:
  - ip: "10.46.124.143"
   hostnames:
   - "server.digitalroute.com"
   - "server"
   - "backupserver.digitalroute.com"
   - "backupserver"
  - ip: "10.46.240.33"
   hostnames:
   - "client.digitalroute.com"
   - "client"In the following example, the server Diameter Stack agent needs to listen to (in this case) the port 3868, whereas the client connects to port 31868. Since the client is outside the cluster, the same IP that is used in the client (as listening port) can be used in the server as remote port (the
nodePort
is not needed for outgoing requests, for example, Capabilities-Exchange-Requests).
This is the full ECD yaml for server inside cluster and client outside cluster. For client inside cluster and server outside, just reverse it.Example - ECD yaml for server inside cluster and client outside cluster
metadata:
 name: "diameter-server"
 annotations:
  meta.helm.sh/release-name: "usage-engine-private-edition-ecd"
  meta.helm.sh/release-namespace: "davids"
 labels:
  app.kubernetes.io/managed-by: "Helm"
  app.kubernetes.io/component: "ecd"
apiVersion: "mz.digitalroute.com/v1alpha1"
kind: "ECDeployment"
spec:
 jvmArgs:
 - "Xms256m"
 - "Xmx512m"
 nodeHost: "dig-srv-test03.dev.drint.net"
 resources:
  requests:
   memory: "320Mi"
  limits:
   memory: "640Mi"
 services:
 - name: "diameter-server-nodeport-1"
  spec:
   externalTrafficPolicy: "Local"
   type: "NodePort"
   ports:
   - protocol: "TCP"
    port: 3868
    targetPort: 3868
    nodePort: 31868
 hostAliases:
  - ip: "10.46.124.143"
   hostnames:
   - "server.digitalroute.com"
   - "server"
   - "backupserver.digitalroute.com"
   - "backupserver"
  - ip: "10.46.240.33"
   hostnames:
   - "client.digitalroute.com"
   - "client"
 manualUpgrade: false