<p>I am creating Kubernetes POD with Golang. Iam trying to set DeletionGracePeriodSeconds but after creating pod, the pod has 30 in this field while I am setting 25.
Name of the pod is OK, so after creating the POD it has name that I assigned in code.</p>
<pre><code>func setupPod(client *Client, ns string, name string, labels map[string]string) (*v1.Pod, error) {
     seconds := func(i int64) *int64 { return &amp;i }(25)
     pod := &amp;v1.Pod{}
     pod.Name = name
     pod.Namespace = ns
     pod.SetDeletionGracePeriodSeconds(seconds) //it is 25 seconds under debugger
     pod.DeletionGracePeriodSeconds = seconds
     pod.Spec.Containers = []v1.Container{v1.Container{Name: &quot;ubuntu&quot;, Image: &quot;ubuntu&quot;, Command: []string{&quot;sleep&quot;, &quot;30&quot;}}}
     pod.Spec.NodeName = &quot;node1&quot;
     if labels != nil {
        pod.Labels = labels
     }
     _, err := client.client.CoreV1().Pods(ns).Create(client.context, pod, metav1.CreateOptions{})
     return pod, err
}
</code></pre>

michealAtmi
<p><code>DeletionGracePeriodSeconds</code> is read-only and hence you can not change it. You should instead set <code>terminationGracePeriodSeconds</code> and kubernetes will set the <code>DeletionGracePeriodSeconds</code> accordingly. You can verify that by getting the value and printing it.</p>
<p>From the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/" rel="nofollow noreferrer">API docs</a></p>
<blockquote>
<p>Number of seconds allowed for this object to gracefully terminate
before it will be removed from the system. Only set when
deletionTimestamp is also set. May only be shortened. <strong>Read-only</strong>.</p>
</blockquote>
<pre><code>podSpec := &amp;v1.Pod{
        Spec: v1.PodSpec{
            TerminationGracePeriodSeconds: &lt;Your-Grace-Period&gt;
        },
    }

    _, err = clientset.CoreV1().Pods(&quot;namespacename&quot;).Create(context.TODO(), podSpec, metav1.CreateOptions{})
</code></pre>
