From c00cff8ba9fadc8092f8c4a5c5897b7931fd5c44 Mon Sep 17 00:00:00 2001 From: zhaoqing Date: Tue, 12 May 2026 11:03:59 +0800 Subject: [PATCH] add java & python code-generator update java & python sdk --- .gitignore | 3 + Makefile | 51 +++ agents/crds/agents.kruise.io_checkpoints.yaml | 102 ++++++ .../crds/agents.kruise.io_sandboxclaims.yaml | 319 ++++++++++++++++++ agents/crds/agents.kruise.io_sandboxes.yaml | 314 +++++++++++++++++ agents/crds/agents.kruise.io_sandboxsets.yaml | 266 +++++++++++++++ .../agents.kruise.io_sandboxtemplates.yaml | 75 ++++ .../agents.kruise.io_sandboxupdateops.yaml | 299 ++++++++++++++++ agents/v1alpha1/sandboxclaim_types.go | 4 +- agents/v1alpha1/zz_generated.deepcopy.go | 2 +- clients/codegen/patch_java_types.py | 170 ++++++++++ clients/codegen/patch_python_types.py | 254 ++++++++++++++ clients/codegen/type_mapping.yaml | 50 +++ clients/java/pom.xml | 34 ++ .../agents/client/v2/models/Checkpoint.java | 9 + .../client/v2/models/CheckpointSpec.java | 89 +++++ .../client/v2/models/CheckpointStatus.java | 91 +++++ .../agents/client/v2/models/Sandbox.java | 9 + .../agents/client/v2/models/SandboxClaim.java | 9 + .../client/v2/models/SandboxClaimSpec.java | 266 +++++++++++++++ .../client/v2/models/SandboxClaimStatus.java | 130 +++++++ .../agents/client/v2/models/SandboxSet.java | 9 + .../client/v2/models/SandboxSetSpec.java | 140 ++++++++ .../client/v2/models/SandboxSetStatus.java | 144 ++++++++ .../agents/client/v2/models/SandboxSpec.java | 174 ++++++++++ .../client/v2/models/SandboxStatus.java | 139 ++++++++ .../client/v2/models/SandboxTemplate.java | 9 + .../client/v2/models/SandboxTemplateSpec.java | 73 ++++ .../client/v2/models/SandboxUpdateOps.java | 9 + .../v2/models/SandboxUpdateOpsSpec.java | 90 +++++ .../v2/models/SandboxUpdateOpsStatus.java | 124 +++++++ .../sandboxclaimspec/DynamicVolumesMount.java | 70 ++++ .../sandboxclaimspec/InplaceUpdate.java | 40 +++ .../v2/models/sandboxclaimspec/Runtimes.java | 21 ++ .../inplaceupdate/Resources.java | 46 +++ .../models/sandboxclaimstatus/Conditions.java | 141 ++++++++ .../v2/models/sandboxsetspec/Runtimes.java | 21 ++ .../models/sandboxsetspec/ScaleStrategy.java | 27 ++ .../v2/models/sandboxsetspec/TemplateRef.java | 59 ++++ .../models/sandboxsetspec/UpdateStrategy.java | 27 ++ .../models/sandboxsetstatus/Conditions.java | 141 ++++++++ .../v2/models/sandboxspec/Lifecycle.java | 42 +++ .../v2/models/sandboxspec/Runtimes.java | 21 ++ .../v2/models/sandboxspec/TemplateRef.java | 59 ++++ .../v2/models/sandboxspec/UpgradePolicy.java | 26 ++ .../sandboxspec/lifecycle/PostUpgrade.java | 42 +++ .../sandboxspec/lifecycle/PreUpgrade.java | 42 +++ .../lifecycle/postupgrade/Exec.java | 28 ++ .../lifecycle/preupgrade/Exec.java | 28 ++ .../v2/models/sandboxstatus/Conditions.java | 141 ++++++++ .../v2/models/sandboxstatus/PodInfo.java | 88 +++++ .../models/sandboxtemplatespec/Runtimes.java | 21 ++ .../sandboxupdateopsspec/Lifecycle.java | 42 +++ .../models/sandboxupdateopsspec/Selector.java | 42 +++ .../sandboxupdateopsspec/UpdateStrategy.java | 25 ++ .../lifecycle/PostUpgrade.java | 42 +++ .../lifecycle/PreUpgrade.java | 42 +++ .../lifecycle/postupgrade/Exec.java | 28 ++ .../lifecycle/preupgrade/Exec.java | 28 ++ .../selector/MatchExpressions.java | 62 ++++ .../sandboxupdateopsstatus/Conditions.java | 141 ++++++++ .../openkruise/agents/models/__init__.py | 31 +- .../openkruise/agents/models/checkpoint.py | 97 ++++++ .../openkruise/agents/models/sandbox.py | 115 ++++++- .../openkruise/agents/models/sandboxclaim.py | 83 ++++- .../openkruise/agents/models/sandboxset.py | 51 ++- .../agents/models/sandboxtemplate.py | 71 ++++ .../agents/models/sandboxupdateops.py | 288 ++++++++++++++++ clients/python/ruff.toml | 3 + docs/sdk-codegen-zh_CN.md | 201 +++++++++++ docs/sdk-codegen.md | 201 +++++++++++ hack/generate_client.sh | 18 + hack/generate_java_sdk.sh | 114 +++++++ hack/generate_python_sdk.sh | 109 ++++++ hack/patch_sdk_types.sh | 87 +++++ hack/update_upstream.sh | 111 ++++++ 76 files changed, 6579 insertions(+), 41 deletions(-) create mode 100644 agents/crds/agents.kruise.io_checkpoints.yaml create mode 100644 agents/crds/agents.kruise.io_sandboxclaims.yaml create mode 100644 agents/crds/agents.kruise.io_sandboxes.yaml create mode 100644 agents/crds/agents.kruise.io_sandboxsets.yaml create mode 100644 agents/crds/agents.kruise.io_sandboxtemplates.yaml create mode 100644 agents/crds/agents.kruise.io_sandboxupdateops.yaml create mode 100755 clients/codegen/patch_java_types.py create mode 100755 clients/codegen/patch_python_types.py create mode 100644 clients/codegen/type_mapping.yaml create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/Checkpoint.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/CheckpointSpec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/CheckpointStatus.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/Sandbox.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaim.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaimSpec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaimStatus.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSet.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSetSpec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSetStatus.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSpec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxStatus.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxTemplate.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxTemplateSpec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOps.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOpsSpec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOpsStatus.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/DynamicVolumesMount.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/InplaceUpdate.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/Runtimes.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/inplaceupdate/Resources.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimstatus/Conditions.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/Runtimes.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/ScaleStrategy.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/TemplateRef.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/UpdateStrategy.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetstatus/Conditions.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/Lifecycle.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/Runtimes.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/TemplateRef.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/UpgradePolicy.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/PostUpgrade.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/PreUpgrade.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/postupgrade/Exec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/preupgrade/Exec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxstatus/Conditions.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxstatus/PodInfo.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxtemplatespec/Runtimes.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/Lifecycle.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/Selector.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/UpdateStrategy.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/PostUpgrade.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/PreUpgrade.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/postupgrade/Exec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/preupgrade/Exec.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/selector/MatchExpressions.java create mode 100644 clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsstatus/Conditions.java create mode 100644 clients/python/openkruise/agents/models/checkpoint.py create mode 100644 clients/python/openkruise/agents/models/sandboxtemplate.py create mode 100644 clients/python/openkruise/agents/models/sandboxupdateops.py create mode 100644 clients/python/ruff.toml create mode 100644 docs/sdk-codegen-zh_CN.md create mode 100644 docs/sdk-codegen.md create mode 100755 hack/generate_java_sdk.sh create mode 100755 hack/generate_python_sdk.sh create mode 100755 hack/patch_sdk_types.sh create mode 100755 hack/update_upstream.sh diff --git a/.gitignore b/.gitignore index 77ef3e5..302c962 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ vendor/ .idea/ + +# Python +.ruff_cache/ \ No newline at end of file diff --git a/Makefile b/Makefile index 38dea1c..6b752b5 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,57 @@ rm -rf $$TMP_DIR ;\ } endef +# Update CRD YAML and Go type definitions from upstream openkruise/agents +.PHONY: update-upstream +update-upstream: + @hack/update_upstream.sh + +# Generate Java SDK from CRD definitions (requires JDK 8+) +.PHONY: generate-java +generate-java: + @hack/generate_java_sdk.sh + @hack/patch_sdk_types.sh --java + +# Generate Python SDK from CRD definitions (requires yq + datamodel-codegen) +.PHONY: generate-python +generate-python: + @hack/generate_python_sdk.sh + @hack/patch_sdk_types.sh --python + +# Patch generated SDK types (AnyType → concrete K8s types) +# Usage: +# make patch-sdk-types # patch both Java and Python +# make patch-sdk-types LANG=java # patch Java only +# make patch-sdk-types LANG=python # patch Python only +.PHONY: patch-sdk-types +patch-sdk-types: +ifeq ($(LANG),java) + @hack/patch_sdk_types.sh --java +else ifeq ($(LANG),python) + @hack/patch_sdk_types.sh --python +else + @hack/patch_sdk_types.sh +endif + +# Generate all SDKs (Go + Java + Python) and apply type patches +# Usage: +# make generate-all # update upstream + generate all + patch types +# make generate-all SKIP_UPDATE=true # skip upstream update, generate + patch only +.PHONY: generate-all +ifeq ($(SKIP_UPDATE),true) +generate-all: + @hack/generate_client.sh --skip-update + @hack/generate_java_sdk.sh --skip-update + @hack/generate_python_sdk.sh --skip-update + @hack/patch_sdk_types.sh +else +generate-all: update-upstream + @hack/generate_client.sh --skip-update + @hack/generate_java_sdk.sh --skip-update + @hack/generate_python_sdk.sh --skip-update + @hack/patch_sdk_types.sh +endif + .PHONY: gen-schema-only gen-schema-only: go run cmd/gen-schema/main.go diff --git a/agents/crds/agents.kruise.io_checkpoints.yaml b/agents/crds/agents.kruise.io_checkpoints.yaml new file mode 100644 index 0000000..183d0ac --- /dev/null +++ b/agents/crds/agents.kruise.io_checkpoints.yaml @@ -0,0 +1,102 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: checkpoints.agents.kruise.io +spec: + group: agents.kruise.io + names: + kind: Checkpoint + listKind: CheckpointList + plural: checkpoints + shortNames: + - cp + singular: checkpoint + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.phase + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: Checkpoint is the Schema for the Checkpoints 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: spec defines the desired state of Checkpoint + properties: + keepRunning: + description: |- + KeepRunning indicates whether the pod remains in the Running state after passing the checkpoint. + Default is true. + type: boolean + persistentContents: + description: 'PersistentContents indicates resume pod with persistent + content, Enum: memory, filesystem' + items: + type: string + type: array + podName: + description: PodName is checkpoint podName. + type: string + sandboxName: + description: SandboxName is checkpoint sandboxName. + type: string + ttlAfterFinished: + description: 'valid format: 30s, 30m, 30d' + type: string + type: object + status: + description: status defines the observed state of Checkpoint + properties: + checkpointId: + description: checkpoint-id + type: string + completionTime: + description: CompletionTime is checkpoint completed time, and phase + is Succeeded or Failed. + format: date-time + type: string + message: + description: message + type: string + observedGeneration: + description: |- + observedGeneration is the most recent generation observed for this Checkpoint. It corresponds to the + Checkpoint's generation, which is updated on mutation by the API Server. + format: int64 + type: integer + phase: + description: Checkpoint Phase + type: string + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/agents/crds/agents.kruise.io_sandboxclaims.yaml b/agents/crds/agents.kruise.io_sandboxclaims.yaml new file mode 100644 index 0000000..563ec95 --- /dev/null +++ b/agents/crds/agents.kruise.io_sandboxclaims.yaml @@ -0,0 +1,319 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: sandboxclaims.agents.kruise.io +spec: + group: agents.kruise.io + names: + kind: SandboxClaim + listKind: SandboxClaimList + plural: sandboxclaims + shortNames: + - sbc + singular: sandboxclaim + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.phase + name: Phase + type: string + - jsonPath: .spec.templateName + name: Template + type: string + - jsonPath: .spec.replicas + name: Desired + type: integer + - jsonPath: .status.claimedReplicas + name: Claimed + type: integer + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: SandboxClaim is the Schema for the sandboxclaims 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: spec defines the desired state of SandboxClaim + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations contains key-value pairs to be added as annotations + to claimed Sandbox resources + type: object + claimTimeout: + default: 1m + description: |- + ClaimTimeout specifies the maximum duration to wait for claiming sandboxes + If the timeout is reached, the claim will be marked as Completed regardless of + whether all replicas were successfully claimed + type: string + x-kubernetes-validations: + - message: claimTimeout must be at least 1 second + rule: duration(self) >= duration('1s') + createOnNoStock: + default: true + description: CreateOnNoStock allows to create new sandbox if no stock + available + type: boolean + dynamicVolumesMount: + description: DynamicVolumesMount specifies the dynamic volumes to + be mounted into the sandbox + items: + properties: + mountID: + type: string + mountPath: + type: string + pvName: + type: string + readOnly: + type: boolean + subPath: + type: string + required: + - mountPath + - pvName + type: object + type: array + envVars: + additionalProperties: + type: string + description: |- + EnvVars contains environment variables to be injected into the sandbox + These will be passed to the sandbox's init endpoint (envd) after claiming + Only applicable if the SandboxSet has envd enabled + type: object + inplaceUpdate: + description: InplaceUpdate allows to perform inplace update for sandbox + while claiming + properties: + image: + description: Image specifies the new image to update to. + type: string + resources: + description: Resources specifies in-place resource update options. + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Limits specifies the target resource limits for each container. + Only CPU is supported for now. The container's original limit must already be set; + otherwise the value is ignored. + The new value must not change the Pod's QoS class; otherwise the claim will be rejected. + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Requests specifies the target resource requests for each container. + Only CPU is supported for now. The container's original request must already be set; + otherwise the value is ignored. + The new value must not change the Pod's QoS class; otherwise the claim will be rejected. + type: object + type: object + type: object + labels: + additionalProperties: + type: string + description: |- + Labels contains key-value pairs to be added as labels + to claimed Sandbox resources + type: object + replicas: + default: 1 + description: |- + Replicas specifies how many sandboxes to claim (default: 1) + For batch claiming support + This field is immutable once set + format: int32 + minimum: 1 + type: integer + x-kubernetes-validations: + - message: replicas is immutable + rule: self == oldSelf + reserveFailedSandbox: + description: Set ReserveFailedSandbox to true to reserve failed sandboxes + type: boolean + runtimes: + description: Runtimes - Runtime configuration for sandbox object + items: + properties: + name: + type: string + required: + - name + type: object + type: array + shutdownTime: + description: |- + ShutdownTime specifies the absolute time when the sandbox should be shut down + This will be set as spec.shutdownTime (absolute time) on the Sandbox + format: date-time + type: string + skipInitRuntime: + default: false + description: SkipInitRuntime allows to skip init runtime for sandbox + while claiming + type: boolean + templateName: + description: TemplateName specifies which SandboxSet pool to claim + from + type: string + ttlAfterCompleted: + default: 60m + description: |- + TTLAfterCompleted specifies the time to live after the claim reaches Completed phase + After this duration, the SandboxClaim will be automatically deleted. + Note: Only the SandboxClaim resource will be deleted; the claimed sandboxes will NOT be deleted + Set to a negative value (e.g., "-1s") to disable automatic deletion (never delete). + type: string + waitReadyTimeout: + default: 30s + description: |- + WaitReadyTimeout specifies the maximum duration for waiting claimed sandbox ready. Default: 30s. + A waiting happens when an inplace update happens, a new sandbox created, etc. + Format: duration string (e.g., "3h", "200s", "15m") + type: string + x-kubernetes-validations: + - message: waitReadyTimeout must be at least 1 second + rule: duration(self) >= duration('1s') + required: + - templateName + type: object + status: + description: status defines the observed state of SandboxClaim + properties: + claimStartTime: + description: |- + ClaimStartTime is the timestamp when claiming started + Used for calculating timeout + format: date-time + type: string + claimedReplicas: + description: |- + ClaimedReplicas indicates how many sandboxes are currently claimed (total) + This is determined by querying sandboxes with matching ownerReference + Only updated during Pending and Claiming phases + format: int32 + type: integer + completionTime: + description: |- + CompletionTime is the timestamp when the claim reached Completed phase + Used for TTL calculation + format: date-time + type: string + conditions: + description: Conditions represent the current state of the SandboxClaim + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the 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: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + message: + description: Message provides human-readable details about the current + phase + type: string + observedGeneration: + description: ObservedGeneration is the most recent generation observed + format: int64 + type: integer + phase: + description: |- + Phase represents the current phase of the claim + Claiming: In the process of claiming sandboxes + Completed: Claim process finished (either all replicas claimed or timeout reached) + type: string + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/agents/crds/agents.kruise.io_sandboxes.yaml b/agents/crds/agents.kruise.io_sandboxes.yaml new file mode 100644 index 0000000..53edea7 --- /dev/null +++ b/agents/crds/agents.kruise.io_sandboxes.yaml @@ -0,0 +1,314 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: sandboxes.agents.kruise.io +spec: + group: agents.kruise.io + names: + kind: Sandbox + listKind: SandboxList + plural: sandboxes + shortNames: + - sbx + singular: sandbox + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.phase + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .metadata.labels.agents\.kruise\.io/sandbox-claimed + name: Claimed + type: string + - jsonPath: .spec.shutdownTime + name: shutdown_time + type: string + - jsonPath: .spec.pauseTime + name: pause_time + type: string + - jsonPath: .status.message + name: Message + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: Sandbox is the Schema for the sandboxes 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: spec defines the desired state of Sandbox + properties: + lifecycle: + description: Lifecycle defines lifecycle hooks for sandbox upgrade. + properties: + postUpgrade: + description: |- + PostUpgrade is the action executed after the upgrade. + It is typically used to restore workspace data. + properties: + exec: + description: |- + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + x-kubernetes-list-type: atomic + type: object + timeoutSeconds: + default: 60 + description: TimeoutSeconds is the timeout for the action + execution in seconds. + format: int32 + type: integer + type: object + preUpgrade: + description: |- + PreUpgrade is the action executed before the upgrade. + It is typically used to backup workspace data. + properties: + exec: + description: |- + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + x-kubernetes-list-type: atomic + type: object + timeoutSeconds: + default: 60 + description: TimeoutSeconds is the timeout for the action + execution in seconds. + format: int32 + type: integer + type: object + type: object + pauseTime: + description: PauseTime - Absolute time when the sandbox will be paused + automatically. + format: date-time + type: string + paused: + description: Paused indicates whether pause the sandbox pod. + type: boolean + persistentContents: + description: 'PersistentContents indicates resume pod with persistent + content, Enum: ip, memory, filesystem' + items: + type: string + type: array + runtimes: + description: Runtimes - Runtime configuration for sandbox object + items: + properties: + name: + type: string + required: + - name + type: object + type: array + shutdownTime: + description: |- + ShutdownTime - Absolute time when the sandbox is deleted. + If a time in the past is provided, the sandbox will be deleted immediately. + format: date-time + type: string + template: + description: |- + Template describes the pods that will be created. + Template is mutual exclusive with TemplateRef + x-kubernetes-preserve-unknown-fields: true + templateRef: + description: TemplateRef references a SandboxTemplate, which will + be used to create the sandbox. + properties: + apiVersion: + description: |- + name of the SandboxTemplate apiVersion + Default to v1 + type: string + kind: + description: |- + name of the SandboxTemplate kind + Default to PodTemplate + type: string + name: + description: name of the SandboxTemplate + type: string + required: + - name + type: object + upgradePolicy: + description: UpgradePolicy defines the upgrade strategy for the sandbox. + properties: + type: + description: |- + Type specifies the upgrade policy type. + When empty (default), upgrading is disabled. + Supported values: Recreate. + type: string + type: object + volumeClaimTemplates: + description: VolumeClaimTemplates is a list of PVC templates to create + for this Sandbox. + x-kubernetes-preserve-unknown-fields: true + type: object + status: + description: status defines the observed state of Sandbox + properties: + conditions: + description: |- + conditions represent the current state of the Sandbox resource. + Each condition has a unique type and reflects the status of a specific aspect of the resource. + The status of each condition is one of True, False, or Unknown. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the 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: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + message: + description: message + type: string + nodeName: + description: NodeName indicates in which node this sandbox is scheduled. + type: string + observedGeneration: + description: |- + observedGeneration is the most recent generation observed for this Sandbox. It corresponds to the + Sandbox's generation, which is updated on mutation by the API Server. + format: int64 + type: integer + phase: + description: Sandbox Phase + type: string + podInfo: + description: Pod Info + properties: + annotations: + additionalProperties: + type: string + description: Annotations contains pod important annotations + type: object + labels: + additionalProperties: + type: string + description: Labels contains pod important labels + type: object + nodeName: + description: NodeName indicates in which node this pod is scheduled. + type: string + podIP: + description: PodIP address allocated to the pod. + type: string + podUID: + description: PodUID is pod uid. + type: string + type: object + sandboxIp: + description: SandboxIp is the ip address allocated to the sandbox. + type: string + updateRevision: + description: UpdateRevision is the template-hash calculated from `spec.template`. + type: string + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/agents/crds/agents.kruise.io_sandboxsets.yaml b/agents/crds/agents.kruise.io_sandboxsets.yaml new file mode 100644 index 0000000..aee6bca --- /dev/null +++ b/agents/crds/agents.kruise.io_sandboxsets.yaml @@ -0,0 +1,266 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: sandboxsets.agents.kruise.io +spec: + group: agents.kruise.io + names: + kind: SandboxSet + listKind: SandboxSetList + plural: sandboxsets + shortNames: + - sbs + singular: sandboxset + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.replicas + name: Replicas + type: integer + - jsonPath: .status.availableReplicas + name: Available + type: integer + - jsonPath: .status.updatedReplicas + name: UpdatedReplicas + type: integer + - jsonPath: .status.updatedAvailableReplicas + name: UpdatedAvailableReplicas + type: integer + - jsonPath: .status.updateRevision + name: UpdateRevision + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: SandboxSet is the Schema for the sandboxsets API, which is an + advanced workload for managing sandboxes. + 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: spec defines the desired state of SandboxSet + properties: + persistentContents: + description: 'PersistentContents indicates resume pod with persistent + content, Enum: ip, memory, filesystem' + items: + type: string + type: array + replicas: + description: Replicas is the number of unused sandboxes, including + available and creating ones. + format: int32 + type: integer + runtimes: + description: Runtimes - Runtime configuration for sandbox object + items: + properties: + name: + type: string + required: + - name + type: object + type: array + scaleStrategy: + description: |- + ScaleStrategy indicates the ScaleStrategy that will be employed to + create and delete Sandboxes in the SandboxSet. + properties: + maxUnavailable: + anyOf: + - type: integer + - type: string + description: |- + The maximum number of sandboxes that can be unavailable for scaled sandboxes. + This field can control the changes rate of replicas for SandboxSet so as to minimize the impact for users' service. + The scale will fail if the number of unavailable sandboxes were greater than this MaxUnavailable at scaling up. + MaxUnavailable works only when scaling up. + x-kubernetes-int-or-string: true + type: object + template: + description: |- + Template describes the pods that will be created. + Template is mutual exclusive with TemplateRef + x-kubernetes-preserve-unknown-fields: true + templateRef: + description: TemplateRef references a SandboxTemplate, which will + be used to create the sandbox. + properties: + apiVersion: + description: |- + name of the SandboxTemplate apiVersion + Default to v1 + type: string + kind: + description: |- + name of the SandboxTemplate kind + Default to PodTemplate + type: string + name: + description: name of the SandboxTemplate + type: string + required: + - name + type: object + updateStrategy: + description: |- + UpdateStrategy indicates the strategy that will be employed to + update Sandboxes in the SandboxSet when the template changes. + properties: + maxUnavailable: + anyOf: + - type: integer + - type: string + description: |- + MaxUnavailable is the maximum number or percentage of pods that can be unavailable during the update. + MaxUnavailable can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). + Absolute number is calculated from percentage by rounding down. + Default is 20%. + x-kubernetes-int-or-string: true + type: object + volumeClaimTemplates: + description: VolumeClaimTemplates is a list of PVC templates to create + for this Sandbox. + x-kubernetes-preserve-unknown-fields: true + required: + - replicas + type: object + status: + description: status defines the observed state of SandboxSet + properties: + availableReplicas: + description: AvailableReplicas is the number of available sandboxes, + which are ready to be claimed. + format: int32 + type: integer + conditions: + description: |- + conditions represent the current state of the SandboxSet resource. + Each condition has a unique type and reflects the status of a specific aspect of the resource. + The status of each condition is one of True, False, or Unknown. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the 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: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + observedGeneration: + description: |- + observedGeneration is the most recent generation observed for this SandboxSet. It corresponds to the + SandboxSet's generation, which is updated on mutation by the API Server. + format: int64 + type: integer + replicas: + description: Replicas is the total number of creating, available, + running and paused sandboxes. + format: int32 + type: integer + selector: + description: |- + Selector is a label query over pods that should match the replica count. + This is same as the label selector but in the string format to avoid + duplication for CRDs that do not support structural schemas. + type: string + updateRevision: + description: |- + UpdateRevision is the hash label of the ControllerRevision created from `spec.template`. + It represents the latest desired template version. + type: string + updatedAvailableReplicas: + description: UpdatedAvailableReplicas is the number of updated sandboxes + that are available. + format: int32 + type: integer + updatedReplicas: + description: UpdatedReplicas is the number of sandboxes that have + been updated to the UpdateRevision. + format: int32 + type: integer + required: + - availableReplicas + - replicas + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas + status: {} diff --git a/agents/crds/agents.kruise.io_sandboxtemplates.yaml b/agents/crds/agents.kruise.io_sandboxtemplates.yaml new file mode 100644 index 0000000..72d9191 --- /dev/null +++ b/agents/crds/agents.kruise.io_sandboxtemplates.yaml @@ -0,0 +1,75 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: sandboxtemplates.agents.kruise.io +spec: + group: agents.kruise.io + names: + kind: SandboxTemplate + listKind: SandboxTemplateList + plural: sandboxtemplates + shortNames: + - sbt + singular: sandboxtemplate + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: SandboxSet is the Schema for the sandboxsets API, which is an + advanced workload for managing sandboxes. + 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: spec defines the desired state of SandboxSet + properties: + persistentContents: + description: 'PersistentContents indicates resume pod with persistent + content, Enum: ip, memory, filesystem' + items: + type: string + type: array + runtimes: + description: Runtimes - Runtime configuration for sandbox object + items: + properties: + name: + type: string + required: + - name + type: object + type: array + template: + description: |- + Template describes the pods that will be created. + Template is mutual exclusive with TemplateRef + x-kubernetes-preserve-unknown-fields: true + volumeClaimTemplates: + description: VolumeClaimTemplates is a list of PVC templates to create + for this Sandbox. + x-kubernetes-preserve-unknown-fields: true + type: object + required: + - spec + type: object + served: true + storage: true diff --git a/agents/crds/agents.kruise.io_sandboxupdateops.yaml b/agents/crds/agents.kruise.io_sandboxupdateops.yaml new file mode 100644 index 0000000..2bad1bc --- /dev/null +++ b/agents/crds/agents.kruise.io_sandboxupdateops.yaml @@ -0,0 +1,299 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: sandboxupdateops.agents.kruise.io +spec: + group: agents.kruise.io + names: + kind: SandboxUpdateOps + listKind: SandboxUpdateOpsList + plural: sandboxupdateops + shortNames: + - suo + singular: sandboxupdateops + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.phase + name: Phase + type: string + - jsonPath: .status.replicas + name: Total + type: integer + - jsonPath: .status.updatedReplicas + name: Updated + type: integer + - jsonPath: .status.updatingReplicas + name: Updating + type: integer + - jsonPath: .status.failedReplicas + name: Failed + type: integer + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: SandboxUpdateOps is the Schema for batch sandbox update operations. + 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: Spec defines the desired update operation. + properties: + lifecycle: + description: Lifecycle defines pre/post upgrade hooks to set on each + sandbox during upgrade. + properties: + postUpgrade: + description: |- + PostUpgrade is the action executed after the upgrade. + It is typically used to restore workspace data. + properties: + exec: + description: |- + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + x-kubernetes-list-type: atomic + type: object + timeoutSeconds: + default: 60 + description: TimeoutSeconds is the timeout for the action + execution in seconds. + format: int32 + type: integer + type: object + preUpgrade: + description: |- + PreUpgrade is the action executed before the upgrade. + It is typically used to backup workspace data. + properties: + exec: + description: |- + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + x-kubernetes-list-type: atomic + type: object + timeoutSeconds: + default: 60 + description: TimeoutSeconds is the timeout for the action + execution in seconds. + format: int32 + type: integer + type: object + type: object + patch: + description: |- + Patch defines the changes to apply to each selected sandbox's template. + The patch is applied as a Strategic Merge Patch on the sandbox's PodTemplateSpec. + x-kubernetes-preserve-unknown-fields: true + paused: + description: Paused indicates whether the update operation is paused. + type: boolean + selector: + description: Selector selects the target sandboxes to update by label. + 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 + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + 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 + updateStrategy: + description: UpdateStrategy defines the strategy for the batch update. + properties: + maxUnavailable: + anyOf: + - type: integer + - type: string + description: |- + MaxUnavailable is the maximum number of sandboxes that can be upgrading at the same time. + Value can be an absolute number (e.g., 5) or a percentage of total sandboxes (e.g., 10%). + x-kubernetes-int-or-string: true + type: object + required: + - selector + type: object + status: + description: Status defines the observed state. + properties: + conditions: + description: Conditions represents the latest available observations. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the 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: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + failedReplicas: + description: FailedReplicas is the number of sandboxes that failed + to update. + format: int32 + type: integer + observedGeneration: + description: ObservedGeneration is the most recent generation observed. + format: int64 + type: integer + phase: + description: Phase is the current phase of the update operation. + type: string + replicas: + description: Replicas is the total number of sandboxes selected for + update. + format: int32 + type: integer + updatedReplicas: + description: UpdatedReplicas is the number of sandboxes that have + been successfully updated. + format: int32 + type: integer + updatingReplicas: + description: UpdatingReplicas is the number of sandboxes currently + being updated. + format: int32 + type: integer + required: + - failedReplicas + - replicas + - updatedReplicas + - updatingReplicas + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/agents/v1alpha1/sandboxclaim_types.go b/agents/v1alpha1/sandboxclaim_types.go index 3d30bac..a0b9cf3 100644 --- a/agents/v1alpha1/sandboxclaim_types.go +++ b/agents/v1alpha1/sandboxclaim_types.go @@ -46,6 +46,7 @@ type SandboxClaimSpec struct { // whether all replicas were successfully claimed // +optional // +kubebuilder:default="1m" + // +kubebuilder:validation:XValidation:rule="duration(self) >= duration('1s')",message="claimTimeout must be at least 1 second" ClaimTimeout *metav1.Duration `json:"claimTimeout,omitempty"` // TTLAfterCompleted specifies the time to live after the claim reaches Completed phase @@ -57,7 +58,7 @@ type SandboxClaimSpec struct { TTLAfterCompleted *metav1.Duration `json:"ttlAfterCompleted,omitempty"` // Labels contains key-value pairs to be added as labels - // to claimed Sandbox resources + // to claimed Sandbox resources and synced to sandbox template labels. // +optional Labels map[string]string `json:"labels,omitempty"` @@ -98,6 +99,7 @@ type SandboxClaimSpec struct { // Format: duration string (e.g., "3h", "200s", "15m") // +optional // +kubebuilder:default="30s" + // +kubebuilder:validation:XValidation:rule="duration(self) >= duration('1s')",message="waitReadyTimeout must be at least 1 second" WaitReadyTimeout *metav1.Duration `json:"waitReadyTimeout,omitempty"` // SkipInitRuntime allows to skip init runtime for sandbox while claiming diff --git a/agents/v1alpha1/zz_generated.deepcopy.go b/agents/v1alpha1/zz_generated.deepcopy.go index a4def41..b1625ee 100644 --- a/agents/v1alpha1/zz_generated.deepcopy.go +++ b/agents/v1alpha1/zz_generated.deepcopy.go @@ -1,7 +1,7 @@ //go:build !ignore_autogenerated /* -Copyright 2025. +Copyright 2026. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/clients/codegen/patch_java_types.py b/clients/codegen/patch_java_types.py new file mode 100755 index 0000000..d373330 --- /dev/null +++ b/clients/codegen/patch_java_types.py @@ -0,0 +1,170 @@ +#!/usr/bin/env python3 +"""Patch generated Java SDK models with correct Kubernetes types. + +Reads replacement rules from hack/type_mapping.yaml and applies them to +generated Java model files. Prints a preview of all changes before applying. + +Usage: + python3 hack/patch_java_types.py +""" + +from __future__ import annotations + +import re +import sys +from pathlib import Path + +import yaml + + +def load_java_rules(mapping_path: Path) -> list[dict]: + """Load Java patching rules from type_mapping.yaml.""" + with mapping_path.open() as fh: + config = yaml.safe_load(fh) + + rules: list[dict] = [] + for field in config.get("fields", []): + java = field.get("java", {}) + if java.get("skip"): + continue + rules.append({ + "field_name": field["name"], + "old_type": java["old_type"], + "new_type": java["new_type"], + }) + + # Sort: longer field names first so "volumeClaimTemplates" is processed + # before "template" (avoids the substring match problem). + rules.sort(key=lambda r: len(r["field_name"]), reverse=True) + return rules + + +def _build_field_patterns(field_name: str) -> list[re.Pattern]: + """Build regex patterns that precisely match a Java field by name. + + Matches: + - field declaration: ` fieldName;` + - getter: `getFieldName()` + - setter: `setFieldName(` + This avoids substring conflicts (e.g. "template" matching "volumeClaimTemplates"). + """ + lower = field_name[0].lower() + field_name[1:] + upper = field_name[0].upper() + field_name[1:] + return [ + re.compile(rf'\b{re.escape(lower)}\b'), # field declaration + re.compile(rf'\bget{re.escape(upper)}\b'), # getter + re.compile(rf'\bset{re.escape(upper)}\b'), # setter + ] + + +def _line_matches_field(line: str, patterns: list[re.Pattern]) -> bool: + """Check if a line matches any of the field patterns.""" + return any(p.search(line) for p in patterns) + + +def collect_java_changes(filepath: Path, rules: list[dict]) -> list[dict]: + """Scan a Java file and return planned changes without modifying it.""" + lines = filepath.read_text().split("\n") + changes: list[dict] = [] + + for rule in rules: + patterns = _build_field_patterns(rule["field_name"]) + old_type = rule["old_type"] + + for line_idx, line in enumerate(lines): + if old_type not in line: + continue + if not _line_matches_field(line, patterns): + continue + new_line = line.replace(old_type, rule["new_type"]) + if new_line != line: + changes.append({ + "file": filepath, + "line_no": line_idx + 1, + "field": rule["field_name"], + "old": line.strip(), + "new": new_line.strip(), + }) + return changes + + +def apply_java_patch(filepath: Path, rules: list[dict]) -> bool: + """Apply patches to a single Java file. Returns True if modified.""" + content = filepath.read_text() + original = content + + for rule in rules: + patterns = _build_field_patterns(rule["field_name"]) + old_type = rule["old_type"] + new_type = rule["new_type"] + + new_lines: list[str] = [] + for line in content.split("\n"): + if old_type in line and _line_matches_field(line, patterns): + line = line.replace(old_type, new_type) + new_lines.append(line) + content = "\n".join(new_lines) + + if content != original: + filepath.write_text(content) + return True + return False + + +def main() -> None: + if len(sys.argv) < 3: + print(f"Usage: {sys.argv[0]} ", file=sys.stderr) + sys.exit(1) + + models_dir = Path(sys.argv[1]) + mapping_path = Path(sys.argv[2]) + + if not models_dir.is_dir(): + print(f"ERROR: Directory not found: {models_dir}", file=sys.stderr) + sys.exit(1) + if not mapping_path.is_file(): + print(f"ERROR: Mapping file not found: {mapping_path}", file=sys.stderr) + sys.exit(1) + + rules = load_java_rules(mapping_path) + + # Phase 1: Collect and print all planned changes + all_changes: list[dict] = [] + for java_file in sorted(models_dir.glob("*.java")): + all_changes.extend(collect_java_changes(java_file, rules)) + + if not all_changes: + print(" No Java type changes needed.") + return + + print(" Planned Java type changes:") + for change in all_changes: + print(f" {change['file'].name}:{change['line_no']} " + f"{change['field']}: {change['old']}") + print(f" → {change['new']}") + print() + + # Phase 2: Apply patches + patched_count = 0 + for java_file in sorted(models_dir.glob("*.java")): + if apply_java_patch(java_file, rules): + patched_count += 1 + + # Phase 3: Verify no old_type remains + remaining_files: list[str] = [] + old_types = {r["old_type"] for r in rules} + for java_file in sorted(models_dir.glob("*.java")): + content = java_file.read_text() + if any(ot in content for ot in old_types): + remaining_files.append(java_file.name) + + if remaining_files: + print(f" WARN: {len(remaining_files)} file(s) still contain placeholder types:") + for fname in remaining_files: + print(f" {fname}") + + print(f" Patched {patched_count} Java file(s)") + + +if __name__ == "__main__": + main() diff --git a/clients/codegen/patch_python_types.py b/clients/codegen/patch_python_types.py new file mode 100755 index 0000000..19ad982 --- /dev/null +++ b/clients/codegen/patch_python_types.py @@ -0,0 +1,254 @@ +#!/usr/bin/env python3 +"""Patch generated Python SDK models with correct Kubernetes types. + +Reads replacement rules from hack/type_mapping.yaml and applies them to +generated Pydantic model files. Prints a preview of all changes before +applying them. + +Usage: + python3 hack/patch_python_types.py +""" + +from __future__ import annotations + +import re +import sys +from pathlib import Path + +import yaml + +CONFIGDICT_MARKER = "model_config = ConfigDict(arbitrary_types_allowed=True)" + + +# ── Load rules from YAML ───────────────────────────────────────────────────── + +def load_python_rules(mapping_path: Path) -> list[dict]: + """Load Python patching rules from type_mapping.yaml.""" + with mapping_path.open() as fh: + config = yaml.safe_load(fh) + + rules: list[dict] = [] + for field in config.get("fields", []): + py = field.get("python", {}) + if py.get("skip"): + continue + + field_name = field["name"] + old_pattern = py["old_pattern"] + new_type = py["new_type"] + k8s_import = py["import"] + + # Build regex: match the field declaration line + if old_pattern == "Any": + regex = rf"^(\s+{field_name}:\s+)Any(\s*\|.*)" + elif old_pattern.startswith("dict["): + escaped = re.escape(old_pattern).replace(r"\ ", r"\s*") + regex = rf"^(\s+{field_name}:\s+){escaped}(\s*\|.*)" + else: + regex = rf"^(\s+{field_name}:\s+){re.escape(old_pattern)}(\s*\|.*)" + + replacement = rf"\g<1>{new_type}\g<2>" + rules.append({ + "field_name": field_name, + "regex": regex, + "replacement": replacement, + "old_pattern": old_pattern, + "new_type": new_type, + "k8s_import": k8s_import, + }) + return rules + + +# ── Diff collection ────────────────────────────────────────────────────────── + +def collect_changes(filepath: Path, rules: list[dict]) -> list[dict]: + """Scan a file and return a list of planned changes without modifying it.""" + lines = filepath.read_text().split("\n") + changes: list[dict] = [] + + for line_idx, line in enumerate(lines): + for rule in rules: + new_line = re.sub(rule["regex"], rule["replacement"], line) + if new_line != line: + changes.append({ + "file": filepath, + "line_no": line_idx + 1, + "field": rule["field_name"], + "old": line.strip(), + "new": new_line.strip(), + "k8s_import": rule["k8s_import"], + }) + return changes + + +# ── Apply patch ────────────────────────────────────────────────────────────── + +def apply_patch(filepath: Path, rules: list[dict]) -> bool: + """Apply all patches to a single file. Returns True if modified.""" + content = filepath.read_text() + original = content + lines = content.split("\n") + + # Step 1: Replace field types + used_k8s_types: set[str] = set() + for i, line in enumerate(lines): + for rule in rules: + new_line = re.sub(rule["regex"], rule["replacement"], line) + if new_line != line: + lines[i] = new_line + used_k8s_types.add(rule["k8s_import"]) + line = new_line + + if not used_k8s_types: + return False + + content = "\n".join(lines) + + # Step 2: Add kubernetes imports + sorted_types = sorted(used_k8s_types) + import_line = f"from kubernetes.client.models import {', '.join(sorted_types)}" + if import_line not in content: + content = re.sub( + r"(from pydantic import )", + import_line + "\n" + r"\g<1>", + content, + count=1, + ) + + # Step 3: Add ConfigDict to pydantic import + if "ConfigDict" not in content: + content = re.sub( + r"from pydantic import (.*)", + lambda m: f"from pydantic import ConfigDict, {m.group(1)}", + content, + count=1, + ) + + # Step 4: Add model_config to classes using K8s types + content = _inject_configdict(content, used_k8s_types) + + # Step 5: Clean up unused Any import + content = _cleanup_any_import(content) + + if content != original: + filepath.write_text(content) + return True + return False + + +def _inject_configdict(content: str, k8s_types: set[str]) -> str: + """Insert model_config = ConfigDict(...) into classes that use K8s types.""" + lines = content.split("\n") + result: list[str] = [] + i = 0 + while i < len(lines): + line = lines[i] + result.append(line) + + class_match = re.match(r"^class (\w+)\(BaseModel\):", line) + if class_match: + has_k8s_type = False + has_configdict = False + lookahead = i + 1 + while lookahead < len(lines): + next_line = lines[lookahead] + if re.match(r"^class \w+", next_line) or ( + next_line.strip() + and not next_line.startswith(" ") + and not next_line.startswith("#") + and not next_line.startswith('"""') + and not next_line.startswith(" ") + ): + break + if CONFIGDICT_MARKER in next_line: + has_configdict = True + for k8s_type in k8s_types: + if re.search(rf"\b{k8s_type}\b", next_line): + has_k8s_type = True + lookahead += 1 + + if has_k8s_type and not has_configdict: + j = i + 1 + if j < len(lines) and lines[j].strip().startswith('"""'): + if lines[j].strip().endswith('"""') and lines[j].strip() != '"""': + j += 1 + else: + j += 1 + while j < len(lines) and '"""' not in lines[j]: + j += 1 + j += 1 + + insert_pos = j + for k in range(i + 1, min(insert_pos, len(lines))): + result.append(lines[k]) + result.append(f" {CONFIGDICT_MARKER}") + result.append("") + i = insert_pos + continue + i += 1 + return "\n".join(result) + + +def _cleanup_any_import(content: str) -> str: + """Remove 'Any' from typing import if no longer used.""" + non_import_lines = [ + line for line in content.split("\n") if "from typing import" not in line + ] + if any(re.search(r"\bAny\b", line) for line in non_import_lines): + return content + + content = re.sub(r"from typing import Any\n", "", content) + content = re.sub(r"from typing import Any, ", "from typing import ", content) + content = re.sub(r"from typing import (.+), Any", r"from typing import \1", content) + return content + + +# ── Main ───────────────────────────────────────────────────────────────────── + +def main() -> None: + if len(sys.argv) < 3: + print(f"Usage: {sys.argv[0]} ", file=sys.stderr) + sys.exit(1) + + models_dir = Path(sys.argv[1]) + mapping_path = Path(sys.argv[2]) + + if not models_dir.is_dir(): + print(f"ERROR: Directory not found: {models_dir}", file=sys.stderr) + sys.exit(1) + if not mapping_path.is_file(): + print(f"ERROR: Mapping file not found: {mapping_path}", file=sys.stderr) + sys.exit(1) + + rules = load_python_rules(mapping_path) + + # Phase 1: Collect and print all planned changes + all_changes: list[dict] = [] + for py_file in sorted(models_dir.glob("*.py")): + if py_file.name == "__init__.py": + continue + all_changes.extend(collect_changes(py_file, rules)) + + if not all_changes: + print(" No Python type changes needed.") + return + + print(" Planned Python type changes:") + for change in all_changes: + print(f" {change['file'].name}:{change['line_no']} " + f"{change['field']}: {change['old']} → {change['new']}") + print() + + # Phase 2: Apply patches + patched_count = 0 + for py_file in sorted(models_dir.glob("*.py")): + if py_file.name == "__init__.py": + continue + if apply_patch(py_file, rules): + patched_count += 1 + + print(f" Patched {patched_count} Python file(s)") + + +if __name__ == "__main__": + main() diff --git a/clients/codegen/type_mapping.yaml b/clients/codegen/type_mapping.yaml new file mode 100644 index 0000000..a4f8e30 --- /dev/null +++ b/clients/codegen/type_mapping.yaml @@ -0,0 +1,50 @@ +# Type mapping rules for SDK type patching. +# +# After code generation, certain CRD fields marked with +# `x-kubernetes-preserve-unknown-fields: true` lose concrete type information. +# This file defines the replacement rules for each field. +# +# Maintenance: +# - When a new field with x-kubernetes-preserve-unknown-fields is added to CRDs, +# add a new entry below with the field name, Go type, and target types for each SDK. +# - Run `make generate-all` to regenerate + auto-patch. + +fields: + - name: metadata + go_type: "metav1.ObjectMeta" + java: + # Java generator handles ObjectMeta correctly, no patch needed + skip: true + python: + old_pattern: 'dict[str, Any]' + new_type: "V1ObjectMeta" + import: "V1ObjectMeta" + + - name: template + go_type: "*corev1.PodTemplateSpec" + java: + old_type: "io.fabric8.kubernetes.api.model.AnyType" + new_type: "io.fabric8.kubernetes.api.model.PodTemplateSpec" + python: + old_pattern: "Any" + new_type: "V1PodTemplateSpec" + import: "V1PodTemplateSpec" + + - name: volumeClaimTemplates + go_type: "[]corev1.PersistentVolumeClaim" + java: + old_type: "io.fabric8.kubernetes.api.model.AnyType" + new_type: "java.util.List" + python: + old_pattern: "Any" + new_type: "list[V1PersistentVolumeClaim]" + import: "V1PersistentVolumeClaim" + + - name: patch + go_type: "runtime.RawExtension" + java: + old_type: "io.fabric8.kubernetes.api.model.AnyType" + new_type: "io.fabric8.kubernetes.api.model.runtime.RawExtension" + python: + # RawExtension maps to dict/Any in Python, keep as-is + skip: true diff --git a/clients/java/pom.xml b/clients/java/pom.xml index eaf09f8..cccc889 100644 --- a/clients/java/pom.xml +++ b/clients/java/pom.xml @@ -259,11 +259,43 @@ jackson-databind-nullable 0.2.6 + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + javax.ws.rs javax.ws.rs-api 2.1.1 + + io.fabric8 + kubernetes-client-api + ${fabric8.version} + + + io.fabric8 + kubernetes-client + ${fabric8.version} + runtime + + + io.fabric8 + generator-annotations + ${fabric8.version} + @@ -274,6 +306,8 @@ 1.5.15 2.10.1 2.9.9 + 6.14.0 + 2.19.0 1.60.0 4.34.0 1.0.0 diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/Checkpoint.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/Checkpoint.java new file mode 100644 index 0000000..7070d8c --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/Checkpoint.java @@ -0,0 +1,9 @@ +package io.openkruise.agents.client.v2.models; + +@io.fabric8.kubernetes.model.annotation.Version(value = "v1alpha1" , storage = true , served = true) +@io.fabric8.kubernetes.model.annotation.Group("agents.kruise.io") +@io.fabric8.kubernetes.model.annotation.Singular("checkpoint") +@io.fabric8.kubernetes.model.annotation.Plural("checkpoints") +public class Checkpoint extends io.fabric8.kubernetes.client.CustomResource implements io.fabric8.kubernetes.api.model.Namespaced { +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/CheckpointSpec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/CheckpointSpec.java new file mode 100644 index 0000000..8c269e6 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/CheckpointSpec.java @@ -0,0 +1,89 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"keepRunning","persistentContents","podName","sandboxName","ttlAfterFinished"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class CheckpointSpec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * KeepRunning indicates whether the pod remains in the Running state after passing the checkpoint. + * Default is true. + */ + @com.fasterxml.jackson.annotation.JsonProperty("keepRunning") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("KeepRunning indicates whether the pod remains in the Running state after passing the checkpoint.\nDefault is true.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Boolean keepRunning; + + public Boolean getKeepRunning() { + return keepRunning; + } + + public void setKeepRunning(Boolean keepRunning) { + this.keepRunning = keepRunning; + } + + /** + * PersistentContents indicates resume pod with persistent content, Enum: memory, filesystem + */ + @com.fasterxml.jackson.annotation.JsonProperty("persistentContents") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PersistentContents indicates resume pod with persistent content, Enum: memory, filesystem") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List persistentContents; + + public java.util.List getPersistentContents() { + return persistentContents; + } + + public void setPersistentContents(java.util.List persistentContents) { + this.persistentContents = persistentContents; + } + + /** + * PodName is checkpoint podName. + */ + @com.fasterxml.jackson.annotation.JsonProperty("podName") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PodName is checkpoint podName.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String podName; + + public String getPodName() { + return podName; + } + + public void setPodName(String podName) { + this.podName = podName; + } + + /** + * SandboxName is checkpoint sandboxName. + */ + @com.fasterxml.jackson.annotation.JsonProperty("sandboxName") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("SandboxName is checkpoint sandboxName.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String sandboxName; + + public String getSandboxName() { + return sandboxName; + } + + public void setSandboxName(String sandboxName) { + this.sandboxName = sandboxName; + } + + /** + * valid format: 30s, 30m, 30d + */ + @com.fasterxml.jackson.annotation.JsonProperty("ttlAfterFinished") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("valid format: 30s, 30m, 30d") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String ttlAfterFinished; + + public String getTtlAfterFinished() { + return ttlAfterFinished; + } + + public void setTtlAfterFinished(String ttlAfterFinished) { + this.ttlAfterFinished = ttlAfterFinished; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/CheckpointStatus.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/CheckpointStatus.java new file mode 100644 index 0000000..2c8df30 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/CheckpointStatus.java @@ -0,0 +1,91 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"checkpointId","completionTime","message","observedGeneration","phase"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class CheckpointStatus implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * checkpoint-id + */ + @com.fasterxml.jackson.annotation.JsonProperty("checkpointId") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("checkpoint-id") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String checkpointId; + + public String getCheckpointId() { + return checkpointId; + } + + public void setCheckpointId(String checkpointId) { + this.checkpointId = checkpointId; + } + + /** + * CompletionTime is checkpoint completed time, and phase is Succeeded or Failed. + */ + @com.fasterxml.jackson.annotation.JsonProperty("completionTime") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("CompletionTime is checkpoint completed time, and phase is Succeeded or Failed.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime completionTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getCompletionTime() { + return completionTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setCompletionTime(java.time.ZonedDateTime completionTime) { + this.completionTime = completionTime; + } + + /** + * message + */ + @com.fasterxml.jackson.annotation.JsonProperty("message") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("message") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + /** + * observedGeneration is the most recent generation observed for this Checkpoint. It corresponds to the + * Checkpoint's generation, which is updated on mutation by the API Server. + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("observedGeneration is the most recent generation observed for this Checkpoint. It corresponds to the\nCheckpoint's generation, which is updated on mutation by the API Server.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * Checkpoint Phase + */ + @com.fasterxml.jackson.annotation.JsonProperty("phase") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Checkpoint Phase") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String phase; + + public String getPhase() { + return phase; + } + + public void setPhase(String phase) { + this.phase = phase; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/Sandbox.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/Sandbox.java new file mode 100644 index 0000000..37e2539 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/Sandbox.java @@ -0,0 +1,9 @@ +package io.openkruise.agents.client.v2.models; + +@io.fabric8.kubernetes.model.annotation.Version(value = "v1alpha1" , storage = true , served = true) +@io.fabric8.kubernetes.model.annotation.Group("agents.kruise.io") +@io.fabric8.kubernetes.model.annotation.Singular("sandbox") +@io.fabric8.kubernetes.model.annotation.Plural("sandboxes") +public class Sandbox extends io.fabric8.kubernetes.client.CustomResource implements io.fabric8.kubernetes.api.model.Namespaced { +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaim.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaim.java new file mode 100644 index 0000000..4e0f86b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaim.java @@ -0,0 +1,9 @@ +package io.openkruise.agents.client.v2.models; + +@io.fabric8.kubernetes.model.annotation.Version(value = "v1alpha1" , storage = true , served = true) +@io.fabric8.kubernetes.model.annotation.Group("agents.kruise.io") +@io.fabric8.kubernetes.model.annotation.Singular("sandboxclaim") +@io.fabric8.kubernetes.model.annotation.Plural("sandboxclaims") +public class SandboxClaim extends io.fabric8.kubernetes.client.CustomResource implements io.fabric8.kubernetes.api.model.Namespaced { +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaimSpec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaimSpec.java new file mode 100644 index 0000000..e71ae95 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaimSpec.java @@ -0,0 +1,266 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"annotations","claimTimeout","createOnNoStock","dynamicVolumesMount","envVars","inplaceUpdate","labels","replicas","reserveFailedSandbox","runtimes","shutdownTime","skipInitRuntime","templateName","ttlAfterCompleted","waitReadyTimeout"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxClaimSpec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Annotations contains key-value pairs to be added as annotations + * to claimed Sandbox resources + */ + @com.fasterxml.jackson.annotation.JsonProperty("annotations") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Annotations contains key-value pairs to be added as annotations\nto claimed Sandbox resources") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.Map annotations; + + public java.util.Map getAnnotations() { + return annotations; + } + + public void setAnnotations(java.util.Map annotations) { + this.annotations = annotations; + } + + /** + * ClaimTimeout specifies the maximum duration to wait for claiming sandboxes + * If the timeout is reached, the claim will be marked as Completed regardless of + * whether all replicas were successfully claimed + */ + @com.fasterxml.jackson.annotation.JsonProperty("claimTimeout") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("ClaimTimeout specifies the maximum duration to wait for claiming sandboxes\nIf the timeout is reached, the claim will be marked as Completed regardless of\nwhether all replicas were successfully claimed") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String claimTimeout = "1m"; + + public String getClaimTimeout() { + return claimTimeout; + } + + public void setClaimTimeout(String claimTimeout) { + this.claimTimeout = claimTimeout; + } + + /** + * CreateOnNoStock allows to create new sandbox if no stock available + */ + @com.fasterxml.jackson.annotation.JsonProperty("createOnNoStock") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("CreateOnNoStock allows to create new sandbox if no stock available") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Boolean createOnNoStock = true; + + public Boolean getCreateOnNoStock() { + return createOnNoStock; + } + + public void setCreateOnNoStock(Boolean createOnNoStock) { + this.createOnNoStock = createOnNoStock; + } + + /** + * DynamicVolumesMount specifies the dynamic volumes to be mounted into the sandbox + */ + @com.fasterxml.jackson.annotation.JsonProperty("dynamicVolumesMount") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("DynamicVolumesMount specifies the dynamic volumes to be mounted into the sandbox") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List dynamicVolumesMount; + + public java.util.List getDynamicVolumesMount() { + return dynamicVolumesMount; + } + + public void setDynamicVolumesMount(java.util.List dynamicVolumesMount) { + this.dynamicVolumesMount = dynamicVolumesMount; + } + + /** + * EnvVars contains environment variables to be injected into the sandbox + * These will be passed to the sandbox's init endpoint (envd) after claiming + * Only applicable if the SandboxSet has envd enabled + */ + @com.fasterxml.jackson.annotation.JsonProperty("envVars") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("EnvVars contains environment variables to be injected into the sandbox\nThese will be passed to the sandbox's init endpoint (envd) after claiming\nOnly applicable if the SandboxSet has envd enabled") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.Map envVars; + + public java.util.Map getEnvVars() { + return envVars; + } + + public void setEnvVars(java.util.Map envVars) { + this.envVars = envVars; + } + + /** + * InplaceUpdate allows to perform inplace update for sandbox while claiming + */ + @com.fasterxml.jackson.annotation.JsonProperty("inplaceUpdate") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("InplaceUpdate allows to perform inplace update for sandbox while claiming") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxclaimspec.InplaceUpdate inplaceUpdate; + + public io.openkruise.agents.client.v2.models.sandboxclaimspec.InplaceUpdate getInplaceUpdate() { + return inplaceUpdate; + } + + public void setInplaceUpdate(io.openkruise.agents.client.v2.models.sandboxclaimspec.InplaceUpdate inplaceUpdate) { + this.inplaceUpdate = inplaceUpdate; + } + + /** + * Labels contains key-value pairs to be added as labels + * to claimed Sandbox resources + */ + @com.fasterxml.jackson.annotation.JsonProperty("labels") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Labels contains key-value pairs to be added as labels\nto claimed Sandbox resources") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.Map labels; + + public java.util.Map getLabels() { + return labels; + } + + public void setLabels(java.util.Map labels) { + this.labels = labels; + } + + /** + * Replicas specifies how many sandboxes to claim (default: 1) + * For batch claiming support + * This field is immutable once set + */ + @com.fasterxml.jackson.annotation.JsonProperty("replicas") + @io.fabric8.generator.annotation.Min(1.0) + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Replicas specifies how many sandboxes to claim (default: 1)\nFor batch claiming support\nThis field is immutable once set") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer replicas = 1; + + public Integer getReplicas() { + return replicas; + } + + public void setReplicas(Integer replicas) { + this.replicas = replicas; + } + + /** + * Set ReserveFailedSandbox to true to reserve failed sandboxes + */ + @com.fasterxml.jackson.annotation.JsonProperty("reserveFailedSandbox") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Set ReserveFailedSandbox to true to reserve failed sandboxes") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Boolean reserveFailedSandbox; + + public Boolean getReserveFailedSandbox() { + return reserveFailedSandbox; + } + + public void setReserveFailedSandbox(Boolean reserveFailedSandbox) { + this.reserveFailedSandbox = reserveFailedSandbox; + } + + /** + * Runtimes - Runtime configuration for sandbox object + */ + @com.fasterxml.jackson.annotation.JsonProperty("runtimes") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Runtimes - Runtime configuration for sandbox object") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List runtimes; + + public java.util.List getRuntimes() { + return runtimes; + } + + public void setRuntimes(java.util.List runtimes) { + this.runtimes = runtimes; + } + + /** + * ShutdownTime specifies the absolute time when the sandbox should be shut down + * This will be set as spec.shutdownTime (absolute time) on the Sandbox + */ + @com.fasterxml.jackson.annotation.JsonProperty("shutdownTime") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("ShutdownTime specifies the absolute time when the sandbox should be shut down\nThis will be set as spec.shutdownTime (absolute time) on the Sandbox") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime shutdownTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getShutdownTime() { + return shutdownTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setShutdownTime(java.time.ZonedDateTime shutdownTime) { + this.shutdownTime = shutdownTime; + } + + /** + * SkipInitRuntime allows to skip init runtime for sandbox while claiming + */ + @com.fasterxml.jackson.annotation.JsonProperty("skipInitRuntime") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("SkipInitRuntime allows to skip init runtime for sandbox while claiming") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Boolean skipInitRuntime = false; + + public Boolean getSkipInitRuntime() { + return skipInitRuntime; + } + + public void setSkipInitRuntime(Boolean skipInitRuntime) { + this.skipInitRuntime = skipInitRuntime; + } + + /** + * TemplateName specifies which SandboxSet pool to claim from + */ + @com.fasterxml.jackson.annotation.JsonProperty("templateName") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("TemplateName specifies which SandboxSet pool to claim from") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String templateName; + + public String getTemplateName() { + return templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + /** + * TTLAfterCompleted specifies the time to live after the claim reaches Completed phase + * After this duration, the SandboxClaim will be automatically deleted. + * Note: Only the SandboxClaim resource will be deleted; the claimed sandboxes will NOT be deleted + * Set to a negative value (e.g., "-1s") to disable automatic deletion (never delete). + */ + @com.fasterxml.jackson.annotation.JsonProperty("ttlAfterCompleted") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("TTLAfterCompleted specifies the time to live after the claim reaches Completed phase\nAfter this duration, the SandboxClaim will be automatically deleted.\nNote: Only the SandboxClaim resource will be deleted; the claimed sandboxes will NOT be deleted\nSet to a negative value (e.g., \"-1s\") to disable automatic deletion (never delete).") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String ttlAfterCompleted = "60m"; + + public String getTtlAfterCompleted() { + return ttlAfterCompleted; + } + + public void setTtlAfterCompleted(String ttlAfterCompleted) { + this.ttlAfterCompleted = ttlAfterCompleted; + } + + /** + * WaitReadyTimeout specifies the maximum duration for waiting claimed sandbox ready. Default: 30s. + * A waiting happens when an inplace update happens, a new sandbox created, etc. + * Format: duration string (e.g., "3h", "200s", "15m") + */ + @com.fasterxml.jackson.annotation.JsonProperty("waitReadyTimeout") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("WaitReadyTimeout specifies the maximum duration for waiting claimed sandbox ready. Default: 30s.\nA waiting happens when an inplace update happens, a new sandbox created, etc.\nFormat: duration string (e.g., \"3h\", \"200s\", \"15m\")") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String waitReadyTimeout = "30s"; + + public String getWaitReadyTimeout() { + return waitReadyTimeout; + } + + public void setWaitReadyTimeout(String waitReadyTimeout) { + this.waitReadyTimeout = waitReadyTimeout; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaimStatus.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaimStatus.java new file mode 100644 index 0000000..8dbeffb --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxClaimStatus.java @@ -0,0 +1,130 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"claimStartTime","claimedReplicas","completionTime","conditions","message","observedGeneration","phase"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxClaimStatus implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * ClaimStartTime is the timestamp when claiming started + * Used for calculating timeout + */ + @com.fasterxml.jackson.annotation.JsonProperty("claimStartTime") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("ClaimStartTime is the timestamp when claiming started\nUsed for calculating timeout") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime claimStartTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getClaimStartTime() { + return claimStartTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setClaimStartTime(java.time.ZonedDateTime claimStartTime) { + this.claimStartTime = claimStartTime; + } + + /** + * ClaimedReplicas indicates how many sandboxes are currently claimed (total) + * This is determined by querying sandboxes with matching ownerReference + * Only updated during Pending and Claiming phases + */ + @com.fasterxml.jackson.annotation.JsonProperty("claimedReplicas") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("ClaimedReplicas indicates how many sandboxes are currently claimed (total)\nThis is determined by querying sandboxes with matching ownerReference\nOnly updated during Pending and Claiming phases") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer claimedReplicas; + + public Integer getClaimedReplicas() { + return claimedReplicas; + } + + public void setClaimedReplicas(Integer claimedReplicas) { + this.claimedReplicas = claimedReplicas; + } + + /** + * CompletionTime is the timestamp when the claim reached Completed phase + * Used for TTL calculation + */ + @com.fasterxml.jackson.annotation.JsonProperty("completionTime") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("CompletionTime is the timestamp when the claim reached Completed phase\nUsed for TTL calculation") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime completionTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getCompletionTime() { + return completionTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setCompletionTime(java.time.ZonedDateTime completionTime) { + this.completionTime = completionTime; + } + + /** + * Conditions represent the current state of the SandboxClaim + */ + @com.fasterxml.jackson.annotation.JsonProperty("conditions") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Conditions represent the current state of the SandboxClaim") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List conditions; + + public java.util.List getConditions() { + return conditions; + } + + public void setConditions(java.util.List conditions) { + this.conditions = conditions; + } + + /** + * Message provides human-readable details about the current phase + */ + @com.fasterxml.jackson.annotation.JsonProperty("message") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Message provides human-readable details about the current phase") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + /** + * ObservedGeneration is the most recent generation observed + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("ObservedGeneration is the most recent generation observed") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * Phase represents the current phase of the claim + * Claiming: In the process of claiming sandboxes + * Completed: Claim process finished (either all replicas claimed or timeout reached) + */ + @com.fasterxml.jackson.annotation.JsonProperty("phase") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Phase represents the current phase of the claim\nClaiming: In the process of claiming sandboxes\nCompleted: Claim process finished (either all replicas claimed or timeout reached)") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String phase; + + public String getPhase() { + return phase; + } + + public void setPhase(String phase) { + this.phase = phase; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSet.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSet.java new file mode 100644 index 0000000..4c59d98 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSet.java @@ -0,0 +1,9 @@ +package io.openkruise.agents.client.v2.models; + +@io.fabric8.kubernetes.model.annotation.Version(value = "v1alpha1" , storage = true , served = true) +@io.fabric8.kubernetes.model.annotation.Group("agents.kruise.io") +@io.fabric8.kubernetes.model.annotation.Singular("sandboxset") +@io.fabric8.kubernetes.model.annotation.Plural("sandboxsets") +public class SandboxSet extends io.fabric8.kubernetes.client.CustomResource implements io.fabric8.kubernetes.api.model.Namespaced { +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSetSpec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSetSpec.java new file mode 100644 index 0000000..59c0d62 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSetSpec.java @@ -0,0 +1,140 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"persistentContents","replicas","runtimes","scaleStrategy","template","templateRef","updateStrategy","volumeClaimTemplates"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxSetSpec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * PersistentContents indicates resume pod with persistent content, Enum: ip, memory, filesystem + */ + @com.fasterxml.jackson.annotation.JsonProperty("persistentContents") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PersistentContents indicates resume pod with persistent content, Enum: ip, memory, filesystem") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List persistentContents; + + public java.util.List getPersistentContents() { + return persistentContents; + } + + public void setPersistentContents(java.util.List persistentContents) { + this.persistentContents = persistentContents; + } + + /** + * Replicas is the number of unused sandboxes, including available and creating ones. + */ + @com.fasterxml.jackson.annotation.JsonProperty("replicas") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Replicas is the number of unused sandboxes, including available and creating ones.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer replicas; + + public Integer getReplicas() { + return replicas; + } + + public void setReplicas(Integer replicas) { + this.replicas = replicas; + } + + /** + * Runtimes - Runtime configuration for sandbox object + */ + @com.fasterxml.jackson.annotation.JsonProperty("runtimes") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Runtimes - Runtime configuration for sandbox object") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List runtimes; + + public java.util.List getRuntimes() { + return runtimes; + } + + public void setRuntimes(java.util.List runtimes) { + this.runtimes = runtimes; + } + + /** + * ScaleStrategy indicates the ScaleStrategy that will be employed to + * create and delete Sandboxes in the SandboxSet. + */ + @com.fasterxml.jackson.annotation.JsonProperty("scaleStrategy") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("ScaleStrategy indicates the ScaleStrategy that will be employed to\ncreate and delete Sandboxes in the SandboxSet.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxsetspec.ScaleStrategy scaleStrategy; + + public io.openkruise.agents.client.v2.models.sandboxsetspec.ScaleStrategy getScaleStrategy() { + return scaleStrategy; + } + + public void setScaleStrategy(io.openkruise.agents.client.v2.models.sandboxsetspec.ScaleStrategy scaleStrategy) { + this.scaleStrategy = scaleStrategy; + } + + /** + * Template describes the pods that will be created. + * Template is mutual exclusive with TemplateRef + */ + @com.fasterxml.jackson.annotation.JsonProperty("template") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Template describes the pods that will be created.\nTemplate is mutual exclusive with TemplateRef") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.fabric8.kubernetes.api.model.PodTemplateSpec template; + + public io.fabric8.kubernetes.api.model.PodTemplateSpec getTemplate() { + return template; + } + + public void setTemplate(io.fabric8.kubernetes.api.model.PodTemplateSpec template) { + this.template = template; + } + + /** + * TemplateRef references a SandboxTemplate, which will be used to create the sandbox. + */ + @com.fasterxml.jackson.annotation.JsonProperty("templateRef") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("TemplateRef references a SandboxTemplate, which will be used to create the sandbox.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxsetspec.TemplateRef templateRef; + + public io.openkruise.agents.client.v2.models.sandboxsetspec.TemplateRef getTemplateRef() { + return templateRef; + } + + public void setTemplateRef(io.openkruise.agents.client.v2.models.sandboxsetspec.TemplateRef templateRef) { + this.templateRef = templateRef; + } + + /** + * UpdateStrategy indicates the strategy that will be employed to + * update Sandboxes in the SandboxSet when the template changes. + */ + @com.fasterxml.jackson.annotation.JsonProperty("updateStrategy") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpdateStrategy indicates the strategy that will be employed to\nupdate Sandboxes in the SandboxSet when the template changes.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxsetspec.UpdateStrategy updateStrategy; + + public io.openkruise.agents.client.v2.models.sandboxsetspec.UpdateStrategy getUpdateStrategy() { + return updateStrategy; + } + + public void setUpdateStrategy(io.openkruise.agents.client.v2.models.sandboxsetspec.UpdateStrategy updateStrategy) { + this.updateStrategy = updateStrategy; + } + + /** + * VolumeClaimTemplates is a list of PVC templates to create for this Sandbox. + */ + @com.fasterxml.jackson.annotation.JsonProperty("volumeClaimTemplates") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("VolumeClaimTemplates is a list of PVC templates to create for this Sandbox.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List volumeClaimTemplates; + + public java.util.List getVolumeClaimTemplates() { + return volumeClaimTemplates; + } + + public void setVolumeClaimTemplates(java.util.List volumeClaimTemplates) { + this.volumeClaimTemplates = volumeClaimTemplates; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSetStatus.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSetStatus.java new file mode 100644 index 0000000..0e26460 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSetStatus.java @@ -0,0 +1,144 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"availableReplicas","conditions","observedGeneration","replicas","selector","updateRevision","updatedAvailableReplicas","updatedReplicas"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxSetStatus implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * AvailableReplicas is the number of available sandboxes, which are ready to be claimed. + */ + @com.fasterxml.jackson.annotation.JsonProperty("availableReplicas") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("AvailableReplicas is the number of available sandboxes, which are ready to be claimed.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer availableReplicas; + + public Integer getAvailableReplicas() { + return availableReplicas; + } + + public void setAvailableReplicas(Integer availableReplicas) { + this.availableReplicas = availableReplicas; + } + + /** + * conditions represent the current state of the SandboxSet resource. + * Each condition has a unique type and reflects the status of a specific aspect of the resource. + * The status of each condition is one of True, False, or Unknown. + */ + @com.fasterxml.jackson.annotation.JsonProperty("conditions") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("conditions represent the current state of the SandboxSet resource.\nEach condition has a unique type and reflects the status of a specific aspect of the resource.\nThe status of each condition is one of True, False, or Unknown.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List conditions; + + public java.util.List getConditions() { + return conditions; + } + + public void setConditions(java.util.List conditions) { + this.conditions = conditions; + } + + /** + * observedGeneration is the most recent generation observed for this SandboxSet. It corresponds to the + * SandboxSet's generation, which is updated on mutation by the API Server. + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("observedGeneration is the most recent generation observed for this SandboxSet. It corresponds to the\nSandboxSet's generation, which is updated on mutation by the API Server.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * Replicas is the total number of creating, available, running and paused sandboxes. + */ + @com.fasterxml.jackson.annotation.JsonProperty("replicas") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Replicas is the total number of creating, available, running and paused sandboxes.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer replicas; + + public Integer getReplicas() { + return replicas; + } + + public void setReplicas(Integer replicas) { + this.replicas = replicas; + } + + /** + * Selector is a label query over pods that should match the replica count. + * This is same as the label selector but in the string format to avoid + * duplication for CRDs that do not support structural schemas. + */ + @com.fasterxml.jackson.annotation.JsonProperty("selector") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Selector is a label query over pods that should match the replica count.\nThis is same as the label selector but in the string format to avoid\nduplication for CRDs that do not support structural schemas.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String selector; + + public String getSelector() { + return selector; + } + + public void setSelector(String selector) { + this.selector = selector; + } + + /** + * UpdateRevision is the hash label of the ControllerRevision created from `spec.template`. + * It represents the latest desired template version. + */ + @com.fasterxml.jackson.annotation.JsonProperty("updateRevision") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpdateRevision is the hash label of the ControllerRevision created from `spec.template`.\nIt represents the latest desired template version.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String updateRevision; + + public String getUpdateRevision() { + return updateRevision; + } + + public void setUpdateRevision(String updateRevision) { + this.updateRevision = updateRevision; + } + + /** + * UpdatedAvailableReplicas is the number of updated sandboxes that are available. + */ + @com.fasterxml.jackson.annotation.JsonProperty("updatedAvailableReplicas") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpdatedAvailableReplicas is the number of updated sandboxes that are available.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer updatedAvailableReplicas; + + public Integer getUpdatedAvailableReplicas() { + return updatedAvailableReplicas; + } + + public void setUpdatedAvailableReplicas(Integer updatedAvailableReplicas) { + this.updatedAvailableReplicas = updatedAvailableReplicas; + } + + /** + * UpdatedReplicas is the number of sandboxes that have been updated to the UpdateRevision. + */ + @com.fasterxml.jackson.annotation.JsonProperty("updatedReplicas") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpdatedReplicas is the number of sandboxes that have been updated to the UpdateRevision.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer updatedReplicas; + + public Integer getUpdatedReplicas() { + return updatedReplicas; + } + + public void setUpdatedReplicas(Integer updatedReplicas) { + this.updatedReplicas = updatedReplicas; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSpec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSpec.java new file mode 100644 index 0000000..38f951b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxSpec.java @@ -0,0 +1,174 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"lifecycle","pauseTime","paused","persistentContents","runtimes","shutdownTime","template","templateRef","upgradePolicy","volumeClaimTemplates"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxSpec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Lifecycle defines lifecycle hooks for sandbox upgrade. + */ + @com.fasterxml.jackson.annotation.JsonProperty("lifecycle") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Lifecycle defines lifecycle hooks for sandbox upgrade.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxspec.Lifecycle lifecycle; + + public io.openkruise.agents.client.v2.models.sandboxspec.Lifecycle getLifecycle() { + return lifecycle; + } + + public void setLifecycle(io.openkruise.agents.client.v2.models.sandboxspec.Lifecycle lifecycle) { + this.lifecycle = lifecycle; + } + + /** + * PauseTime - Absolute time when the sandbox will be paused automatically. + */ + @com.fasterxml.jackson.annotation.JsonProperty("pauseTime") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PauseTime - Absolute time when the sandbox will be paused automatically.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime pauseTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getPauseTime() { + return pauseTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setPauseTime(java.time.ZonedDateTime pauseTime) { + this.pauseTime = pauseTime; + } + + /** + * Paused indicates whether pause the sandbox pod. + */ + @com.fasterxml.jackson.annotation.JsonProperty("paused") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Paused indicates whether pause the sandbox pod.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Boolean paused; + + public Boolean getPaused() { + return paused; + } + + public void setPaused(Boolean paused) { + this.paused = paused; + } + + /** + * PersistentContents indicates resume pod with persistent content, Enum: ip, memory, filesystem + */ + @com.fasterxml.jackson.annotation.JsonProperty("persistentContents") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PersistentContents indicates resume pod with persistent content, Enum: ip, memory, filesystem") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List persistentContents; + + public java.util.List getPersistentContents() { + return persistentContents; + } + + public void setPersistentContents(java.util.List persistentContents) { + this.persistentContents = persistentContents; + } + + /** + * Runtimes - Runtime configuration for sandbox object + */ + @com.fasterxml.jackson.annotation.JsonProperty("runtimes") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Runtimes - Runtime configuration for sandbox object") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List runtimes; + + public java.util.List getRuntimes() { + return runtimes; + } + + public void setRuntimes(java.util.List runtimes) { + this.runtimes = runtimes; + } + + /** + * ShutdownTime - Absolute time when the sandbox is deleted. + * If a time in the past is provided, the sandbox will be deleted immediately. + */ + @com.fasterxml.jackson.annotation.JsonProperty("shutdownTime") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("ShutdownTime - Absolute time when the sandbox is deleted.\nIf a time in the past is provided, the sandbox will be deleted immediately.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime shutdownTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getShutdownTime() { + return shutdownTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setShutdownTime(java.time.ZonedDateTime shutdownTime) { + this.shutdownTime = shutdownTime; + } + + /** + * Template describes the pods that will be created. + * Template is mutual exclusive with TemplateRef + */ + @com.fasterxml.jackson.annotation.JsonProperty("template") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Template describes the pods that will be created.\nTemplate is mutual exclusive with TemplateRef") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.fabric8.kubernetes.api.model.PodTemplateSpec template; + + public io.fabric8.kubernetes.api.model.PodTemplateSpec getTemplate() { + return template; + } + + public void setTemplate(io.fabric8.kubernetes.api.model.PodTemplateSpec template) { + this.template = template; + } + + /** + * TemplateRef references a SandboxTemplate, which will be used to create the sandbox. + */ + @com.fasterxml.jackson.annotation.JsonProperty("templateRef") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("TemplateRef references a SandboxTemplate, which will be used to create the sandbox.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxspec.TemplateRef templateRef; + + public io.openkruise.agents.client.v2.models.sandboxspec.TemplateRef getTemplateRef() { + return templateRef; + } + + public void setTemplateRef(io.openkruise.agents.client.v2.models.sandboxspec.TemplateRef templateRef) { + this.templateRef = templateRef; + } + + /** + * UpgradePolicy defines the upgrade strategy for the sandbox. + */ + @com.fasterxml.jackson.annotation.JsonProperty("upgradePolicy") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpgradePolicy defines the upgrade strategy for the sandbox.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxspec.UpgradePolicy upgradePolicy; + + public io.openkruise.agents.client.v2.models.sandboxspec.UpgradePolicy getUpgradePolicy() { + return upgradePolicy; + } + + public void setUpgradePolicy(io.openkruise.agents.client.v2.models.sandboxspec.UpgradePolicy upgradePolicy) { + this.upgradePolicy = upgradePolicy; + } + + /** + * VolumeClaimTemplates is a list of PVC templates to create for this Sandbox. + */ + @com.fasterxml.jackson.annotation.JsonProperty("volumeClaimTemplates") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("VolumeClaimTemplates is a list of PVC templates to create for this Sandbox.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List volumeClaimTemplates; + + public java.util.List getVolumeClaimTemplates() { + return volumeClaimTemplates; + } + + public void setVolumeClaimTemplates(java.util.List volumeClaimTemplates) { + this.volumeClaimTemplates = volumeClaimTemplates; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxStatus.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxStatus.java new file mode 100644 index 0000000..39b7071 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxStatus.java @@ -0,0 +1,139 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"conditions","message","nodeName","observedGeneration","phase","podInfo","sandboxIp","updateRevision"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxStatus implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * conditions represent the current state of the Sandbox resource. + * Each condition has a unique type and reflects the status of a specific aspect of the resource. + * The status of each condition is one of True, False, or Unknown. + */ + @com.fasterxml.jackson.annotation.JsonProperty("conditions") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("conditions represent the current state of the Sandbox resource.\nEach condition has a unique type and reflects the status of a specific aspect of the resource.\nThe status of each condition is one of True, False, or Unknown.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List conditions; + + public java.util.List getConditions() { + return conditions; + } + + public void setConditions(java.util.List conditions) { + this.conditions = conditions; + } + + /** + * message + */ + @com.fasterxml.jackson.annotation.JsonProperty("message") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("message") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + /** + * NodeName indicates in which node this sandbox is scheduled. + */ + @com.fasterxml.jackson.annotation.JsonProperty("nodeName") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("NodeName indicates in which node this sandbox is scheduled.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String nodeName; + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + /** + * observedGeneration is the most recent generation observed for this Sandbox. It corresponds to the + * Sandbox's generation, which is updated on mutation by the API Server. + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("observedGeneration is the most recent generation observed for this Sandbox. It corresponds to the\nSandbox's generation, which is updated on mutation by the API Server.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * Sandbox Phase + */ + @com.fasterxml.jackson.annotation.JsonProperty("phase") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Sandbox Phase") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String phase; + + public String getPhase() { + return phase; + } + + public void setPhase(String phase) { + this.phase = phase; + } + + /** + * Pod Info + */ + @com.fasterxml.jackson.annotation.JsonProperty("podInfo") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Pod Info") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxstatus.PodInfo podInfo; + + public io.openkruise.agents.client.v2.models.sandboxstatus.PodInfo getPodInfo() { + return podInfo; + } + + public void setPodInfo(io.openkruise.agents.client.v2.models.sandboxstatus.PodInfo podInfo) { + this.podInfo = podInfo; + } + + /** + * SandboxIp is the ip address allocated to the sandbox. + */ + @com.fasterxml.jackson.annotation.JsonProperty("sandboxIp") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("SandboxIp is the ip address allocated to the sandbox.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String sandboxIp; + + public String getSandboxIp() { + return sandboxIp; + } + + public void setSandboxIp(String sandboxIp) { + this.sandboxIp = sandboxIp; + } + + /** + * UpdateRevision is the template-hash calculated from `spec.template`. + */ + @com.fasterxml.jackson.annotation.JsonProperty("updateRevision") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpdateRevision is the template-hash calculated from `spec.template`.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String updateRevision; + + public String getUpdateRevision() { + return updateRevision; + } + + public void setUpdateRevision(String updateRevision) { + this.updateRevision = updateRevision; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxTemplate.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxTemplate.java new file mode 100644 index 0000000..94177f6 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxTemplate.java @@ -0,0 +1,9 @@ +package io.openkruise.agents.client.v2.models; + +@io.fabric8.kubernetes.model.annotation.Version(value = "v1alpha1" , storage = true , served = true) +@io.fabric8.kubernetes.model.annotation.Group("agents.kruise.io") +@io.fabric8.kubernetes.model.annotation.Singular("sandboxtemplate") +@io.fabric8.kubernetes.model.annotation.Plural("sandboxtemplates") +public class SandboxTemplate extends io.fabric8.kubernetes.client.CustomResource implements io.fabric8.kubernetes.api.model.Namespaced { +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxTemplateSpec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxTemplateSpec.java new file mode 100644 index 0000000..472caa5 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxTemplateSpec.java @@ -0,0 +1,73 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"persistentContents","runtimes","template","volumeClaimTemplates"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxTemplateSpec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * PersistentContents indicates resume pod with persistent content, Enum: ip, memory, filesystem + */ + @com.fasterxml.jackson.annotation.JsonProperty("persistentContents") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PersistentContents indicates resume pod with persistent content, Enum: ip, memory, filesystem") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List persistentContents; + + public java.util.List getPersistentContents() { + return persistentContents; + } + + public void setPersistentContents(java.util.List persistentContents) { + this.persistentContents = persistentContents; + } + + /** + * Runtimes - Runtime configuration for sandbox object + */ + @com.fasterxml.jackson.annotation.JsonProperty("runtimes") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Runtimes - Runtime configuration for sandbox object") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List runtimes; + + public java.util.List getRuntimes() { + return runtimes; + } + + public void setRuntimes(java.util.List runtimes) { + this.runtimes = runtimes; + } + + /** + * Template describes the pods that will be created. + * Template is mutual exclusive with TemplateRef + */ + @com.fasterxml.jackson.annotation.JsonProperty("template") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Template describes the pods that will be created.\nTemplate is mutual exclusive with TemplateRef") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.fabric8.kubernetes.api.model.PodTemplateSpec template; + + public io.fabric8.kubernetes.api.model.PodTemplateSpec getTemplate() { + return template; + } + + public void setTemplate(io.fabric8.kubernetes.api.model.PodTemplateSpec template) { + this.template = template; + } + + /** + * VolumeClaimTemplates is a list of PVC templates to create for this Sandbox. + */ + @com.fasterxml.jackson.annotation.JsonProperty("volumeClaimTemplates") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("VolumeClaimTemplates is a list of PVC templates to create for this Sandbox.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List volumeClaimTemplates; + + public java.util.List getVolumeClaimTemplates() { + return volumeClaimTemplates; + } + + public void setVolumeClaimTemplates(java.util.List volumeClaimTemplates) { + this.volumeClaimTemplates = volumeClaimTemplates; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOps.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOps.java new file mode 100644 index 0000000..f9373ce --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOps.java @@ -0,0 +1,9 @@ +package io.openkruise.agents.client.v2.models; + +@io.fabric8.kubernetes.model.annotation.Version(value = "v1alpha1" , storage = true , served = true) +@io.fabric8.kubernetes.model.annotation.Group("agents.kruise.io") +@io.fabric8.kubernetes.model.annotation.Singular("sandboxupdateops") +@io.fabric8.kubernetes.model.annotation.Plural("sandboxupdateops") +public class SandboxUpdateOps extends io.fabric8.kubernetes.client.CustomResource implements io.fabric8.kubernetes.api.model.Namespaced { +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOpsSpec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOpsSpec.java new file mode 100644 index 0000000..0fecb7d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOpsSpec.java @@ -0,0 +1,90 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"lifecycle","patch","paused","selector","updateStrategy"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxUpdateOpsSpec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Lifecycle defines pre/post upgrade hooks to set on each sandbox during upgrade. + */ + @com.fasterxml.jackson.annotation.JsonProperty("lifecycle") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Lifecycle defines pre/post upgrade hooks to set on each sandbox during upgrade.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxupdateopsspec.Lifecycle lifecycle; + + public io.openkruise.agents.client.v2.models.sandboxupdateopsspec.Lifecycle getLifecycle() { + return lifecycle; + } + + public void setLifecycle(io.openkruise.agents.client.v2.models.sandboxupdateopsspec.Lifecycle lifecycle) { + this.lifecycle = lifecycle; + } + + /** + * Patch defines the changes to apply to each selected sandbox's template. + * The patch is applied as a Strategic Merge Patch on the sandbox's PodTemplateSpec. + */ + @com.fasterxml.jackson.annotation.JsonProperty("patch") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Patch defines the changes to apply to each selected sandbox's template.\nThe patch is applied as a Strategic Merge Patch on the sandbox's PodTemplateSpec.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.fabric8.kubernetes.api.model.runtime.RawExtension patch; + + public io.fabric8.kubernetes.api.model.runtime.RawExtension getPatch() { + return patch; + } + + public void setPatch(io.fabric8.kubernetes.api.model.runtime.RawExtension patch) { + this.patch = patch; + } + + /** + * Paused indicates whether the update operation is paused. + */ + @com.fasterxml.jackson.annotation.JsonProperty("paused") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Paused indicates whether the update operation is paused.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Boolean paused; + + public Boolean getPaused() { + return paused; + } + + public void setPaused(Boolean paused) { + this.paused = paused; + } + + /** + * Selector selects the target sandboxes to update by label. + */ + @com.fasterxml.jackson.annotation.JsonProperty("selector") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Selector selects the target sandboxes to update by label.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxupdateopsspec.Selector selector; + + public io.openkruise.agents.client.v2.models.sandboxupdateopsspec.Selector getSelector() { + return selector; + } + + public void setSelector(io.openkruise.agents.client.v2.models.sandboxupdateopsspec.Selector selector) { + this.selector = selector; + } + + /** + * UpdateStrategy defines the strategy for the batch update. + */ + @com.fasterxml.jackson.annotation.JsonProperty("updateStrategy") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpdateStrategy defines the strategy for the batch update.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxupdateopsspec.UpdateStrategy updateStrategy; + + public io.openkruise.agents.client.v2.models.sandboxupdateopsspec.UpdateStrategy getUpdateStrategy() { + return updateStrategy; + } + + public void setUpdateStrategy(io.openkruise.agents.client.v2.models.sandboxupdateopsspec.UpdateStrategy updateStrategy) { + this.updateStrategy = updateStrategy; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOpsStatus.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOpsStatus.java new file mode 100644 index 0000000..9761ab3 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/SandboxUpdateOpsStatus.java @@ -0,0 +1,124 @@ +package io.openkruise.agents.client.v2.models; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"conditions","failedReplicas","observedGeneration","phase","replicas","updatedReplicas","updatingReplicas"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class SandboxUpdateOpsStatus implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Conditions represents the latest available observations. + */ + @com.fasterxml.jackson.annotation.JsonProperty("conditions") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Conditions represents the latest available observations.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List conditions; + + public java.util.List getConditions() { + return conditions; + } + + public void setConditions(java.util.List conditions) { + this.conditions = conditions; + } + + /** + * FailedReplicas is the number of sandboxes that failed to update. + */ + @com.fasterxml.jackson.annotation.JsonProperty("failedReplicas") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("FailedReplicas is the number of sandboxes that failed to update.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer failedReplicas; + + public Integer getFailedReplicas() { + return failedReplicas; + } + + public void setFailedReplicas(Integer failedReplicas) { + this.failedReplicas = failedReplicas; + } + + /** + * ObservedGeneration is the most recent generation observed. + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("ObservedGeneration is the most recent generation observed.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * Phase is the current phase of the update operation. + */ + @com.fasterxml.jackson.annotation.JsonProperty("phase") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Phase is the current phase of the update operation.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String phase; + + public String getPhase() { + return phase; + } + + public void setPhase(String phase) { + this.phase = phase; + } + + /** + * Replicas is the total number of sandboxes selected for update. + */ + @com.fasterxml.jackson.annotation.JsonProperty("replicas") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Replicas is the total number of sandboxes selected for update.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer replicas; + + public Integer getReplicas() { + return replicas; + } + + public void setReplicas(Integer replicas) { + this.replicas = replicas; + } + + /** + * UpdatedReplicas is the number of sandboxes that have been successfully updated. + */ + @com.fasterxml.jackson.annotation.JsonProperty("updatedReplicas") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpdatedReplicas is the number of sandboxes that have been successfully updated.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer updatedReplicas; + + public Integer getUpdatedReplicas() { + return updatedReplicas; + } + + public void setUpdatedReplicas(Integer updatedReplicas) { + this.updatedReplicas = updatedReplicas; + } + + /** + * UpdatingReplicas is the number of sandboxes currently being updated. + */ + @com.fasterxml.jackson.annotation.JsonProperty("updatingReplicas") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("UpdatingReplicas is the number of sandboxes currently being updated.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer updatingReplicas; + + public Integer getUpdatingReplicas() { + return updatingReplicas; + } + + public void setUpdatingReplicas(Integer updatingReplicas) { + this.updatingReplicas = updatingReplicas; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/DynamicVolumesMount.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/DynamicVolumesMount.java new file mode 100644 index 0000000..a10a1d2 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/DynamicVolumesMount.java @@ -0,0 +1,70 @@ +package io.openkruise.agents.client.v2.models.sandboxclaimspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"mountID","mountPath","pvName","readOnly","subPath"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class DynamicVolumesMount implements io.fabric8.kubernetes.api.model.KubernetesResource { + + @com.fasterxml.jackson.annotation.JsonProperty("mountID") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String mountID; + + public String getMountID() { + return mountID; + } + + public void setMountID(String mountID) { + this.mountID = mountID; + } + + @com.fasterxml.jackson.annotation.JsonProperty("mountPath") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String mountPath; + + public String getMountPath() { + return mountPath; + } + + public void setMountPath(String mountPath) { + this.mountPath = mountPath; + } + + @com.fasterxml.jackson.annotation.JsonProperty("pvName") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String pvName; + + public String getPvName() { + return pvName; + } + + public void setPvName(String pvName) { + this.pvName = pvName; + } + + @com.fasterxml.jackson.annotation.JsonProperty("readOnly") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Boolean readOnly; + + public Boolean getReadOnly() { + return readOnly; + } + + public void setReadOnly(Boolean readOnly) { + this.readOnly = readOnly; + } + + @com.fasterxml.jackson.annotation.JsonProperty("subPath") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String subPath; + + public String getSubPath() { + return subPath; + } + + public void setSubPath(String subPath) { + this.subPath = subPath; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/InplaceUpdate.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/InplaceUpdate.java new file mode 100644 index 0000000..aebdff4 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/InplaceUpdate.java @@ -0,0 +1,40 @@ +package io.openkruise.agents.client.v2.models.sandboxclaimspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"image","resources"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class InplaceUpdate implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Image specifies the new image to update to. + */ + @com.fasterxml.jackson.annotation.JsonProperty("image") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Image specifies the new image to update to.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String image; + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + /** + * Resources specifies in-place resource update options. + */ + @com.fasterxml.jackson.annotation.JsonProperty("resources") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Resources specifies in-place resource update options.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxclaimspec.inplaceupdate.Resources resources; + + public io.openkruise.agents.client.v2.models.sandboxclaimspec.inplaceupdate.Resources getResources() { + return resources; + } + + public void setResources(io.openkruise.agents.client.v2.models.sandboxclaimspec.inplaceupdate.Resources resources) { + this.resources = resources; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/Runtimes.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/Runtimes.java new file mode 100644 index 0000000..54a2af4 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/Runtimes.java @@ -0,0 +1,21 @@ +package io.openkruise.agents.client.v2.models.sandboxclaimspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"name"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Runtimes implements io.fabric8.kubernetes.api.model.KubernetesResource { + + @com.fasterxml.jackson.annotation.JsonProperty("name") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/inplaceupdate/Resources.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/inplaceupdate/Resources.java new file mode 100644 index 0000000..6dd93ec --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimspec/inplaceupdate/Resources.java @@ -0,0 +1,46 @@ +package io.openkruise.agents.client.v2.models.sandboxclaimspec.inplaceupdate; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"limits","requests"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Resources implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Limits specifies the target resource limits for each container. + * Only CPU is supported for now. The container's original limit must already be set; + * otherwise the value is ignored. + * The new value must not change the Pod's QoS class; otherwise the claim will be rejected. + */ + @com.fasterxml.jackson.annotation.JsonProperty("limits") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Limits specifies the target resource limits for each container.\nOnly CPU is supported for now. The container's original limit must already be set;\notherwise the value is ignored.\nThe new value must not change the Pod's QoS class; otherwise the claim will be rejected.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.Map limits; + + public java.util.Map getLimits() { + return limits; + } + + public void setLimits(java.util.Map limits) { + this.limits = limits; + } + + /** + * Requests specifies the target resource requests for each container. + * Only CPU is supported for now. The container's original request must already be set; + * otherwise the value is ignored. + * The new value must not change the Pod's QoS class; otherwise the claim will be rejected. + */ + @com.fasterxml.jackson.annotation.JsonProperty("requests") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Requests specifies the target resource requests for each container.\nOnly CPU is supported for now. The container's original request must already be set;\notherwise the value is ignored.\nThe new value must not change the Pod's QoS class; otherwise the claim will be rejected.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.Map requests; + + public java.util.Map getRequests() { + return requests; + } + + public void setRequests(java.util.Map requests) { + this.requests = requests; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimstatus/Conditions.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimstatus/Conditions.java new file mode 100644 index 0000000..db53929 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxclaimstatus/Conditions.java @@ -0,0 +1,141 @@ +package io.openkruise.agents.client.v2.models.sandboxclaimstatus; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"lastTransitionTime","message","observedGeneration","reason","status","type"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Conditions implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * lastTransitionTime is the 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. + */ + @com.fasterxml.jackson.annotation.JsonProperty("lastTransitionTime") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("lastTransitionTime is the last time the condition transitioned from one status to another.\nThis should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime lastTransitionTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getLastTransitionTime() { + return lastTransitionTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setLastTransitionTime(java.time.ZonedDateTime lastTransitionTime) { + this.lastTransitionTime = lastTransitionTime; + } + + /** + * message is a human readable message indicating details about the transition. + * This may be an empty string. + */ + @com.fasterxml.jackson.annotation.JsonProperty("message") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("message is a human readable message indicating details about the transition.\nThis may be an empty string.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + /** + * observedGeneration represents the .metadata.generation that the condition was set based upon. + * For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + * with respect to the current state of the instance. + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @io.fabric8.generator.annotation.Min(0.0) + @com.fasterxml.jackson.annotation.JsonPropertyDescription("observedGeneration represents the .metadata.generation that the condition was set based upon.\nFor instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date\nwith respect to the current state of the instance.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * reason contains a programmatic identifier indicating the reason for the condition's last transition. + * Producers of specific condition types may define expected values and meanings for this field, + * and whether the values are considered a guaranteed API. + * The value should be a CamelCase string. + * This field may not be empty. + */ + @com.fasterxml.jackson.annotation.JsonProperty("reason") + @io.fabric8.generator.annotation.Required() + @io.fabric8.generator.annotation.Pattern("^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("reason contains a programmatic identifier indicating the reason for the condition's last transition.\nProducers of specific condition types may define expected values and meanings for this field,\nand whether the values are considered a guaranteed API.\nThe value should be a CamelCase string.\nThis field may not be empty.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String reason; + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public enum Status { + + @com.fasterxml.jackson.annotation.JsonProperty("True") + TRUE("True"), @com.fasterxml.jackson.annotation.JsonProperty("False") + FALSE("False"), @com.fasterxml.jackson.annotation.JsonProperty("Unknown") + UNKNOWN("Unknown"); + + java.lang.String value; + + Status(java.lang.String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue() + public java.lang.String getValue() { + return value; + } + } + + /** + * status of the condition, one of True, False, Unknown. + */ + @com.fasterxml.jackson.annotation.JsonProperty("status") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("status of the condition, one of True, False, Unknown.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Status status; + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + /** + * type of condition in CamelCase or in foo.example.com/CamelCase. + */ + @com.fasterxml.jackson.annotation.JsonProperty("type") + @io.fabric8.generator.annotation.Required() + @io.fabric8.generator.annotation.Pattern("^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("type of condition in CamelCase or in foo.example.com/CamelCase.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/Runtimes.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/Runtimes.java new file mode 100644 index 0000000..a1b0b85 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/Runtimes.java @@ -0,0 +1,21 @@ +package io.openkruise.agents.client.v2.models.sandboxsetspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"name"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Runtimes implements io.fabric8.kubernetes.api.model.KubernetesResource { + + @com.fasterxml.jackson.annotation.JsonProperty("name") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/ScaleStrategy.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/ScaleStrategy.java new file mode 100644 index 0000000..7adcdb7 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/ScaleStrategy.java @@ -0,0 +1,27 @@ +package io.openkruise.agents.client.v2.models.sandboxsetspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"maxUnavailable"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class ScaleStrategy implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * The maximum number of sandboxes that can be unavailable for scaled sandboxes. + * This field can control the changes rate of replicas for SandboxSet so as to minimize the impact for users' service. + * The scale will fail if the number of unavailable sandboxes were greater than this MaxUnavailable at scaling up. + * MaxUnavailable works only when scaling up. + */ + @com.fasterxml.jackson.annotation.JsonProperty("maxUnavailable") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("The maximum number of sandboxes that can be unavailable for scaled sandboxes.\nThis field can control the changes rate of replicas for SandboxSet so as to minimize the impact for users' service.\nThe scale will fail if the number of unavailable sandboxes were greater than this MaxUnavailable at scaling up.\nMaxUnavailable works only when scaling up.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.fabric8.kubernetes.api.model.IntOrString maxUnavailable; + + public io.fabric8.kubernetes.api.model.IntOrString getMaxUnavailable() { + return maxUnavailable; + } + + public void setMaxUnavailable(io.fabric8.kubernetes.api.model.IntOrString maxUnavailable) { + this.maxUnavailable = maxUnavailable; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/TemplateRef.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/TemplateRef.java new file mode 100644 index 0000000..83a994e --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/TemplateRef.java @@ -0,0 +1,59 @@ +package io.openkruise.agents.client.v2.models.sandboxsetspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"apiVersion","kind","name"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class TemplateRef implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * name of the SandboxTemplate apiVersion + * Default to v1 + */ + @com.fasterxml.jackson.annotation.JsonProperty("apiVersion") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("name of the SandboxTemplate apiVersion\nDefault to v1") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String apiVersion; + + public String getApiVersion() { + return apiVersion; + } + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + /** + * name of the SandboxTemplate kind + * Default to PodTemplate + */ + @com.fasterxml.jackson.annotation.JsonProperty("kind") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("name of the SandboxTemplate kind\nDefault to PodTemplate") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String kind; + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + /** + * name of the SandboxTemplate + */ + @com.fasterxml.jackson.annotation.JsonProperty("name") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("name of the SandboxTemplate") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/UpdateStrategy.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/UpdateStrategy.java new file mode 100644 index 0000000..d5680e7 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetspec/UpdateStrategy.java @@ -0,0 +1,27 @@ +package io.openkruise.agents.client.v2.models.sandboxsetspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"maxUnavailable"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class UpdateStrategy implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * MaxUnavailable is the maximum number or percentage of pods that can be unavailable during the update. + * MaxUnavailable can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). + * Absolute number is calculated from percentage by rounding down. + * Default is 20%. + */ + @com.fasterxml.jackson.annotation.JsonProperty("maxUnavailable") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("MaxUnavailable is the maximum number or percentage of pods that can be unavailable during the update.\nMaxUnavailable can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).\nAbsolute number is calculated from percentage by rounding down.\nDefault is 20%.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.fabric8.kubernetes.api.model.IntOrString maxUnavailable; + + public io.fabric8.kubernetes.api.model.IntOrString getMaxUnavailable() { + return maxUnavailable; + } + + public void setMaxUnavailable(io.fabric8.kubernetes.api.model.IntOrString maxUnavailable) { + this.maxUnavailable = maxUnavailable; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetstatus/Conditions.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetstatus/Conditions.java new file mode 100644 index 0000000..f96cb9b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxsetstatus/Conditions.java @@ -0,0 +1,141 @@ +package io.openkruise.agents.client.v2.models.sandboxsetstatus; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"lastTransitionTime","message","observedGeneration","reason","status","type"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Conditions implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * lastTransitionTime is the 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. + */ + @com.fasterxml.jackson.annotation.JsonProperty("lastTransitionTime") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("lastTransitionTime is the last time the condition transitioned from one status to another.\nThis should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime lastTransitionTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getLastTransitionTime() { + return lastTransitionTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setLastTransitionTime(java.time.ZonedDateTime lastTransitionTime) { + this.lastTransitionTime = lastTransitionTime; + } + + /** + * message is a human readable message indicating details about the transition. + * This may be an empty string. + */ + @com.fasterxml.jackson.annotation.JsonProperty("message") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("message is a human readable message indicating details about the transition.\nThis may be an empty string.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + /** + * observedGeneration represents the .metadata.generation that the condition was set based upon. + * For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + * with respect to the current state of the instance. + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @io.fabric8.generator.annotation.Min(0.0) + @com.fasterxml.jackson.annotation.JsonPropertyDescription("observedGeneration represents the .metadata.generation that the condition was set based upon.\nFor instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date\nwith respect to the current state of the instance.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * reason contains a programmatic identifier indicating the reason for the condition's last transition. + * Producers of specific condition types may define expected values and meanings for this field, + * and whether the values are considered a guaranteed API. + * The value should be a CamelCase string. + * This field may not be empty. + */ + @com.fasterxml.jackson.annotation.JsonProperty("reason") + @io.fabric8.generator.annotation.Required() + @io.fabric8.generator.annotation.Pattern("^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("reason contains a programmatic identifier indicating the reason for the condition's last transition.\nProducers of specific condition types may define expected values and meanings for this field,\nand whether the values are considered a guaranteed API.\nThe value should be a CamelCase string.\nThis field may not be empty.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String reason; + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public enum Status { + + @com.fasterxml.jackson.annotation.JsonProperty("True") + TRUE("True"), @com.fasterxml.jackson.annotation.JsonProperty("False") + FALSE("False"), @com.fasterxml.jackson.annotation.JsonProperty("Unknown") + UNKNOWN("Unknown"); + + java.lang.String value; + + Status(java.lang.String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue() + public java.lang.String getValue() { + return value; + } + } + + /** + * status of the condition, one of True, False, Unknown. + */ + @com.fasterxml.jackson.annotation.JsonProperty("status") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("status of the condition, one of True, False, Unknown.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Status status; + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + /** + * type of condition in CamelCase or in foo.example.com/CamelCase. + */ + @com.fasterxml.jackson.annotation.JsonProperty("type") + @io.fabric8.generator.annotation.Required() + @io.fabric8.generator.annotation.Pattern("^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("type of condition in CamelCase or in foo.example.com/CamelCase.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/Lifecycle.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/Lifecycle.java new file mode 100644 index 0000000..5c4cd0e --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/Lifecycle.java @@ -0,0 +1,42 @@ +package io.openkruise.agents.client.v2.models.sandboxspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"postUpgrade","preUpgrade"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Lifecycle implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * PostUpgrade is the action executed after the upgrade. + * It is typically used to restore workspace data. + */ + @com.fasterxml.jackson.annotation.JsonProperty("postUpgrade") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PostUpgrade is the action executed after the upgrade.\nIt is typically used to restore workspace data.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.PostUpgrade postUpgrade; + + public io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.PostUpgrade getPostUpgrade() { + return postUpgrade; + } + + public void setPostUpgrade(io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.PostUpgrade postUpgrade) { + this.postUpgrade = postUpgrade; + } + + /** + * PreUpgrade is the action executed before the upgrade. + * It is typically used to backup workspace data. + */ + @com.fasterxml.jackson.annotation.JsonProperty("preUpgrade") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PreUpgrade is the action executed before the upgrade.\nIt is typically used to backup workspace data.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.PreUpgrade preUpgrade; + + public io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.PreUpgrade getPreUpgrade() { + return preUpgrade; + } + + public void setPreUpgrade(io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.PreUpgrade preUpgrade) { + this.preUpgrade = preUpgrade; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/Runtimes.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/Runtimes.java new file mode 100644 index 0000000..2c70cf5 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/Runtimes.java @@ -0,0 +1,21 @@ +package io.openkruise.agents.client.v2.models.sandboxspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"name"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Runtimes implements io.fabric8.kubernetes.api.model.KubernetesResource { + + @com.fasterxml.jackson.annotation.JsonProperty("name") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/TemplateRef.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/TemplateRef.java new file mode 100644 index 0000000..a3f1513 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/TemplateRef.java @@ -0,0 +1,59 @@ +package io.openkruise.agents.client.v2.models.sandboxspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"apiVersion","kind","name"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class TemplateRef implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * name of the SandboxTemplate apiVersion + * Default to v1 + */ + @com.fasterxml.jackson.annotation.JsonProperty("apiVersion") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("name of the SandboxTemplate apiVersion\nDefault to v1") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String apiVersion; + + public String getApiVersion() { + return apiVersion; + } + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + /** + * name of the SandboxTemplate kind + * Default to PodTemplate + */ + @com.fasterxml.jackson.annotation.JsonProperty("kind") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("name of the SandboxTemplate kind\nDefault to PodTemplate") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String kind; + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + /** + * name of the SandboxTemplate + */ + @com.fasterxml.jackson.annotation.JsonProperty("name") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("name of the SandboxTemplate") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/UpgradePolicy.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/UpgradePolicy.java new file mode 100644 index 0000000..a066f10 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/UpgradePolicy.java @@ -0,0 +1,26 @@ +package io.openkruise.agents.client.v2.models.sandboxspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"type"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class UpgradePolicy implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Type specifies the upgrade policy type. + * When empty (default), upgrading is disabled. + * Supported values: Recreate. + */ + @com.fasterxml.jackson.annotation.JsonProperty("type") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Type specifies the upgrade policy type.\nWhen empty (default), upgrading is disabled.\nSupported values: Recreate.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/PostUpgrade.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/PostUpgrade.java new file mode 100644 index 0000000..48fa961 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/PostUpgrade.java @@ -0,0 +1,42 @@ +package io.openkruise.agents.client.v2.models.sandboxspec.lifecycle; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"exec","timeoutSeconds"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class PostUpgrade implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Exec specifies the command to execute inside the sandbox via envd. + * The first element is the command, the rest are args. + * For shell scripts, use: ["/bin/bash", "-c", "your-script"] + */ + @com.fasterxml.jackson.annotation.JsonProperty("exec") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Exec specifies the command to execute inside the sandbox via envd.\nThe first element is the command, the rest are args.\nFor shell scripts, use: [\"/bin/bash\", \"-c\", \"your-script\"]") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.postupgrade.Exec exec; + + public io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.postupgrade.Exec getExec() { + return exec; + } + + public void setExec(io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.postupgrade.Exec exec) { + this.exec = exec; + } + + /** + * TimeoutSeconds is the timeout for the action execution in seconds. + */ + @com.fasterxml.jackson.annotation.JsonProperty("timeoutSeconds") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("TimeoutSeconds is the timeout for the action execution in seconds.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer timeoutSeconds = 60; + + public Integer getTimeoutSeconds() { + return timeoutSeconds; + } + + public void setTimeoutSeconds(Integer timeoutSeconds) { + this.timeoutSeconds = timeoutSeconds; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/PreUpgrade.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/PreUpgrade.java new file mode 100644 index 0000000..64a1aff --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/PreUpgrade.java @@ -0,0 +1,42 @@ +package io.openkruise.agents.client.v2.models.sandboxspec.lifecycle; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"exec","timeoutSeconds"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class PreUpgrade implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Exec specifies the command to execute inside the sandbox via envd. + * The first element is the command, the rest are args. + * For shell scripts, use: ["/bin/bash", "-c", "your-script"] + */ + @com.fasterxml.jackson.annotation.JsonProperty("exec") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Exec specifies the command to execute inside the sandbox via envd.\nThe first element is the command, the rest are args.\nFor shell scripts, use: [\"/bin/bash\", \"-c\", \"your-script\"]") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.preupgrade.Exec exec; + + public io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.preupgrade.Exec getExec() { + return exec; + } + + public void setExec(io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.preupgrade.Exec exec) { + this.exec = exec; + } + + /** + * TimeoutSeconds is the timeout for the action execution in seconds. + */ + @com.fasterxml.jackson.annotation.JsonProperty("timeoutSeconds") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("TimeoutSeconds is the timeout for the action execution in seconds.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer timeoutSeconds = 60; + + public Integer getTimeoutSeconds() { + return timeoutSeconds; + } + + public void setTimeoutSeconds(Integer timeoutSeconds) { + this.timeoutSeconds = timeoutSeconds; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/postupgrade/Exec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/postupgrade/Exec.java new file mode 100644 index 0000000..2e210c5 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/postupgrade/Exec.java @@ -0,0 +1,28 @@ +package io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.postupgrade; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"command"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Exec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Command is the command line to execute inside the container, the working directory for the + * command is root ('/') in the container's filesystem. The command is simply exec'd, it is + * not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + * a shell, you need to explicitly call out to that shell. + * Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + */ + @com.fasterxml.jackson.annotation.JsonProperty("command") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Command is the command line to execute inside the container, the working directory for the\ncommand is root ('/') in the container's filesystem. The command is simply exec'd, it is\nnot run inside a shell, so traditional shell instructions ('|', etc) won't work. To use\na shell, you need to explicitly call out to that shell.\nExit status of 0 is treated as live/healthy and non-zero is unhealthy.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List command; + + public java.util.List getCommand() { + return command; + } + + public void setCommand(java.util.List command) { + this.command = command; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/preupgrade/Exec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/preupgrade/Exec.java new file mode 100644 index 0000000..adb67d9 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxspec/lifecycle/preupgrade/Exec.java @@ -0,0 +1,28 @@ +package io.openkruise.agents.client.v2.models.sandboxspec.lifecycle.preupgrade; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"command"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Exec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Command is the command line to execute inside the container, the working directory for the + * command is root ('/') in the container's filesystem. The command is simply exec'd, it is + * not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + * a shell, you need to explicitly call out to that shell. + * Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + */ + @com.fasterxml.jackson.annotation.JsonProperty("command") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Command is the command line to execute inside the container, the working directory for the\ncommand is root ('/') in the container's filesystem. The command is simply exec'd, it is\nnot run inside a shell, so traditional shell instructions ('|', etc) won't work. To use\na shell, you need to explicitly call out to that shell.\nExit status of 0 is treated as live/healthy and non-zero is unhealthy.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List command; + + public java.util.List getCommand() { + return command; + } + + public void setCommand(java.util.List command) { + this.command = command; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxstatus/Conditions.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxstatus/Conditions.java new file mode 100644 index 0000000..6516e80 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxstatus/Conditions.java @@ -0,0 +1,141 @@ +package io.openkruise.agents.client.v2.models.sandboxstatus; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"lastTransitionTime","message","observedGeneration","reason","status","type"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Conditions implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * lastTransitionTime is the 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. + */ + @com.fasterxml.jackson.annotation.JsonProperty("lastTransitionTime") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("lastTransitionTime is the last time the condition transitioned from one status to another.\nThis should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime lastTransitionTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getLastTransitionTime() { + return lastTransitionTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setLastTransitionTime(java.time.ZonedDateTime lastTransitionTime) { + this.lastTransitionTime = lastTransitionTime; + } + + /** + * message is a human readable message indicating details about the transition. + * This may be an empty string. + */ + @com.fasterxml.jackson.annotation.JsonProperty("message") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("message is a human readable message indicating details about the transition.\nThis may be an empty string.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + /** + * observedGeneration represents the .metadata.generation that the condition was set based upon. + * For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + * with respect to the current state of the instance. + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @io.fabric8.generator.annotation.Min(0.0) + @com.fasterxml.jackson.annotation.JsonPropertyDescription("observedGeneration represents the .metadata.generation that the condition was set based upon.\nFor instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date\nwith respect to the current state of the instance.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * reason contains a programmatic identifier indicating the reason for the condition's last transition. + * Producers of specific condition types may define expected values and meanings for this field, + * and whether the values are considered a guaranteed API. + * The value should be a CamelCase string. + * This field may not be empty. + */ + @com.fasterxml.jackson.annotation.JsonProperty("reason") + @io.fabric8.generator.annotation.Required() + @io.fabric8.generator.annotation.Pattern("^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("reason contains a programmatic identifier indicating the reason for the condition's last transition.\nProducers of specific condition types may define expected values and meanings for this field,\nand whether the values are considered a guaranteed API.\nThe value should be a CamelCase string.\nThis field may not be empty.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String reason; + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public enum Status { + + @com.fasterxml.jackson.annotation.JsonProperty("True") + TRUE("True"), @com.fasterxml.jackson.annotation.JsonProperty("False") + FALSE("False"), @com.fasterxml.jackson.annotation.JsonProperty("Unknown") + UNKNOWN("Unknown"); + + java.lang.String value; + + Status(java.lang.String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue() + public java.lang.String getValue() { + return value; + } + } + + /** + * status of the condition, one of True, False, Unknown. + */ + @com.fasterxml.jackson.annotation.JsonProperty("status") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("status of the condition, one of True, False, Unknown.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Status status; + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + /** + * type of condition in CamelCase or in foo.example.com/CamelCase. + */ + @com.fasterxml.jackson.annotation.JsonProperty("type") + @io.fabric8.generator.annotation.Required() + @io.fabric8.generator.annotation.Pattern("^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("type of condition in CamelCase or in foo.example.com/CamelCase.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxstatus/PodInfo.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxstatus/PodInfo.java new file mode 100644 index 0000000..22b499d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxstatus/PodInfo.java @@ -0,0 +1,88 @@ +package io.openkruise.agents.client.v2.models.sandboxstatus; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"annotations","labels","nodeName","podIP","podUID"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class PodInfo implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Annotations contains pod important annotations + */ + @com.fasterxml.jackson.annotation.JsonProperty("annotations") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Annotations contains pod important annotations") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.Map annotations; + + public java.util.Map getAnnotations() { + return annotations; + } + + public void setAnnotations(java.util.Map annotations) { + this.annotations = annotations; + } + + /** + * Labels contains pod important labels + */ + @com.fasterxml.jackson.annotation.JsonProperty("labels") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Labels contains pod important labels") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.Map labels; + + public java.util.Map getLabels() { + return labels; + } + + public void setLabels(java.util.Map labels) { + this.labels = labels; + } + + /** + * NodeName indicates in which node this pod is scheduled. + */ + @com.fasterxml.jackson.annotation.JsonProperty("nodeName") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("NodeName indicates in which node this pod is scheduled.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String nodeName; + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + /** + * PodIP address allocated to the pod. + */ + @com.fasterxml.jackson.annotation.JsonProperty("podIP") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PodIP address allocated to the pod.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String podIP; + + public String getPodIP() { + return podIP; + } + + public void setPodIP(String podIP) { + this.podIP = podIP; + } + + /** + * PodUID is pod uid. + */ + @com.fasterxml.jackson.annotation.JsonProperty("podUID") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PodUID is pod uid.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String podUID; + + public String getPodUID() { + return podUID; + } + + public void setPodUID(String podUID) { + this.podUID = podUID; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxtemplatespec/Runtimes.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxtemplatespec/Runtimes.java new file mode 100644 index 0000000..a6f82e6 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxtemplatespec/Runtimes.java @@ -0,0 +1,21 @@ +package io.openkruise.agents.client.v2.models.sandboxtemplatespec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"name"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Runtimes implements io.fabric8.kubernetes.api.model.KubernetesResource { + + @com.fasterxml.jackson.annotation.JsonProperty("name") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/Lifecycle.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/Lifecycle.java new file mode 100644 index 0000000..75ceb9b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/Lifecycle.java @@ -0,0 +1,42 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"postUpgrade","preUpgrade"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Lifecycle implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * PostUpgrade is the action executed after the upgrade. + * It is typically used to restore workspace data. + */ + @com.fasterxml.jackson.annotation.JsonProperty("postUpgrade") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PostUpgrade is the action executed after the upgrade.\nIt is typically used to restore workspace data.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.PostUpgrade postUpgrade; + + public io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.PostUpgrade getPostUpgrade() { + return postUpgrade; + } + + public void setPostUpgrade(io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.PostUpgrade postUpgrade) { + this.postUpgrade = postUpgrade; + } + + /** + * PreUpgrade is the action executed before the upgrade. + * It is typically used to backup workspace data. + */ + @com.fasterxml.jackson.annotation.JsonProperty("preUpgrade") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("PreUpgrade is the action executed before the upgrade.\nIt is typically used to backup workspace data.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.PreUpgrade preUpgrade; + + public io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.PreUpgrade getPreUpgrade() { + return preUpgrade; + } + + public void setPreUpgrade(io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.PreUpgrade preUpgrade) { + this.preUpgrade = preUpgrade; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/Selector.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/Selector.java new file mode 100644 index 0000000..a620aef --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/Selector.java @@ -0,0 +1,42 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"matchExpressions","matchLabels"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Selector implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * matchExpressions is a list of label selector requirements. The requirements are ANDed. + */ + @com.fasterxml.jackson.annotation.JsonProperty("matchExpressions") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("matchExpressions is a list of label selector requirements. The requirements are ANDed.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List matchExpressions; + + public java.util.List getMatchExpressions() { + return matchExpressions; + } + + public void setMatchExpressions(java.util.List matchExpressions) { + this.matchExpressions = matchExpressions; + } + + /** + * 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. + */ + @com.fasterxml.jackson.annotation.JsonProperty("matchLabels") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels\nmap is equivalent to an element of matchExpressions, whose key field is \"key\", the\noperator is \"In\", and the values array contains only \"value\". The requirements are ANDed.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.Map matchLabels; + + public java.util.Map getMatchLabels() { + return matchLabels; + } + + public void setMatchLabels(java.util.Map matchLabels) { + this.matchLabels = matchLabels; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/UpdateStrategy.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/UpdateStrategy.java new file mode 100644 index 0000000..dba5b7d --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/UpdateStrategy.java @@ -0,0 +1,25 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsspec; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"maxUnavailable"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class UpdateStrategy implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * MaxUnavailable is the maximum number of sandboxes that can be upgrading at the same time. + * Value can be an absolute number (e.g., 5) or a percentage of total sandboxes (e.g., 10%). + */ + @com.fasterxml.jackson.annotation.JsonProperty("maxUnavailable") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("MaxUnavailable is the maximum number of sandboxes that can be upgrading at the same time.\nValue can be an absolute number (e.g., 5) or a percentage of total sandboxes (e.g., 10%).") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.fabric8.kubernetes.api.model.IntOrString maxUnavailable; + + public io.fabric8.kubernetes.api.model.IntOrString getMaxUnavailable() { + return maxUnavailable; + } + + public void setMaxUnavailable(io.fabric8.kubernetes.api.model.IntOrString maxUnavailable) { + this.maxUnavailable = maxUnavailable; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/PostUpgrade.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/PostUpgrade.java new file mode 100644 index 0000000..97f793b --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/PostUpgrade.java @@ -0,0 +1,42 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"exec","timeoutSeconds"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class PostUpgrade implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Exec specifies the command to execute inside the sandbox via envd. + * The first element is the command, the rest are args. + * For shell scripts, use: ["/bin/bash", "-c", "your-script"] + */ + @com.fasterxml.jackson.annotation.JsonProperty("exec") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Exec specifies the command to execute inside the sandbox via envd.\nThe first element is the command, the rest are args.\nFor shell scripts, use: [\"/bin/bash\", \"-c\", \"your-script\"]") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.postupgrade.Exec exec; + + public io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.postupgrade.Exec getExec() { + return exec; + } + + public void setExec(io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.postupgrade.Exec exec) { + this.exec = exec; + } + + /** + * TimeoutSeconds is the timeout for the action execution in seconds. + */ + @com.fasterxml.jackson.annotation.JsonProperty("timeoutSeconds") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("TimeoutSeconds is the timeout for the action execution in seconds.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer timeoutSeconds = 60; + + public Integer getTimeoutSeconds() { + return timeoutSeconds; + } + + public void setTimeoutSeconds(Integer timeoutSeconds) { + this.timeoutSeconds = timeoutSeconds; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/PreUpgrade.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/PreUpgrade.java new file mode 100644 index 0000000..9972621 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/PreUpgrade.java @@ -0,0 +1,42 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"exec","timeoutSeconds"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class PreUpgrade implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Exec specifies the command to execute inside the sandbox via envd. + * The first element is the command, the rest are args. + * For shell scripts, use: ["/bin/bash", "-c", "your-script"] + */ + @com.fasterxml.jackson.annotation.JsonProperty("exec") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Exec specifies the command to execute inside the sandbox via envd.\nThe first element is the command, the rest are args.\nFor shell scripts, use: [\"/bin/bash\", \"-c\", \"your-script\"]") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.preupgrade.Exec exec; + + public io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.preupgrade.Exec getExec() { + return exec; + } + + public void setExec(io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.preupgrade.Exec exec) { + this.exec = exec; + } + + /** + * TimeoutSeconds is the timeout for the action execution in seconds. + */ + @com.fasterxml.jackson.annotation.JsonProperty("timeoutSeconds") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("TimeoutSeconds is the timeout for the action execution in seconds.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Integer timeoutSeconds = 60; + + public Integer getTimeoutSeconds() { + return timeoutSeconds; + } + + public void setTimeoutSeconds(Integer timeoutSeconds) { + this.timeoutSeconds = timeoutSeconds; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/postupgrade/Exec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/postupgrade/Exec.java new file mode 100644 index 0000000..1562111 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/postupgrade/Exec.java @@ -0,0 +1,28 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.postupgrade; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"command"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Exec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Command is the command line to execute inside the container, the working directory for the + * command is root ('/') in the container's filesystem. The command is simply exec'd, it is + * not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + * a shell, you need to explicitly call out to that shell. + * Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + */ + @com.fasterxml.jackson.annotation.JsonProperty("command") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Command is the command line to execute inside the container, the working directory for the\ncommand is root ('/') in the container's filesystem. The command is simply exec'd, it is\nnot run inside a shell, so traditional shell instructions ('|', etc) won't work. To use\na shell, you need to explicitly call out to that shell.\nExit status of 0 is treated as live/healthy and non-zero is unhealthy.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List command; + + public java.util.List getCommand() { + return command; + } + + public void setCommand(java.util.List command) { + this.command = command; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/preupgrade/Exec.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/preupgrade/Exec.java new file mode 100644 index 0000000..040a680 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/lifecycle/preupgrade/Exec.java @@ -0,0 +1,28 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsspec.lifecycle.preupgrade; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"command"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Exec implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * Command is the command line to execute inside the container, the working directory for the + * command is root ('/') in the container's filesystem. The command is simply exec'd, it is + * not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + * a shell, you need to explicitly call out to that shell. + * Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + */ + @com.fasterxml.jackson.annotation.JsonProperty("command") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("Command is the command line to execute inside the container, the working directory for the\ncommand is root ('/') in the container's filesystem. The command is simply exec'd, it is\nnot run inside a shell, so traditional shell instructions ('|', etc) won't work. To use\na shell, you need to explicitly call out to that shell.\nExit status of 0 is treated as live/healthy and non-zero is unhealthy.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List command; + + public java.util.List getCommand() { + return command; + } + + public void setCommand(java.util.List command) { + this.command = command; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/selector/MatchExpressions.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/selector/MatchExpressions.java new file mode 100644 index 0000000..c68b7c9 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsspec/selector/MatchExpressions.java @@ -0,0 +1,62 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsspec.selector; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"key","operator","values"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class MatchExpressions implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * key is the label key that the selector applies to. + */ + @com.fasterxml.jackson.annotation.JsonProperty("key") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("key is the label key that the selector applies to.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String key; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + /** + * operator represents a key's relationship to a set of values. + * Valid operators are In, NotIn, Exists and DoesNotExist. + */ + @com.fasterxml.jackson.annotation.JsonProperty("operator") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("operator represents a key's relationship to a set of values.\nValid operators are In, NotIn, Exists and DoesNotExist.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String operator; + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + /** + * 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. + */ + @com.fasterxml.jackson.annotation.JsonProperty("values") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("values is an array of string values. If the operator is In or NotIn,\nthe values array must be non-empty. If the operator is Exists or DoesNotExist,\nthe values array must be empty. This array is replaced during a strategic\nmerge patch.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.util.List values; + + public java.util.List getValues() { + return values; + } + + public void setValues(java.util.List values) { + this.values = values; + } +} + diff --git a/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsstatus/Conditions.java b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsstatus/Conditions.java new file mode 100644 index 0000000..aea2615 --- /dev/null +++ b/clients/java/src/main/java/io/openkruise/agents/client/v2/models/sandboxupdateopsstatus/Conditions.java @@ -0,0 +1,141 @@ +package io.openkruise.agents.client.v2.models.sandboxupdateopsstatus; + +@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) +@com.fasterxml.jackson.annotation.JsonPropertyOrder({"lastTransitionTime","message","observedGeneration","reason","status","type"}) +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class) +public class Conditions implements io.fabric8.kubernetes.api.model.KubernetesResource { + + /** + * lastTransitionTime is the 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. + */ + @com.fasterxml.jackson.annotation.JsonProperty("lastTransitionTime") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("lastTransitionTime is the last time the condition transitioned from one status to another.\nThis should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private java.time.ZonedDateTime lastTransitionTime; + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV") + public java.time.ZonedDateTime getLastTransitionTime() { + return lastTransitionTime; + } + + @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[XXX][VV]") + public void setLastTransitionTime(java.time.ZonedDateTime lastTransitionTime) { + this.lastTransitionTime = lastTransitionTime; + } + + /** + * message is a human readable message indicating details about the transition. + * This may be an empty string. + */ + @com.fasterxml.jackson.annotation.JsonProperty("message") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("message is a human readable message indicating details about the transition.\nThis may be an empty string.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + /** + * observedGeneration represents the .metadata.generation that the condition was set based upon. + * For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + * with respect to the current state of the instance. + */ + @com.fasterxml.jackson.annotation.JsonProperty("observedGeneration") + @io.fabric8.generator.annotation.Min(0.0) + @com.fasterxml.jackson.annotation.JsonPropertyDescription("observedGeneration represents the .metadata.generation that the condition was set based upon.\nFor instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date\nwith respect to the current state of the instance.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Long observedGeneration; + + public Long getObservedGeneration() { + return observedGeneration; + } + + public void setObservedGeneration(Long observedGeneration) { + this.observedGeneration = observedGeneration; + } + + /** + * reason contains a programmatic identifier indicating the reason for the condition's last transition. + * Producers of specific condition types may define expected values and meanings for this field, + * and whether the values are considered a guaranteed API. + * The value should be a CamelCase string. + * This field may not be empty. + */ + @com.fasterxml.jackson.annotation.JsonProperty("reason") + @io.fabric8.generator.annotation.Required() + @io.fabric8.generator.annotation.Pattern("^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("reason contains a programmatic identifier indicating the reason for the condition's last transition.\nProducers of specific condition types may define expected values and meanings for this field,\nand whether the values are considered a guaranteed API.\nThe value should be a CamelCase string.\nThis field may not be empty.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String reason; + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public enum Status { + + @com.fasterxml.jackson.annotation.JsonProperty("True") + TRUE("True"), @com.fasterxml.jackson.annotation.JsonProperty("False") + FALSE("False"), @com.fasterxml.jackson.annotation.JsonProperty("Unknown") + UNKNOWN("Unknown"); + + java.lang.String value; + + Status(java.lang.String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue() + public java.lang.String getValue() { + return value; + } + } + + /** + * status of the condition, one of True, False, Unknown. + */ + @com.fasterxml.jackson.annotation.JsonProperty("status") + @io.fabric8.generator.annotation.Required() + @com.fasterxml.jackson.annotation.JsonPropertyDescription("status of the condition, one of True, False, Unknown.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private Status status; + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + /** + * type of condition in CamelCase or in foo.example.com/CamelCase. + */ + @com.fasterxml.jackson.annotation.JsonProperty("type") + @io.fabric8.generator.annotation.Required() + @io.fabric8.generator.annotation.Pattern("^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$") + @com.fasterxml.jackson.annotation.JsonPropertyDescription("type of condition in CamelCase or in foo.example.com/CamelCase.") + @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP) + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} + diff --git a/clients/python/openkruise/agents/models/__init__.py b/clients/python/openkruise/agents/models/__init__.py index 0b6e456..8d33768 100644 --- a/clients/python/openkruise/agents/models/__init__.py +++ b/clients/python/openkruise/agents/models/__init__.py @@ -1,3 +1,8 @@ +from .checkpoint import ( + Checkpoint, + Spec as CheckpointSpec, + Status as CheckpointStatus, +) from .sandbox import ( Sandbox, Spec as SandboxSpec, @@ -7,6 +12,14 @@ PodInfo as SandboxPodInfo, Runtime as SandboxRuntime, ) +from .sandboxclaim import ( + SandboxClaim, + Spec as SandboxClaimSpec, + Status as SandboxClaimStatus, + Condition as SandboxClaimCondition, + InplaceUpdate as SandboxClaimInplaceUpdate, + Runtime as SandboxClaimRuntime, +) from .sandboxset import ( SandboxSet, Spec as SandboxSetSpec, @@ -16,11 +29,15 @@ ScaleStrategy as SandboxSetScaleStrategy, Runtime as SandboxSetRuntime, ) -from .sandboxclaim import ( - SandboxClaim, - Spec as SandboxClaimSpec, - Status as SandboxClaimStatus, - Condition as SandboxClaimCondition, - InplaceUpdate as SandboxClaimInplaceUpdate, - Runtime as SandboxClaimRuntime, +from .sandboxtemplate import ( + SandboxTemplate, + Spec as SandboxTemplateSpec, + Runtime as SandboxTemplateRuntime, +) +from .sandboxupdateops import ( + SandboxUpdateOps, + Spec as SandboxUpdateOpsSpec, + Status as SandboxUpdateOpsStatus, + Selector as SandboxUpdateOpsSelector, + Lifecycle as SandboxUpdateOpsLifecycle, ) diff --git a/clients/python/openkruise/agents/models/checkpoint.py b/clients/python/openkruise/agents/models/checkpoint.py new file mode 100644 index 0000000..b023df9 --- /dev/null +++ b/clients/python/openkruise/agents/models/checkpoint.py @@ -0,0 +1,97 @@ +# generated by datamodel-codegen: +# filename: checkpoint_schema.json +# timestamp: 2026-05-13T06:54:58+00:00 + +from __future__ import annotations + +from kubernetes.client.models import V1ObjectMeta +from pydantic import AwareDatetime, BaseModel, ConfigDict + + +class Checkpoint(BaseModel): + """ + Checkpoint is the Schema for the Checkpoints API + """ + + model_config = ConfigDict(arbitrary_types_allowed=True) + + apiVersion: str | None = None + """ + 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 + """ + kind: str | None = None + """ + 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 + """ + metadata: V1ObjectMeta | None = None + spec: Spec + """ + spec defines the desired state of Checkpoint + """ + status: Status | None = None + """ + status defines the observed state of Checkpoint + """ + + +class Spec(BaseModel): + """ + spec defines the desired state of Checkpoint + """ + + keepRunning: bool | None = None + """ + KeepRunning indicates whether the pod remains in the Running state after passing the checkpoint. + Default is true. + """ + persistentContents: list[str] | None = None + """ + PersistentContents indicates resume pod with persistent content, Enum: memory, filesystem + """ + podName: str | None = None + """ + PodName is checkpoint podName. + """ + sandboxName: str | None = None + """ + SandboxName is checkpoint sandboxName. + """ + ttlAfterFinished: str | None = None + """ + valid format: 30s, 30m, 30d + """ + + +class Status(BaseModel): + """ + status defines the observed state of Checkpoint + """ + + checkpointId: str | None = None + """ + checkpoint-id + """ + completionTime: AwareDatetime | None = None + """ + CompletionTime is checkpoint completed time, and phase is Succeeded or Failed. + """ + message: str | None = None + """ + message + """ + observedGeneration: int | None = None + """ + observedGeneration is the most recent generation observed for this Checkpoint. It corresponds to the + Checkpoint's generation, which is updated on mutation by the API Server. + """ + phase: str | None = None + """ + Checkpoint Phase + """ diff --git a/clients/python/openkruise/agents/models/sandbox.py b/clients/python/openkruise/agents/models/sandbox.py index daa6f59..1eb2195 100644 --- a/clients/python/openkruise/agents/models/sandbox.py +++ b/clients/python/openkruise/agents/models/sandbox.py @@ -1,15 +1,17 @@ # generated by datamodel-codegen: # filename: sandbox_schema.json -# timestamp: 2026-04-03T09:19:07+00:00 +# timestamp: 2026-05-13T06:55:00+00:00 from __future__ import annotations -from datetime import datetime from enum import StrEnum -from kubernetes.client.models import (V1ObjectMeta, V1PersistentVolumeClaim, - V1PodTemplateSpec) -from pydantic import BaseModel, ConfigDict, Field +from kubernetes.client.models import ( + V1ObjectMeta, + V1PersistentVolumeClaim, + V1PodTemplateSpec, +) +from pydantic import AwareDatetime, BaseModel, ConfigDict, Field class Condition(BaseModel): @@ -17,7 +19,7 @@ class Condition(BaseModel): Condition contains details for one aspect of the current state of this API Resource. """ - lastTransitionTime: datetime + lastTransitionTime: AwareDatetime """ lastTransitionTime is the 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. @@ -60,6 +62,40 @@ class Condition(BaseModel): """ +class Exec(BaseModel): + """ + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + """ + + command: list[str] | None = None + """ + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + """ + + +class Lifecycle(BaseModel): + """ + Lifecycle defines lifecycle hooks for sandbox upgrade. + """ + + postUpgrade: PostUpgrade | None = None + """ + PostUpgrade is the action executed after the upgrade. + It is typically used to restore workspace data. + """ + preUpgrade: PreUpgrade | None = None + """ + PreUpgrade is the action executed before the upgrade. + It is typically used to backup workspace data. + """ + + class PodInfo(BaseModel): """ Pod Info @@ -87,16 +123,53 @@ class PodInfo(BaseModel): """ +class PostUpgrade(BaseModel): + """ + PostUpgrade is the action executed after the upgrade. + It is typically used to restore workspace data. + """ + + exec: Exec | None = None + """ + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + """ + timeoutSeconds: int | None = 60 + """ + TimeoutSeconds is the timeout for the action execution in seconds. + """ + + +class PreUpgrade(BaseModel): + """ + PreUpgrade is the action executed before the upgrade. + It is typically used to backup workspace data. + """ + + exec: Exec | None = None + """ + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + """ + timeoutSeconds: int | None = 60 + """ + TimeoutSeconds is the timeout for the action execution in seconds. + """ + + class Runtime(BaseModel): name: str class Sandbox(BaseModel): - model_config = ConfigDict(arbitrary_types_allowed=True) """ Sandbox is the Schema for the sandboxes API """ + model_config = ConfigDict(arbitrary_types_allowed=True) + apiVersion: str | None = None """ APIVersion defines the versioned schema of this representation of an object. @@ -124,12 +197,17 @@ class Sandbox(BaseModel): class Spec(BaseModel): - model_config = ConfigDict(arbitrary_types_allowed=True) """ spec defines the desired state of Sandbox """ - pauseTime: datetime | None = None + model_config = ConfigDict(arbitrary_types_allowed=True) + + lifecycle: Lifecycle | None = None + """ + Lifecycle defines lifecycle hooks for sandbox upgrade. + """ + pauseTime: AwareDatetime | None = None """ PauseTime - Absolute time when the sandbox will be paused automatically. """ @@ -145,7 +223,7 @@ class Spec(BaseModel): """ Runtimes - Runtime configuration for sandbox object """ - shutdownTime: datetime | None = None + shutdownTime: AwareDatetime | None = None """ ShutdownTime - Absolute time when the sandbox is deleted. If a time in the past is provided, the sandbox will be deleted immediately. @@ -159,6 +237,10 @@ class Spec(BaseModel): """ TemplateRef references a SandboxTemplate, which will be used to create the sandbox. """ + upgradePolicy: UpgradePolicy | None = None + """ + UpgradePolicy defines the upgrade strategy for the sandbox. + """ volumeClaimTemplates: list[V1PersistentVolumeClaim] | None = None """ VolumeClaimTemplates is a list of PVC templates to create for this Sandbox. @@ -236,3 +318,16 @@ class TemplateRef(BaseModel): """ name of the SandboxTemplate """ + + +class UpgradePolicy(BaseModel): + """ + UpgradePolicy defines the upgrade strategy for the sandbox. + """ + + type: str | None = None + """ + Type specifies the upgrade policy type. + When empty (default), upgrading is disabled. + Supported values: Recreate. + """ diff --git a/clients/python/openkruise/agents/models/sandboxclaim.py b/clients/python/openkruise/agents/models/sandboxclaim.py index fdc8956..f08f675 100644 --- a/clients/python/openkruise/agents/models/sandboxclaim.py +++ b/clients/python/openkruise/agents/models/sandboxclaim.py @@ -1,15 +1,13 @@ # generated by datamodel-codegen: # filename: sandboxclaim_schema.json -# timestamp: 2026-04-03T09:19:02+00:00 +# timestamp: 2026-05-13T06:54:59+00:00 from __future__ import annotations -from datetime import datetime from enum import StrEnum -from kubernetes.client.models import (V1ObjectMeta, V1PersistentVolumeClaim, - V1PodTemplateSpec) -from pydantic import BaseModel, ConfigDict, Field +from kubernetes.client.models import V1ObjectMeta +from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel class Condition(BaseModel): @@ -17,7 +15,7 @@ class Condition(BaseModel): Condition contains details for one aspect of the current state of this API Resource. """ - lastTransitionTime: datetime + lastTransitionTime: AwareDatetime """ lastTransitionTime is the 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. @@ -73,9 +71,62 @@ class InplaceUpdate(BaseModel): InplaceUpdate allows to perform inplace update for sandbox while claiming """ - image: str + image: str | None = None """ - Image specifies the new image to update to + Image specifies the new image to update to. + """ + resources: Resources | None = None + """ + Resources specifies in-place resource update options. + """ + + +class Limits(RootModel[int]): + root: int = Field( + ..., + pattern="^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + ) + + +class Limits1(RootModel[str]): + root: str = Field( + ..., + pattern="^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + ) + + +class Requests(RootModel[int]): + root: int = Field( + ..., + pattern="^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + ) + + +class Requests1(RootModel[str]): + root: str = Field( + ..., + pattern="^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$", + ) + + +class Resources(BaseModel): + """ + Resources specifies in-place resource update options. + """ + + limits: dict[str, Limits | Limits1] | None = None + """ + Limits specifies the target resource limits for each container. + Only CPU is supported for now. The container's original limit must already be set; + otherwise the value is ignored. + The new value must not change the Pod's QoS class; otherwise the claim will be rejected. + """ + requests: dict[str, Requests | Requests1] | None = None + """ + Requests specifies the target resource requests for each container. + Only CPU is supported for now. The container's original request must already be set; + otherwise the value is ignored. + The new value must not change the Pod's QoS class; otherwise the claim will be rejected. """ @@ -84,11 +135,12 @@ class Runtime(BaseModel): class SandboxClaim(BaseModel): - model_config = ConfigDict(arbitrary_types_allowed=True) """ SandboxClaim is the Schema for the sandboxclaims API """ + model_config = ConfigDict(arbitrary_types_allowed=True) + apiVersion: str | None = None """ APIVersion defines the versioned schema of this representation of an object. @@ -168,20 +220,25 @@ class Spec(BaseModel): """ Runtimes - Runtime configuration for sandbox object """ - shutdownTime: datetime | None = None + shutdownTime: AwareDatetime | None = None """ ShutdownTime specifies the absolute time when the sandbox should be shut down This will be set as spec.shutdownTime (absolute time) on the Sandbox """ + skipInitRuntime: bool | None = False + """ + SkipInitRuntime allows to skip init runtime for sandbox while claiming + """ templateName: str """ TemplateName specifies which SandboxSet pool to claim from """ - ttlAfterCompleted: str | None = "5m" + ttlAfterCompleted: str | None = "60m" """ TTLAfterCompleted specifies the time to live after the claim reaches Completed phase After this duration, the SandboxClaim will be automatically deleted. Note: Only the SandboxClaim resource will be deleted; the claimed sandboxes will NOT be deleted + Set to a negative value (e.g., "-1s") to disable automatic deletion (never delete). """ waitReadyTimeout: str | None = "30s" """ @@ -196,7 +253,7 @@ class Status(BaseModel): status defines the observed state of SandboxClaim """ - claimStartTime: datetime | None = None + claimStartTime: AwareDatetime | None = None """ ClaimStartTime is the timestamp when claiming started Used for calculating timeout @@ -207,7 +264,7 @@ class Status(BaseModel): This is determined by querying sandboxes with matching ownerReference Only updated during Pending and Claiming phases """ - completionTime: datetime | None = None + completionTime: AwareDatetime | None = None """ CompletionTime is the timestamp when the claim reached Completed phase Used for TTL calculation diff --git a/clients/python/openkruise/agents/models/sandboxset.py b/clients/python/openkruise/agents/models/sandboxset.py index acd6df6..f2043bc 100644 --- a/clients/python/openkruise/agents/models/sandboxset.py +++ b/clients/python/openkruise/agents/models/sandboxset.py @@ -1,15 +1,17 @@ # generated by datamodel-codegen: # filename: sandboxset_schema.json -# timestamp: 2026-04-03T09:19:12+00:00 +# timestamp: 2026-05-13T06:55:00+00:00 from __future__ import annotations -from datetime import datetime from enum import StrEnum -from kubernetes.client.models import (V1ObjectMeta, V1PersistentVolumeClaim, - V1PodTemplateSpec) -from pydantic import BaseModel, ConfigDict, Field +from kubernetes.client.models import ( + V1ObjectMeta, + V1PersistentVolumeClaim, + V1PodTemplateSpec, +) +from pydantic import AwareDatetime, BaseModel, ConfigDict, Field class Condition(BaseModel): @@ -17,7 +19,7 @@ class Condition(BaseModel): Condition contains details for one aspect of the current state of this API Resource. """ - lastTransitionTime: datetime + lastTransitionTime: AwareDatetime """ lastTransitionTime is the 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. @@ -65,11 +67,12 @@ class Runtime(BaseModel): class SandboxSet(BaseModel): - model_config = ConfigDict(arbitrary_types_allowed=True) """ SandboxSet is the Schema for the sandboxsets API, which is an advanced workload for managing sandboxes. """ + model_config = ConfigDict(arbitrary_types_allowed=True) + apiVersion: str | None = None """ APIVersion defines the versioned schema of this representation of an object. @@ -112,11 +115,12 @@ class ScaleStrategy(BaseModel): class Spec(BaseModel): - model_config = ConfigDict(arbitrary_types_allowed=True) """ spec defines the desired state of SandboxSet """ + model_config = ConfigDict(arbitrary_types_allowed=True) + persistentContents: list[str] | None = None """ PersistentContents indicates resume pod with persistent content, Enum: ip, memory, filesystem @@ -143,6 +147,11 @@ class Spec(BaseModel): """ TemplateRef references a SandboxTemplate, which will be used to create the sandbox. """ + updateStrategy: UpdateStrategy | None = None + """ + UpdateStrategy indicates the strategy that will be employed to + update Sandboxes in the SandboxSet when the template changes. + """ volumeClaimTemplates: list[V1PersistentVolumeClaim] | None = None """ VolumeClaimTemplates is a list of PVC templates to create for this Sandbox. @@ -181,7 +190,16 @@ class Status(BaseModel): """ updateRevision: str | None = None """ - UpdateRevision is the template-hash calculated from `spec.template`. + UpdateRevision is the hash label of the ControllerRevision created from `spec.template`. + It represents the latest desired template version. + """ + updatedAvailableReplicas: int | None = None + """ + UpdatedAvailableReplicas is the number of updated sandboxes that are available. + """ + updatedReplicas: int | None = None + """ + UpdatedReplicas is the number of sandboxes that have been updated to the UpdateRevision. """ @@ -214,3 +232,18 @@ class TemplateRef(BaseModel): """ name of the SandboxTemplate """ + + +class UpdateStrategy(BaseModel): + """ + UpdateStrategy indicates the strategy that will be employed to + update Sandboxes in the SandboxSet when the template changes. + """ + + maxUnavailable: int | str | None = None + """ + MaxUnavailable is the maximum number or percentage of pods that can be unavailable during the update. + MaxUnavailable can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). + Absolute number is calculated from percentage by rounding down. + Default is 20%. + """ diff --git a/clients/python/openkruise/agents/models/sandboxtemplate.py b/clients/python/openkruise/agents/models/sandboxtemplate.py new file mode 100644 index 0000000..3d5927f --- /dev/null +++ b/clients/python/openkruise/agents/models/sandboxtemplate.py @@ -0,0 +1,71 @@ +# generated by datamodel-codegen: +# filename: sandboxtemplate_schema.json +# timestamp: 2026-05-13T06:55:01+00:00 + +from __future__ import annotations + +from kubernetes.client.models import ( + V1ObjectMeta, + V1PersistentVolumeClaim, + V1PodTemplateSpec, +) +from pydantic import BaseModel, ConfigDict + + +class Runtime(BaseModel): + name: str + + +class SandboxTemplate(BaseModel): + """ + SandboxSet is the Schema for the sandboxsets API, which is an advanced workload for managing sandboxes. + """ + + model_config = ConfigDict(arbitrary_types_allowed=True) + + apiVersion: str | None = None + """ + 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 + """ + kind: str | None = None + """ + 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 + """ + metadata: V1ObjectMeta | None = None + spec: Spec + """ + spec defines the desired state of SandboxSet + """ + + +class Spec(BaseModel): + """ + spec defines the desired state of SandboxSet + """ + + model_config = ConfigDict(arbitrary_types_allowed=True) + + persistentContents: list[str] | None = None + """ + PersistentContents indicates resume pod with persistent content, Enum: ip, memory, filesystem + """ + runtimes: list[Runtime] | None = None + """ + Runtimes - Runtime configuration for sandbox object + """ + template: V1PodTemplateSpec | None = None + """ + Template describes the pods that will be created. + Template is mutual exclusive with TemplateRef + """ + volumeClaimTemplates: list[V1PersistentVolumeClaim] | None = None + """ + VolumeClaimTemplates is a list of PVC templates to create for this Sandbox. + """ diff --git a/clients/python/openkruise/agents/models/sandboxupdateops.py b/clients/python/openkruise/agents/models/sandboxupdateops.py new file mode 100644 index 0000000..187fd2c --- /dev/null +++ b/clients/python/openkruise/agents/models/sandboxupdateops.py @@ -0,0 +1,288 @@ +# generated by datamodel-codegen: +# filename: sandboxupdateops_schema.json +# timestamp: 2026-05-13T06:55:02+00:00 + +from __future__ import annotations + +from enum import StrEnum +from typing import Any + +from kubernetes.client.models import V1ObjectMeta +from pydantic import AwareDatetime, BaseModel, ConfigDict, Field + + +class Condition(BaseModel): + """ + Condition contains details for one aspect of the current state of this API Resource. + """ + + lastTransitionTime: AwareDatetime + """ + lastTransitionTime is the 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. + """ + message: str = Field(..., max_length=32768) + """ + message is a human readable message indicating details about the transition. + This may be an empty string. + """ + observedGeneration: int | None = Field(None, ge=0) + """ + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + """ + reason: str = Field( + ..., + max_length=1024, + min_length=1, + pattern="^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$", + ) + """ + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + """ + status: Status1 + """ + status of the condition, one of True, False, Unknown. + """ + type: str = Field( + ..., + max_length=316, + pattern="^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$", + ) + """ + type of condition in CamelCase or in foo.example.com/CamelCase. + """ + + +class Exec(BaseModel): + """ + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + """ + + command: list[str] | None = None + """ + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + """ + + +class Lifecycle(BaseModel): + """ + Lifecycle defines pre/post upgrade hooks to set on each sandbox during upgrade. + """ + + postUpgrade: PostUpgrade | None = None + """ + PostUpgrade is the action executed after the upgrade. + It is typically used to restore workspace data. + """ + preUpgrade: PreUpgrade | None = None + """ + PreUpgrade is the action executed before the upgrade. + It is typically used to backup workspace data. + """ + + +class MatchExpression(BaseModel): + """ + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + """ + + key: str + """ + key is the label key that the selector applies to. + """ + operator: str + """ + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + """ + values: list[str] | None = None + """ + 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. + """ + + +class PostUpgrade(BaseModel): + """ + PostUpgrade is the action executed after the upgrade. + It is typically used to restore workspace data. + """ + + exec: Exec | None = None + """ + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + """ + timeoutSeconds: int | None = 60 + """ + TimeoutSeconds is the timeout for the action execution in seconds. + """ + + +class PreUpgrade(BaseModel): + """ + PreUpgrade is the action executed before the upgrade. + It is typically used to backup workspace data. + """ + + exec: Exec | None = None + """ + Exec specifies the command to execute inside the sandbox via envd. + The first element is the command, the rest are args. + For shell scripts, use: ["/bin/bash", "-c", "your-script"] + """ + timeoutSeconds: int | None = 60 + """ + TimeoutSeconds is the timeout for the action execution in seconds. + """ + + +class SandboxUpdateOps(BaseModel): + """ + SandboxUpdateOps is the Schema for batch sandbox update operations. + """ + + model_config = ConfigDict(arbitrary_types_allowed=True) + + apiVersion: str | None = None + """ + 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 + """ + kind: str | None = None + """ + 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 + """ + metadata: V1ObjectMeta | None = None + spec: Spec + """ + Spec defines the desired update operation. + """ + status: Status | None = None + """ + Status defines the observed state. + """ + + +class Selector(BaseModel): + """ + Selector selects the target sandboxes to update by label. + """ + + matchExpressions: list[MatchExpression] | None = None + """ + matchExpressions is a list of label selector requirements. The requirements are ANDed. + """ + matchLabels: dict[str, str] | None = None + """ + 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. + """ + + +class Spec(BaseModel): + """ + Spec defines the desired update operation. + """ + + lifecycle: Lifecycle | None = None + """ + Lifecycle defines pre/post upgrade hooks to set on each sandbox during upgrade. + """ + patch: Any | None = None + """ + Patch defines the changes to apply to each selected sandbox's template. + The patch is applied as a Strategic Merge Patch on the sandbox's PodTemplateSpec. + """ + paused: bool | None = None + """ + Paused indicates whether the update operation is paused. + """ + selector: Selector + """ + Selector selects the target sandboxes to update by label. + """ + updateStrategy: UpdateStrategy | None = None + """ + UpdateStrategy defines the strategy for the batch update. + """ + + +class Status(BaseModel): + """ + Status defines the observed state. + """ + + conditions: list[Condition] | None = None + """ + Conditions represents the latest available observations. + """ + failedReplicas: int + """ + FailedReplicas is the number of sandboxes that failed to update. + """ + observedGeneration: int | None = None + """ + ObservedGeneration is the most recent generation observed. + """ + phase: str | None = None + """ + Phase is the current phase of the update operation. + """ + replicas: int + """ + Replicas is the total number of sandboxes selected for update. + """ + updatedReplicas: int + """ + UpdatedReplicas is the number of sandboxes that have been successfully updated. + """ + updatingReplicas: int + """ + UpdatingReplicas is the number of sandboxes currently being updated. + """ + + +class Status1(StrEnum): + """ + status of the condition, one of True, False, Unknown. + """ + + True_ = "True" + False_ = "False" + Unknown = "Unknown" + + +class UpdateStrategy(BaseModel): + """ + UpdateStrategy defines the strategy for the batch update. + """ + + maxUnavailable: int | str | None = None + """ + MaxUnavailable is the maximum number of sandboxes that can be upgrading at the same time. + Value can be an absolute number (e.g., 5) or a percentage of total sandboxes (e.g., 10%). + """ diff --git a/clients/python/ruff.toml b/clients/python/ruff.toml new file mode 100644 index 0000000..219b681 --- /dev/null +++ b/clients/python/ruff.toml @@ -0,0 +1,3 @@ +[lint.per-file-ignores] +# __init__.py re-exports are manually curated; skip isort to keep combined imports +"__init__.py" = ["I"] diff --git a/docs/sdk-codegen-zh_CN.md b/docs/sdk-codegen-zh_CN.md new file mode 100644 index 0000000..bd88995 --- /dev/null +++ b/docs/sdk-codegen-zh_CN.md @@ -0,0 +1,201 @@ +# SDK 代码生成指南 + +本文档介绍如何为 Kruise Agents API 生成多语言 SDK 客户端代码。 + +## 概览 + +项目支持三种语言的 SDK 生成: + +| 语言 | 生成工具 | 输出目录 | +|--------|-----------------------------------|-------------------| +| Go | k8s code-generator | `client/` | +| Java | Fabric8 java-generator-cli 6.14.0 | `clients/java/` | +| Python | datamodel-codegen(Pydantic v2) | `clients/python/` | + +## 前置依赖 + +### Go + +- Go 1.21+ + +### Java + +- JDK 8+ +- Fabric8 java-generator-cli(脚本自动下载) + +### Python + +- Python 3.11+ +- 安装依赖: + +```bash +pip install datamodel-code-generator ruff pyyaml +brew install yq +``` + +## 快速开始 + +### 一键生成所有 SDK + +```bash +# 从上游同步 CRD + 生成所有 SDK + 自动修补类型 +make generate-all + +# 跳过上游同步,仅生成 + 修补 +make generate-all SKIP_UPDATE=true +``` + +> **⚠️ 注意:** 上游同步通过 GitHub API 下载 CRD 文件,未携带 Token 时可能触发限流(HTTP 403)。如果遇到限流,可以手动将最新的 CRD YAML 文件放到 `agents/crds/` 目录下,然后使用 `SKIP_UPDATE=true` 跳过自动同步。 + +### 单独生成某个语言 + +```bash +# Go 客户端 +make generate + +# Java SDK +make generate-java + +# Python SDK +make generate-python +``` + +### 仅执行类型修补 + +```bash +# 修补所有 SDK +make patch-sdk-types + +# 仅修补 Java +make patch-sdk-types LANG=java + +# 仅修补 Python +make patch-sdk-types LANG=python +``` + +## 生成流程详解 + +### Go 客户端 + +使用 Kubernetes 官方 `code-generator` 生成 clientset、lister、informer。 + +``` +hack/generate_client.sh + → k8s.io/code-generator(clientset / lister / informer) + → 输出到 client/ +``` + +### Java SDK + +使用 Fabric8 java-generator-cli 从 CRD YAML 生成 Java 模型类。 + +``` +hack/generate_java_sdk.sh + → Fabric8 java-generator-cli + → 输出到 clients/java/.../models/ + → hack/patch_sdk_types.sh --java(类型修补) +``` + +**生成的 Java 模型**位于: + +``` +clients/java/src/main/java/io/openkruise/agents/client/v2/models/ +``` + +包含 Sandbox、SandboxSet、SandboxTemplate、SandboxClaim、SandboxUpdateOps、Checkpoint 等所有 CRD 资源的 Java 类型定义。 + +### Python SDK + +使用 datamodel-codegen 从 CRD JSON Schema 生成 Pydantic v2 模型。 + +``` +hack/generate_python_sdk.sh + → datamodel-codegen(Pydantic v2) + → ruff 格式化 + → 输出到 clients/python/.../models/ + → hack/patch_sdk_types.sh --python(类型修补 + ruff 格式化) +``` + +**生成的 Python 模型**位于: + +``` +clients/python/openkruise/agents/models/ +``` + +每个 CRD 对应一个 Python 文件(如 `sandbox.py`、`sandboxset.py`),包含 Pydantic BaseModel 类定义。 + +## 类型修补机制 + +### 为什么需要类型修补? + +CRD 中标记了 `x-kubernetes-preserve-unknown-fields: true` 的字段,在代码生成时会丢失具体类型信息: + +| 字段 | Go 类型 | Java 生成结果 | Python 生成结果 | +|------------------------|----------------------------------|-------------|--------------------| +| `template` | `*corev1.PodTemplateSpec` | `AnyType` ❌ | `Any` ❌ | +| `volumeClaimTemplates` | `[]corev1.PersistentVolumeClaim` | `AnyType` ❌ | `Any` ❌ | +| `metadata` | `metav1.ObjectMeta` | ✅ 正常 | `dict[str, Any]` ❌ | +| `patch` | `runtime.RawExtension` | `AnyType` ❌ | ✅ 保留 Any | + +类型修补脚本会自动将这些占位符类型替换为正确的 Kubernetes 类型。 + +### 修补规则配置 + +所有替换规则集中维护在 `clients/codegen/type_mapping.yaml`: + +```yaml +fields: + - name: template + go_type: "*corev1.PodTemplateSpec" + java: + old_type: "io.fabric8.kubernetes.api.model.AnyType" + new_type: "io.fabric8.kubernetes.api.model.PodTemplateSpec" + python: + old_pattern: "Any" + new_type: "V1PodTemplateSpec" + import: "V1PodTemplateSpec" +``` + +**新增字段规则**时,只需在此 YAML 文件中添加一条记录,然后重新执行 `make generate-all` 即可。 + +### 修补执行流程 + +执行修补时,脚本会先打印所有即将修改的位置和内容,然后再执行替换: + +``` +==> SDK Type Patching (rules: type_mapping.yaml) +==> Patching Java SDK types... + Planned Java type changes: + SandboxSetSpec.java:81 template: private AnyType template; + → private PodTemplateSpec template; + ... + Patched 4 Java file(s) +==> Patching Python SDK types... + Planned Python type changes: + sandbox.py:223 template: template: Any | None = None + → template: V1PodTemplateSpec | None = None + ... + Patched 6 Python file(s) +``` + +## 项目结构 + +``` +agents-api/ +├── agents/crds/ # CRD YAML 定义(数据源) +├── client/ # Go clientset / lister / informer +├── clients/ +│ ├── codegen/ # 代码生成后处理工具 +│ │ ├── type_mapping.yaml # 类型替换规则配置 +│ │ ├── patch_java_types.py # Java 类型修补脚本 +│ │ └── patch_python_types.py # Python 类型修补脚本 +│ ├── java/ # Java SDK +│ └── python/ # Python SDK +├── hack/ +│ ├── generate_client.sh # Go 客户端生成 +│ ├── generate_java_sdk.sh # Java SDK 生成 +│ ├── generate_python_sdk.sh # Python SDK 生成 +│ ├── patch_sdk_types.sh # 类型修补入口脚本 +│ └── update_upstream.sh # 上游 CRD 同步 +└── Makefile # 构建入口 +``` diff --git a/docs/sdk-codegen.md b/docs/sdk-codegen.md new file mode 100644 index 0000000..4c799dc --- /dev/null +++ b/docs/sdk-codegen.md @@ -0,0 +1,201 @@ +# SDK Code Generation Guide + +This document describes how to generate multi-language SDK client code for the Kruise Agents API. + +## Overview + +The project supports SDK generation for three languages: + +| Language | Generator | Output Directory | +| --- | --- | --- | +| Go | k8s code-generator | `client/` | +| Java | Fabric8 java-generator-cli 6.14.0 | `clients/java/` | +| Python | datamodel-codegen (Pydantic v2) | `clients/python/` | + +## Prerequisites + +### Go + +- Go 1.21+ + +### Java + +- JDK 8+ +- Fabric8 java-generator-cli (auto-downloaded by script) + +### Python + +- Python 3.11+ +- Install dependencies: + +```bash +pip install datamodel-code-generator ruff pyyaml +brew install yq +``` + +## Quick Start + +### Generate All SDKs at Once + +```bash +# Sync CRDs from upstream + generate all SDKs + auto-patch types +make generate-all + +# Skip upstream sync, generate + patch only +make generate-all SKIP_UPDATE=true +``` + +> **⚠️ Note:** Upstream sync downloads CRD files via the GitHub API. Without a token, you may hit rate limiting (HTTP 403). If this happens, manually place the latest CRD YAML files into the `agents/crds/` directory, then use `SKIP_UPDATE=true` to skip the automatic sync. + +### Generate a Single Language + +```bash +# Go client +make generate + +# Java SDK +make generate-java + +# Python SDK +make generate-python +``` + +### Run Type Patching Only + +```bash +# Patch all SDKs +make patch-sdk-types + +# Patch Java only +make patch-sdk-types LANG=java + +# Patch Python only +make patch-sdk-types LANG=python +``` + +## Generation Workflow + +### Go Client + +Uses the official Kubernetes `code-generator` to produce clientset, lister, and informer. + +``` +hack/generate_client.sh + → k8s.io/code-generator (clientset / lister / informer) + → Output: client/ +``` + +### Java SDK + +Uses Fabric8 java-generator-cli to generate Java model classes from CRD YAML definitions. + +``` +hack/generate_java_sdk.sh + → Fabric8 java-generator-cli + → Output: clients/java/.../models/ + → hack/patch_sdk_types.sh --java (type patching) +``` + +**Generated Java models** are located at: + +``` +clients/java/src/main/java/io/openkruise/agents/client/v2/models/ +``` + +This includes Java type definitions for all CRD resources: Sandbox, SandboxSet, SandboxTemplate, SandboxClaim, SandboxUpdateOps, Checkpoint, etc. + +### Python SDK + +Uses datamodel-codegen to generate Pydantic v2 models from CRD JSON Schema. + +``` +hack/generate_python_sdk.sh + → datamodel-codegen (Pydantic v2) + → ruff formatting + → Output: clients/python/.../models/ + → hack/patch_sdk_types.sh --python (type patching + ruff formatting) +``` + +**Generated Python models** are located at: + +``` +clients/python/openkruise/agents/models/ +``` + +Each CRD maps to a Python file (e.g. `sandbox.py`, `sandboxset.py`), containing Pydantic BaseModel class definitions. + +## Type Patching Mechanism + +### Why Is Type Patching Needed? + +CRD fields marked with `x-kubernetes-preserve-unknown-fields: true` lose concrete type information during code generation: + +| Field | Go Type | Java Generated | Python Generated | +| --- | --- | --- | --- | +| `template` | `*corev1.PodTemplateSpec` | `AnyType` ❌ | `Any` ❌ | +| `volumeClaimTemplates` | `[]corev1.PersistentVolumeClaim` | `AnyType` ❌ | `Any` ❌ | +| `metadata` | `metav1.ObjectMeta` | ✅ Correct | `dict[str, Any]` ❌ | +| `patch` | `runtime.RawExtension` | `AnyType` ❌ | ✅ Kept as Any | + +The type patching scripts automatically replace these placeholder types with the correct Kubernetes types. + +### Patching Rules Configuration + +All replacement rules are centrally maintained in `clients/codegen/type_mapping.yaml`: + +```yaml +fields: + - name: template + go_type: "*corev1.PodTemplateSpec" + java: + old_type: "io.fabric8.kubernetes.api.model.AnyType" + new_type: "io.fabric8.kubernetes.api.model.PodTemplateSpec" + python: + old_pattern: "Any" + new_type: "V1PodTemplateSpec" + import: "V1PodTemplateSpec" +``` + +To **add a new field rule**, simply add a new entry to this YAML file and re-run `make generate-all`. + +### Patching Execution Flow + +When patching runs, the script first prints all planned changes (file, line number, before/after), then applies them: + +``` +==> SDK Type Patching (rules: type_mapping.yaml) +==> Patching Java SDK types... + Planned Java type changes: + SandboxSetSpec.java:81 template: private AnyType template; + → private PodTemplateSpec template; + ... + Patched 4 Java file(s) +==> Patching Python SDK types... + Planned Python type changes: + sandbox.py:223 template: template: Any | None = None + → template: V1PodTemplateSpec | None = None + ... + Patched 6 Python file(s) +``` + +## Project Structure + +``` +agents-api/ +├── agents/crds/ # CRD YAML definitions (data source) +├── client/ # Go clientset / lister / informer +├── clients/ +│ ├── codegen/ # Post-generation tooling +│ │ ├── type_mapping.yaml # Type replacement rules +│ │ ├── patch_java_types.py # Java type patching script +│ │ └── patch_python_types.py # Python type patching script +│ ├── java/ # Java SDK +│ └── python/ # Python SDK +├── hack/ +│ ├── generate_client.sh # Go client generation +│ ├── generate_java_sdk.sh # Java SDK generation +│ ├── generate_python_sdk.sh # Python SDK generation +│ ├── patch_sdk_types.sh # Type patching entry script +│ └── update_upstream.sh # Upstream CRD sync +└── Makefile # Build entry point +``` diff --git a/hack/generate_client.sh b/hack/generate_client.sh index 231189d..a0a92e7 100755 --- a/hack/generate_client.sh +++ b/hack/generate_client.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Usage: +# ./hack/generate_client.sh # update upstream + generate +# ./hack/generate_client.sh --skip-update # skip upstream update, generate only + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +SKIP_UPDATE=false +for arg in "$@"; do + case "${arg}" in + --skip-update) SKIP_UPDATE=true ;; + esac +done + +if [[ "${SKIP_UPDATE}" == "false" ]]; then + echo "==> Updating upstream definitions (CRD + Go types)..." + "${SCRIPT_DIR}/update_upstream.sh" +fi + go mod vendor retVal=$? if [ $retVal -ne 0 ]; then diff --git a/hack/generate_java_sdk.sh b/hack/generate_java_sdk.sh new file mode 100755 index 0000000..4ddd930 --- /dev/null +++ b/hack/generate_java_sdk.sh @@ -0,0 +1,114 @@ +#!/usr/bin/env bash +# Generate Java SDK v2 from CRD YAML definitions using Fabric8 java-generator-cli. +# +# Prerequisites: +# - JDK 8+ installed +# - CRD YAML files present in agents/crds/ +# +# Usage: +# ./hack/generate_java_sdk.sh # update upstream + generate +# ./hack/generate_java_sdk.sh --skip-update # skip upstream update, generate only +# make generate-java +# +# NOTE: This script only generates raw Java classes. +# Field type refinements (e.g. AnyType → PodTemplateSpec) are handled +# separately via hack/patch_sdk_types.sh. + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" + +# ── Parse arguments ─────────────────────────────────────────────────────────── +SKIP_UPDATE=false +for arg in "$@"; do + case "${arg}" in + --skip-update) SKIP_UPDATE=true ;; + esac +done + +if [[ "${SKIP_UPDATE}" == "false" ]]; then + echo "==> Updating upstream definitions (CRD + Go types)..." + "${SCRIPT_DIR}/update_upstream.sh" +fi + +# ── Configuration ───────────────────────────────────────────────────────────── +FABRIC8_VERSION="6.14.0" +CRD_SOURCE_DIR="${PROJECT_ROOT}/agents/crds" +JAVA_TARGET_DIR="${PROJECT_ROOT}/clients/java/src/main/java" +TARGET_PACKAGE="io.openkruise.agents.client.v2.models" +CLI_JAR_DIR="${PROJECT_ROOT}/bin" +CLI_JAR="${CLI_JAR_DIR}/java-generator-cli-${FABRIC8_VERSION}.jar" +MAVEN_REPO_URL="https://repo1.maven.org/maven2/io/fabric8/java-generator-cli/${FABRIC8_VERSION}/java-generator-cli-${FABRIC8_VERSION}.jar" + +# ── Pre-flight checks ──────────────────────────────────────────────────────── +echo "==> Pre-flight checks..." + +if ! command -v java &>/dev/null; then + echo "ERROR: java is not installed. Please install JDK 8+." + exit 1 +fi +echo " Java: $(java -version 2>&1 | head -1)" + +if [[ ! -d "${CRD_SOURCE_DIR}" ]]; then + echo "ERROR: CRD source directory not found: ${CRD_SOURCE_DIR}" + exit 1 +fi + +CRD_COUNT=$(find "${CRD_SOURCE_DIR}" -name '*.yaml' | wc -l | tr -d ' ') +if [[ "${CRD_COUNT}" -eq 0 ]]; then + echo "ERROR: No CRD YAML files found in ${CRD_SOURCE_DIR}" + exit 1 +fi +echo " CRDs: ${CRD_COUNT} files in ${CRD_SOURCE_DIR}" + +# ── Download CLI jar if not present ─────────────────────────────────────────── +if [[ ! -f "${CLI_JAR}" ]]; then + echo "==> Downloading Fabric8 java-generator-cli ${FABRIC8_VERSION}..." + mkdir -p "${CLI_JAR_DIR}" + curl -fsSL -o "${CLI_JAR}" "${MAVEN_REPO_URL}" +fi + +# ── Generate Java classes ───────────────────────────────────────────────────── +V2_MODELS_DIR="${JAVA_TARGET_DIR}/io/openkruise/agents/client/v2/models" +TARGET_PACKAGE_DIR=$(echo "${TARGET_PACKAGE}" | tr '.' '/') + +echo "==> Generating Java SDK v2..." + +GEN_TEMP_DIR=$(mktemp -d) +trap "rm -rf ${GEN_TEMP_DIR}" EXIT + +java -jar "${CLI_JAR}" \ + --source "${CRD_SOURCE_DIR}" \ + --target "${GEN_TEMP_DIR}" \ + --package-overrides io.kruise.agents.v1alpha1="${TARGET_PACKAGE}" \ + --enum-uppercase \ + --skip-generated-annotations + +GENERATED_ROOT="${GEN_TEMP_DIR}/${TARGET_PACKAGE_DIR}" + +if [[ ! -d "${GENERATED_ROOT}" ]]; then + echo "ERROR: Expected generated directory not found: ${GENERATED_ROOT}" + find "${GEN_TEMP_DIR}" -type f + exit 1 +fi + +# Install generated files +rm -rf "${V2_MODELS_DIR}" +mkdir -p "${V2_MODELS_DIR}" +cp -R "${GENERATED_ROOT}"/* "${V2_MODELS_DIR}/" + +# ── Summary ─────────────────────────────────────────────────────────────────── +JAVA_FILE_COUNT=$(find "${V2_MODELS_DIR}" -name '*.java' | wc -l | tr -d ' ') +echo "" +echo "=========================================" +echo " Java SDK v2 generation complete!" +echo " Tool: Fabric8 java-generator-cli ${FABRIC8_VERSION}" +echo " Source: ${CRD_SOURCE_DIR} (${CRD_COUNT} CRD files)" +echo " Generated: ${JAVA_FILE_COUNT} Java files" +echo " Package: ${TARGET_PACKAGE}" +echo " Location: ${V2_MODELS_DIR}" +echo "=========================================" +echo "" +echo "NOTE: Run 'make patch-sdk-types LANG=java' to refine field types" +echo " (e.g. AnyType → PodTemplateSpec, RawExtension, etc.)" diff --git a/hack/generate_python_sdk.sh b/hack/generate_python_sdk.sh new file mode 100755 index 0000000..833a5b7 --- /dev/null +++ b/hack/generate_python_sdk.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash +# Generate Python SDK models from local CRD YAML using datamodel-codegen. +# +# Prerequisites: +# - Python 3.11+ +# - pip install datamodel-code-generator black isort +# - yq (https://github.com/mikefarah/yq) +# - CRD YAML files present in agents/crds/ +# +# Usage: +# ./hack/generate_python_sdk.sh # update upstream + generate +# ./hack/generate_python_sdk.sh --skip-update # skip upstream update, generate only +# make generate-python +# +# NOTE: This script only generates raw Pydantic models. +# Field type refinements (e.g. Any → V1PodTemplateSpec) are handled +# separately via hack/patch_sdk_types.sh. + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" + +# ── Parse arguments ─────────────────────────────────────────────────────────── +SKIP_UPDATE=false +for arg in "$@"; do + case "${arg}" in + --skip-update) SKIP_UPDATE=true ;; + esac +done + +if [[ "${SKIP_UPDATE}" == "false" ]]; then + echo "==> Updating upstream definitions (CRD + Go types)..." + "${SCRIPT_DIR}/update_upstream.sh" +fi + +# ── Configuration ───────────────────────────────────────────────────────────── +CRD_SOURCE_DIR="${PROJECT_ROOT}/agents/crds" +MODELS_DIR="${PROJECT_ROOT}/clients/python/openkruise/agents/models" + +WORK_DIR=$(mktemp -d) +trap "rm -rf ${WORK_DIR}" EXIT +SCHEMAS_DIR="${WORK_DIR}/schemas" +mkdir -p "${SCHEMAS_DIR}" + +# ── Pre-flight checks ──────────────────────────────────────────────────────── +echo "==> Pre-flight checks..." + +for cmd in yq datamodel-codegen ruff; do + if ! command -v "${cmd}" &>/dev/null; then + echo "ERROR: ${cmd} is not installed." + echo " pip install datamodel-code-generator ruff" + echo " brew install yq" + exit 1 + fi +done + +if [[ ! -d "${CRD_SOURCE_DIR}" ]]; then + echo "ERROR: CRD source directory not found: ${CRD_SOURCE_DIR}" + exit 1 +fi + +CRD_COUNT=$(find "${CRD_SOURCE_DIR}" -name '*.yaml' -type f | wc -l | tr -d ' ') +echo " CRDs: ${CRD_COUNT} files in ${CRD_SOURCE_DIR}" + +# ── Generate Pydantic models ────────────────────────────────────────────────── +echo "==> Generating Pydantic models..." + +for crd_file in "${CRD_SOURCE_DIR}"/*.yaml; do + kind=$(yq '.spec.names.kind' < "${crd_file}") + kind_lower=$(echo "${kind}" | tr '[:upper:]' '[:lower:]') + + schema_json="${SCHEMAS_DIR}/${kind_lower}_schema.json" + output_model="${MODELS_DIR}/${kind_lower}.py" + + echo " ${kind} ($(basename "${crd_file}"))" + + yq '.spec.versions[0].schema.openAPIV3Schema' -o=json < "${crd_file}" > "${schema_json}" + + datamodel-codegen \ + --input "${schema_json}" \ + --output "${output_model}" \ + --input-file-type jsonschema \ + --target-python-version 3.11 \ + --use-schema-description \ + --use-field-description \ + --field-constraints \ + --keep-model-order \ + --class-name "${kind}" + + sed -i '' 's/regex=/pattern=/g' "${output_model}" + + ruff check --fix --select I -q "${output_model}" 2>/dev/null || true + ruff format -q "${output_model}" +done + +# ── Summary ─────────────────────────────────────────────────────────────────── +PY_FILE_COUNT=$(find "${MODELS_DIR}" -name '*.py' ! -name '__init__.py' | wc -l | tr -d ' ') +echo "" +echo "=========================================" +echo " Python SDK generation complete!" +echo " Tool: datamodel-codegen" +echo " Source: ${CRD_SOURCE_DIR} (${CRD_COUNT} CRD files)" +echo " Generated: ${PY_FILE_COUNT} model files" +echo " Location: ${MODELS_DIR}" +echo "=========================================" +echo "" +echo "NOTE: Run 'make patch-sdk-types LANG=python' to refine field types" +echo " (e.g. Any → V1PodTemplateSpec, V1ObjectMeta, etc.)" diff --git a/hack/patch_sdk_types.sh b/hack/patch_sdk_types.sh new file mode 100755 index 0000000..413e491 --- /dev/null +++ b/hack/patch_sdk_types.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# Patch generated SDK type placeholders with correct Kubernetes types. +# +# Reads replacement rules from clients/codegen/type_mapping.yaml and applies them to +# generated Java and Python SDK files. Prints a preview of all changes +# before applying. +# +# Usage: +# ./hack/patch_sdk_types.sh # patch both Java and Python +# ./hack/patch_sdk_types.sh --java # patch Java only +# ./hack/patch_sdk_types.sh --python # patch Python only +# make patch-sdk-types + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" + +# ── Configuration ───────────────────────────────────────────────────────────── +CODEGEN_DIR="${PROJECT_ROOT}/clients/codegen" +MAPPING_FILE="${CODEGEN_DIR}/type_mapping.yaml" +JAVA_MODELS_DIR="${PROJECT_ROOT}/clients/java/src/main/java/io/openkruise/agents/client/v2/models" +PYTHON_MODELS_DIR="${PROJECT_ROOT}/clients/python/openkruise/agents/models" + +# ── Parse arguments ─────────────────────────────────────────────────────────── +PATCH_JAVA=true +PATCH_PYTHON=true +for arg in "$@"; do + case "${arg}" in + --java) PATCH_JAVA=true; PATCH_PYTHON=false ;; + --python) PATCH_JAVA=false; PATCH_PYTHON=true ;; + esac +done + +if [[ ! -f "${MAPPING_FILE}" ]]; then + echo "ERROR: Type mapping file not found: ${MAPPING_FILE}" + exit 1 +fi + +# ── Java Type Patching ──────────────────────────────────────────────────────── +patch_java() { + if [[ ! -d "${JAVA_MODELS_DIR}" ]]; then + echo "WARN: Java models directory not found: ${JAVA_MODELS_DIR}" + return 0 + fi + + echo "==> Patching Java SDK types..." + python3 "${CODEGEN_DIR}/patch_java_types.py" "${JAVA_MODELS_DIR}" "${MAPPING_FILE}" +} + +# ── Python Type Patching ────────────────────────────────────────────────────── +patch_python() { + if [[ ! -d "${PYTHON_MODELS_DIR}" ]]; then + echo "WARN: Python models directory not found: ${PYTHON_MODELS_DIR}" + return 0 + fi + + echo "==> Patching Python SDK types..." + python3 "${CODEGEN_DIR}/patch_python_types.py" "${PYTHON_MODELS_DIR}" "${MAPPING_FILE}" + + echo "==> Formatting Python SDK code..." + if command -v ruff &>/dev/null; then + ruff check --fix --select I "${PYTHON_MODELS_DIR}" 2>/dev/null || true + ruff format "${PYTHON_MODELS_DIR}" 2>/dev/null || true + elif command -v black &>/dev/null; then + isort "${PYTHON_MODELS_DIR}" 2>/dev/null || true + black "${PYTHON_MODELS_DIR}" 2>/dev/null || true + else + echo " WARN: No Python formatter found (ruff/black), skipping format" + fi +} + +# ── Main ────────────────────────────────────────────────────────────────────── +echo "==> SDK Type Patching (rules: $(basename "${MAPPING_FILE}"))" + +if [[ "${PATCH_JAVA}" == "true" ]]; then + patch_java +fi + +if [[ "${PATCH_PYTHON}" == "true" ]]; then + patch_python +fi + +echo "" +echo "=========================================" +echo " SDK type patching complete!" +echo "=========================================" diff --git a/hack/update_upstream.sh b/hack/update_upstream.sh new file mode 100755 index 0000000..2104fa9 --- /dev/null +++ b/hack/update_upstream.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bash +# Download the latest CRD YAML and Go type definitions from the upstream +# openkruise/agents repository on GitHub. +# +# Sources: +# - CRD: github.com/openkruise/agents/config/crd/bases → agents/crds/ +# - Go types: github.com/openkruise/agents/api/v1alpha1 → agents/v1alpha1/ +# +# Prerequisites: +# - curl +# +# Usage: +# ./hack/update_upstream.sh # update both CRD and Go types +# ./hack/update_upstream.sh --crds-only # update CRD files only +# ./hack/update_upstream.sh --types-only # update Go type files only + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" + +# ── Configuration ───────────────────────────────────────────────────────────── +UPSTREAM_REPO="openkruise/agents" +UPSTREAM_BRANCH="master" +RAW_BASE="https://raw.githubusercontent.com/${UPSTREAM_REPO}/${UPSTREAM_BRANCH}" +API_BASE="https://api.github.com/repos/${UPSTREAM_REPO}/contents" + +CRD_REMOTE_PATH="config/crd/bases" +TYPES_REMOTE_PATH="api/v1alpha1" + +CRD_LOCAL_DIR="${PROJECT_ROOT}/agents/crds" +TYPES_LOCAL_DIR="${PROJECT_ROOT}/agents/v1alpha1" + +# ── Parse arguments ─────────────────────────────────────────────────────────── +UPDATE_CRDS=true +UPDATE_TYPES=true + +for arg in "$@"; do + case "${arg}" in + --crds-only) + UPDATE_TYPES=false + ;; + --types-only) + UPDATE_CRDS=false + ;; + --help|-h) + echo "Usage: $0 [--crds-only] [--types-only]" + exit 0 + ;; + *) + echo "Unknown argument: ${arg}" + exit 1 + ;; + esac +done + +# ── Helper: download all files in a GitHub directory ────────────────────────── +# Usage: download_github_dir +download_github_dir() { + local remote_path="$1" + local local_dir="$2" + local file_ext="$3" + + echo " Fetching file list from GitHub API: ${API_BASE}/${remote_path} ..." + + local file_list + file_list=$(curl -fsSL "${API_BASE}/${remote_path}?ref=${UPSTREAM_BRANCH}" \ + | grep '"name"' \ + | sed 's/.*"name": *"\([^"]*\)".*/\1/') + + if [[ -z "${file_list}" ]]; then + echo " ERROR: Failed to fetch file list from GitHub API." + echo " You may be rate-limited. Try again later or set GITHUB_TOKEN." + exit 1 + fi + + mkdir -p "${local_dir}" + + local count=0 + for filename in ${file_list}; do + # Filter by extension if specified + if [[ -n "${file_ext}" && "${filename}" != *"${file_ext}" ]]; then + continue + fi + + local url="${RAW_BASE}/${remote_path}/${filename}" + echo " ↓ ${filename}" + curl -fsSL -o "${local_dir}/${filename}" "${url}" + count=$((count + 1)) + done + + echo " Downloaded ${count} files to ${local_dir}" +} + +# ── Main ────────────────────────────────────────────────────────────────────── +echo "==> Updating upstream definitions from ${UPSTREAM_REPO}@${UPSTREAM_BRANCH}" + +if [[ "${UPDATE_CRDS}" == "true" ]]; then + echo "" + echo "--- Updating CRD YAML files ---" + download_github_dir "${CRD_REMOTE_PATH}" "${CRD_LOCAL_DIR}" ".yaml" +fi + +if [[ "${UPDATE_TYPES}" == "true" ]]; then + echo "" + echo "--- Updating Go type definitions ---" + download_github_dir "${TYPES_REMOTE_PATH}" "${TYPES_LOCAL_DIR}" ".go" +fi + +echo "" +echo "==> Upstream update complete!"