<p>I am trying to create new patches using the golang kubernetes sdk and am running into problems removing environmental variables from my containers by using a new deployment that doesn't include them.  I've been reading that when doing a new deployment you need to set the new environmental variable to null but how the kubernetes env structs are set up, they use a string field, you cannot set this as null only as &quot;&quot; which just ends up being omitted.  Trying to set this as empty string just results in the previous env value persisting and not including it does the same behavior.</p>
<p>Does anyone know the proper way to delete environmental variables from pods using patch and golang?</p>

rrabinowitz
<p>containers.env has type list. So you can use [] for empty list</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      run: nginx
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        env: []
        resources: {}
status: {}
</code></pre>
