<p>I have a very big issue. We have a large number of deployments for a component which up until now were using the RollingUpdate deployment strategy type.</p>
<pre><code>spec:
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
</code></pre>
<p>Now a new design decision needs us to move this to a <code>Recreate</code> strategy, which would be fairly easy if we could just write a shell script to call <code>kubectl patch</code> and use the <code>$retainKeys</code> method <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#use-strategic-merge-patch-to-update-a-deployment-using-the-retainkeys-strategy" rel="nofollow noreferrer">described in the docs</a>.</p>
<p>However, we use a custom tool written in Golang to manage our gazillion deployments and we'd like to integrate this into our regular update cycle and avoid this hack. Therefore, I've changed the code to look like this:</p>
<pre><code>deploy := &amp;appsv1.Deployment{
        Spec: appsv1.DeploymentSpec{
            Strategy: appsv1.DeploymentStrategy{
                Type: appsv1.RecreateDeploymentStrategyType,
            },
</code></pre>
<p>Obviously, when we run the update procedure, the tool fails with the following error:</p>
<pre><code>Error updating *v1.Deployment Deployment.apps &quot;cluster-agent&quot; is invalid: spec.strategy.rollingUpdate: Forbidden: may not be specified when strategy `type` is 'Recreate'
</code></pre>
<p>According to the above link, the <code>retainKeys</code> trick has to be used but I have not managed to find out how that can be done from within Golang.</p>
<p>I can see in the k8s api sources that the patch strategy supports the retainKeys method:</p>
<pre><code>Strategy DeploymentStrategy `json:&quot;strategy,omitempty&quot; patchStrategy:&quot;retainKeys&quot;
</code></pre>
<p>But would someone be so kind as to let me know how can I specify the <code>retainKeys</code> list within my Golang structs/code? Thank you very much!</p>

<p>Latest update from this <a href="https://github.com/gimlet-io/onechart/issues/35" rel="nofollow noreferrer">issue</a> works</p>
<pre><code>  strategy:
    rollingUpdate: null
    type: Recreate
</code></pre>
