There's anyway using OpenShift command oc to obtain the current number of replicas?. I'm doing an auto scaling logic and I would need to know the current number of pods, in oder to do number_of_pods +1 for the replica number update.
The oc client, as well as kubectl, can do this with the jsonpath or the go-template options. Here's how to get the number of replicas for a Deployment:
kubectl get deploy -n ci ssp-kube -o "jsonpath={.metadata.name} => {.status.availableReplicas}"
ssp-kube => 1Or all deployments in that namespace:
kubectl get deploy -n ci -o "jsonpath={.items[*].status.availableReplicas}"
1 2 2 ...Looking at your deployments configurations, you should be able to figure out which keys to extract.
Now, you mention working on auto-scaling: have you considered HorizontalPodAutoscalers ? With OpenShift, you probably have the required metrics server gathering cpu/memory usages (check with oc adm top pods / oc adm top nodes).
See: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/