How to get default values for attributs of Kubernetes resources?

213 views Asked by At

I am trying to put together a diff tool to get the difference between the manifest of a Helm resource and the resources live on the system (to spot added keys to configmaps, different labels and annotations, etc). The outputs of the live resources show all the fields, with their defaults (for instance a Deployment resource will show progressDeadlineSeconds: 600), so, to create a clean diff, I would like to avoid to compare the attributes set to a default value.

With Kubernetes CRD it is possible to get the default values of objects attribute. For example:

kubectl get crd postgresclusters.postgres-operator.crunchydata.com -o yaml | grep -C2 default:
                            type: string
                          enabled:
                            default: false
                            description: Whether or not in-place pgBackRest restores
                              are enabled for this PostgresCluster.
--
                        type: object
                      stanza:
                        default: db
                        description: The name of an existing pgBackRest stanza to
                          use as the data source for the new PostgresCluster. Defaults
...

Is it possible to get the same information for builtin objects, such as Deployment?

It is possible to query kinds information from OpenAPI, for instance, the fields of a Deployments are visible in:

kubectl get --raw /openapi/v2  | jq '.definitions."io.k8s.api.apps.v1.DeploymentSpec".properties'

however on OpenAPI the fields deafults are not available (neither for CRDs nor for builtin kinds).

Is it possible to get the same information you may get about CRDs for builtin objects?

0

There are 0 answers