To route the client traffic to a microservice based application, you have to write Ingress rules that must propagate in the Ingress proxy for better traffic distribution. Ingress proxy acts as Application Delivery Controller to load balance microservice based application.
Citrix has a container based Ingress proxy called as NetScaler CPX. It provides application load balancing, acceleration, security, and offload feature set in a simple, easy-to-install container. The NetScaler CPX is built from the same code base as the NetScaler and is packaged as a Docker container.
In this article, NetScaler CPX (a containerized form-factor) routes the Ingress traffic to the Apache microservice application.
NetScaler CPX supports the following deployment modes:
Deploy a standalone NetScaler CPX (NetScaler CPX per Kubernetes cluster)
-
Deploy a stand-alone NetScaler CPX as an ingress proxy.
```kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yamlkubectl get pods -l app=cpx-ingresskubectl get svc cpx-service```
-
Send traffic to the Apache microservice.
```curl -s -H "Host: www.ingress.com" http://<Master IP:<NodePort>```
-
Clean up the setup.
kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml
Deploy NetScaler CPX per node of a Kubernetes cluster
-
Get the list of nodes in a cluster and deploy NetScaler CPX per node.
kubectl get nodeskubectl create -f <https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/cpx-per-node-mode.yaml>kubectl get pods -l app=cpx-ingresskubectl get svc cpx-service
The number of
CPX-ingress
pods are equal to the number of nodes in the Kubernetes cluster deploying pods. -
Deploy traffic to the Apache microservice.
```curl -s -H "Host: www.ingress.com" <http://<Master IP:<NodePort>```
-
Clean up the setup.
kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/cpx-per-node-mode.yaml
Deploy NetScaler CPX per namespace deployment
The following example shows how to deploy NetScaler CPX in multiple namespaces.
-
Create three namespaces in the Kubernetes cluster.
```kubectl create namespace team-Akubectl create namespace team-Bkubectl create namespace team-C```
-
Deploy the NetScaler CPX in each namespace.
kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml -n team-A kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml -n team-B kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml -n team-C
-
Deploy the
colddrink
microservice apps in all namespaces.kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-app.yaml -n team-A kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-app.yaml -n team-B kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-app.yaml -n team-C
-
Verify the deployment using the following commands:
kubectl get pods -l app=frontend-colddrinks -n team-A kubectl get pods -l app=frontend-colddrinks -n team-B kubectl get pods -l app=frontend-colddrinks -n team-C
-
Deploy Ingress rules that send traffic to http://www.colddrink.com.
kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-ingress.yaml -n team-A kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-ingress.yaml -n team-B kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-ingress.yaml -n team-C
-
Verify the Ingress using the following commands:
kubectl get ingress -n team-A kubectl get svc cpx-service -n team-A kubectl get ingress -n team-B kubectl get svc cpx-service -n team-B kubectl get ingress -n team-C kubectl get svc cpx-service -n team-C
-
Deploy the traffic for each NetScaler CPX deployed in different namespaces.
kubectl get pods -l app=cpx-ingress -n team-A kubectl get pods -l app=cpx-ingress -n team-B kubectl get pods -l app=cpx-ingress -n team-C kubectl get svc -n team-A kubectl get svc -n team-B kubectl get svc -n team-C
-
Verify NodePort for all CPXs and create cURL requests.
curl -s -H "Host: www.ingress.com" http://<Master IP:<NodePort>
-
Clean up the setup.
kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml -n team-A kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml -n team-B kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml -n team-C kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-app.yaml -n team-A kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-app.yaml -n team-B kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-app.yaml -n team-C kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-ingress.yaml -n team-A kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-ingress.yaml -n team-B kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/colddrink-ingress.yaml -n team-C kubectl delete namespace team-A team-B team-C
High availability NetScaler CPX deployment
This example shows how to deploy NetScaler CPX in high availability mode.
-
Deploy NetScaler CPX in high availability mode.
kubectl create -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml kubectl get pods -l app=cpx-ingress
-
Scale up the NetScaler CPX to two instances.
kubectl scale deployment cpx-ingress --replicas=2 kubectl get pods -l app=cpx-ingress
Now both NetScaler CPXs are capable to take distributed Ingress traffic.
-
Scale down NetScaler CPX pods to a single instance.
kubectl scale deployment cpx-ingress --replicas=1 kubectl get pods app=cpx-ingress
-
Test the Kubernetes self-healing mechanism.
kubectl get pods -l app=cpx-ingress kubectl delete pod <cpx-ingress pod name> kubectl get pods -l app=cpx-ingress
You can see that a new NetScaler CPX pod has come up immediately after a running pod goes down.
-
Try out Horizontal pod autoscaling for NetScaler CPX.
NetScaler CPX supports Horizontal Pod Autoscaling (HPA) to automatically scale the number of pods in your workload based on different metrics like actual resource usage. Try out CPX HPA from [CPX HPA documentation](https://developer-docs.citrix.com/projects/citrix-k8s-ingress-controller/en/latest/how-to/cpx-hpa/)
-
Clean up the setup.
kubectl delete -f https://raw.githubusercontent.com/citrix/cloud-native-getting-started/master/beginners-guide/manifest/standalone-cpx-mode.yaml
For more information, see the NetScaler CPX documentation.
For more information on the Citrix ingress controller, see the Citrix ingress controller documentation.
For more tutorials, see beginners-guides.
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now