<ul>
<li>I want scale up my statefulset and want to initiate this scale up from inside the pod(container) using
the Kubernetes API(http request) to the kubernetes rest server.</li>
<li>I tried scaling up statefulset pods using</li>
</ul>
<blockquote>
<p>PUT /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/scale</p>
</blockquote>
<ul>
<li>but it didn't work for me.</li>
</ul>
<p>Even tried fetching the scale data of specified statefulset using</p>
<blockquote>
<p>&quot;GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/scale&quot;</p>
</blockquote>
<blockquote>
<p>REQUEST : curl -s -k -H &quot;Authorization: Bearer $TOKEN&quot; -X GET <a href="https://kubernetes.default.svc:443/apis/apps/v1/namespaces/$Namespace/$Kind/$PodNamePrefix/scale" rel="nofollow noreferrer">https://kubernetes.default.svc:443/apis/apps/v1/namespaces/$Namespace/$Kind/$PodNamePrefix/scale</a></p>
</blockquote>
<p>Gives an error :</p>
<ul>
<li><p>&quot;message&quot;: &quot;statefulsets.apps &quot;app-4x&quot; is forbidden: User
&quot;system:serviceaccount::default&quot; cannot get resource
&quot;statefulsets/scale&quot; in API group &quot;apps&quot; in the namespace
&quot;&quot;&quot;,&quot;reason&quot;: &quot;Forbidden&quot;,</p>
</li>
<li><p>Reference : <a href="https://v1-14.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/" rel="nofollow noreferrer">https://v1-14.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/</a></p>
</li>
</ul>
<p>Can somebody help me with this?</p>

himanshu
<p>You need to define <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="noreferrer">RBAC</a> using <code>Role</code> and <code>RoleBinding</code> to authorize the service account to perform the required operations</p>
<pre><code>apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: default
  name: ss-role
rules:
- apiGroups: [&quot;apps&quot;]
  resources: [&quot;statefulsets/scale&quot; ]
  verbs: [&quot;get&quot;, &quot;list&quot;, &quot;create&quot;]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  namespace: default
  name: ss-rolebinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: ss-role
subjects:
- kind: ServiceAccount
  name: default
  namespace: default
</code></pre>
<p>Above <code>Role</code> and <code>RoleBinding</code> is based on the assumption that you are using <code>default</code> service account of <code>default</code> namespace to scale <code>statefulsets</code> in <code>default</code> namespace.</p>
