<p>I use io.fabric8.kubernetes-client, version 3.1.8 to do RollingUpdate of kubernetes resource. It is fine for Deployment. But I meet an exception for StatefulSet. But it is also fine if I use 'kubectl apply -f ***.yaml' for the StatefulSet.</p>

<p>Code to RollingUpdate Deployment:</p>

<pre><code>public void createOrReplaceResourceByYaml(String namespace, KubernetesResource resource) {
  KubernetesClient client = k8sRestClient.newKubeClient();
  Deployment deployment = (Deployment) resource;
  logger.info(String.format("Create/Replace Deployment [%s] in namespace [%s].", ((Deployment) resource).getMetadata().getName(), namespace));
  NonNamespaceOperation&lt;Deployment, DeploymentList, DoneableDeployment, ScalableResource&lt;Deployment, DoneableDeployment&gt;&gt; deployments = client.extensions().deployments().inNamespace(namespace);
  Deployment result = deployments.createOrReplace(deployment);
  logger.info(String.format("Created/Replaced Deployment [%s].", result.getMetadata().getName()));
}
</code></pre>

<p>Code to RollingUpdate StatefulSet</p>

<pre><code>public void createOrReplaceResourceByYaml(String namespace, KubernetesResource resource) {
  KubernetesClient client = k8sRestClient.newKubeClient();
  StatefulSet statefulSet = (StatefulSet) resource;
  logger.info(String.format("Create/Replace StatefulSet [%s] in namespace [%s].", statefulSet.getMetadata().getName(), namespace));
  NonNamespaceOperation&lt;StatefulSet, StatefulSetList, DoneableStatefulSet, RollableScalableResource&lt;StatefulSet, DoneableStatefulSet&gt;&gt; statefulSets = client.apps().statefulSets().inNamespace(namespace);
  StatefulSet result = statefulSets.createOrReplace(statefulSet);
  logger.info(String.format("Created/Replaced StatefulSet [%s].", result.getMetadata().getName()));
}
</code></pre>

<p>Exception when do RollingUpdate of StatefulSet</p>

<blockquote>
  <p>Failure executing: PUT at: <a href="https://kubernetes.default.svc/apis/apps/v1beta1/namespaces/itsma1/statefulsets/pro-rabbitmq" rel="noreferrer">https://kubernetes.default.svc/apis/apps/v1beta1/namespaces/itsma1/statefulsets/pro-rabbitmq</a>. Message: StatefulSet.apps "pro-rabbitmq" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden.. Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec, message=Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden., reason=FieldValueForbidden, additionalProperties={})], group=apps, kind=StatefulSet, name=pro-rabbitmq, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=StatefulSet.apps "pro-rabbitmq" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden., metadata=ListMeta(resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).</p>
</blockquote>

<p><strong>I am curious why the error happened and how to fix it.</strong></p>

<p>In StatefulSet, unlike Deployment, you can update only limited number of values - <code>replicas</code>, <code>template</code>, and <code>updateStrategy</code>.</p>

<p>You issue happening because Fabric trying to update values which is impossible to update.</p>

<p>The only thing you can do is carefully prepare a new <code>statefulSet</code> object which will have a same name as old but contain only values which you can update. </p>

<p>Alternative way is to delete old <code>statefulSet</code> before upload a new one with a same name.</p>

<p>Also, try to use a Kubernetes version upper 1.9 if you don't, because <code>statefulSet</code> is officially stable only in 1.9 and above.</p>

<p>BTW, here is a <a href="https://github.com/fabric8io/kubernetes-client/issues/931" rel="noreferrer">bug</a> in Fabric's GitHub which can effect your code.</p>
