Configure {{page.netscaler-cpx-short}} in Kubernetes Using ConfigMaps

Last published : Sep 02, 2026
In Kubernetes, you can configure the {{page.netscaler-cpx-short}} instance using ConfigMaps. Using ConfigMaps you can dynamically configure the {{page.netscaler-cpx-short}} instance during instance startup.
Create a cpx.conf configuration file that includes NetScaler-specific configuration and bash shell commands that you want to run dynamically on the {{page.netscaler-cpx-short}} instance. The configuration file structure requires two types of tags, #NetScaler Commands and #Shell Commands. Under the #NetScaler Commands tag, you must add all the NetScaler commands to configure NetScaler-specific configuration on {{page.netscaler-cpx-short}} instance. Under the #Shell Commands tag, you must add the shell commands that you want to run on the {{page.netscaler-cpx-short}} instance.
Important:
  • The tags can be repeated multiple times in the configuration file.
  • The configuration file can also include comments. Add a “#” character before comments.
  • The tags are not case-sensitive.
  • If there are failure scenarios while deploying the {{page.netscaler-cpx-short}} container with the configuration file, the failures are logged in the ns.log file.
  • After the {{page.netscaler-cpx-short}} instance starts, if you change the ConfigMap, the updated configuration is applied only when the {{page.netscaler-cpx-short}} instance is restarted.
The following is a sample configuration file:
#NetScaler Commands
add lb vserver v1 http 1.1.1.1 80
add service s1 2.2.2.2 http 80
bind lb vserver v1 s1
#Shell Commands
touch /etc/a.txt
echo "this is a" > /etc/a.txt
#NetScaler Commands
add lb vserver v2 http
#Shell Commands
echo "this is a 1" >> /etc/a.txt
#NetScaler Commands
add lb vserver v3 http
Once you have created the configuration file, you must create a ConfigMap from the configuration file using the kubectl create configmap command.
kubectl create configmap cpx-config --from-file=cpx.conf
In the example above, you can create a ConfigMap, cpx-config based on the configuration file cpx.conf. You can then use this ConfigMap in the YAML file used to deploy the {{page.netscaler-cpx-short}} instance.
You can view the created ConfigMap using the kubectl get configmap command. root@node1:~/yaml# kubectl get configmap cpx-config -o yaml
Sample:
apiVersion: v1
data:
    cpx.conf: |
    #NetScaler Commands
        add lb vserver v1 http 1.1.1.1 80
        add service s1 2.2.2.2 http 80
        bind lb vserver v1 s1
    #Shell Commands
        touch /etc/a.txt
        echo "this is a" > /etc/a.txt
        echo "this is the file" >> /etc/a.txt
        ls >> /etc/a.txt
    #NetScaler Commands
        add lb vserver v2 http
    #Shell Commands
        echo "this is a 1" >> /etc/a.txt
    #NetScaler Commands
        add lb vserver v3 http
    #end of file
kind: ConfigMap
metadata:
    creationTimestamp: 2017-12-26T06:26:50Z
    name: cpx-config
    namespace: default
    resourceVersion: "8865149"
    selfLink: /api/v1/namespaces/default/configmaps/cpx-config
    uid: c1c7cb5b-ea05-11e7-914a-926745c10b02
You can specify the created ConfigMap, cpx-config in the YAML file used to deploy the {{page.netscaler-cpx-short}} instance as shown below:
apiVersion: v1
kind: Pod
metadata:
  name: cpx-1
  labels:
    app: cpx-daemon
  annotations:
    NETSCALER_AS_APP: "True"
spec:
  hostNetwork: true
  containers:
  - name: cpx
    image: "quay.io/citrix/citrix-k8s-cpx-ingress:12.1-51.16"
    securityContext:
      privileged: true
    volumeMounts:
    - name: config-volume
      mountPath: /cpx/conf
    env:
      - name: "EULA"
        value: "yes"
      - name: "NS_NETMODE"
        value: "HOST"
      - name: "kubernetes_url"
        value: "https://10.90.248.101:6443"
      - name: "NS_MGMT_SERVER"
        value: "10.90.248.99"
      - name: "NS_MGMT_FINGER_PRINT"
        value: "19:71:A3:36:85:0A:2B:62:24:65:0F:7E:72:CC:DC:AD:B8:BF:53:1E"
      - name: "NS_ROUTABLE"
        value: "FALSE"
      - name: "KUBERNETES_TASK_ID"
        valueFrom:
          fieldRef:
            fieldPath: metadata.name
    imagePullPolicy: Never
  volumes:
  - name: config-volume
    configMap:
      name: cpx-config
Once the {{page.netscaler-cpx-short}} is instance is deployed and starts the configuration specified in the ConfigMap, cpx-config is applied to the {{page.netscaler-cpx-short}} instance.