Configure Citrix ADC CPX in Kubernetes Using ConfigMaps

In Kubernetes, you can configure the Citrix ADC CPX instance using ConfigMaps. Using ConfigMaps you can dynamically configure the Citrix ADC CPX 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 Citrix ADC CPX 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 Citrix ADC CPX instance. Under the #Shell Commands tag, you must add the shell commands that you want to run on the Citrix ADC CPX 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 Citrix ADC CPX container with the configuration file, the failures are logged in the ns.log file.
  • After the Citrix ADC CPX instance starts, if you change the ConfigMap, the updated configuration is applied only when the Citrix ADC CPX 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 Citrix ADC CPX 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 Citrix ADC CPX 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: "cpx:latest"
        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.106.76.31:6443"
            - name: "NS_MGMT_SERVER"
              value: "10.106.76.144"
            - name: "NS_MGMT_FINGER_PRINT"
              value: "A6:1F:7C:16:90:42:52:C9:0F:74:59:28:E7:A5:D6:D6:3C:6D:DC:DE"
            - name: "NS_ROUTABLE"
              value: "FALSE"
            - name: "KUBERNETES_TASK_ID"
        valueFrom:
        fieldRef:
        fieldPath: metadata.name
        imagePullPolicy: Never
        volumes:
            - name: config-volume
        configMap:
            name: cpx-config
        nodeSelector:
            node: node1

Once the Citrix ADC CPX is instance is deployed and starts the configuration specified in the ConfigMap, cpx-config is applied to the Citrix ADC CPX instance.

Configure Citrix ADC CPX in Kubernetes Using ConfigMaps

In this article