From 99c6d2125c4fde0840dd6cc656d02a0e9b0e0a92 Mon Sep 17 00:00:00 2001 From: Tim Usner Date: Tue, 24 Aug 2021 15:10:36 +0200 Subject: [PATCH 1/2] Fix CRD manifests --- kubernetes/crds/machine.sapcloud.io_machineclasses.yaml | 1 + kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml | 2 ++ kubernetes/crds/machine.sapcloud.io_machines.yaml | 3 ++- kubernetes/crds/machine.sapcloud.io_machinesets.yaml | 2 ++ pkg/apis/machine/v1alpha1/machine_types.go | 3 ++- pkg/apis/machine/v1alpha1/machineclass_types.go | 1 + pkg/apis/machine/v1alpha1/shared_types.go | 1 + pkg/openapi/openapi_generated.go | 2 +- 8 files changed, 12 insertions(+), 3 deletions(-) diff --git a/kubernetes/crds/machine.sapcloud.io_machineclasses.yaml b/kubernetes/crds/machine.sapcloud.io_machineclasses.yaml index 9a2099b67..467ef109e 100644 --- a/kubernetes/crds/machine.sapcloud.io_machineclasses.yaml +++ b/kubernetes/crds/machine.sapcloud.io_machineclasses.yaml @@ -56,6 +56,7 @@ spec: providerSpec: description: Provider-specific configuration to use during node creation. type: object + x-kubernetes-preserve-unknown-fields: true secretRef: description: SecretRef stores the necessary secrets such as credentials or userdata. diff --git a/kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml b/kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml index 8a5f5c207..24b5bfd2c 100644 --- a/kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml +++ b/kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml @@ -204,6 +204,7 @@ spec: metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' type: object + x-kubernetes-preserve-unknown-fields: true spec: description: 'Specification of the desired behavior of the machine. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status' @@ -250,6 +251,7 @@ spec: properties: metadata: type: object + x-kubernetes-preserve-unknown-fields: true spec: description: NodeSpec describes the attributes that a node is created with. diff --git a/kubernetes/crds/machine.sapcloud.io_machines.yaml b/kubernetes/crds/machine.sapcloud.io_machines.yaml index be3ed63d0..14e4e3fd0 100644 --- a/kubernetes/crds/machine.sapcloud.io_machines.yaml +++ b/kubernetes/crds/machine.sapcloud.io_machines.yaml @@ -19,7 +19,7 @@ spec: - name: v1alpha1 schema: openAPIV3Schema: - description: Machine TODO + description: Machine is the representation of a physical or virtual machine. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -76,6 +76,7 @@ spec: properties: metadata: type: object + x-kubernetes-preserve-unknown-fields: true spec: description: NodeSpec describes the attributes that a node is created with. diff --git a/kubernetes/crds/machine.sapcloud.io_machinesets.yaml b/kubernetes/crds/machine.sapcloud.io_machinesets.yaml index d3ddcaa9b..55222d45e 100644 --- a/kubernetes/crds/machine.sapcloud.io_machinesets.yaml +++ b/kubernetes/crds/machine.sapcloud.io_machinesets.yaml @@ -128,6 +128,7 @@ spec: metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata' type: object + x-kubernetes-preserve-unknown-fields: true spec: description: 'Specification of the desired behavior of the machine. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status' @@ -174,6 +175,7 @@ spec: properties: metadata: type: object + x-kubernetes-preserve-unknown-fields: true spec: description: NodeSpec describes the attributes that a node is created with. diff --git a/pkg/apis/machine/v1alpha1/machine_types.go b/pkg/apis/machine/v1alpha1/machine_types.go index a311d2f87..5a9e3c52a 100644 --- a/pkg/apis/machine/v1alpha1/machine_types.go +++ b/pkg/apis/machine/v1alpha1/machine_types.go @@ -32,7 +32,7 @@ import ( // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// Machine TODO +// Machine is the representation of a physical or virtual machine. type Machine struct { // ObjectMeta for machine object metav1.ObjectMeta `json:"metadata,omitempty"` @@ -81,6 +81,7 @@ type ClassSpec struct { // NodeTemplateSpec describes the data a node should have when created from a template type NodeTemplateSpec struct { + // +kubebuilder:validation:XPreserveUnknownFields // +optional metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/pkg/apis/machine/v1alpha1/machineclass_types.go b/pkg/apis/machine/v1alpha1/machineclass_types.go index 905835ad7..3682ab812 100644 --- a/pkg/apis/machine/v1alpha1/machineclass_types.go +++ b/pkg/apis/machine/v1alpha1/machineclass_types.go @@ -37,6 +37,7 @@ type MachineClass struct { metav1.TypeMeta `json:",inline"` // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +kubebuilder:validation:XPreserveUnknownFields // Provider-specific configuration to use during node creation. ProviderSpec runtime.RawExtension `json:"providerSpec"` // SecretRef stores the necessary secrets such as credentials or userdata. diff --git a/pkg/apis/machine/v1alpha1/shared_types.go b/pkg/apis/machine/v1alpha1/shared_types.go index d1d56f6ab..c5737c45b 100644 --- a/pkg/apis/machine/v1alpha1/shared_types.go +++ b/pkg/apis/machine/v1alpha1/shared_types.go @@ -24,6 +24,7 @@ import ( // MachineTemplateSpec describes the data a machine should have when created from a template type MachineTemplateSpec struct { + // +kubebuilder:validation:XPreserveUnknownFields // Standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata // +optional diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go index 125b1d120..e34d4e795 100644 --- a/pkg/openapi/openapi_generated.go +++ b/pkg/openapi/openapi_generated.go @@ -2309,7 +2309,7 @@ func schema_pkg_apis_machine_v1alpha1_Machine(ref common.ReferenceCallback) comm return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "Machine TODO", + Description: "Machine is the representation of a physical or virtual machine.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "metadata": { From 4bb8db0636bbc35bfaa7e32e5fdf481ae746d2fb Mon Sep 17 00:00:00 2001 From: Tim Usner Date: Tue, 24 Aug 2021 15:38:02 +0200 Subject: [PATCH 2/2] Add additional printer columns --- kubernetes/crds/machine.sapcloud.io_machines.yaml | 13 ++++++++++++- pkg/apis/machine/v1alpha1/machine_types.go | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/kubernetes/crds/machine.sapcloud.io_machines.yaml b/kubernetes/crds/machine.sapcloud.io_machines.yaml index 14e4e3fd0..80c1839d3 100644 --- a/kubernetes/crds/machine.sapcloud.io_machines.yaml +++ b/kubernetes/crds/machine.sapcloud.io_machines.yaml @@ -16,7 +16,18 @@ spec: singular: machine scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - description: Current status of the machine. + jsonPath: .status.currentStatus.phase + name: Status + type: string + - description: |- + CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. + Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 schema: openAPIV3Schema: description: Machine is the representation of a physical or virtual machine. diff --git a/pkg/apis/machine/v1alpha1/machine_types.go b/pkg/apis/machine/v1alpha1/machine_types.go index 5a9e3c52a..32d281272 100644 --- a/pkg/apis/machine/v1alpha1/machine_types.go +++ b/pkg/apis/machine/v1alpha1/machine_types.go @@ -31,6 +31,8 @@ import ( // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.currentStatus.phase`,description="Current status of the machine." +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" // Machine is the representation of a physical or virtual machine. type Machine struct {