In the last blogpost I created, instantiated and started a TIBCO BWCE application Docker image on a local OpenShift cluster (Origin). In this blogpost I will be explaining how to easily scale to keep up with user demand. Since OpenShift is actually using Kubernetes under the hood, there are many similarities (besides a slightly different syntax). For directly scaling TIBCO on Kubernetes you can have a look in one of my previous blogs (Scaling TIBCO on Kubernetes).
Scaling a deployment (increasing the number of replicas) will make sure that new pods are created or removed. Pods can also be autoscaled using the “oc autoscale” command, but for this blogpost we will be doing this manually by using the command line. As you can see below we can also achieve this by using the OpenShift web console (up/down arrow), but that’s no fun!
Scaling is accomplished by changing the number of replicas in a Deployment.
1. Let’s start by running the following command to get a list of the actual deploymentconfig objects available (note: in Kubernetes just deployment, in OpenShift it is deploymentconfig!):
MacBook-Pro:~ ruben.middeljans$ oc get deploymentconfig NAME REVISION DESIRED CURRENT TRIGGERED BY helloworldbwce-node 1 1 1 config
- REVISION shows the revision id
- DESIRED shows the configured replicas
- CURRENT shows how many replicas are running now
Notice that the following information is missing if we compare this to Kubernetes.
- UP-TO-DATE shows the number of replicas that were updated to match the desired state
- AVAILABLE shows how many replicas are actually AVAILABLE to the users
2. To scale up our TIBCO BWCE “helloworld” application we use the “oc scale” command followed by the object type (“dc”), the name of the deploymentconfig object (“helloworldbwce-node”) and the amount of replicas we “desire” (4).
MacBook-Pro:~ ruben.middeljans$ oc scale dc helloworldbwce-node --replicas=4deploymentconfig "helloworldbwce-node" scaled
3. To verify that the application was properly scaled up to 4 instances we re-run the following command:
MacBook-Pro:~ ruben.middeljans$ oc get deploymentconfig NAME REVISION DESIRED CURRENT TRIGGERED BY helloworldbwce-node 1 4 4 config
As we can see the change was applied and we have now 4 instances running of the TIBCO BWCE “helloworld” application in just a matter of seconds! We can also see this change reflected in the OpenShift web console (https://127.0.0.1:8443) -> Applications -> Deployments-> helloworldbwce-node -> #1.
4. To verify the correct amount of pods and corresponding internal IP addresses we can run the following command:
MacBook-Pro:~ ruben.middeljans$ oc get pods -o wideNAME READY STATUS RESTARTS AGE IP NODE helloworldbwce-node-1-9ggbp 1/1 Running 0 3m 172.17.0.2 localhost helloworldbwce-node-1-b96pk 1/1 Running 0 3m 172.17.0.4 localhost helloworldbwce-node-1-pt2r8 1/1 Running 0 3m 172.17.0.7 localhost helloworldbwce-node-1-slhpk 1/1 Running 0 14m 172.17.0.3 localhost
There are 4 pods now with different (internal) IP addresses.
5. To verify that the original service is now load-balancing the traffic towards all 4 pods we can run the following command:
MacBook-Pro:~ ruben.middeljans$ oc describe service Name: helloworldbwce-node Namespace: helloworldbwce Labels: run=helloworldbwce-node Annotations: <none> Selector: run=helloworldbwce-nodeType: LoadBalancerIP: 172.30.65.43 External IPs: 172.29.191.7 LoadBalancer Ingress: 172.29.191.7 Port: <unset> 8080/TCPNodePort: <unset> 30687/ TCPEndpoints: 172.17.0.2:8080,172.17.0.3:8080,172.17.0.4:8080 + 1 more... Session Affinity: NoneEvents: <none>
As we can see there are 4 (tcp) endpoints each with the corresponding IP address of one of the pods and the corresponding internal port (8080) or our TIBCO BWCE “helloworld” application.
6. To scale down our TIBCO BWCE “helloworld” application we use the “oc scale” command in the same way as we did before.
MacBook-Pro:~ ruben.middeljans$ oc scale dc helloworldbwce-node --replicas=1 deploymentconfig "helloworldbwce-node" scaled