From 94600f6155e6817ba33a8a403ccaf074a7de5f50 Mon Sep 17 00:00:00 2001 From: Danil-Grigorev Date: Mon, 26 Aug 2024 17:18:30 +0200 Subject: [PATCH] Add API types per proposal Signed-off-by: Danil-Grigorev --- ...er-turtles-exp-etcdrestore-components.yaml | 245 +++++++++++++++++- ...s-capi.cattle.io_etcdmachinesnapshots.yaml | 125 ++++++++- ...s-capi.cattle.io_etcdsnapshotrestores.yaml | 124 ++++++++- ...tle.io_rke2etcdmachinesnapshotconfigs.yaml | 200 ++++++++++++++ .../api/v1alpha1/etcdmachinesnapshot_types.go | 28 +- .../etcdmachinesnapshotconfig_types.go | 69 +++++ .../api/v1alpha1/etcdsnapshotrestore_types.go | 32 ++- .../api/v1alpha1/zz_generated.deepcopy.go | 133 +++++++++- 8 files changed, 928 insertions(+), 28 deletions(-) create mode 100644 config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_rke2etcdmachinesnapshotconfigs.yaml create mode 100644 exp/etcdrestore/api/v1alpha1/etcdmachinesnapshotconfig_types.go diff --git a/charts/rancher-turtles/templates/rancher-turtles-exp-etcdrestore-components.yaml b/charts/rancher-turtles/templates/rancher-turtles-exp-etcdrestore-components.yaml index 7d4506525..11433e8ca 100644 --- a/charts/rancher-turtles/templates/rancher-turtles-exp-etcdrestore-components.yaml +++ b/charts/rancher-turtles/templates/rancher-turtles-exp-etcdrestore-components.yaml @@ -38,18 +38,131 @@ spec: metadata: type: object spec: - description: EtcdMachineSnapshotSpec defines the desired state of EtcdMachineSnapshot. + description: EtcdMachineSnapshotSpec defines the desired state of EtcdMachineSnapshot properties: - foo: + clusterName: + type: string + configRef: + description: |- + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. + + + Instead of using this type, create a locally provided and used type that is well-focused on your reference. + For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: |- + If referring to a piece of an object instead of an entire object, this string + should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within a pod, this would take on a value like: + "spec.containers{name}" (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" (container with + index 2 in this pod). This syntax is chosen only to have some well-defined way of + referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + type: string + resourceVersion: + description: |- + Specific resourceVersion to which this reference is made, if any. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + uid: + description: |- + UID of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + type: string + type: object + x-kubernetes-map-type: atomic + machineName: type: string required: - - foo + - clusterName + - configRef + - machineName type: object status: default: {} - description: EtcdMachineSnapshotStatus defines observed state of EtcdMachineSnapshot. + description: EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore properties: - bar: + conditions: + description: Conditions provide observations of the operational state + of a Cluster API resource. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + phase: + description: ETCDSnapshotPhase is a string representation of the phase + of the etcd snapshot type: string required: - bar @@ -101,16 +214,132 @@ spec: spec: description: EtcdSnapshotRestoreSpec defines the desired state of EtcdSnapshotRestore. properties: - foo: + clusterName: + type: string + configRef: + description: |- + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. + + + Instead of using this type, create a locally provided and used type that is well-focused on your reference. + For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: |- + If referring to a piece of an object instead of an entire object, this string + should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within a pod, this would take on a value like: + "spec.containers{name}" (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" (container with + index 2 in this pod). This syntax is chosen only to have some well-defined way of + referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + type: string + resourceVersion: + description: |- + Specific resourceVersion to which this reference is made, if any. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + uid: + description: |- + UID of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + type: string + type: object + x-kubernetes-map-type: atomic + etcdMachineSnapshotName: type: string + ttlSecondsAfterFinished: + type: integer required: - - foo + - clusterName + - configRef + - etcdMachineSnapshotName + - ttlSecondsAfterFinished type: object status: default: {} description: EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore. properties: - bar: + conditions: + description: Conditions provide observations of the operational state + of a Cluster API resource. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + phase: + description: ETCDSnapshotPhase is a string representation of the phase + of the etcd snapshot type: string required: - bar diff --git a/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_etcdmachinesnapshots.yaml b/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_etcdmachinesnapshots.yaml index fad2ef4f8..a0a99b864 100644 --- a/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_etcdmachinesnapshots.yaml +++ b/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_etcdmachinesnapshots.yaml @@ -38,20 +38,131 @@ spec: metadata: type: object spec: - description: EtcdMachineSnapshotSpec defines the desired state of EtcdMachineSnapshot. + description: EtcdMachineSnapshotSpec defines the desired state of EtcdMachineSnapshot properties: - foo: + clusterName: + type: string + configRef: + description: |- + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. + + + Instead of using this type, create a locally provided and used type that is well-focused on your reference. + For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: |- + If referring to a piece of an object instead of an entire object, this string + should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within a pod, this would take on a value like: + "spec.containers{name}" (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" (container with + index 2 in this pod). This syntax is chosen only to have some well-defined way of + referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + type: string + resourceVersion: + description: |- + Specific resourceVersion to which this reference is made, if any. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + uid: + description: |- + UID of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + type: string + type: object + x-kubernetes-map-type: atomic + machineName: type: string required: - - foo + - clusterName + - configRef + - machineName type: object status: - description: EtcdMachineSnapshotStatus defines observed state of EtcdMachineSnapshot. + description: EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore properties: - bar: + conditions: + description: Conditions provide observations of the operational state + of a Cluster API resource. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + phase: + description: ETCDSnapshotPhase is a string representation of the phase + of the etcd snapshot type: string - required: - - bar type: object type: object served: true diff --git a/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_etcdsnapshotrestores.yaml b/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_etcdsnapshotrestores.yaml index 0b944eff1..7e820575c 100644 --- a/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_etcdsnapshotrestores.yaml +++ b/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_etcdsnapshotrestores.yaml @@ -40,18 +40,132 @@ spec: spec: description: EtcdSnapshotRestoreSpec defines the desired state of EtcdSnapshotRestore. properties: - foo: + clusterName: type: string + configRef: + description: |- + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. + + + Instead of using this type, create a locally provided and used type that is well-focused on your reference. + For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: |- + If referring to a piece of an object instead of an entire object, this string + should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within a pod, this would take on a value like: + "spec.containers{name}" (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" (container with + index 2 in this pod). This syntax is chosen only to have some well-defined way of + referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + type: string + resourceVersion: + description: |- + Specific resourceVersion to which this reference is made, if any. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + uid: + description: |- + UID of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + type: string + type: object + x-kubernetes-map-type: atomic + etcdMachineSnapshotName: + type: string + ttlSecondsAfterFinished: + type: integer required: - - foo + - clusterName + - configRef + - etcdMachineSnapshotName + - ttlSecondsAfterFinished type: object status: description: EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore. properties: - bar: + conditions: + description: Conditions provide observations of the operational state + of a Cluster API resource. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + phase: + description: ETCDSnapshotPhase is a string representation of the phase + of the etcd snapshot type: string - required: - - bar type: object type: object served: true diff --git a/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_rke2etcdmachinesnapshotconfigs.yaml b/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_rke2etcdmachinesnapshotconfigs.yaml new file mode 100644 index 000000000..d4d868e4b --- /dev/null +++ b/config/exp/etcdrestore/crd/bases/turtles-capi.cattle.io_rke2etcdmachinesnapshotconfigs.yaml @@ -0,0 +1,200 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: rke2etcdmachinesnapshotconfigs.turtles-capi.cattle.io +spec: + group: turtles-capi.cattle.io + names: + kind: RKE2EtcdMachineSnapshotConfig + listKind: RKE2EtcdMachineSnapshotConfigList + plural: rke2etcdmachinesnapshotconfigs + singular: rke2etcdmachinesnapshotconfig + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: RKE2EtcdMachineSnapshotConfig is the config for the RKE2EtcdMachineSnapshotConfig + API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: RKE2EtcdMachineSnapshotConfigSpec defines the desired state + of RKE2EtcdMachineSnapshotConfig + properties: + local: + properties: + dataDir: + type: string + required: + - dataDir + type: object + manual: + type: boolean + s3: + properties: + bucket: + type: string + endpoint: + type: string + endpointCAsecret: + description: |- + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. + + + Instead of using this type, create a locally provided and used type that is well-focused on your reference. + For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: |- + If referring to a piece of an object instead of an entire object, this string + should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within a pod, this would take on a value like: + "spec.containers{name}" (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" (container with + index 2 in this pod). This syntax is chosen only to have some well-defined way of + referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + type: string + resourceVersion: + description: |- + Specific resourceVersion to which this reference is made, if any. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + uid: + description: |- + UID of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + type: string + type: object + x-kubernetes-map-type: atomic + enforceSslVerify: + type: boolean + folder: + type: string + region: + type: string + s3CredentialSecret: + description: |- + ObjectReference contains enough information to let you inspect or modify the referred object. + --- + New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs. + 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage. + 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular + restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted". + Those cannot be well described when embedded. + 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen. + 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity + during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple + and the version of the actual struct is irrelevant. + 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type + will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control. + + + Instead of using this type, create a locally provided and used type that is well-focused on your reference. + For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 . + properties: + apiVersion: + description: API version of the referent. + type: string + fieldPath: + description: |- + If referring to a piece of an object instead of an entire object, this string + should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. + For example, if the object reference is to a container within a pod, this would take on a value like: + "spec.containers{name}" (where "name" refers to the name of the container that triggered + the event) or if no container name is specified "spec.containers[2]" (container with + index 2 in this pod). This syntax is chosen only to have some well-defined way of + referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. + type: string + kind: + description: |- + Kind of the referent. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + description: |- + Namespace of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + type: string + resourceVersion: + description: |- + Specific resourceVersion to which this reference is made, if any. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + uid: + description: |- + UID of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids + type: string + type: object + x-kubernetes-map-type: atomic + required: + - endpoint + - s3CredentialSecret + type: object + required: + - local + - manual + - s3 + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/exp/etcdrestore/api/v1alpha1/etcdmachinesnapshot_types.go b/exp/etcdrestore/api/v1alpha1/etcdmachinesnapshot_types.go index a20730d2d..738d3232e 100644 --- a/exp/etcdrestore/api/v1alpha1/etcdmachinesnapshot_types.go +++ b/exp/etcdrestore/api/v1alpha1/etcdmachinesnapshot_types.go @@ -18,16 +18,36 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + corev1 "k8s.io/api/core/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +// ETCDSnapshotPhase is a string representation of the phase of the etcd snapshot +type ETCDSnapshotPhase string + +const ( + // ETCDSnapshotPhasePending is the phase when the snapshot was submitted but was not registered + ETCDSnapshotPhasePending ETCDSnapshotPhase = "Pending" + // ETCDSnapshotPhaseRunning is the phase when the snapshot creation has started + ETCDSnapshotPhaseRunning ETCDSnapshotPhase = "Running" + // ETCDSnapshotPhaseFailed is the phase when the snapshot creation has failed + ETCDSnapshotPhaseFailed ETCDSnapshotPhase = "Failed" + // ETCDSnapshotPhaseDone is the phase when the snapshot creation has finished + ETCDSnapshotPhaseDone ETCDSnapshotPhase = "Done" ) -// EtcdMachineSnapshotSpec defines the desired state of EtcdMachineSnapshot. +// EtcdMachineSnapshotSpec defines the desired state of EtcdMachineSnapshot type EtcdMachineSnapshotSpec struct { - Foo string `json:"foo"` + ClusterName string `json:"clusterName"` + MachineName string `json:"machineName"` + ConfigRef corev1.ObjectReference `json:"configRef"` } -// EtcdMachineSnapshotStatus defines observed state of EtcdMachineSnapshot. +// EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore type EtcdMachineSnapshotStatus struct { - Bar string `json:"bar"` + Phase ETCDSnapshotPhase `json:"phase,omitempty"` + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // EtcdMachineSnapshot is the Schema for the EtcdMachineSnapshot API. diff --git a/exp/etcdrestore/api/v1alpha1/etcdmachinesnapshotconfig_types.go b/exp/etcdrestore/api/v1alpha1/etcdmachinesnapshotconfig_types.go new file mode 100644 index 000000000..415e46f16 --- /dev/null +++ b/exp/etcdrestore/api/v1alpha1/etcdmachinesnapshotconfig_types.go @@ -0,0 +1,69 @@ +/* +Copyright © 2023 - 2024 SUSE LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// RKE2EtcdMachineSnapshotConfigSpec defines the desired state of RKE2EtcdMachineSnapshotConfig +type RKE2EtcdMachineSnapshotConfigSpec struct { + Manual bool `json:"manual"` + S3 S3Config `json:"s3"` + Local LocalConfig `json:"local"` +} + +type LocalConfig struct { + DataDir string `json:"dataDir"` +} + +type S3Config struct { + Endpoint string `json:"endpoint"` + EndpointCASecret *corev1.ObjectReference `json:"endpointCAsecret,omitempty"` + EnforceSSLVerify bool `json:"enforceSslVerify,omitempty"` + S3CredentialSecret corev1.ObjectReference `json:"s3CredentialSecret"` + Bucket string `json:"bucket,omitempty"` + Region string `json:"region,omitempty"` + Folder string `json:"folder,omitempty"` +} + +// RKE2EtcdMachineSnapshotConfig is the schema for the snapshot config. +// +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status + +// RKE2EtcdMachineSnapshotConfig is the config for the RKE2EtcdMachineSnapshotConfig API +type RKE2EtcdMachineSnapshotConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec RKE2EtcdMachineSnapshotConfigSpec `json:"spec,omitempty"` +} + +//+kubebuilder:object:root=true + +// RKE2EtcdMachineSnapshotConfigList contains a list of RKE2EtcdMachineSnapshotConfigs. +type RKE2EtcdMachineSnapshotConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []EtcdSnapshotRestore `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &RKE2EtcdMachineSnapshotConfig{}, &RKE2EtcdMachineSnapshotConfigList{}) +} diff --git a/exp/etcdrestore/api/v1alpha1/etcdsnapshotrestore_types.go b/exp/etcdrestore/api/v1alpha1/etcdsnapshotrestore_types.go index c71686a6b..3f053305e 100644 --- a/exp/etcdrestore/api/v1alpha1/etcdsnapshotrestore_types.go +++ b/exp/etcdrestore/api/v1alpha1/etcdsnapshotrestore_types.go @@ -17,17 +17,45 @@ limitations under the License. package v1alpha1 import ( + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +// ETCDSnapshotPhase is a string representation of the phase of the etcd snapshot +type ETCDSnapshotRestorePhase string + +const ( + // ETCDSnapshotRestorePhasePending is the phase when the snapshot was submitted but was not registered + ETCDSnapshotRestorePhasePending ETCDSnapshotRestorePhase = "Pending" + // ETCDSnapshotRestorePhaseStarted is the phase when the snapshot creation has started + ETCDSnapshotRestorePhaseStarted ETCDSnapshotRestorePhase = "Started" + // ETCDSnapshotRestorePhaseShutdown is the phase when the etcd cluster is being shutdown + ETCDSnapshotRestorePhaseShutdown ETCDSnapshotRestorePhase = "Shutdown" + // ETCDSnapshotRestorePhaseRunning is the phase when the snapshot is being restored + ETCDSnapshotRestorePhaseRunning ETCDSnapshotRestorePhase = "Running" + // ETCDSnapshotRestorePhaseAgentRestart is the phase when the cluster is being restarted + ETCDSnapshotRestorePhaseAgentRestart ETCDSnapshotRestorePhase = "Restart" + // ETCDSnapshotRestorePhaseJoinAgents is the phase when the snapshot creation has finished + ETCDSnapshotRestorePhaseJoinAgents ETCDSnapshotRestorePhase = "Joining" + // ETCDSnapshotRestorePhaseFailed is the phase when the snapshot creation has failed + ETCDSnapshotRestorePhaseFailed ETCDSnapshotRestorePhase = "Failed" + // ETCDSnapshotRestorePhaseFinished is the phase when the snapshot creation has finished + ETCDSnapshotRestorePhaseFinished ETCDSnapshotRestorePhase = "Done" ) // EtcdSnapshotRestoreSpec defines the desired state of EtcdSnapshotRestore. type EtcdSnapshotRestoreSpec struct { - Foo string `json:"foo"` + ClusterName string `json:"clusterName"` + EtcdMachineSnapshotName string `json:"etcdMachineSnapshotName"` + TTLSecondsAfterFinished int `json:"ttlSecondsAfterFinished"` + ConfigRef corev1.ObjectReference `json:"configRef"` } // EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore. type EtcdSnapshotRestoreStatus struct { - Bar string `json:"bar"` + Phase ETCDSnapshotPhase `json:"phase,omitempty"` + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // EtcdSnapshotRestore is the schema for the EtcdSnapshotRestore API. diff --git a/exp/etcdrestore/api/v1alpha1/zz_generated.deepcopy.go b/exp/etcdrestore/api/v1alpha1/zz_generated.deepcopy.go index c2c3c9ce5..012e26081 100644 --- a/exp/etcdrestore/api/v1alpha1/zz_generated.deepcopy.go +++ b/exp/etcdrestore/api/v1alpha1/zz_generated.deepcopy.go @@ -21,7 +21,9 @@ limitations under the License. package v1alpha1 import ( + "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/cluster-api/api/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -30,7 +32,7 @@ func (in *EtcdMachineSnapshot) DeepCopyInto(out *EtcdMachineSnapshot) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EtcdMachineSnapshot. @@ -86,6 +88,7 @@ func (in *EtcdMachineSnapshotList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EtcdMachineSnapshotSpec) DeepCopyInto(out *EtcdMachineSnapshotSpec) { *out = *in + out.ConfigRef = in.ConfigRef } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EtcdMachineSnapshotSpec. @@ -101,6 +104,13 @@ func (in *EtcdMachineSnapshotSpec) DeepCopy() *EtcdMachineSnapshotSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EtcdMachineSnapshotStatus) DeepCopyInto(out *EtcdMachineSnapshotStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EtcdMachineSnapshotStatus. @@ -119,7 +129,7 @@ func (in *EtcdSnapshotRestore) DeepCopyInto(out *EtcdSnapshotRestore) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EtcdSnapshotRestore. @@ -175,6 +185,7 @@ func (in *EtcdSnapshotRestoreList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EtcdSnapshotRestoreSpec) DeepCopyInto(out *EtcdSnapshotRestoreSpec) { *out = *in + out.ConfigRef = in.ConfigRef } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EtcdSnapshotRestoreSpec. @@ -190,6 +201,13 @@ func (in *EtcdSnapshotRestoreSpec) DeepCopy() *EtcdSnapshotRestoreSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EtcdSnapshotRestoreStatus) DeepCopyInto(out *EtcdSnapshotRestoreStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EtcdSnapshotRestoreStatus. @@ -201,3 +219,114 @@ func (in *EtcdSnapshotRestoreStatus) DeepCopy() *EtcdSnapshotRestoreStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LocalConfig) DeepCopyInto(out *LocalConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalConfig. +func (in *LocalConfig) DeepCopy() *LocalConfig { + if in == nil { + return nil + } + out := new(LocalConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RKE2EtcdMachineSnapshotConfig) DeepCopyInto(out *RKE2EtcdMachineSnapshotConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RKE2EtcdMachineSnapshotConfig. +func (in *RKE2EtcdMachineSnapshotConfig) DeepCopy() *RKE2EtcdMachineSnapshotConfig { + if in == nil { + return nil + } + out := new(RKE2EtcdMachineSnapshotConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RKE2EtcdMachineSnapshotConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RKE2EtcdMachineSnapshotConfigList) DeepCopyInto(out *RKE2EtcdMachineSnapshotConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]EtcdSnapshotRestore, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RKE2EtcdMachineSnapshotConfigList. +func (in *RKE2EtcdMachineSnapshotConfigList) DeepCopy() *RKE2EtcdMachineSnapshotConfigList { + if in == nil { + return nil + } + out := new(RKE2EtcdMachineSnapshotConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RKE2EtcdMachineSnapshotConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RKE2EtcdMachineSnapshotConfigSpec) DeepCopyInto(out *RKE2EtcdMachineSnapshotConfigSpec) { + *out = *in + in.S3.DeepCopyInto(&out.S3) + out.Local = in.Local +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RKE2EtcdMachineSnapshotConfigSpec. +func (in *RKE2EtcdMachineSnapshotConfigSpec) DeepCopy() *RKE2EtcdMachineSnapshotConfigSpec { + if in == nil { + return nil + } + out := new(RKE2EtcdMachineSnapshotConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *S3Config) DeepCopyInto(out *S3Config) { + *out = *in + if in.EndpointCASecret != nil { + in, out := &in.EndpointCASecret, &out.EndpointCASecret + *out = new(v1.ObjectReference) + **out = **in + } + out.S3CredentialSecret = in.S3CredentialSecret +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new S3Config. +func (in *S3Config) DeepCopy() *S3Config { + if in == nil { + return nil + } + out := new(S3Config) + in.DeepCopyInto(out) + return out +}