From 2f6f4966e0bba6b3f479cc87431b9e0ef675f9c5 Mon Sep 17 00:00:00 2001 From: zongz Date: Thu, 24 Oct 2024 16:13:12 +0800 Subject: [PATCH] feat: add 'deploymentStrategy' to konfig Signed-off-by: zongz --- konfig/kcl.mod | 2 +- konfig/models/kube/backend/server_backend.k | 2 ++ .../frontend/deployment/deployment_strategy.k | 23 +++++++++++++++++++ .../deployment/rolling_update_deployment.k | 23 +++++++++++++++++++ konfig/models/kube/frontend/server.k | 4 ++++ 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 konfig/models/kube/frontend/deployment/deployment_strategy.k create mode 100644 konfig/models/kube/frontend/deployment/rolling_update_deployment.k diff --git a/konfig/kcl.mod b/konfig/kcl.mod index e573f779..380f7779 100644 --- a/konfig/kcl.mod +++ b/konfig/kcl.mod @@ -1,6 +1,6 @@ [package] name = "konfig" -version = "0.10.0" +version = "0.11.0" description = "Konfig provides users with an out-of-the-box, highly abstract configuration interface. The original starting point of the model library is to improve the efficiency and experience of YAML users. We hope to simplify the writing of user-side configuration code by abstracting and encapsulating the model with more complex code into a unified model." [dependencies] diff --git a/konfig/models/kube/backend/server_backend.k b/konfig/models/kube/backend/server_backend.k index 7676dcbc..5614d5d7 100644 --- a/konfig/models/kube/backend/server_backend.k +++ b/konfig/models/kube/backend/server_backend.k @@ -81,6 +81,8 @@ schema ServerBackend[inputConfig: server.Server]: serviceAccountName = config.serviceAccount.name } } + if config.deploymentStrategy: + strategy = config.deploymentStrategy } } diff --git a/konfig/models/kube/frontend/deployment/deployment_strategy.k b/konfig/models/kube/frontend/deployment/deployment_strategy.k new file mode 100644 index 00000000..61d59b16 --- /dev/null +++ b/konfig/models/kube/frontend/deployment/deployment_strategy.k @@ -0,0 +1,23 @@ +""" +This is the deployment_strategy module in k8s.api.apps.v1 package. +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + + +schema DeploymentStrategy: + """ + DeploymentStrategy describes how to replace existing pods with new ones. + + Attributes + ---------- + rollingUpdate : RollingUpdateDeployment, default is Undefined, optional + Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate. + $type : str, default is Undefined, optional + Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate. + """ + + + rollingUpdate?: RollingUpdateDeployment + + $type?: str \ No newline at end of file diff --git a/konfig/models/kube/frontend/deployment/rolling_update_deployment.k b/konfig/models/kube/frontend/deployment/rolling_update_deployment.k new file mode 100644 index 00000000..69984c30 --- /dev/null +++ b/konfig/models/kube/frontend/deployment/rolling_update_deployment.k @@ -0,0 +1,23 @@ +""" +This is the rolling_update_deployment module in k8s.api.apps.v1 package. +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + + +schema RollingUpdateDeployment: + """ + Spec to control the desired behavior of rolling update. + + Attributes + ---------- + maxSurge : int | str, default is Undefined, optional + The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new ReplicaSet can be scaled up further, ensuring that total number of pods running at any time during the update is at most 130% of desired pods. + maxUnavailable : int | str, default is Undefined, optional + The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old ReplicaSet can be scaled down further, followed by scaling up the new ReplicaSet, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods. + """ + + + maxSurge?: int | str + + maxUnavailable?: int | str diff --git a/konfig/models/kube/frontend/server.k b/konfig/models/kube/frontend/server.k index 61d9a38e..196fcb70 100644 --- a/konfig/models/kube/frontend/server.k +++ b/konfig/models/kube/frontend/server.k @@ -9,6 +9,7 @@ import models.kube.frontend.volume import models.kube.frontend.sidecar as s import models.kube.frontend.strategy import models.kube.frontend.storage +import models.kube.frontend.deployment schema Server: """Server is abstaction of Deployment and StatefulSet. @@ -143,3 +144,6 @@ schema Server: # extra resources extraResources?: {str: {str:}} + + # Strategy for deployment + deploymentStrategy?: deployment.DeploymentStrategy