<p>There's anyway using OpenShift command <code>oc</code> 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.</p>

paul
<p>The oc client, as well as kubectl, can do this with the <code>jsonpath</code> or the <code>go-template</code> options. Here's how to get the number of replicas for a Deployment:</p>
<pre><code>kubectl get deploy -n ci ssp-kube -o &quot;jsonpath={.metadata.name} =&gt; {.status.availableReplicas}&quot;
ssp-kube =&gt; 1
</code></pre>
<p>Or all deployments in that namespace:</p>
<pre><code>kubectl get deploy -n ci  -o &quot;jsonpath={.items[*].status.availableReplicas}&quot;
1 2 2 ...
</code></pre>
<p>Looking at your deployments configurations, you should be able to figure out which keys to extract.</p>
<hr />
<p>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 <code>oc adm top pods</code> / <code>oc adm top nodes</code>).</p>
<p>See: <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/</a></p>
