Recently, I’m developing operators using CRD/CR.
CRD spec supports default values, but CRD status does not specify default values.
Does CRD status not originally support the default value?
Example
I thought that this would set the default value of status.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: testcrds.foo.bar.com
spec:
group: foo.bar.com
versions:
- name: v1alpha
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
required:
- "selector"
properties:
selector:
type: object
description: "label selector for selecting resources"
additionalProperties:
type: string
target:
type: string
description: "target resources"
default: "pod" # This value is set to default value
status:
type: object
properties:
powerStatus:
type: string
default: "OFF" # I want to set default power status !
subresources:
status: { }
additionalPrinterColumns:
- name: "powerStatus"
type: string
description: "ON/OFF Power Status"
jsonPath: .status.powerStatus
scope: Namespaced
names:
plural: testcrds
singular: testcrd
kind: TestCrd
shortNames:
- tcrd
But it doesn’t work properly like in the picture.
Cluster information:
Kubernetes version: v1.22.2
Cloud being used: -
Installation method: I use minikube (v1.23.2)
Host OS: Mac (Not M1)