<p>I was searching for a way to remove a specific value from a list on a pod through a patch, specifically on the SecurityContext.Capabilities attribute. At first I came across the json patch remove limitation which requires an index but after some more digging I found the $deleteFromPrimitiveList directive used in the strategic patch type. Thing is this directive is not documented anywhere under the official documentation and only has a couple of hits in forums and the source code itself. This is what I ended up with which is working for me:</p>
<p>patch.yaml:</p>
<pre><code>spec:
  template:
    spec:
      containers:
      - name: test
        securityContext:
          capabilities:
            $deleteFromPrimitiveList/add: [&quot;SYS_RAWIO&quot;]
</code></pre>
<p>patch command:</p>
<pre><code>kubectl patch deployment test --patch=&quot;$(cat patch.json)&quot;
</code></pre>
<p>My question is, should I use this, is this officially supported? If so, is there a needed minimum cluster version?
and is there a reason its not documented anywhere?
Thanks</p>

Shlomi Wexler
<p>It seems to be officially supported, but not well documented.</p>
<p>The best documentation I could find was <a href="https://github.com/kubernetes/community/blob/94b696bef96aefba2ca9bf97029694565a84495e/contributors/devel/sig-api-machinery/strategic-merge-patch.md" rel="nofollow noreferrer">a markdown file in the community repo</a> that covers this and other strategic merge patch directives.</p>
<p>This documentation specifically calls out backward compatibility:</p>
<blockquote>
<p>Changes to the strategic merge patch must be backwards compatible such that patch requests valid in previous versions continue to be valid. That is, old patch formats sent by old clients to new servers with must continue to function correctly.</p>
</blockquote>
