Running IBM API Connect on specific Worker Nodes

Kok Sing Khong
2 min readDec 17, 2018

--

As you would know, it is common to run a certain workload on specific nodes in the Kubernetes cluster. API Connect is no exception. A common way to do this is to make use of node labels and node selectors.

However, this may not be straightforward in API Connect because the node selector configurations are not explicitly exposed in the Helm Chart. This article describes the steps on how to do this.

Firstly, you need to label the worker nodes accordingly. E.g. you want to label 3 worker nodes node1, node2 and node3 with the label hostgroup=apic.

kubectl label nodes node1 hostgroup=apic
kubectl label nodes node2 hostgroup=apic
kubectl label nodes node3 hostgroup=apic

Next, following the steps in the IBM Knowledge Center to generate a plan for each of the components. Note: Do not run the installation immediately.

apicup subsys install mgmt --out=mgmt-out
apicup subsys install analyt --out=analyt-out
apicup subsys install ptl --out=ptl-out

Reference: https://www.ibm.com/support/knowledgecenter/en/SSMNED_2018/com.ibm.apic.install.doc/tapic_install_Kubernetes_mgmt.html

The commands above will generate Helm Charts and deployment templates files in the respective folders.

Run the following script file to update the value of the node selectors in the values.yaml file. It simply does the following:

  • Unpack the Helm archive files into temp folders.
  • Set the nodeSelector: hostgroup:apic in all the values.yaml file.
  • Remove the previous Helm archive file and repack the Helm archive file.
  • Remove the temp folders.
PROJECT_NAME=apic41dev
cd $PROJECT_NAME
#
# Management
#
cd ./mgmt-out/helm
tar zxf apiconnect-2.0.0.tgz
tar zxf cassandra-operator-1.0.0.tgz
for i in `find . -type f -name "values.yaml" -print`;
do
sed -i 's/nodeSelector: null/nodeSelector:\n hostgroup: apic/g' $i
sed -i 's/ affinity: null/ affinity:\n nodeAffinity:\n requiredDuringSchedulingIgnoredDuringExecution:\n nodeSelectorTerms:\n - matchExpressions:\n - key: hostgroup\n operator: In\n values:\n - apic/g' $i
done
rm -f apiconnect-2.0.0.tgz
rm -f cassandra-operator-1.0.0.tgz
tar czvf apiconnect-2.0.0.tgz apiconnect
tar czvf cassandra-operator-1.0.0.tgz cassandra-operator
rm -fr apiconnect
rm -fr cassandra-operator
cd ../..#
# Analytics
#
cd ./analyt-out/helm
tar zxf apic-analytics-2.0.0.tgz
for i in `find . -type f -name "values.yaml" -print`;
do
sed -i 's/nodeSelector: null/nodeSelector:\n hostgroup: apic/g' $i
done
rm -f apic-analytics-2.0.0.tgz
tar czvf apic-analytics-2.0.0.tgz apic-analytics
rm -fr apic-analytics

cd ../..
#
# Portal
#
cd ./ptl-out/helm
tar zxf apic-portal-2.0.0.tgz
for i in `find . -type f -name "values.yaml" -print`;
do
sed -i 's/nodeSelector: null/nodeSelector:\n hostgroup: apic/g' $i
done
rm -f apic-portal-2.0.0.tgz
tar czvf apic-portal-2.0.0.tgz apic-portal
rm -fr apic-portal

cd ../../..

Finally, run the installation from the folders (not re-generating the folders).

apicup subsys install mgmt --plan-dir=./apic41dev/mgmt-out
apicup subsys install mgmt --plan-dir=./apic41dev/analyt-out
apicup subsys install mgmt --plan-dir=./apic41dev/ptl-out

Disclaimer:

All opinions expressed here are very much my own and not of IBM. All codes/scripts/artifacts are provided as-is with no support unless otherwise stated.

--

--

Kok Sing Khong
Kok Sing Khong

No responses yet