Deploying Applications and Testing Traffic¶
Prerequisites¶
Make sure that the external and internal VLAN CRs are configured, see F5SPKVLAN.
Make sure to apply BNKGateway CR to assign IPAM IP ranges.
Ingress Traffic¶
To test ingress traffic, you can deploy a test NGINX web application on your Kubernetes cluster’s Host node. The Ingress path originates from the external Client and is directed towards the Virtual Server IP (destination address). The Virtual Server then distributes the request among the available application pods in its pool for load balancing.
Example¶
Create a
nginx-app-deployfile with the content below:vi nginx-app-deploy.yaml
Contents:
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx-tcp spec: replicas: 1 selector: matchLabels: app: nginx-tcp template: metadata: labels: app: nginx-tcp spec: containers: - name: nginx-tcp image: nginx:latest ports: - containerPort: 80 imagePullPolicy: IfNotPresent --- apiVersion: v1 kind: Service metadata: name: nginx-app-svc spec: type: LoadBalancer ports: - port: 80 targetPort: 80 selector: app: nginx-tcp
Deploy the NGINX application into a namespace that your BIG-IP Next for Kubernetes is watching (watchNamespace).
kubectl apply -f nginx-app-deploy.yaml -n <your application namespace>
Example:
kubectl apply -f nginx-app-deploy.yaml -n app-ns
Create a Gateway API application with custom resources to make the NGINX application accessible through a service proxy endpoint. The IP Address should be within the same CIDR range as your
externalnetwork and must not already be in use.For example, if your external network’s CIDR range is 192.168.10.0/24, any IP address between 192.168.10.1 and 192.168.10.255 will work.
Create a
gateway-tcp-cr.yamlfile with the contents below:vi gateway-tcp-cr.yaml
Note
Update the product-ns to the namespace in which CNEInstance CR is installed.
User must define
listeners.kinds.groupfor L4Route. Gateway CRs should be applied on app namespace.
Contents:
apiVersion: gateway.networking.k8s.io/v1 kind: GatewayClass metadata: name: my-gateway-class spec: controllerName: "f5.com/f5-bnk-instance-f5-cne-controller" description: "F5 BIG-IP Kubernetes Gateway" --- apiVersion: k8s.f5net.com/v1 kind: F5BnkGateway metadata: name: my-gateway namespace: f5-bnk spec: ingressConfig: defaultListenerNetworks: - name: default_ipv4 ipv4BaseCidr: 22.22.22.100/24 startAddress: 22.22.22.160 endAddress: 22.22.22.170 - name: default_ipv6 ipv6BaseCidr: 2002::22:22:22:100/112 startAddress: 2002::22:22:22:161 endAddress: 2002::22:22:22:170 --- apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: my-l4route-tcp-gateway namespace: app-ns spec: infrastructure: parametersRef: group: k8s.f5net.com kind: F5BnkGateway name: test-bnkgateway gatewayClassName: f5-gateway-class listeners: - name: l4-nginx-tcp protocol: TCP port: 80 allowedRoutes: namespaces: from: Same kinds: - kind: L4Route group: gateway.k8s.f5net.com --- apiVersion: gateway.k8s.f5net.com/v1 kind: L4Route metadata: name: l4-tcp-nginx-app namespace: app-ns spec: protocol: TCP parentRefs: - name: my-l4route-tcp-gateway namespace: app-ns port: 80 sectionName: l4-nginx-tcp rules: - backendRefs: - name: nginx-app-svc namespace: app-ns port: 80
Once the gateway CR has been deployed, you will be able to ping and curl the IP Address from a Node outside of your cluster that falls within the same CIDR range, run:
curl <IP Address>
Response:
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
Egress Traffic¶
Egress traffic is when you want to reach a server outside of your
Kubernetes cluster from a Pod that is running inside of your cluster.
In the below example egress test, we perform a “curl” from the NGINX application pod running
in the cluster to the Client on the external network.
The Client node has a listener, in this case the NGINX web server, running on it.
Note: Ensure that there is an IP on the node’s interface that is similar to the VLAN connectivity check.
Check for IPs in the interface within the /24 CIDR range. Make sure that there is at least one IP that is in the same CIDR range as the external VLAN. On the Client (
<IP Address>external), run:ip a
Response:
4: ens17f0np0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether b8:3g:dg:c0:49:20 brd ff:ff:ff:ff:ff:ff altname enp152s0f0np0 inet <IP Address>/24 scope global ens17f0np0 valid_lft forever preferred_lft forever
You will need an application pod (such as NGINX) to be running in your Kubernetes cluster. See step 1 and 2 from Ingress Traffic to install an NGINX test application pod.
Egress with VLAN¶
Create a snatpool and egress custom resource file with the contents below:
vi snatpool-cr.yaml
The snatpool address will be used as the snat IP to identify the egress traffic that is coming from BIG-IP Next for Kubernetes. The snatpool IP “
<IP Address>” should be in your network CIDR range on theexternalnetwork.Contents:
snatpool-cr:
apiVersion: "k8s.f5net.com/v1" kind: F5SPKSnatpool metadata: name: "egress-snat-3000" spec: name: "egress_snatpool" sharedSnatAddressEnabled: true addressList: - - <IP Address> # <-- snat IP
egress_with_vlan:
apiVersion: k8s.f5net.com/v3 kind: F5SPKEgress metadata: name: egress-vlan spec: dualStackEnabled: false snatType: SRC_TRANS_SNATPOOL maxTmmReplicas: 1 egressSnatpool: egress_snatpool vlans: vlanList: - internal disableListedVlans: false pseudoCNIConfig: namespaces: - app appPodInterface: eth0 appNodeInterface: <appNodeInterface>
egress_with_vlan:
Apply your snatpool-cr.yaml:
kubectl apply -f snatpool-cr.yaml --namespace f5-bnk-instance
To test
egresstraffic, you can shell (exec -it) into the application Pod inside the cluster.a. Get the pod ID for the NGINX application:
kubectl get pods -n app-ns
Response:
NAME READY STATUS RESTARTS AGE nginx-deploy-5798c85b9c-qtqnd 1/1 Running 0 4d21h
b. Shell into the application pod:
kubectl exec -it pod/nginx-deploy-5798c85b9c-qtqnd -n app-ns -- bash
Perform a curl from inside the NGINX application pod in the Kubernetes cluster to the Client Server’s NGINX web server. In the NGINX application pod, run:
curl <IP Address>
If your setup is working correctly, you will receive a response from the NGINX server running on the Client server outside of your Kubernetes cluster.
Response:
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
Egress with VxLAN¶
Create a snatpool and egress custom resource file.
The snatpool address will be used as the snat IP to identify the egress traffic that is coming from BIG-IP Next for Kubernetes. The snatpool IP “
<IP Address>” should be in your network CIDR range on theexternalnetwork.snatpool-cr:
apiVersion: "k8s.f5net.com/v1" kind: F5SPKSnatpool metadata: name: "egress-snat-3000" spec: name: "egress_snatpool" sharedSnatAddressEnabled: true addressList: - - <IP Address> # <-- snat IP
egress_with_vxlan:
apiVersion: k8s.f5net.com/v3 kind: F5SPKEgress metadata: name: egress-vxlan spec: dualStackEnabled: false snatType: SRC_TRANS_SNATPOOL egressSnatpool: egress_snatpool pseudoCNIConfig: namespaces: - app # Routing default pod interface eth0. # Assumes pod does not have additional interfaces configured. appPodInterface: eth0 vxlan: create: true tmmInterfaceName: internal key: 100
Apply your snatpool-cr.yaml:
kubectl apply -f snatpool-cr.yaml --namespace f5-bnk-instance
To test
egresstraffic, you can shell (exec -it) into the application Pod inside the cluster.a. Get the pod ID for the NGINX application:
kubectl get pods -n app-ns
Response:
NAME READY STATUS RESTARTS AGE nginx-deploy-5798c85b9c-qtqnd 1/1 Running 0 4d21h
b. Shell into the application pod:
kubectl exec -it pod/nginx-deploy-5798c85b9c-qtqnd -n app-ns -- bash
Perform a curl from inside the NGINX application pod in the Kubernetes cluster to the Client Server’s NGINX web server. In the NGINX application pod, run:
curl <IP Address>
If your setup is working correctly, you will receive a response from the NGINX server running on the Client server outside of your Kubernetes cluster.
Response:
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>