Kubernetes: Is it possible to mutate the status subresources in the mutation admission webhooks?

1/2/2020

I am writing the mutate and validate admission webhooks for the CRDs. I am using kubebuilder to setup the CRDs. Spec and status subresources are behaving correctly.

As a part of mutation, I am having a requirement where I need to update the status subresources.

For example, Exam is my CR and status.status is the Exam status. I want to set the status to "NotDone" in mutation.

I tried following approaches

  1. Json patching approach explained here https://banzaicloud.com/blog/k8s-admission-webhooks/ This gives error that the custom resource not found. i.e. it expects the custom resource for which we are updating the status.
  2. Get and update status using go client https://book-v1.book.kubebuilder.io/basics/status_subresource.html

but none of the approach worked for me.

I am wondering if it is even possible to update the status subresources in the admission webhooks?

-- Yudi
kubebuilder
kubernetes

0 Answers