From a699ef2093d2111c5ad713a5621274e8e64af7f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ho=C3=9F?= Date: Sun, 4 Feb 2024 12:05:14 +0100 Subject: [PATCH] add aws/zone-aware-controllers-for-k8s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sebastian Hoß --- .reuse/dep5 | 4 + code-generator/src/catalog.rs | 8 ++ .../v1/zoneawareupdates.yaml | 88 +++++++++++++ .../v1/zonedisruptionbudgets.yaml | 123 ++++++++++++++++++ kube-custom-resources-rs/Cargo.toml | 1 + kube-custom-resources-rs/src/lib.rs | 8 ++ .../src/zonecontrol_k8s_aws/mod.rs | 1 + .../src/zonecontrol_k8s_aws/v1/mod.rs | 2 + .../v1/zoneawareupdates.rs | 59 +++++++++ .../v1/zonedisruptionbudgets.rs | 76 +++++++++++ 10 files changed, 370 insertions(+) create mode 100644 crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zoneawareupdates.yaml create mode 100644 crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zonedisruptionbudgets.yaml create mode 100644 kube-custom-resources-rs/src/zonecontrol_k8s_aws/mod.rs create mode 100644 kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/mod.rs create mode 100644 kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/zoneawareupdates.rs create mode 100644 kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/zonedisruptionbudgets.rs diff --git a/.reuse/dep5 b/.reuse/dep5 index 17769a6ad..13e902cc3 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -95,6 +95,10 @@ Files: crd-catalog/aws/aws-app-mesh-controller-for-k8/* Copyright: The aws/aws-app-mesh-controller-for-k8 Authors License: Apache-2.0 +Files: crd-catalog/aws/zone-aware-controllers-for-k8s/* +Copyright: The aws/zone-aware-controllers-for-k8s Authors +License: Apache-2.0 + Files: crd-catalog/aws-controllers-k8s/apigatewayv2-controller/* Copyright: The aws-controllers-k8s/apigatewayv2-controller Authors License: Apache-2.0 diff --git a/code-generator/src/catalog.rs b/code-generator/src/catalog.rs index 7c3063be2..8b7e43a26 100644 --- a/code-generator/src/catalog.rs +++ b/code-generator/src/catalog.rs @@ -241,6 +241,14 @@ pub const CRD_V1_SOURCES: &'static [UpstreamSource] = &[ "https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/config/crd/bases/appmesh.k8s.aws_virtualservices.yaml", ], }, + UpstreamSource { + project_name: "aws/zone-aware-controllers-for-k8s", + license: APACHE_V2, + urls: &[ + "https://github.com/aws/zone-aware-controllers-for-k8s/blob/main/config/crd/bases/zonecontrol.k8s.aws_zoneawareupdates.yaml", + "https://github.com/aws/zone-aware-controllers-for-k8s/blob/main/config/crd/bases/zonecontrol.k8s.aws_zonedisruptionbudgets.yaml", + ], + }, UpstreamSource { project_name: "aws-controllers-k8s/apigatewayv2-controller", license: APACHE_V2, diff --git a/crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zoneawareupdates.yaml b/crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zoneawareupdates.yaml new file mode 100644 index 000000000..2ba5ee3f7 --- /dev/null +++ b/crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zoneawareupdates.yaml @@ -0,0 +1,88 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.2 + name: zoneawareupdates.zonecontrol.k8s.aws +spec: + group: zonecontrol.k8s.aws + names: + kind: ZoneAwareUpdate + listKind: ZoneAwareUpdateList + plural: zoneawareupdates + shortNames: + - zau + singular: zoneawareupdate + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: ZoneAwareUpdate is the Schema for the zoneawareupdates 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: ZoneAwareUpdateSpec defines the desired state of ZoneAwareUpdate + properties: + dryRun: + description: Dryn-run mode that can be used to test the new controller before enable it + type: boolean + exponentialFactor: + default: '2.0' + description: The exponential growth rate in float string. Default value is 2.0. It's possible to disable exponential updates by setting the ExponentialFactor to 0. In this case, the number of pods updated at each step is defined only by the MaxUnavailable param. + type: string + ignoreAlarm: + description: Flag to ignore the PauseRolloutAlarm (default false) + type: boolean + maxUnavailable: + anyOf: + - type: integer + - type: string + description: Max number (or %) of pods that can be updated at the same time. + x-kubernetes-int-or-string: true + pauseRolloutAlarm: + description: CW alarm name used to pause/skip updates. Alarm should be on the same account and region. + type: string + statefulset: + description: The name of the StatefulSet for which the ZoneAwareUpdate applies to. + type: string + type: object + status: + description: ZoneAwareUpdateStatus defines the observed state of ZoneAwareUpdate + properties: + currentRevision: + description: CurrentRevision indicates the version of the StatefulSet used to generate Pods + type: string + deletedReplicas: + description: DeletedReplicas is the number of replicas deleted in the last reconcile loop. + format: int32 + type: integer + oldReplicas: + additionalProperties: + format: int32 + type: integer + description: OldReplicas is the number of Pods *per zone* in the CurrentRevision, when there is new UpdateRevision. It becomes zero for all zones when all pods are in the new revision. + type: object + pausedRollout: + description: PausedRollout indicates if the rollout was paused becaused the PauseRolloutAlarm is in alarm. + type: boolean + updateRevision: + description: UpdateRevision indicates the new version of the StatefulSet + type: string + updateStep: + description: UpdateStep is used to track the rollout progress. Everytime pods are deleted/updated this is increased. It becomes zero when all pods are in the new revision. + format: int32 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zonedisruptionbudgets.yaml b/crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zonedisruptionbudgets.yaml new file mode 100644 index 000000000..14cda13d1 --- /dev/null +++ b/crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zonedisruptionbudgets.yaml @@ -0,0 +1,123 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.2 + name: zonedisruptionbudgets.zonecontrol.k8s.aws +spec: + group: zonecontrol.k8s.aws + names: + kind: ZoneDisruptionBudget + listKind: ZoneDisruptionBudgetList + plural: zonedisruptionbudgets + shortNames: + - zdb + singular: zonedisruptionbudget + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: ZoneDisruptionBudget is the Schema for the zonedisruptionbudgets 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: ZoneDisruptionBudgetSpec defines the desired state of ZoneDisruptionBudget + properties: + dryRun: + description: Dryn-run mode that can be used to test the new controller before enable it + type: boolean + maxUnavailable: + anyOf: + - type: integer + - type: string + description: Evict pod specification is allowed if at most "maxUnavailable" pods selected by "selector" are unavailable in the same zone after the above operation for pod. Evictions are not allowed if there are unavailable pods in other zones. + x-kubernetes-int-or-string: true + selector: + description: Selector label query over pods managed by the budget + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + type: object + status: + description: ZoneDisruptionBudgetStatus defines the observed state of ZoneDisruptionBudget + properties: + currentHealthy: + additionalProperties: + format: int32 + type: integer + description: Current number of healthy pods per zone + type: object + currentUnhealthy: + additionalProperties: + format: int32 + type: integer + description: Current number of unhealthy pods per zone + type: object + desiredHealthy: + additionalProperties: + format: int32 + type: integer + description: Minimum desired number of healthy pods per zone + type: object + disruptedPods: + additionalProperties: + format: date-time + type: string + description: DisruptedPods contains information about pods whose eviction was processed by the API server eviction subresource handler but has not yet been observed by the ZoneDisruptionBudget controller. A pod will be in this map from the time when the API server processed the eviction request to the time when the pod is seen by ZDB controller as having been marked for deletion (or after a timeout). The key in the map is the name of the pod and the value is the time when the API server processed the eviction request. If the deletion didn't occur and a pod is still there it will be removed from the list automatically by ZoneDisruptionBudget controller after some time. + type: object + disruptionsAllowed: + additionalProperties: + format: int32 + type: integer + description: Number of pod disruptions that are currently allowed *per zone* + type: object + expectedPods: + additionalProperties: + format: int32 + type: integer + description: Total number of expected replicas per zone + type: object + observedGeneration: + description: Most recent generation observed when updating this ZDB status. DisruptionsAllowed and other status information is valid only if observedGeneration equals to ZDB's object generation. + format: int64 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/kube-custom-resources-rs/Cargo.toml b/kube-custom-resources-rs/Cargo.toml index 0ace9054f..6aae368b7 100644 --- a/kube-custom-resources-rs/Cargo.toml +++ b/kube-custom-resources-rs/Cargo.toml @@ -296,3 +296,4 @@ wgpolicyk8s_io = [] wildfly_org = [] work_karmada_io = [] workloads_kubeblocks_io = [] +zonecontrol_k8s_aws = [] diff --git a/kube-custom-resources-rs/src/lib.rs b/kube-custom-resources-rs/src/lib.rs index c3a3fc88b..0cd7b36e0 100644 --- a/kube-custom-resources-rs/src/lib.rs +++ b/kube-custom-resources-rs/src/lib.rs @@ -2375,6 +2375,12 @@ apiVersion `work.karmada.io/v1alpha2`: apiVersion `workloads.kubeblocks.io/v1alpha1`: - `ReplicatedStateMachine` + +## zonecontrol_k8s_aws + +apiVersion `zonecontrol.k8s.aws/v1`: +- `ZoneAwareUpdate` +- `ZoneDisruptionBudget` */ #[cfg(feature = "about_k8s_io")] @@ -2925,3 +2931,5 @@ pub mod wildfly_org; pub mod work_karmada_io; #[cfg(feature = "workloads_kubeblocks_io")] pub mod workloads_kubeblocks_io; +#[cfg(feature = "zonecontrol_k8s_aws")] +pub mod zonecontrol_k8s_aws; diff --git a/kube-custom-resources-rs/src/zonecontrol_k8s_aws/mod.rs b/kube-custom-resources-rs/src/zonecontrol_k8s_aws/mod.rs new file mode 100644 index 000000000..a3a6d96c3 --- /dev/null +++ b/kube-custom-resources-rs/src/zonecontrol_k8s_aws/mod.rs @@ -0,0 +1 @@ +pub mod v1; diff --git a/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/mod.rs b/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/mod.rs new file mode 100644 index 000000000..fa2be3eef --- /dev/null +++ b/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/mod.rs @@ -0,0 +1,2 @@ +pub mod zoneawareupdates; +pub mod zonedisruptionbudgets; diff --git a/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/zoneawareupdates.rs b/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/zoneawareupdates.rs new file mode 100644 index 000000000..7fb448b11 --- /dev/null +++ b/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/zoneawareupdates.rs @@ -0,0 +1,59 @@ +// WARNING: generated by kopium - manual changes will be overwritten +// kopium command: kopium --docs --filename=./crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zoneawareupdates.yaml --derive=Default --derive=PartialEq +// kopium version: 0.16.5 + +use kube::CustomResource; +use serde::{Serialize, Deserialize}; +use std::collections::BTreeMap; +use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString; + +/// ZoneAwareUpdateSpec defines the desired state of ZoneAwareUpdate +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)] +#[kube(group = "zonecontrol.k8s.aws", version = "v1", kind = "ZoneAwareUpdate", plural = "zoneawareupdates")] +#[kube(namespaced)] +#[kube(status = "ZoneAwareUpdateStatus")] +#[kube(schema = "disabled")] +pub struct ZoneAwareUpdateSpec { + /// Dryn-run mode that can be used to test the new controller before enable it + #[serde(default, skip_serializing_if = "Option::is_none", rename = "dryRun")] + pub dry_run: Option, + /// The exponential growth rate in float string. Default value is 2.0. It's possible to disable exponential updates by setting the ExponentialFactor to 0. In this case, the number of pods updated at each step is defined only by the MaxUnavailable param. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "exponentialFactor")] + pub exponential_factor: Option, + /// Flag to ignore the PauseRolloutAlarm (default false) + #[serde(default, skip_serializing_if = "Option::is_none", rename = "ignoreAlarm")] + pub ignore_alarm: Option, + /// Max number (or %) of pods that can be updated at the same time. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxUnavailable")] + pub max_unavailable: Option, + /// CW alarm name used to pause/skip updates. Alarm should be on the same account and region. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "pauseRolloutAlarm")] + pub pause_rollout_alarm: Option, + /// The name of the StatefulSet for which the ZoneAwareUpdate applies to. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub statefulset: Option, +} + +/// ZoneAwareUpdateStatus defines the observed state of ZoneAwareUpdate +#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] +pub struct ZoneAwareUpdateStatus { + /// CurrentRevision indicates the version of the StatefulSet used to generate Pods + #[serde(default, skip_serializing_if = "Option::is_none", rename = "currentRevision")] + pub current_revision: Option, + /// DeletedReplicas is the number of replicas deleted in the last reconcile loop. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "deletedReplicas")] + pub deleted_replicas: Option, + /// OldReplicas is the number of Pods *per zone* in the CurrentRevision, when there is new UpdateRevision. It becomes zero for all zones when all pods are in the new revision. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "oldReplicas")] + pub old_replicas: Option>, + /// PausedRollout indicates if the rollout was paused becaused the PauseRolloutAlarm is in alarm. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "pausedRollout")] + pub paused_rollout: Option, + /// UpdateRevision indicates the new version of the StatefulSet + #[serde(default, skip_serializing_if = "Option::is_none", rename = "updateRevision")] + pub update_revision: Option, + /// UpdateStep is used to track the rollout progress. Everytime pods are deleted/updated this is increased. It becomes zero when all pods are in the new revision. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "updateStep")] + pub update_step: Option, +} + diff --git a/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/zonedisruptionbudgets.rs b/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/zonedisruptionbudgets.rs new file mode 100644 index 000000000..961536286 --- /dev/null +++ b/kube-custom-resources-rs/src/zonecontrol_k8s_aws/v1/zonedisruptionbudgets.rs @@ -0,0 +1,76 @@ +// WARNING: generated by kopium - manual changes will be overwritten +// kopium command: kopium --docs --filename=./crd-catalog/aws/zone-aware-controllers-for-k8s/zonecontrol.k8s.aws/v1/zonedisruptionbudgets.yaml --derive=Default --derive=PartialEq +// kopium version: 0.16.5 + +use kube::CustomResource; +use serde::{Serialize, Deserialize}; +use std::collections::BTreeMap; +use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString; + +/// ZoneDisruptionBudgetSpec defines the desired state of ZoneDisruptionBudget +#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)] +#[kube(group = "zonecontrol.k8s.aws", version = "v1", kind = "ZoneDisruptionBudget", plural = "zonedisruptionbudgets")] +#[kube(namespaced)] +#[kube(status = "ZoneDisruptionBudgetStatus")] +#[kube(schema = "disabled")] +pub struct ZoneDisruptionBudgetSpec { + /// Dryn-run mode that can be used to test the new controller before enable it + #[serde(default, skip_serializing_if = "Option::is_none", rename = "dryRun")] + pub dry_run: Option, + /// Evict pod specification is allowed if at most "maxUnavailable" pods selected by "selector" are unavailable in the same zone after the above operation for pod. Evictions are not allowed if there are unavailable pods in other zones. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxUnavailable")] + pub max_unavailable: Option, + /// Selector label query over pods managed by the budget + #[serde(default, skip_serializing_if = "Option::is_none")] + pub selector: Option, +} + +/// Selector label query over pods managed by the budget +#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] +pub struct ZoneDisruptionBudgetSelector { + /// matchExpressions is a list of label selector requirements. The requirements are ANDed. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")] + pub match_expressions: Option>, + /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")] + pub match_labels: Option>, +} + +/// A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. +#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] +pub struct ZoneDisruptionBudgetSelectorMatchExpressions { + /// key is the label key that the selector applies to. + pub key: String, + /// operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + pub operator: String, + /// values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub values: Option>, +} + +/// ZoneDisruptionBudgetStatus defines the observed state of ZoneDisruptionBudget +#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] +pub struct ZoneDisruptionBudgetStatus { + /// Current number of healthy pods per zone + #[serde(default, skip_serializing_if = "Option::is_none", rename = "currentHealthy")] + pub current_healthy: Option>, + /// Current number of unhealthy pods per zone + #[serde(default, skip_serializing_if = "Option::is_none", rename = "currentUnhealthy")] + pub current_unhealthy: Option>, + /// Minimum desired number of healthy pods per zone + #[serde(default, skip_serializing_if = "Option::is_none", rename = "desiredHealthy")] + pub desired_healthy: Option>, + /// DisruptedPods contains information about pods whose eviction was processed by the API server eviction subresource handler but has not yet been observed by the ZoneDisruptionBudget controller. A pod will be in this map from the time when the API server processed the eviction request to the time when the pod is seen by ZDB controller as having been marked for deletion (or after a timeout). The key in the map is the name of the pod and the value is the time when the API server processed the eviction request. If the deletion didn't occur and a pod is still there it will be removed from the list automatically by ZoneDisruptionBudget controller after some time. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "disruptedPods")] + pub disrupted_pods: Option>, + /// Number of pod disruptions that are currently allowed *per zone* + #[serde(default, skip_serializing_if = "Option::is_none", rename = "disruptionsAllowed")] + pub disruptions_allowed: Option>, + /// Total number of expected replicas per zone + #[serde(default, skip_serializing_if = "Option::is_none", rename = "expectedPods")] + pub expected_pods: Option>, + /// Most recent generation observed when updating this ZDB status. DisruptionsAllowed and other status information is valid only if observedGeneration equals to ZDB's object generation. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "observedGeneration")] + pub observed_generation: Option, +} +