From 4ec756a3d2e2083cb4d420e5c127f11bf0b5edbe Mon Sep 17 00:00:00 2001 From: kerthcet Date: Wed, 17 Jul 2024 18:13:48 +0800 Subject: [PATCH] [1/N] Add support for per model deployment Signed-off-by: kerthcet --- .github/workflows/kube-workflow-init.yaml | 2 +- Dockerfile | 3 +- Makefile | 52 +++- api/core/v1alpha1/doc.go | 20 ++ api/{ => core}/v1alpha1/groupversion_info.go | 9 + api/{ => core}/v1alpha1/model_types.go | 4 +- api/core/v1alpha1/types.go | 23 ++ .../v1alpha1/zz_generated.deepcopy.go | 6 +- api/inference/v1alpha1/config_types.go | 75 +++++ api/inference/v1alpha1/doc.go | 20 ++ api/inference/v1alpha1/groupversion_info.go | 9 + api/inference/v1alpha1/playground_types.go | 12 +- api/inference/v1alpha1/service_types.go | 13 +- api/inference/v1alpha1/types.go | 56 +--- .../v1alpha1/zz_generated.deepcopy.go | 22 +- .../core/v1alpha1/datasource.go | 47 +++ .../core/v1alpha1/flavor.go | 82 +++++ .../applyconfiguration/core/v1alpha1/model.go | 218 +++++++++++++ .../core/v1alpha1/modelclaim.go | 53 ++++ .../core/v1alpha1/modelspec.go | 65 ++++ .../core/v1alpha1/modelstatus.go | 44 +++ .../core/v1alpha1/multimodelsclaim.go | 64 ++++ .../inference/v1alpha1/backendconfig.go | 83 +++++ .../inference/v1alpha1/elasticconfig.go | 47 +++ .../inference/v1alpha1/playground.go | 218 +++++++++++++ .../inference/v1alpha1/playgroundspec.go | 83 +++++ .../inference/v1alpha1/playgroundstatus.go | 44 +++ .../v1alpha1/resourcerequirements.go | 51 ++++ .../inference/v1alpha1/service.go | 218 +++++++++++++ .../inference/v1alpha1/servicespec.go | 66 ++++ .../inference/v1alpha1/servicestatus.go | 44 +++ .../applyconfiguration/internal/internal.go | 61 ++++ client-go/applyconfiguration/utils.go | 70 +++++ client-go/clientset/versioned/clientset.go | 132 ++++++++ .../versioned/fake/clientset_generated.go | 91 ++++++ client-go/clientset/versioned/fake/doc.go | 19 ++ .../clientset/versioned/fake/register.go | 57 ++++ client-go/clientset/versioned/scheme/doc.go | 19 ++ .../clientset/versioned/scheme/register.go | 57 ++++ .../typed/core/v1alpha1/core_client.go | 106 +++++++ .../versioned/typed/core/v1alpha1/doc.go | 19 ++ .../versioned/typed/core/v1alpha1/fake/doc.go | 19 ++ .../core/v1alpha1/fake/fake_core_client.go | 39 +++ .../typed/core/v1alpha1/fake/fake_model.go | 188 ++++++++++++ .../core/v1alpha1/generated_expansion.go | 20 ++ .../versioned/typed/core/v1alpha1/model.go | 255 ++++++++++++++++ .../versioned/typed/inference/v1alpha1/doc.go | 19 ++ .../typed/inference/v1alpha1/fake/doc.go | 19 ++ .../v1alpha1/fake/fake_inference_client.go | 43 +++ .../v1alpha1/fake/fake_playground.go | 188 ++++++++++++ .../inference/v1alpha1/fake/fake_service.go | 188 ++++++++++++ .../inference/v1alpha1/generated_expansion.go | 22 ++ .../inference/v1alpha1/inference_client.go | 111 +++++++ .../typed/inference/v1alpha1/playground.go | 255 ++++++++++++++++ .../typed/inference/v1alpha1/service.go | 255 ++++++++++++++++ .../externalversions/core/interface.go | 45 +++ .../core/v1alpha1/interface.go | 44 +++ .../externalversions/core/v1alpha1/model.go | 89 ++++++ .../informers/externalversions/factory.go | 266 ++++++++++++++++ .../informers/externalversions/generic.go | 68 +++++ .../externalversions/inference/interface.go | 45 +++ .../inference/v1alpha1/interface.go | 51 ++++ .../inference/v1alpha1/playground.go | 89 ++++++ .../inference/v1alpha1/service.go | 89 ++++++ .../internalinterfaces/factory_interfaces.go | 39 +++ .../core/v1alpha1/expansion_generated.go | 26 ++ client-go/listers/core/v1alpha1/model.go | 98 ++++++ .../inference/v1alpha1/expansion_generated.go | 34 +++ .../listers/inference/v1alpha1/playground.go | 98 ++++++ .../listers/inference/v1alpha1/service.go | 98 ++++++ cmd/main.go | 10 +- .../bases/inference.llmaz.io_playgrounds.yaml | 3 +- .../bases/inference.llmaz.io_services.yaml | 5 +- config/crd/bases/llmaz.io_models.yaml | 90 +----- config/manager/kustomization.yaml | 4 +- config/samples/_v1alpha1_model.yaml | 2 +- go.mod | 10 +- go.sum | 18 ++ hack/e2e-test.sh | 46 +++ hack/internal/tools.go | 22 ++ hack/update-codegen.sh | 33 ++ .../inference/playground_controller.go | 62 ---- .../inference/service_controller.go | 62 ---- pkg/backend/backend.go | 50 +++ pkg/backend/backend_test.go | 59 ++++ pkg/backend/vllm.go | 72 +++++ {internal => pkg}/cert/cert.go | 0 .../inference/playground_controller.go | 289 ++++++++++++++++++ .../inference/service_controller.go | 137 +++++++++ .../controller/inference/suite_test.go | 0 .../controller/model_controller.go | 12 +- {internal => pkg}/controller/suite_test.go | 4 +- pkg/util/client.go | 49 +++ {internal => pkg}/webhook/model_webhook.go | 2 +- .../webhook/playground_webhook.go | 0 test/e2e/config/image_pull_policy.yaml | 11 + test/e2e/config/kustomization.yaml | 8 + test/e2e/model_test.go | 32 ++ test/e2e/playground_test.go | 57 ++++ test/e2e/suit_test.go | 107 +++++++ .../controller/inference/playground_test.go | 72 +++++ .../controller/inference/suit_test.go | 129 ++++++++ test/integration/webhook/model_test.go | 8 +- test/integration/webhook/suit_test.go | 10 +- test/util/mock.go | 34 +++ test/util/wrapper/model.go | 15 +- test/util/wrapper/playground.go | 2 +- 107 files changed, 6394 insertions(+), 316 deletions(-) create mode 100644 api/core/v1alpha1/doc.go rename api/{ => core}/v1alpha1/groupversion_info.go (77%) rename api/{ => core}/v1alpha1/model_types.go (98%) create mode 100644 api/core/v1alpha1/types.go rename api/{ => core}/v1alpha1/zz_generated.deepcopy.go (98%) create mode 100644 api/inference/v1alpha1/config_types.go create mode 100644 api/inference/v1alpha1/doc.go create mode 100644 client-go/applyconfiguration/core/v1alpha1/datasource.go create mode 100644 client-go/applyconfiguration/core/v1alpha1/flavor.go create mode 100644 client-go/applyconfiguration/core/v1alpha1/model.go create mode 100644 client-go/applyconfiguration/core/v1alpha1/modelclaim.go create mode 100644 client-go/applyconfiguration/core/v1alpha1/modelspec.go create mode 100644 client-go/applyconfiguration/core/v1alpha1/modelstatus.go create mode 100644 client-go/applyconfiguration/core/v1alpha1/multimodelsclaim.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/backendconfig.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/elasticconfig.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/playground.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/playgroundspec.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/playgroundstatus.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/resourcerequirements.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/service.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/servicespec.go create mode 100644 client-go/applyconfiguration/inference/v1alpha1/servicestatus.go create mode 100644 client-go/applyconfiguration/internal/internal.go create mode 100644 client-go/applyconfiguration/utils.go create mode 100644 client-go/clientset/versioned/clientset.go create mode 100644 client-go/clientset/versioned/fake/clientset_generated.go create mode 100644 client-go/clientset/versioned/fake/doc.go create mode 100644 client-go/clientset/versioned/fake/register.go create mode 100644 client-go/clientset/versioned/scheme/doc.go create mode 100644 client-go/clientset/versioned/scheme/register.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/core_client.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/doc.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/fake/doc.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_model.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/generated_expansion.go create mode 100644 client-go/clientset/versioned/typed/core/v1alpha1/model.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/doc.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/fake/doc.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_inference_client.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_playground.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_service.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/generated_expansion.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/inference_client.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/playground.go create mode 100644 client-go/clientset/versioned/typed/inference/v1alpha1/service.go create mode 100644 client-go/informers/externalversions/core/interface.go create mode 100644 client-go/informers/externalversions/core/v1alpha1/interface.go create mode 100644 client-go/informers/externalversions/core/v1alpha1/model.go create mode 100644 client-go/informers/externalversions/factory.go create mode 100644 client-go/informers/externalversions/generic.go create mode 100644 client-go/informers/externalversions/inference/interface.go create mode 100644 client-go/informers/externalversions/inference/v1alpha1/interface.go create mode 100644 client-go/informers/externalversions/inference/v1alpha1/playground.go create mode 100644 client-go/informers/externalversions/inference/v1alpha1/service.go create mode 100644 client-go/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 client-go/listers/core/v1alpha1/expansion_generated.go create mode 100644 client-go/listers/core/v1alpha1/model.go create mode 100644 client-go/listers/inference/v1alpha1/expansion_generated.go create mode 100644 client-go/listers/inference/v1alpha1/playground.go create mode 100644 client-go/listers/inference/v1alpha1/service.go create mode 100755 hack/e2e-test.sh create mode 100644 hack/internal/tools.go create mode 100755 hack/update-codegen.sh delete mode 100644 internal/controller/inference/playground_controller.go delete mode 100644 internal/controller/inference/service_controller.go create mode 100644 pkg/backend/backend.go create mode 100644 pkg/backend/backend_test.go create mode 100644 pkg/backend/vllm.go rename {internal => pkg}/cert/cert.go (100%) create mode 100644 pkg/controller/inference/playground_controller.go create mode 100644 pkg/controller/inference/service_controller.go rename {internal => pkg}/controller/inference/suite_test.go (100%) rename {internal => pkg}/controller/model_controller.go (85%) rename {internal => pkg}/controller/suite_test.go (96%) create mode 100644 pkg/util/client.go rename {internal => pkg}/webhook/model_webhook.go (98%) rename {internal => pkg}/webhook/playground_webhook.go (100%) create mode 100644 test/e2e/config/image_pull_policy.yaml create mode 100644 test/e2e/config/kustomization.yaml create mode 100644 test/e2e/model_test.go create mode 100644 test/e2e/playground_test.go create mode 100644 test/e2e/suit_test.go create mode 100644 test/integration/controller/inference/playground_test.go create mode 100644 test/integration/controller/inference/suit_test.go create mode 100644 test/util/mock.go diff --git a/.github/workflows/kube-workflow-init.yaml b/.github/workflows/kube-workflow-init.yaml index d1117cc..4a97fac 100644 --- a/.github/workflows/kube-workflow-init.yaml +++ b/.github/workflows/kube-workflow-init.yaml @@ -1,4 +1,4 @@ -name: init +name: workflow-as-kube-init on: workflow_dispatch: diff --git a/Dockerfile b/Dockerfile index c3c6b0c..8430915 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,8 @@ RUN go mod download # Copy the go source COPY cmd/main.go cmd/main.go COPY api/ api/ -COPY internal/ internal/ +COPY pkg/ pkg/ +COPY client-go/ client-go/ # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command diff --git a/Makefile b/Makefile index dba5373..9ffa783 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ +# We use 1.30.0 here because there's a bug about invalid defaults of creationTimestamp. +# See https://github.com/kubernetes/kubernetes/pull/120757 for more details. +# FIXME: But seems not related, will revisit this later. # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.28.3 +ENVTEST_K8S_VERSION = 1.30.0 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -43,6 +46,8 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) ARTIFACTS ?= $(PROJECT_DIR)/bin GINKGO_VERSION ?= $(shell go list -m -f '{{.Version}}' github.com/onsi/ginkgo/v2) GO_VERSION := $(shell awk '/^go /{print $$2}' go.mod|head -n1) +E2E_KIND_VERSION ?= kindest/node:v1.30.0 +USE_EXISTING_CLUSTER ?= false GINKGO = $(shell pwd)/bin/ginkgo .PHONY: ginkgo @@ -56,12 +61,13 @@ BASE_IMAGE ?= gcr.io/distroless/static:nonroot DOCKER_BUILDX_CMD ?= docker buildx IMAGE_BUILD_CMD ?= $(DOCKER_BUILDX_CMD) build IMAGE_BUILD_EXTRA_OPTS ?= -IMAGE_REGISTRY ?= docker.io/inftyai +IMAGE_REGISTRY ?= inftyai IMAGE_NAME ?= llmaz IMAGE_REPO := $(IMAGE_REGISTRY)/$(IMAGE_NAME) GIT_TAG ?= $(shell git describe --tags --dirty --always) IMG ?= $(IMAGE_REPO):$(GIT_TAG) BUILDER_IMAGE ?= golang:$(GO_VERSION) +KIND_CLUSTER_NAME ?= kind ##@ Development @@ -74,9 +80,28 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust paths="./..." .PHONY: generate -generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. +generate: controller-gen code-generator ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." +# This is a fixed bug in v1.31, will remove this command in the future. +# Now, we have to modify the files ourself each time regenerate the client-go codes. +# Generally replace "inftyai.com/llmaz/api/core/v1alpha1" with "inftyai.com/llmaz/api/v1alpha1" +# See https://github.com/kubernetes/kubernetes/pull/125162 +.PHONY: generate-client-go +generate-client-go: code-generator + ./hack/update-codegen.sh go $(PROJECT_DIR)/bin + +# Use same code-generator version as k8s.io/api +CODEGEN_VERSION := $(shell go list -m -f '{{.Version}}' k8s.io/api) +CODEGEN = $(shell pwd)/bin/code-generator +CODEGEN_ROOT = $(shell go env GOMODCACHE)/k8s.io/code-generator@$(CODEGEN_VERSION) +.PHONY: code-generator +code-generator: + @GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on go install k8s.io/code-generator/cmd/client-gen@$(CODEGEN_VERSION) + cp -f $(CODEGEN_ROOT)/generate-groups.sh $(PROJECT_DIR)/bin/ + cp -f $(CODEGEN_ROOT)/generate-internal-groups.sh $(PROJECT_DIR)/bin/ + cp -f $(CODEGEN_ROOT)/kube_codegen.sh $(PROJECT_DIR)/bin/ + .PHONY: fmt fmt: ## Run go fmt against code. go fmt ./... @@ -94,6 +119,11 @@ test-integration: manifests fmt vet envtest ginkgo ## Run integration tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \ $(GINKGO) --junit-report=junit.xml --output-dir=$(ARTIFACTS) -v $(INTEGRATION_TARGET) +.PHONY: test-e2e +# FIXME: we should install lws CRD. +test-e2e: kustomize manifests fmt vet envtest ginkgo kind-image-build + E2E_KIND_VERSION=$(E2E_KIND_VERSION) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) KIND=$(KIND) KUBECTL=$(KUBECTL) KUSTOMIZE=$(KUSTOMIZE) GINKGO=$(GINKGO) USE_EXISTING_CLUSTER=$(USE_EXISTING_CLUSTER) IMAGE_TAG=$(IMG) ./hack/e2e-test.sh + GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint GOLANGCI_LINT_VERSION ?= v1.54.2 golangci-lint: @@ -150,6 +180,16 @@ image-build: image-push: PUSH=--push image-push: image-build +KIND = $(shell pwd)/bin/kind +.PHONY: kind +kind: + @GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on go install sigs.k8s.io/kind@v0.23.0 + +.PHONY: kind-image-build +kind-image-build: PLATFORMS=linux/amd64 +kind-image-build: kind image-build + kind load docker-image $(IMG) + ##@ Deployment ifndef ignore-not-found @@ -169,6 +209,12 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} $(KUSTOMIZE) build config/default | $(KUBECTL) apply --server-side --force-conflicts -f - +# This is only used in local development with kind. +.PHONY: quick-deploy +quick-deploy: manifests kustomize kind-image-build ## Deploy controller to the K8s cluster specified in ~/.kube/config. + cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} + $(KUSTOMIZE) build config/default | $(KUBECTL) apply --server-side --force-conflicts -f - + .PHONY: undeploy undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - diff --git a/api/core/v1alpha1/doc.go b/api/core/v1alpha1/doc.go new file mode 100644 index 0000000..634d050 --- /dev/null +++ b/api/core/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +kubebuilder:object:generate=true +// +groupName=llmaz.io + +package v1alpha1 diff --git a/api/v1alpha1/groupversion_info.go b/api/core/v1alpha1/groupversion_info.go similarity index 77% rename from api/v1alpha1/groupversion_info.go rename to api/core/v1alpha1/groupversion_info.go index 683c06e..b47bb6b 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/core/v1alpha1/groupversion_info.go @@ -28,9 +28,18 @@ var ( // GroupVersion is group version used to register these objects GroupVersion = schema.GroupVersion{Group: "llmaz.io", Version: "v1alpha1"} + // SchemeGroupVersion is alias to GroupVersion for client-go libraries. + // It is required by pkg/client/informers/externalversions/... + SchemeGroupVersion = GroupVersion + // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme ) + +// Resource is required by pkg/client/listers/... +func Resource(resource string) schema.GroupResource { + return GroupVersion.WithResource(resource).GroupResource() +} diff --git a/api/v1alpha1/model_types.go b/api/core/v1alpha1/model_types.go similarity index 98% rename from api/v1alpha1/model_types.go rename to api/core/v1alpha1/model_types.go index 87dedad..57e133f 100644 --- a/api/v1alpha1/model_types.go +++ b/api/core/v1alpha1/model_types.go @@ -23,6 +23,7 @@ import ( const ( ModelFamilyNameLabelKey = "llmaz.io/model-family-name" + ModelNameLabelKey = "llmaz.io/model-name" ) // DataSource represents where to load the model. @@ -75,7 +76,7 @@ type Flavor struct { // cloud-provider.com/accelerator: nvidia-a100. // NodeSelector will be auto injected to the Pods as scheduling primitives. // +optional - NodeSelector []v1.NodeSelector `json:"nodeSelector,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` // Params stores other useful parameters and will be consumed by the autoscaling components // like cluster-autoscaler, Karpenter. // E.g. when scaling up nodes with 8x Nvidia A00, the parameter can be injected with @@ -146,6 +147,7 @@ type ModelStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` } +//+genclient //+kubebuilder:object:root=true //+kubebuilder:subresource:status //+kubebuilder:resource:scope=Cluster diff --git a/api/core/v1alpha1/types.go b/api/core/v1alpha1/types.go new file mode 100644 index 0000000..b369ae6 --- /dev/null +++ b/api/core/v1alpha1/types.go @@ -0,0 +1,23 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +This file is needed for kubernetes/code-generator/kube_codegen.sh script used in hack/update-codegen.sh. +*/ + +package v1alpha1 + +//+genclient diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/core/v1alpha1/zz_generated.deepcopy.go similarity index 98% rename from api/v1alpha1/zz_generated.deepcopy.go rename to api/core/v1alpha1/zz_generated.deepcopy.go index 56d3fec..ac8966b 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/core/v1alpha1/zz_generated.deepcopy.go @@ -63,9 +63,9 @@ func (in *Flavor) DeepCopyInto(out *Flavor) { } if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector - *out = make([]v1.NodeSelector, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val } } if in.Params != nil { diff --git a/api/inference/v1alpha1/config_types.go b/api/inference/v1alpha1/config_types.go new file mode 100644 index 0000000..78d62ec --- /dev/null +++ b/api/inference/v1alpha1/config_types.go @@ -0,0 +1,75 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import corev1 "k8s.io/api/core/v1" + +type BackendName string + +const ( + DefaultBackend BackendName = "vllm" + VLLM BackendName = "vllm" +) + +type BackendConfig struct { + // Name represents the inference backend under the hood, e.g. vLLM. + // +kubebuilder:validation:Enum={vllm} + // +kubebuilder:default=vllm + // +optional + Name *BackendName `json:"name,omitempty"` + // Version represents the backend version if you want a different one + // from the default version. + // +optional + Version *string `json:"version,omitempty"` + // Args represents the arguments passed to the backend. + // +optional + Args []string `json:"args,omitempty"` + // Envs represents the environments set to the container. + // +optional + Envs []corev1.EnvVar `json:"envs,omitempty"` + // Resources represents the resource requirements for backend, like cpu/mem, + // accelerators like GPU should not be defined here, but at the Model flavors, + // or the same accelerator requirements defined there will be covered and + // the workload will lose the fungibility capacity. + Resources *ResourceRequirements `json:"resources,omitempty"` +} + +// TODO: Do not support DRA yet, we can support that once needed. +type ResourceRequirements struct { + // Limits describes the maximum amount of compute resources allowed. + // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + // +optional + Limits corev1.ResourceList `json:"limits,omitempty"` + // Requests describes the minimum amount of compute resources required. + // If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + // otherwise to an implementation-defined value. Requests cannot exceed Limits. + // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + // +optional + Requests corev1.ResourceList `json:"requests,omitempty"` +} + +type ElasticConfig struct { + // MinReplicas indicates the minimum number of inference workloads based on the traffic. + // Default to nil means we can scale down the instances to 1. + // +kubebuilder:default=1 + // +optional + MinReplicas *int32 `json:"minReplicas,omitempty"` + // MaxReplicas indicates the maximum number of inference workloads based on the traffic. + // Default to nil means there's no limit for the instance number. + // +optional + MaxReplicas *int32 `json:"maxReplicas,omitempty"` +} diff --git a/api/inference/v1alpha1/doc.go b/api/inference/v1alpha1/doc.go new file mode 100644 index 0000000..071f08f --- /dev/null +++ b/api/inference/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +kubebuilder:object:generate=true +// +groupName=inference.llmaz.io + +package v1alpha1 diff --git a/api/inference/v1alpha1/groupversion_info.go b/api/inference/v1alpha1/groupversion_info.go index 6de3201..9824bed 100644 --- a/api/inference/v1alpha1/groupversion_info.go +++ b/api/inference/v1alpha1/groupversion_info.go @@ -28,9 +28,18 @@ var ( // GroupVersion is group version used to register these objects GroupVersion = schema.GroupVersion{Group: "inference.llmaz.io", Version: "v1alpha1"} + // SchemeGroupVersion is alias to GroupVersion for client-go libraries. + // It is required by pkg/client/informers/externalversions/... + SchemeGroupVersion = GroupVersion + // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme ) + +// Resource is required by pkg/client/listers/... +func Resource(resource string) schema.GroupResource { + return GroupVersion.WithResource(resource).GroupResource() +} diff --git a/api/inference/v1alpha1/playground_types.go b/api/inference/v1alpha1/playground_types.go index 0288b54..8a96932 100644 --- a/api/inference/v1alpha1/playground_types.go +++ b/api/inference/v1alpha1/playground_types.go @@ -17,8 +17,9 @@ limitations under the License. package v1alpha1 import ( - api "inftyai.com/llmaz/api/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + api "inftyai.com/llmaz/api/core/v1alpha1" ) // PlaygroundSpec defines the desired state of Playground @@ -50,12 +51,21 @@ type PlaygroundSpec struct { ElasticConfig *ElasticConfig `json:"elasticConfig,omitempty"` } +const ( + // PlaygroundProgressing means the Playground is progressing now, such as waiting for the + // inference service creation, rolling update or scaling up and down. + PlaygroundProgressing = "Progressing" + // PlaygroundAvailable indicates the corresponding inference service is available now. + PlaygroundAvailable string = "Available" +) + // PlaygroundStatus defines the observed state of Playground type PlaygroundStatus struct { // Conditions represents the Inference condition. Conditions []metav1.Condition `json:"conditions,omitempty"` } +//+genclient //+kubebuilder:object:root=true //+kubebuilder:subresource:status diff --git a/api/inference/v1alpha1/service_types.go b/api/inference/v1alpha1/service_types.go index cf2d69e..f4c7e5a 100644 --- a/api/inference/v1alpha1/service_types.go +++ b/api/inference/v1alpha1/service_types.go @@ -20,7 +20,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" lws "sigs.k8s.io/lws/api/leaderworkerset/v1" - api "inftyai.com/llmaz/api/v1alpha1" + api "inftyai.com/llmaz/api/core/v1alpha1" ) // ServiceSpec defines the desired state of Service. @@ -45,14 +45,25 @@ type ServiceSpec struct { ElasticConfig *ElasticConfig `json:"elasticConfig,omitempty"` } +const ( + // ServiceAvailable means the inferenceService is available and all the + // workloads are running as expected. + ServiceAvailable = "Available" + // ServiceProgressing means the inferenceService is progressing now, such as + // in creation, rolling update or scaling up and down. + ServiceProgressing = "Progressing" +) + // ServiceStatus defines the observed state of Service type ServiceStatus struct { // Conditions represents the Inference condition. Conditions []metav1.Condition `json:"conditions,omitempty"` } +//+genclient //+kubebuilder:object:root=true //+kubebuilder:subresource:status +//+kubebuilder:resource:shortName={isvc} // Service is the Schema for the services API type Service struct { diff --git a/api/inference/v1alpha1/types.go b/api/inference/v1alpha1/types.go index b0fb738..b369ae6 100644 --- a/api/inference/v1alpha1/types.go +++ b/api/inference/v1alpha1/types.go @@ -14,56 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 - -import corev1 "k8s.io/api/core/v1" - -type BackendName string - -type BackendConfig struct { - // Name represents the inference backend under the hood, e.g. vLLM. - // +kubebuilder:validation:Enum={vllm} - // +kubebuilder:default=vllm - // +optional - Name *BackendName `json:"name,omitempty"` - // Version represents the backend version if you want a different one - // from the default version. - // +optional - Version *string `json:"version,omitempty"` - // Args represents the arguments passed to the backend. - // +optional - Args []string `json:"args,omitempty"` - // Envs represents the environments set to the container. - // +optional - Envs []corev1.EnvVar `json:"envs,omitempty"` - // Resources represents the resource requirements for backend, like cpu/mem, - // accelerators like GPU should not be defined here, but at the Model flavors, - // or the same accelerator requirements defined there will be covered and - // the workload will lose the fungibility capacity. - Resources *ResourceRequirements `json:"resources,omitempty"` -} +/* +This file is needed for kubernetes/code-generator/kube_codegen.sh script used in hack/update-codegen.sh. +*/ -// TODO: Do not support DRA yet, we can support that once needed. -type ResourceRequirements struct { - // Limits describes the maximum amount of compute resources allowed. - // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - // +optional - Limits corev1.ResourceList `json:"limits,omitempty"` - // Requests describes the minimum amount of compute resources required. - // If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, - // otherwise to an implementation-defined value. Requests cannot exceed Limits. - // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - // +optional - Requests corev1.ResourceList `json:"requests,omitempty"` -} +package v1alpha1 -type ElasticConfig struct { - // MinReplicas indicates the minimum number of inference workloads based on the traffic. - // Default to nil means we can scale down the instances to 0. - // +optional - MinReplicas *int32 `json:"minReplicas,omitempty"` - // MaxReplicas indicates the maximum number of inference workloads based on the traffic. - // Default to nil means there's no limit for the instance number. - // +optional - MaxReplicas *int32 `json:"maxReplicas,omitempty"` -} +//+genclient diff --git a/api/inference/v1alpha1/zz_generated.deepcopy.go b/api/inference/v1alpha1/zz_generated.deepcopy.go index b00c873..d8974c8 100644 --- a/api/inference/v1alpha1/zz_generated.deepcopy.go +++ b/api/inference/v1alpha1/zz_generated.deepcopy.go @@ -21,9 +21,9 @@ limitations under the License. package v1alpha1 import ( - apiv1alpha1 "inftyai.com/llmaz/api/v1alpha1" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -47,7 +47,7 @@ func (in *BackendConfig) DeepCopyInto(out *BackendConfig) { } if in.Envs != nil { in, out := &in.Envs, &out.Envs - *out = make([]corev1.EnvVar, len(*in)) + *out = make([]v1.EnvVar, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -163,12 +163,12 @@ func (in *PlaygroundSpec) DeepCopyInto(out *PlaygroundSpec) { } if in.ModelClaim != nil { in, out := &in.ModelClaim, &out.ModelClaim - *out = new(apiv1alpha1.ModelClaim) + *out = new(corev1alpha1.ModelClaim) (*in).DeepCopyInto(*out) } if in.MultiModelsClaims != nil { in, out := &in.MultiModelsClaims, &out.MultiModelsClaims - *out = make([]apiv1alpha1.MultiModelsClaim, len(*in)) + *out = make([]corev1alpha1.MultiModelsClaim, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -200,7 +200,7 @@ func (in *PlaygroundStatus) DeepCopyInto(out *PlaygroundStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -222,14 +222,14 @@ func (in *ResourceRequirements) DeepCopyInto(out *ResourceRequirements) { *out = *in if in.Limits != nil { in, out := &in.Limits, &out.Limits - *out = make(corev1.ResourceList, len(*in)) + *out = make(v1.ResourceList, len(*in)) for key, val := range *in { (*out)[key] = val.DeepCopy() } } if in.Requests != nil { in, out := &in.Requests, &out.Requests - *out = make(corev1.ResourceList, len(*in)) + *out = make(v1.ResourceList, len(*in)) for key, val := range *in { (*out)[key] = val.DeepCopy() } @@ -310,7 +310,7 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { *out = *in if in.MultiModelsClaims != nil { in, out := &in.MultiModelsClaims, &out.MultiModelsClaims - *out = make([]apiv1alpha1.MultiModelsClaim, len(*in)) + *out = make([]corev1alpha1.MultiModelsClaim, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -338,7 +338,7 @@ func (in *ServiceStatus) DeepCopyInto(out *ServiceStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } diff --git a/client-go/applyconfiguration/core/v1alpha1/datasource.go b/client-go/applyconfiguration/core/v1alpha1/datasource.go new file mode 100644 index 0000000..7b81afc --- /dev/null +++ b/client-go/applyconfiguration/core/v1alpha1/datasource.go @@ -0,0 +1,47 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// DataSourceApplyConfiguration represents an declarative configuration of the DataSource type for use +// with apply. +type DataSourceApplyConfiguration struct { + ModelID *string `json:"modelID,omitempty"` + ModelHub *string `json:"modelHub,omitempty"` +} + +// DataSourceApplyConfiguration constructs an declarative configuration of the DataSource type for use with +// apply. +func DataSource() *DataSourceApplyConfiguration { + return &DataSourceApplyConfiguration{} +} + +// WithModelID sets the ModelID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ModelID field is set to the value of the last call. +func (b *DataSourceApplyConfiguration) WithModelID(value string) *DataSourceApplyConfiguration { + b.ModelID = &value + return b +} + +// WithModelHub sets the ModelHub field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ModelHub field is set to the value of the last call. +func (b *DataSourceApplyConfiguration) WithModelHub(value string) *DataSourceApplyConfiguration { + b.ModelHub = &value + return b +} diff --git a/client-go/applyconfiguration/core/v1alpha1/flavor.go b/client-go/applyconfiguration/core/v1alpha1/flavor.go new file mode 100644 index 0000000..27d2451 --- /dev/null +++ b/client-go/applyconfiguration/core/v1alpha1/flavor.go @@ -0,0 +1,82 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + v1 "k8s.io/api/core/v1" +) + +// FlavorApplyConfiguration represents an declarative configuration of the Flavor type for use +// with apply. +type FlavorApplyConfiguration struct { + Name *v1alpha1.FlavorName `json:"name,omitempty"` + Requests *v1.ResourceList `json:"requests,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + Params map[string]string `json:"params,omitempty"` +} + +// FlavorApplyConfiguration constructs an declarative configuration of the Flavor type for use with +// apply. +func Flavor() *FlavorApplyConfiguration { + return &FlavorApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *FlavorApplyConfiguration) WithName(value v1alpha1.FlavorName) *FlavorApplyConfiguration { + b.Name = &value + return b +} + +// WithRequests sets the Requests field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Requests field is set to the value of the last call. +func (b *FlavorApplyConfiguration) WithRequests(value v1.ResourceList) *FlavorApplyConfiguration { + b.Requests = &value + return b +} + +// WithNodeSelector puts the entries into the NodeSelector field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the NodeSelector field, +// overwriting an existing map entries in NodeSelector field with the same key. +func (b *FlavorApplyConfiguration) WithNodeSelector(entries map[string]string) *FlavorApplyConfiguration { + if b.NodeSelector == nil && len(entries) > 0 { + b.NodeSelector = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.NodeSelector[k] = v + } + return b +} + +// WithParams puts the entries into the Params field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Params field, +// overwriting an existing map entries in Params field with the same key. +func (b *FlavorApplyConfiguration) WithParams(entries map[string]string) *FlavorApplyConfiguration { + if b.Params == nil && len(entries) > 0 { + b.Params = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Params[k] = v + } + return b +} diff --git a/client-go/applyconfiguration/core/v1alpha1/model.go b/client-go/applyconfiguration/core/v1alpha1/model.go new file mode 100644 index 0000000..4fcce23 --- /dev/null +++ b/client-go/applyconfiguration/core/v1alpha1/model.go @@ -0,0 +1,218 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// ModelApplyConfiguration represents an declarative configuration of the Model type for use +// with apply. +type ModelApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *ModelSpecApplyConfiguration `json:"spec,omitempty"` + Status *ModelStatusApplyConfiguration `json:"status,omitempty"` +} + +// Model constructs an declarative configuration of the Model type for use with +// apply. +func Model(name, namespace string) *ModelApplyConfiguration { + b := &ModelApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Model") + b.WithAPIVersion("llmaz.io/v1alpha1") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithKind(value string) *ModelApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithAPIVersion(value string) *ModelApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithName(value string) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithGenerateName(value string) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithNamespace(value string) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithUID(value types.UID) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithResourceVersion(value string) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithGeneration(value int64) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *ModelApplyConfiguration) WithLabels(entries map[string]string) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *ModelApplyConfiguration) WithAnnotations(entries map[string]string) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *ModelApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *ModelApplyConfiguration) WithFinalizers(values ...string) *ModelApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *ModelApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithSpec(value *ModelSpecApplyConfiguration) *ModelApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *ModelApplyConfiguration) WithStatus(value *ModelStatusApplyConfiguration) *ModelApplyConfiguration { + b.Status = value + return b +} diff --git a/client-go/applyconfiguration/core/v1alpha1/modelclaim.go b/client-go/applyconfiguration/core/v1alpha1/modelclaim.go new file mode 100644 index 0000000..969dedd --- /dev/null +++ b/client-go/applyconfiguration/core/v1alpha1/modelclaim.go @@ -0,0 +1,53 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" +) + +// ModelClaimApplyConfiguration represents an declarative configuration of the ModelClaim type for use +// with apply. +type ModelClaimApplyConfiguration struct { + ModelName *v1alpha1.ModelName `json:"modelName,omitempty"` + InferenceFlavors []v1alpha1.FlavorName `json:"inferenceFlavors,omitempty"` +} + +// ModelClaimApplyConfiguration constructs an declarative configuration of the ModelClaim type for use with +// apply. +func ModelClaim() *ModelClaimApplyConfiguration { + return &ModelClaimApplyConfiguration{} +} + +// WithModelName sets the ModelName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ModelName field is set to the value of the last call. +func (b *ModelClaimApplyConfiguration) WithModelName(value v1alpha1.ModelName) *ModelClaimApplyConfiguration { + b.ModelName = &value + return b +} + +// WithInferenceFlavors adds the given value to the InferenceFlavors field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the InferenceFlavors field. +func (b *ModelClaimApplyConfiguration) WithInferenceFlavors(values ...v1alpha1.FlavorName) *ModelClaimApplyConfiguration { + for i := range values { + b.InferenceFlavors = append(b.InferenceFlavors, values[i]) + } + return b +} diff --git a/client-go/applyconfiguration/core/v1alpha1/modelspec.go b/client-go/applyconfiguration/core/v1alpha1/modelspec.go new file mode 100644 index 0000000..dffc4d5 --- /dev/null +++ b/client-go/applyconfiguration/core/v1alpha1/modelspec.go @@ -0,0 +1,65 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" +) + +// ModelSpecApplyConfiguration represents an declarative configuration of the ModelSpec type for use +// with apply. +type ModelSpecApplyConfiguration struct { + FamilyName *v1alpha1.ModelName `json:"familyName,omitempty"` + DataSource *DataSourceApplyConfiguration `json:"dataSource,omitempty"` + InferenceFlavors []FlavorApplyConfiguration `json:"inferenceFlavors,omitempty"` +} + +// ModelSpecApplyConfiguration constructs an declarative configuration of the ModelSpec type for use with +// apply. +func ModelSpec() *ModelSpecApplyConfiguration { + return &ModelSpecApplyConfiguration{} +} + +// WithFamilyName sets the FamilyName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FamilyName field is set to the value of the last call. +func (b *ModelSpecApplyConfiguration) WithFamilyName(value v1alpha1.ModelName) *ModelSpecApplyConfiguration { + b.FamilyName = &value + return b +} + +// WithDataSource sets the DataSource field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DataSource field is set to the value of the last call. +func (b *ModelSpecApplyConfiguration) WithDataSource(value *DataSourceApplyConfiguration) *ModelSpecApplyConfiguration { + b.DataSource = value + return b +} + +// WithInferenceFlavors adds the given value to the InferenceFlavors field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the InferenceFlavors field. +func (b *ModelSpecApplyConfiguration) WithInferenceFlavors(values ...*FlavorApplyConfiguration) *ModelSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithInferenceFlavors") + } + b.InferenceFlavors = append(b.InferenceFlavors, *values[i]) + } + return b +} diff --git a/client-go/applyconfiguration/core/v1alpha1/modelstatus.go b/client-go/applyconfiguration/core/v1alpha1/modelstatus.go new file mode 100644 index 0000000..f0447dd --- /dev/null +++ b/client-go/applyconfiguration/core/v1alpha1/modelstatus.go @@ -0,0 +1,44 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ModelStatusApplyConfiguration represents an declarative configuration of the ModelStatus type for use +// with apply. +type ModelStatusApplyConfiguration struct { + Conditions []v1.Condition `json:"conditions,omitempty"` +} + +// ModelStatusApplyConfiguration constructs an declarative configuration of the ModelStatus type for use with +// apply. +func ModelStatus() *ModelStatusApplyConfiguration { + return &ModelStatusApplyConfiguration{} +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *ModelStatusApplyConfiguration) WithConditions(values ...v1.Condition) *ModelStatusApplyConfiguration { + for i := range values { + b.Conditions = append(b.Conditions, values[i]) + } + return b +} diff --git a/client-go/applyconfiguration/core/v1alpha1/multimodelsclaim.go b/client-go/applyconfiguration/core/v1alpha1/multimodelsclaim.go new file mode 100644 index 0000000..e7bb91c --- /dev/null +++ b/client-go/applyconfiguration/core/v1alpha1/multimodelsclaim.go @@ -0,0 +1,64 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" +) + +// MultiModelsClaimApplyConfiguration represents an declarative configuration of the MultiModelsClaim type for use +// with apply. +type MultiModelsClaimApplyConfiguration struct { + ModelNames []v1alpha1.ModelName `json:"modelNames,omitempty"` + InferenceFlavors []v1alpha1.FlavorName `json:"inferenceFlavors,omitempty"` + Rate *int32 `json:"rate,omitempty"` +} + +// MultiModelsClaimApplyConfiguration constructs an declarative configuration of the MultiModelsClaim type for use with +// apply. +func MultiModelsClaim() *MultiModelsClaimApplyConfiguration { + return &MultiModelsClaimApplyConfiguration{} +} + +// WithModelNames adds the given value to the ModelNames field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the ModelNames field. +func (b *MultiModelsClaimApplyConfiguration) WithModelNames(values ...v1alpha1.ModelName) *MultiModelsClaimApplyConfiguration { + for i := range values { + b.ModelNames = append(b.ModelNames, values[i]) + } + return b +} + +// WithInferenceFlavors adds the given value to the InferenceFlavors field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the InferenceFlavors field. +func (b *MultiModelsClaimApplyConfiguration) WithInferenceFlavors(values ...v1alpha1.FlavorName) *MultiModelsClaimApplyConfiguration { + for i := range values { + b.InferenceFlavors = append(b.InferenceFlavors, values[i]) + } + return b +} + +// WithRate sets the Rate field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Rate field is set to the value of the last call. +func (b *MultiModelsClaimApplyConfiguration) WithRate(value int32) *MultiModelsClaimApplyConfiguration { + b.Rate = &value + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/backendconfig.go b/client-go/applyconfiguration/inference/v1alpha1/backendconfig.go new file mode 100644 index 0000000..f2094ea --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/backendconfig.go @@ -0,0 +1,83 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + v1 "k8s.io/api/core/v1" +) + +// BackendConfigApplyConfiguration represents an declarative configuration of the BackendConfig type for use +// with apply. +type BackendConfigApplyConfiguration struct { + Name *v1alpha1.BackendName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` + Args []string `json:"args,omitempty"` + Envs []v1.EnvVar `json:"envs,omitempty"` + Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"` +} + +// BackendConfigApplyConfiguration constructs an declarative configuration of the BackendConfig type for use with +// apply. +func BackendConfig() *BackendConfigApplyConfiguration { + return &BackendConfigApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *BackendConfigApplyConfiguration) WithName(value v1alpha1.BackendName) *BackendConfigApplyConfiguration { + b.Name = &value + return b +} + +// WithVersion sets the Version field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Version field is set to the value of the last call. +func (b *BackendConfigApplyConfiguration) WithVersion(value string) *BackendConfigApplyConfiguration { + b.Version = &value + return b +} + +// WithArgs adds the given value to the Args field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Args field. +func (b *BackendConfigApplyConfiguration) WithArgs(values ...string) *BackendConfigApplyConfiguration { + for i := range values { + b.Args = append(b.Args, values[i]) + } + return b +} + +// WithEnvs adds the given value to the Envs field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Envs field. +func (b *BackendConfigApplyConfiguration) WithEnvs(values ...v1.EnvVar) *BackendConfigApplyConfiguration { + for i := range values { + b.Envs = append(b.Envs, values[i]) + } + return b +} + +// WithResources sets the Resources field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Resources field is set to the value of the last call. +func (b *BackendConfigApplyConfiguration) WithResources(value *ResourceRequirementsApplyConfiguration) *BackendConfigApplyConfiguration { + b.Resources = value + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/elasticconfig.go b/client-go/applyconfiguration/inference/v1alpha1/elasticconfig.go new file mode 100644 index 0000000..7bb527f --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/elasticconfig.go @@ -0,0 +1,47 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ElasticConfigApplyConfiguration represents an declarative configuration of the ElasticConfig type for use +// with apply. +type ElasticConfigApplyConfiguration struct { + MinReplicas *int32 `json:"minReplicas,omitempty"` + MaxReplicas *int32 `json:"maxReplicas,omitempty"` +} + +// ElasticConfigApplyConfiguration constructs an declarative configuration of the ElasticConfig type for use with +// apply. +func ElasticConfig() *ElasticConfigApplyConfiguration { + return &ElasticConfigApplyConfiguration{} +} + +// WithMinReplicas sets the MinReplicas field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MinReplicas field is set to the value of the last call. +func (b *ElasticConfigApplyConfiguration) WithMinReplicas(value int32) *ElasticConfigApplyConfiguration { + b.MinReplicas = &value + return b +} + +// WithMaxReplicas sets the MaxReplicas field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MaxReplicas field is set to the value of the last call. +func (b *ElasticConfigApplyConfiguration) WithMaxReplicas(value int32) *ElasticConfigApplyConfiguration { + b.MaxReplicas = &value + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/playground.go b/client-go/applyconfiguration/inference/v1alpha1/playground.go new file mode 100644 index 0000000..631c518 --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/playground.go @@ -0,0 +1,218 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// PlaygroundApplyConfiguration represents an declarative configuration of the Playground type for use +// with apply. +type PlaygroundApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *PlaygroundSpecApplyConfiguration `json:"spec,omitempty"` + Status *PlaygroundStatusApplyConfiguration `json:"status,omitempty"` +} + +// Playground constructs an declarative configuration of the Playground type for use with +// apply. +func Playground(name, namespace string) *PlaygroundApplyConfiguration { + b := &PlaygroundApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Playground") + b.WithAPIVersion("inference.llmaz.io/v1alpha1") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithKind(value string) *PlaygroundApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithAPIVersion(value string) *PlaygroundApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithName(value string) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithGenerateName(value string) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithNamespace(value string) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithUID(value types.UID) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithResourceVersion(value string) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithGeneration(value int64) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithCreationTimestamp(value metav1.Time) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *PlaygroundApplyConfiguration) WithLabels(entries map[string]string) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *PlaygroundApplyConfiguration) WithAnnotations(entries map[string]string) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *PlaygroundApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *PlaygroundApplyConfiguration) WithFinalizers(values ...string) *PlaygroundApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *PlaygroundApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithSpec(value *PlaygroundSpecApplyConfiguration) *PlaygroundApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *PlaygroundApplyConfiguration) WithStatus(value *PlaygroundStatusApplyConfiguration) *PlaygroundApplyConfiguration { + b.Status = value + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/playgroundspec.go b/client-go/applyconfiguration/inference/v1alpha1/playgroundspec.go new file mode 100644 index 0000000..f189fd5 --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/playgroundspec.go @@ -0,0 +1,83 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" +) + +// PlaygroundSpecApplyConfiguration represents an declarative configuration of the PlaygroundSpec type for use +// with apply. +type PlaygroundSpecApplyConfiguration struct { + Replicas *int32 `json:"replicas,omitempty"` + ModelClaim *v1alpha1.ModelClaimApplyConfiguration `json:"modelClaim,omitempty"` + MultiModelsClaims []v1alpha1.MultiModelsClaimApplyConfiguration `json:"multiModelsClaims,omitempty"` + BackendConfig *BackendConfigApplyConfiguration `json:"backendConfig,omitempty"` + ElasticConfig *ElasticConfigApplyConfiguration `json:"elasticConfig,omitempty"` +} + +// PlaygroundSpecApplyConfiguration constructs an declarative configuration of the PlaygroundSpec type for use with +// apply. +func PlaygroundSpec() *PlaygroundSpecApplyConfiguration { + return &PlaygroundSpecApplyConfiguration{} +} + +// WithReplicas sets the Replicas field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Replicas field is set to the value of the last call. +func (b *PlaygroundSpecApplyConfiguration) WithReplicas(value int32) *PlaygroundSpecApplyConfiguration { + b.Replicas = &value + return b +} + +// WithModelClaim sets the ModelClaim field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ModelClaim field is set to the value of the last call. +func (b *PlaygroundSpecApplyConfiguration) WithModelClaim(value *v1alpha1.ModelClaimApplyConfiguration) *PlaygroundSpecApplyConfiguration { + b.ModelClaim = value + return b +} + +// WithMultiModelsClaims adds the given value to the MultiModelsClaims field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the MultiModelsClaims field. +func (b *PlaygroundSpecApplyConfiguration) WithMultiModelsClaims(values ...*v1alpha1.MultiModelsClaimApplyConfiguration) *PlaygroundSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMultiModelsClaims") + } + b.MultiModelsClaims = append(b.MultiModelsClaims, *values[i]) + } + return b +} + +// WithBackendConfig sets the BackendConfig field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the BackendConfig field is set to the value of the last call. +func (b *PlaygroundSpecApplyConfiguration) WithBackendConfig(value *BackendConfigApplyConfiguration) *PlaygroundSpecApplyConfiguration { + b.BackendConfig = value + return b +} + +// WithElasticConfig sets the ElasticConfig field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ElasticConfig field is set to the value of the last call. +func (b *PlaygroundSpecApplyConfiguration) WithElasticConfig(value *ElasticConfigApplyConfiguration) *PlaygroundSpecApplyConfiguration { + b.ElasticConfig = value + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/playgroundstatus.go b/client-go/applyconfiguration/inference/v1alpha1/playgroundstatus.go new file mode 100644 index 0000000..e0b093e --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/playgroundstatus.go @@ -0,0 +1,44 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// PlaygroundStatusApplyConfiguration represents an declarative configuration of the PlaygroundStatus type for use +// with apply. +type PlaygroundStatusApplyConfiguration struct { + Conditions []v1.Condition `json:"conditions,omitempty"` +} + +// PlaygroundStatusApplyConfiguration constructs an declarative configuration of the PlaygroundStatus type for use with +// apply. +func PlaygroundStatus() *PlaygroundStatusApplyConfiguration { + return &PlaygroundStatusApplyConfiguration{} +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *PlaygroundStatusApplyConfiguration) WithConditions(values ...v1.Condition) *PlaygroundStatusApplyConfiguration { + for i := range values { + b.Conditions = append(b.Conditions, values[i]) + } + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/resourcerequirements.go b/client-go/applyconfiguration/inference/v1alpha1/resourcerequirements.go new file mode 100644 index 0000000..e1819c5 --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/resourcerequirements.go @@ -0,0 +1,51 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" +) + +// ResourceRequirementsApplyConfiguration represents an declarative configuration of the ResourceRequirements type for use +// with apply. +type ResourceRequirementsApplyConfiguration struct { + Limits *v1.ResourceList `json:"limits,omitempty"` + Requests *v1.ResourceList `json:"requests,omitempty"` +} + +// ResourceRequirementsApplyConfiguration constructs an declarative configuration of the ResourceRequirements type for use with +// apply. +func ResourceRequirements() *ResourceRequirementsApplyConfiguration { + return &ResourceRequirementsApplyConfiguration{} +} + +// WithLimits sets the Limits field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Limits field is set to the value of the last call. +func (b *ResourceRequirementsApplyConfiguration) WithLimits(value v1.ResourceList) *ResourceRequirementsApplyConfiguration { + b.Limits = &value + return b +} + +// WithRequests sets the Requests field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Requests field is set to the value of the last call. +func (b *ResourceRequirementsApplyConfiguration) WithRequests(value v1.ResourceList) *ResourceRequirementsApplyConfiguration { + b.Requests = &value + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/service.go b/client-go/applyconfiguration/inference/v1alpha1/service.go new file mode 100644 index 0000000..b2f92e2 --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/service.go @@ -0,0 +1,218 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// ServiceApplyConfiguration represents an declarative configuration of the Service type for use +// with apply. +type ServiceApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *ServiceSpecApplyConfiguration `json:"spec,omitempty"` + Status *ServiceStatusApplyConfiguration `json:"status,omitempty"` +} + +// Service constructs an declarative configuration of the Service type for use with +// apply. +func Service(name, namespace string) *ServiceApplyConfiguration { + b := &ServiceApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Service") + b.WithAPIVersion("inference.llmaz.io/v1alpha1") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithKind(value string) *ServiceApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithAPIVersion(value string) *ServiceApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithName(value string) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithGenerateName(value string) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithNamespace(value string) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithUID(value types.UID) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithResourceVersion(value string) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithGeneration(value int64) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *ServiceApplyConfiguration) WithLabels(entries map[string]string) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *ServiceApplyConfiguration) WithAnnotations(entries map[string]string) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *ServiceApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *ServiceApplyConfiguration) WithFinalizers(values ...string) *ServiceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *ServiceApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithSpec(value *ServiceSpecApplyConfiguration) *ServiceApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *ServiceApplyConfiguration) WithStatus(value *ServiceStatusApplyConfiguration) *ServiceApplyConfiguration { + b.Status = value + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/servicespec.go b/client-go/applyconfiguration/inference/v1alpha1/servicespec.go new file mode 100644 index 0000000..b08dd32 --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/servicespec.go @@ -0,0 +1,66 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" + v1 "sigs.k8s.io/lws/api/leaderworkerset/v1" +) + +// ServiceSpecApplyConfiguration represents an declarative configuration of the ServiceSpec type for use +// with apply. +type ServiceSpecApplyConfiguration struct { + MultiModelsClaims []v1alpha1.MultiModelsClaimApplyConfiguration `json:"multiModelsClaims,omitempty"` + WorkloadTemplate *v1.LeaderWorkerSetSpec `json:"workloadTemplate,omitempty"` + ElasticConfig *ElasticConfigApplyConfiguration `json:"elasticConfig,omitempty"` +} + +// ServiceSpecApplyConfiguration constructs an declarative configuration of the ServiceSpec type for use with +// apply. +func ServiceSpec() *ServiceSpecApplyConfiguration { + return &ServiceSpecApplyConfiguration{} +} + +// WithMultiModelsClaims adds the given value to the MultiModelsClaims field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the MultiModelsClaims field. +func (b *ServiceSpecApplyConfiguration) WithMultiModelsClaims(values ...*v1alpha1.MultiModelsClaimApplyConfiguration) *ServiceSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMultiModelsClaims") + } + b.MultiModelsClaims = append(b.MultiModelsClaims, *values[i]) + } + return b +} + +// WithWorkloadTemplate sets the WorkloadTemplate field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the WorkloadTemplate field is set to the value of the last call. +func (b *ServiceSpecApplyConfiguration) WithWorkloadTemplate(value v1.LeaderWorkerSetSpec) *ServiceSpecApplyConfiguration { + b.WorkloadTemplate = &value + return b +} + +// WithElasticConfig sets the ElasticConfig field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ElasticConfig field is set to the value of the last call. +func (b *ServiceSpecApplyConfiguration) WithElasticConfig(value *ElasticConfigApplyConfiguration) *ServiceSpecApplyConfiguration { + b.ElasticConfig = value + return b +} diff --git a/client-go/applyconfiguration/inference/v1alpha1/servicestatus.go b/client-go/applyconfiguration/inference/v1alpha1/servicestatus.go new file mode 100644 index 0000000..8b67d75 --- /dev/null +++ b/client-go/applyconfiguration/inference/v1alpha1/servicestatus.go @@ -0,0 +1,44 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ServiceStatusApplyConfiguration represents an declarative configuration of the ServiceStatus type for use +// with apply. +type ServiceStatusApplyConfiguration struct { + Conditions []v1.Condition `json:"conditions,omitempty"` +} + +// ServiceStatusApplyConfiguration constructs an declarative configuration of the ServiceStatus type for use with +// apply. +func ServiceStatus() *ServiceStatusApplyConfiguration { + return &ServiceStatusApplyConfiguration{} +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *ServiceStatusApplyConfiguration) WithConditions(values ...v1.Condition) *ServiceStatusApplyConfiguration { + for i := range values { + b.Conditions = append(b.Conditions, values[i]) + } + return b +} diff --git a/client-go/applyconfiguration/internal/internal.go b/client-go/applyconfiguration/internal/internal.go new file mode 100644 index 0000000..69b6634 --- /dev/null +++ b/client-go/applyconfiguration/internal/internal.go @@ -0,0 +1,61 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/client-go/applyconfiguration/utils.go b/client-go/applyconfiguration/utils.go new file mode 100644 index 0000000..e3f4078 --- /dev/null +++ b/client-go/applyconfiguration/utils.go @@ -0,0 +1,70 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package applyconfiguration + +import ( + corev1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + applyconfigurationcorev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" + inferencev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/inference/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=inference.llmaz.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("BackendConfig"): + return &inferencev1alpha1.BackendConfigApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ElasticConfig"): + return &inferencev1alpha1.ElasticConfigApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Playground"): + return &inferencev1alpha1.PlaygroundApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("PlaygroundSpec"): + return &inferencev1alpha1.PlaygroundSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("PlaygroundStatus"): + return &inferencev1alpha1.PlaygroundStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ResourceRequirements"): + return &inferencev1alpha1.ResourceRequirementsApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Service"): + return &inferencev1alpha1.ServiceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ServiceSpec"): + return &inferencev1alpha1.ServiceSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ServiceStatus"): + return &inferencev1alpha1.ServiceStatusApplyConfiguration{} + + // Group=llmaz.io, Version=v1alpha1 + case corev1alpha1.SchemeGroupVersion.WithKind("DataSource"): + return &applyconfigurationcorev1alpha1.DataSourceApplyConfiguration{} + case corev1alpha1.SchemeGroupVersion.WithKind("Flavor"): + return &applyconfigurationcorev1alpha1.FlavorApplyConfiguration{} + case corev1alpha1.SchemeGroupVersion.WithKind("Model"): + return &applyconfigurationcorev1alpha1.ModelApplyConfiguration{} + case corev1alpha1.SchemeGroupVersion.WithKind("ModelClaim"): + return &applyconfigurationcorev1alpha1.ModelClaimApplyConfiguration{} + case corev1alpha1.SchemeGroupVersion.WithKind("ModelSpec"): + return &applyconfigurationcorev1alpha1.ModelSpecApplyConfiguration{} + case corev1alpha1.SchemeGroupVersion.WithKind("ModelStatus"): + return &applyconfigurationcorev1alpha1.ModelStatusApplyConfiguration{} + case corev1alpha1.SchemeGroupVersion.WithKind("MultiModelsClaim"): + return &applyconfigurationcorev1alpha1.MultiModelsClaimApplyConfiguration{} + + } + return nil +} diff --git a/client-go/clientset/versioned/clientset.go b/client-go/clientset/versioned/clientset.go new file mode 100644 index 0000000..fc29507 --- /dev/null +++ b/client-go/clientset/versioned/clientset.go @@ -0,0 +1,132 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package versioned + +import ( + "fmt" + "net/http" + + llmazv1alpha1 "inftyai.com/llmaz/client-go/clientset/versioned/typed/core/v1alpha1" + inferencev1alpha1 "inftyai.com/llmaz/client-go/clientset/versioned/typed/inference/v1alpha1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + LlmazV1alpha1() llmazv1alpha1.LlmazV1alpha1Interface + InferenceV1alpha1() inferencev1alpha1.InferenceV1alpha1Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + llmazV1alpha1 *llmazv1alpha1.LlmazV1alpha1Client + inferenceV1alpha1 *inferencev1alpha1.InferenceV1alpha1Client +} + +// LlmazV1alpha1 retrieves the LlmazV1alpha1Client +func (c *Clientset) LlmazV1alpha1() llmazv1alpha1.LlmazV1alpha1Interface { + return c.llmazV1alpha1 +} + +// InferenceV1alpha1 retrieves the InferenceV1alpha1Client +func (c *Clientset) InferenceV1alpha1() inferencev1alpha1.InferenceV1alpha1Interface { + return c.inferenceV1alpha1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + + var cs Clientset + var err error + cs.llmazV1alpha1, err = llmazv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + cs.inferenceV1alpha1, err = inferencev1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.llmazV1alpha1 = llmazv1alpha1.New(c) + cs.inferenceV1alpha1 = inferencev1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/client-go/clientset/versioned/fake/clientset_generated.go b/client-go/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000..a3a77b5 --- /dev/null +++ b/client-go/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,91 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + clientset "inftyai.com/llmaz/client-go/clientset/versioned" + llmazv1alpha1 "inftyai.com/llmaz/client-go/clientset/versioned/typed/core/v1alpha1" + fakellmazv1alpha1 "inftyai.com/llmaz/client-go/clientset/versioned/typed/core/v1alpha1/fake" + inferencev1alpha1 "inftyai.com/llmaz/client-go/clientset/versioned/typed/inference/v1alpha1" + fakeinferencev1alpha1 "inftyai.com/llmaz/client-go/clientset/versioned/typed/inference/v1alpha1/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) + +// LlmazV1alpha1 retrieves the LlmazV1alpha1Client +func (c *Clientset) LlmazV1alpha1() llmazv1alpha1.LlmazV1alpha1Interface { + return &fakellmazv1alpha1.FakeLlmazV1alpha1{Fake: &c.Fake} +} + +// InferenceV1alpha1 retrieves the InferenceV1alpha1Client +func (c *Clientset) InferenceV1alpha1() inferencev1alpha1.InferenceV1alpha1Interface { + return &fakeinferencev1alpha1.FakeInferenceV1alpha1{Fake: &c.Fake} +} diff --git a/client-go/clientset/versioned/fake/doc.go b/client-go/clientset/versioned/fake/doc.go new file mode 100644 index 0000000..57c8c1b --- /dev/null +++ b/client-go/clientset/versioned/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/client-go/clientset/versioned/fake/register.go b/client-go/clientset/versioned/fake/register.go new file mode 100644 index 0000000..3ac598a --- /dev/null +++ b/client-go/clientset/versioned/fake/register.go @@ -0,0 +1,57 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + llmazv1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + inferencev1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + llmazv1alpha1.AddToScheme, + inferencev1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/client-go/clientset/versioned/scheme/doc.go b/client-go/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000..b00a2a6 --- /dev/null +++ b/client-go/clientset/versioned/scheme/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/client-go/clientset/versioned/scheme/register.go b/client-go/clientset/versioned/scheme/register.go new file mode 100644 index 0000000..cd1f9dc --- /dev/null +++ b/client-go/clientset/versioned/scheme/register.go @@ -0,0 +1,57 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + llmazv1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + inferencev1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + llmazv1alpha1.AddToScheme, + inferencev1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/core_client.go b/client-go/clientset/versioned/typed/core/v1alpha1/core_client.go new file mode 100644 index 0000000..e21101d --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/core_client.go @@ -0,0 +1,106 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + "inftyai.com/llmaz/client-go/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type LlmazV1alpha1Interface interface { + RESTClient() rest.Interface + ModelsGetter +} + +// LlmazV1alpha1Client is used to interact with features provided by the llmaz.io group. +type LlmazV1alpha1Client struct { + restClient rest.Interface +} + +func (c *LlmazV1alpha1Client) Models(namespace string) ModelInterface { + return newModels(c, namespace) +} + +// NewForConfig creates a new LlmazV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*LlmazV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new LlmazV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*LlmazV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &LlmazV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new LlmazV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *LlmazV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new LlmazV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *LlmazV1alpha1Client { + return &LlmazV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *LlmazV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/doc.go b/client-go/clientset/versioned/typed/core/v1alpha1/doc.go new file mode 100644 index 0000000..c0c36e9 --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/fake/doc.go b/client-go/clientset/versioned/typed/core/v1alpha1/fake/doc.go new file mode 100644 index 0000000..3514f7d --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go new file mode 100644 index 0000000..5f1fa65 --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go @@ -0,0 +1,39 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "inftyai.com/llmaz/client-go/clientset/versioned/typed/core/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeLlmazV1alpha1 struct { + *testing.Fake +} + +func (c *FakeLlmazV1alpha1) Models(namespace string) v1alpha1.ModelInterface { + return &FakeModels{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeLlmazV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_model.go b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_model.go new file mode 100644 index 0000000..b243d0b --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/fake/fake_model.go @@ -0,0 +1,188 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + corev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeModels implements ModelInterface +type FakeModels struct { + Fake *FakeLlmazV1alpha1 + ns string +} + +var modelsResource = v1alpha1.SchemeGroupVersion.WithResource("models") + +var modelsKind = v1alpha1.SchemeGroupVersion.WithKind("Model") + +// Get takes name of the model, and returns the corresponding model object, and an error if there is any. +func (c *FakeModels) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Model, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(modelsResource, c.ns, name), &v1alpha1.Model{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Model), err +} + +// List takes label and field selectors, and returns the list of Models that match those selectors. +func (c *FakeModels) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ModelList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(modelsResource, modelsKind, c.ns, opts), &v1alpha1.ModelList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ModelList{ListMeta: obj.(*v1alpha1.ModelList).ListMeta} + for _, item := range obj.(*v1alpha1.ModelList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested models. +func (c *FakeModels) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(modelsResource, c.ns, opts)) + +} + +// Create takes the representation of a model and creates it. Returns the server's representation of the model, and an error, if there is any. +func (c *FakeModels) Create(ctx context.Context, model *v1alpha1.Model, opts v1.CreateOptions) (result *v1alpha1.Model, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(modelsResource, c.ns, model), &v1alpha1.Model{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Model), err +} + +// Update takes the representation of a model and updates it. Returns the server's representation of the model, and an error, if there is any. +func (c *FakeModels) Update(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (result *v1alpha1.Model, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(modelsResource, c.ns, model), &v1alpha1.Model{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Model), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeModels) UpdateStatus(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (*v1alpha1.Model, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(modelsResource, "status", c.ns, model), &v1alpha1.Model{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Model), err +} + +// Delete takes name of the model and deletes it. Returns an error if one occurs. +func (c *FakeModels) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(modelsResource, c.ns, name, opts), &v1alpha1.Model{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeModels) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(modelsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ModelList{}) + return err +} + +// Patch applies the patch and returns the patched model. +func (c *FakeModels) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Model, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(modelsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Model{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Model), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied model. +func (c *FakeModels) Apply(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) { + if model == nil { + return nil, fmt.Errorf("model provided to Apply must not be nil") + } + data, err := json.Marshal(model) + if err != nil { + return nil, err + } + name := model.Name + if name == nil { + return nil, fmt.Errorf("model.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(modelsResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.Model{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Model), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeModels) ApplyStatus(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) { + if model == nil { + return nil, fmt.Errorf("model provided to Apply must not be nil") + } + data, err := json.Marshal(model) + if err != nil { + return nil, err + } + name := model.Name + if name == nil { + return nil, fmt.Errorf("model.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(modelsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.Model{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Model), err +} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/generated_expansion.go b/client-go/clientset/versioned/typed/core/v1alpha1/generated_expansion.go new file mode 100644 index 0000000..0d589e9 --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/generated_expansion.go @@ -0,0 +1,20 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type ModelExpansion interface{} diff --git a/client-go/clientset/versioned/typed/core/v1alpha1/model.go b/client-go/clientset/versioned/typed/core/v1alpha1/model.go new file mode 100644 index 0000000..4344174 --- /dev/null +++ b/client-go/clientset/versioned/typed/core/v1alpha1/model.go @@ -0,0 +1,255 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + corev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" + scheme "inftyai.com/llmaz/client-go/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ModelsGetter has a method to return a ModelInterface. +// A group's client should implement this interface. +type ModelsGetter interface { + Models(namespace string) ModelInterface +} + +// ModelInterface has methods to work with Model resources. +type ModelInterface interface { + Create(ctx context.Context, model *v1alpha1.Model, opts v1.CreateOptions) (*v1alpha1.Model, error) + Update(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (*v1alpha1.Model, error) + UpdateStatus(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (*v1alpha1.Model, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Model, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ModelList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Model, err error) + Apply(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) + ApplyStatus(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) + ModelExpansion +} + +// models implements ModelInterface +type models struct { + client rest.Interface + ns string +} + +// newModels returns a Models +func newModels(c *LlmazV1alpha1Client, namespace string) *models { + return &models{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the model, and returns the corresponding model object, and an error if there is any. +func (c *models) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Model, err error) { + result = &v1alpha1.Model{} + err = c.client.Get(). + Namespace(c.ns). + Resource("models"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Models that match those selectors. +func (c *models) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ModelList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ModelList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("models"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested models. +func (c *models) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("models"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a model and creates it. Returns the server's representation of the model, and an error, if there is any. +func (c *models) Create(ctx context.Context, model *v1alpha1.Model, opts v1.CreateOptions) (result *v1alpha1.Model, err error) { + result = &v1alpha1.Model{} + err = c.client.Post(). + Namespace(c.ns). + Resource("models"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(model). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a model and updates it. Returns the server's representation of the model, and an error, if there is any. +func (c *models) Update(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (result *v1alpha1.Model, err error) { + result = &v1alpha1.Model{} + err = c.client.Put(). + Namespace(c.ns). + Resource("models"). + Name(model.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(model). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *models) UpdateStatus(ctx context.Context, model *v1alpha1.Model, opts v1.UpdateOptions) (result *v1alpha1.Model, err error) { + result = &v1alpha1.Model{} + err = c.client.Put(). + Namespace(c.ns). + Resource("models"). + Name(model.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(model). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the model and deletes it. Returns an error if one occurs. +func (c *models) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("models"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *models) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("models"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched model. +func (c *models) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Model, err error) { + result = &v1alpha1.Model{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("models"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied model. +func (c *models) Apply(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) { + if model == nil { + return nil, fmt.Errorf("model provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(model) + if err != nil { + return nil, err + } + name := model.Name + if name == nil { + return nil, fmt.Errorf("model.Name must be provided to Apply") + } + result = &v1alpha1.Model{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("models"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *models) ApplyStatus(ctx context.Context, model *corev1alpha1.ModelApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Model, err error) { + if model == nil { + return nil, fmt.Errorf("model provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(model) + if err != nil { + return nil, err + } + + name := model.Name + if name == nil { + return nil, fmt.Errorf("model.Name must be provided to Apply") + } + + result = &v1alpha1.Model{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("models"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/doc.go b/client-go/clientset/versioned/typed/inference/v1alpha1/doc.go new file mode 100644 index 0000000..c0c36e9 --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/fake/doc.go b/client-go/clientset/versioned/typed/inference/v1alpha1/fake/doc.go new file mode 100644 index 0000000..3514f7d --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/fake/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_inference_client.go b/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_inference_client.go new file mode 100644 index 0000000..2477ee9 --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_inference_client.go @@ -0,0 +1,43 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "inftyai.com/llmaz/client-go/clientset/versioned/typed/inference/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeInferenceV1alpha1 struct { + *testing.Fake +} + +func (c *FakeInferenceV1alpha1) Playgrounds(namespace string) v1alpha1.PlaygroundInterface { + return &FakePlaygrounds{c, namespace} +} + +func (c *FakeInferenceV1alpha1) Services(namespace string) v1alpha1.ServiceInterface { + return &FakeServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeInferenceV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_playground.go b/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_playground.go new file mode 100644 index 0000000..c6598de --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_playground.go @@ -0,0 +1,188 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + inferencev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/inference/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakePlaygrounds implements PlaygroundInterface +type FakePlaygrounds struct { + Fake *FakeInferenceV1alpha1 + ns string +} + +var playgroundsResource = v1alpha1.SchemeGroupVersion.WithResource("playgrounds") + +var playgroundsKind = v1alpha1.SchemeGroupVersion.WithKind("Playground") + +// Get takes name of the playground, and returns the corresponding playground object, and an error if there is any. +func (c *FakePlaygrounds) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Playground, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(playgroundsResource, c.ns, name), &v1alpha1.Playground{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Playground), err +} + +// List takes label and field selectors, and returns the list of Playgrounds that match those selectors. +func (c *FakePlaygrounds) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PlaygroundList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(playgroundsResource, playgroundsKind, c.ns, opts), &v1alpha1.PlaygroundList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PlaygroundList{ListMeta: obj.(*v1alpha1.PlaygroundList).ListMeta} + for _, item := range obj.(*v1alpha1.PlaygroundList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested playgrounds. +func (c *FakePlaygrounds) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(playgroundsResource, c.ns, opts)) + +} + +// Create takes the representation of a playground and creates it. Returns the server's representation of the playground, and an error, if there is any. +func (c *FakePlaygrounds) Create(ctx context.Context, playground *v1alpha1.Playground, opts v1.CreateOptions) (result *v1alpha1.Playground, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(playgroundsResource, c.ns, playground), &v1alpha1.Playground{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Playground), err +} + +// Update takes the representation of a playground and updates it. Returns the server's representation of the playground, and an error, if there is any. +func (c *FakePlaygrounds) Update(ctx context.Context, playground *v1alpha1.Playground, opts v1.UpdateOptions) (result *v1alpha1.Playground, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(playgroundsResource, c.ns, playground), &v1alpha1.Playground{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Playground), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakePlaygrounds) UpdateStatus(ctx context.Context, playground *v1alpha1.Playground, opts v1.UpdateOptions) (*v1alpha1.Playground, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(playgroundsResource, "status", c.ns, playground), &v1alpha1.Playground{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Playground), err +} + +// Delete takes name of the playground and deletes it. Returns an error if one occurs. +func (c *FakePlaygrounds) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(playgroundsResource, c.ns, name, opts), &v1alpha1.Playground{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePlaygrounds) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(playgroundsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.PlaygroundList{}) + return err +} + +// Patch applies the patch and returns the patched playground. +func (c *FakePlaygrounds) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Playground, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(playgroundsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Playground{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Playground), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied playground. +func (c *FakePlaygrounds) Apply(ctx context.Context, playground *inferencev1alpha1.PlaygroundApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Playground, err error) { + if playground == nil { + return nil, fmt.Errorf("playground provided to Apply must not be nil") + } + data, err := json.Marshal(playground) + if err != nil { + return nil, err + } + name := playground.Name + if name == nil { + return nil, fmt.Errorf("playground.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(playgroundsResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.Playground{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Playground), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakePlaygrounds) ApplyStatus(ctx context.Context, playground *inferencev1alpha1.PlaygroundApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Playground, err error) { + if playground == nil { + return nil, fmt.Errorf("playground provided to Apply must not be nil") + } + data, err := json.Marshal(playground) + if err != nil { + return nil, err + } + name := playground.Name + if name == nil { + return nil, fmt.Errorf("playground.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(playgroundsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.Playground{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Playground), err +} diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_service.go b/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_service.go new file mode 100644 index 0000000..98e2a77 --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/fake/fake_service.go @@ -0,0 +1,188 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + inferencev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/inference/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeServices implements ServiceInterface +type FakeServices struct { + Fake *FakeInferenceV1alpha1 + ns string +} + +var servicesResource = v1alpha1.SchemeGroupVersion.WithResource("services") + +var servicesKind = v1alpha1.SchemeGroupVersion.WithKind("Service") + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *FakeServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(servicesResource, c.ns, name), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *FakeServices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(servicesResource, servicesKind, c.ns, opts), &v1alpha1.ServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ServiceList{ListMeta: obj.(*v1alpha1.ServiceList).ListMeta} + for _, item := range obj.(*v1alpha1.ServiceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested services. +func (c *FakeServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(servicesResource, c.ns, opts)) + +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *FakeServices) Create(ctx context.Context, service *v1alpha1.Service, opts v1.CreateOptions) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(servicesResource, c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *FakeServices) Update(ctx context.Context, service *v1alpha1.Service, opts v1.UpdateOptions) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(servicesResource, c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeServices) UpdateStatus(ctx context.Context, service *v1alpha1.Service, opts v1.UpdateOptions) (*v1alpha1.Service, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(servicesResource, "status", c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *FakeServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(servicesResource, c.ns, name, opts), &v1alpha1.Service{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(servicesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ServiceList{}) + return err +} + +// Patch applies the patch and returns the patched service. +func (c *FakeServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied service. +func (c *FakeServices) Apply(ctx context.Context, service *inferencev1alpha1.ServiceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Service, err error) { + if service == nil { + return nil, fmt.Errorf("service provided to Apply must not be nil") + } + data, err := json.Marshal(service) + if err != nil { + return nil, err + } + name := service.Name + if name == nil { + return nil, fmt.Errorf("service.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeServices) ApplyStatus(ctx context.Context, service *inferencev1alpha1.ServiceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Service, err error) { + if service == nil { + return nil, fmt.Errorf("service provided to Apply must not be nil") + } + data, err := json.Marshal(service) + if err != nil { + return nil, err + } + name := service.Name + if name == nil { + return nil, fmt.Errorf("service.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/generated_expansion.go b/client-go/clientset/versioned/typed/inference/v1alpha1/generated_expansion.go new file mode 100644 index 0000000..4583bf1 --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/generated_expansion.go @@ -0,0 +1,22 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type PlaygroundExpansion interface{} + +type ServiceExpansion interface{} diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/inference_client.go b/client-go/clientset/versioned/typed/inference/v1alpha1/inference_client.go new file mode 100644 index 0000000..d8c40f1 --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/inference_client.go @@ -0,0 +1,111 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + "inftyai.com/llmaz/client-go/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type InferenceV1alpha1Interface interface { + RESTClient() rest.Interface + PlaygroundsGetter + ServicesGetter +} + +// InferenceV1alpha1Client is used to interact with features provided by the inference.llmaz.io group. +type InferenceV1alpha1Client struct { + restClient rest.Interface +} + +func (c *InferenceV1alpha1Client) Playgrounds(namespace string) PlaygroundInterface { + return newPlaygrounds(c, namespace) +} + +func (c *InferenceV1alpha1Client) Services(namespace string) ServiceInterface { + return newServices(c, namespace) +} + +// NewForConfig creates a new InferenceV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*InferenceV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new InferenceV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*InferenceV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &InferenceV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new InferenceV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *InferenceV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new InferenceV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *InferenceV1alpha1Client { + return &InferenceV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *InferenceV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/playground.go b/client-go/clientset/versioned/typed/inference/v1alpha1/playground.go new file mode 100644 index 0000000..7ef5490 --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/playground.go @@ -0,0 +1,255 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + inferencev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/inference/v1alpha1" + scheme "inftyai.com/llmaz/client-go/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// PlaygroundsGetter has a method to return a PlaygroundInterface. +// A group's client should implement this interface. +type PlaygroundsGetter interface { + Playgrounds(namespace string) PlaygroundInterface +} + +// PlaygroundInterface has methods to work with Playground resources. +type PlaygroundInterface interface { + Create(ctx context.Context, playground *v1alpha1.Playground, opts v1.CreateOptions) (*v1alpha1.Playground, error) + Update(ctx context.Context, playground *v1alpha1.Playground, opts v1.UpdateOptions) (*v1alpha1.Playground, error) + UpdateStatus(ctx context.Context, playground *v1alpha1.Playground, opts v1.UpdateOptions) (*v1alpha1.Playground, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Playground, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PlaygroundList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Playground, err error) + Apply(ctx context.Context, playground *inferencev1alpha1.PlaygroundApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Playground, err error) + ApplyStatus(ctx context.Context, playground *inferencev1alpha1.PlaygroundApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Playground, err error) + PlaygroundExpansion +} + +// playgrounds implements PlaygroundInterface +type playgrounds struct { + client rest.Interface + ns string +} + +// newPlaygrounds returns a Playgrounds +func newPlaygrounds(c *InferenceV1alpha1Client, namespace string) *playgrounds { + return &playgrounds{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the playground, and returns the corresponding playground object, and an error if there is any. +func (c *playgrounds) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Playground, err error) { + result = &v1alpha1.Playground{} + err = c.client.Get(). + Namespace(c.ns). + Resource("playgrounds"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Playgrounds that match those selectors. +func (c *playgrounds) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PlaygroundList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PlaygroundList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("playgrounds"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested playgrounds. +func (c *playgrounds) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("playgrounds"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a playground and creates it. Returns the server's representation of the playground, and an error, if there is any. +func (c *playgrounds) Create(ctx context.Context, playground *v1alpha1.Playground, opts v1.CreateOptions) (result *v1alpha1.Playground, err error) { + result = &v1alpha1.Playground{} + err = c.client.Post(). + Namespace(c.ns). + Resource("playgrounds"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(playground). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a playground and updates it. Returns the server's representation of the playground, and an error, if there is any. +func (c *playgrounds) Update(ctx context.Context, playground *v1alpha1.Playground, opts v1.UpdateOptions) (result *v1alpha1.Playground, err error) { + result = &v1alpha1.Playground{} + err = c.client.Put(). + Namespace(c.ns). + Resource("playgrounds"). + Name(playground.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(playground). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *playgrounds) UpdateStatus(ctx context.Context, playground *v1alpha1.Playground, opts v1.UpdateOptions) (result *v1alpha1.Playground, err error) { + result = &v1alpha1.Playground{} + err = c.client.Put(). + Namespace(c.ns). + Resource("playgrounds"). + Name(playground.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(playground). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the playground and deletes it. Returns an error if one occurs. +func (c *playgrounds) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("playgrounds"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *playgrounds) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("playgrounds"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched playground. +func (c *playgrounds) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Playground, err error) { + result = &v1alpha1.Playground{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("playgrounds"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied playground. +func (c *playgrounds) Apply(ctx context.Context, playground *inferencev1alpha1.PlaygroundApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Playground, err error) { + if playground == nil { + return nil, fmt.Errorf("playground provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(playground) + if err != nil { + return nil, err + } + name := playground.Name + if name == nil { + return nil, fmt.Errorf("playground.Name must be provided to Apply") + } + result = &v1alpha1.Playground{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("playgrounds"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *playgrounds) ApplyStatus(ctx context.Context, playground *inferencev1alpha1.PlaygroundApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Playground, err error) { + if playground == nil { + return nil, fmt.Errorf("playground provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(playground) + if err != nil { + return nil, err + } + + name := playground.Name + if name == nil { + return nil, fmt.Errorf("playground.Name must be provided to Apply") + } + + result = &v1alpha1.Playground{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("playgrounds"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/clientset/versioned/typed/inference/v1alpha1/service.go b/client-go/clientset/versioned/typed/inference/v1alpha1/service.go new file mode 100644 index 0000000..779692c --- /dev/null +++ b/client-go/clientset/versioned/typed/inference/v1alpha1/service.go @@ -0,0 +1,255 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + inferencev1alpha1 "inftyai.com/llmaz/client-go/applyconfiguration/inference/v1alpha1" + scheme "inftyai.com/llmaz/client-go/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ServicesGetter has a method to return a ServiceInterface. +// A group's client should implement this interface. +type ServicesGetter interface { + Services(namespace string) ServiceInterface +} + +// ServiceInterface has methods to work with Service resources. +type ServiceInterface interface { + Create(ctx context.Context, service *v1alpha1.Service, opts v1.CreateOptions) (*v1alpha1.Service, error) + Update(ctx context.Context, service *v1alpha1.Service, opts v1.UpdateOptions) (*v1alpha1.Service, error) + UpdateStatus(ctx context.Context, service *v1alpha1.Service, opts v1.UpdateOptions) (*v1alpha1.Service, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Service, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ServiceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Service, err error) + Apply(ctx context.Context, service *inferencev1alpha1.ServiceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Service, err error) + ApplyStatus(ctx context.Context, service *inferencev1alpha1.ServiceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Service, err error) + ServiceExpansion +} + +// services implements ServiceInterface +type services struct { + client rest.Interface + ns string +} + +// newServices returns a Services +func newServices(c *InferenceV1alpha1Client, namespace string) *services { + return &services{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *services) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *services) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested services. +func (c *services) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Create(ctx context.Context, service *v1alpha1.Service, opts v1.CreateOptions) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Post(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(service). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Update(ctx context.Context, service *v1alpha1.Service, opts v1.UpdateOptions) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(service). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *services) UpdateStatus(ctx context.Context, service *v1alpha1.Service, opts v1.UpdateOptions) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(service). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *services) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("services"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *services) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched service. +func (c *services) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("services"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied service. +func (c *services) Apply(ctx context.Context, service *inferencev1alpha1.ServiceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Service, err error) { + if service == nil { + return nil, fmt.Errorf("service provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(service) + if err != nil { + return nil, err + } + name := service.Name + if name == nil { + return nil, fmt.Errorf("service.Name must be provided to Apply") + } + result = &v1alpha1.Service{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("services"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *services) ApplyStatus(ctx context.Context, service *inferencev1alpha1.ServiceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Service, err error) { + if service == nil { + return nil, fmt.Errorf("service provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(service) + if err != nil { + return nil, err + } + + name := service.Name + if name == nil { + return nil, fmt.Errorf("service.Name must be provided to Apply") + } + + result = &v1alpha1.Service{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("services"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client-go/informers/externalversions/core/interface.go b/client-go/informers/externalversions/core/interface.go new file mode 100644 index 0000000..cbc4758 --- /dev/null +++ b/client-go/informers/externalversions/core/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package core + +import ( + v1alpha1 "inftyai.com/llmaz/client-go/informers/externalversions/core/v1alpha1" + internalinterfaces "inftyai.com/llmaz/client-go/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/client-go/informers/externalversions/core/v1alpha1/interface.go b/client-go/informers/externalversions/core/v1alpha1/interface.go new file mode 100644 index 0000000..3aa3188 --- /dev/null +++ b/client-go/informers/externalversions/core/v1alpha1/interface.go @@ -0,0 +1,44 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "inftyai.com/llmaz/client-go/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Models returns a ModelInformer. + Models() ModelInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Models returns a ModelInformer. +func (v *version) Models() ModelInformer { + return &modelInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/client-go/informers/externalversions/core/v1alpha1/model.go b/client-go/informers/externalversions/core/v1alpha1/model.go new file mode 100644 index 0000000..52a504f --- /dev/null +++ b/client-go/informers/externalversions/core/v1alpha1/model.go @@ -0,0 +1,89 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + versioned "inftyai.com/llmaz/client-go/clientset/versioned" + internalinterfaces "inftyai.com/llmaz/client-go/informers/externalversions/internalinterfaces" + v1alpha1 "inftyai.com/llmaz/client-go/listers/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ModelInformer provides access to a shared informer and lister for +// Models. +type ModelInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ModelLister +} + +type modelInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewModelInformer constructs a new informer for Model type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewModelInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredModelInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredModelInformer constructs a new informer for Model type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredModelInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.LlmazV1alpha1().Models(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.LlmazV1alpha1().Models(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.Model{}, + resyncPeriod, + indexers, + ) +} + +func (f *modelInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredModelInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *modelInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.Model{}, f.defaultInformer) +} + +func (f *modelInformer) Lister() v1alpha1.ModelLister { + return v1alpha1.NewModelLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/externalversions/factory.go b/client-go/informers/externalversions/factory.go new file mode 100644 index 0000000..4091e4e --- /dev/null +++ b/client-go/informers/externalversions/factory.go @@ -0,0 +1,266 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "inftyai.com/llmaz/client-go/clientset/versioned" + core "inftyai.com/llmaz/client-go/informers/externalversions/core" + inference "inftyai.com/llmaz/client-go/informers/externalversions/inference" + internalinterfaces "inftyai.com/llmaz/client-go/informers/externalversions/internalinterfaces" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + transform cache.TransformFunc + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// WithTransform sets a transform on all informers. +func WithTransform(transform cache.TransformFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.transform = transform + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + if f.shuttingDown { + return + } + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + f.wg.Add(1) + // We need a new variable in each loop iteration, + // otherwise the goroutine would use the loop variable + // and that keeps changing. + informer := informer + go func() { + defer f.wg.Done() + informer.Run(stopCh) + }() + f.startedInformers[informerType] = true + } + } +} + +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() +} + +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + informer.SetTransform(f.transform) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + Start(stopCh <-chan struct{}) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Llmaz() core.Interface + Inference() inference.Interface +} + +func (f *sharedInformerFactory) Llmaz() core.Interface { + return core.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) Inference() inference.Interface { + return inference.New(f, f.namespace, f.tweakListOptions) +} diff --git a/client-go/informers/externalversions/generic.go b/client-go/informers/externalversions/generic.go new file mode 100644 index 0000000..8c3b7bf --- /dev/null +++ b/client-go/informers/externalversions/generic.go @@ -0,0 +1,68 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + corev1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=inference.llmaz.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("playgrounds"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Inference().V1alpha1().Playgrounds().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("services"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Inference().V1alpha1().Services().Informer()}, nil + + // Group=llmaz.io, Version=v1alpha1 + case corev1alpha1.SchemeGroupVersion.WithResource("models"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Llmaz().V1alpha1().Models().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/client-go/informers/externalversions/inference/interface.go b/client-go/informers/externalversions/inference/interface.go new file mode 100644 index 0000000..23d56fd --- /dev/null +++ b/client-go/informers/externalversions/inference/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package inference + +import ( + v1alpha1 "inftyai.com/llmaz/client-go/informers/externalversions/inference/v1alpha1" + internalinterfaces "inftyai.com/llmaz/client-go/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/client-go/informers/externalversions/inference/v1alpha1/interface.go b/client-go/informers/externalversions/inference/v1alpha1/interface.go new file mode 100644 index 0000000..5f39c1b --- /dev/null +++ b/client-go/informers/externalversions/inference/v1alpha1/interface.go @@ -0,0 +1,51 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "inftyai.com/llmaz/client-go/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Playgrounds returns a PlaygroundInformer. + Playgrounds() PlaygroundInformer + // Services returns a ServiceInformer. + Services() ServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Playgrounds returns a PlaygroundInformer. +func (v *version) Playgrounds() PlaygroundInformer { + return &playgroundInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Services returns a ServiceInformer. +func (v *version) Services() ServiceInformer { + return &serviceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/client-go/informers/externalversions/inference/v1alpha1/playground.go b/client-go/informers/externalversions/inference/v1alpha1/playground.go new file mode 100644 index 0000000..57bf291 --- /dev/null +++ b/client-go/informers/externalversions/inference/v1alpha1/playground.go @@ -0,0 +1,89 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + inferencev1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + versioned "inftyai.com/llmaz/client-go/clientset/versioned" + internalinterfaces "inftyai.com/llmaz/client-go/informers/externalversions/internalinterfaces" + v1alpha1 "inftyai.com/llmaz/client-go/listers/inference/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// PlaygroundInformer provides access to a shared informer and lister for +// Playgrounds. +type PlaygroundInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PlaygroundLister +} + +type playgroundInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPlaygroundInformer constructs a new informer for Playground type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewPlaygroundInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPlaygroundInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPlaygroundInformer constructs a new informer for Playground type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredPlaygroundInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.InferenceV1alpha1().Playgrounds(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.InferenceV1alpha1().Playgrounds(namespace).Watch(context.TODO(), options) + }, + }, + &inferencev1alpha1.Playground{}, + resyncPeriod, + indexers, + ) +} + +func (f *playgroundInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPlaygroundInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *playgroundInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&inferencev1alpha1.Playground{}, f.defaultInformer) +} + +func (f *playgroundInformer) Lister() v1alpha1.PlaygroundLister { + return v1alpha1.NewPlaygroundLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/externalversions/inference/v1alpha1/service.go b/client-go/informers/externalversions/inference/v1alpha1/service.go new file mode 100644 index 0000000..e25f292 --- /dev/null +++ b/client-go/informers/externalversions/inference/v1alpha1/service.go @@ -0,0 +1,89 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + inferencev1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + versioned "inftyai.com/llmaz/client-go/clientset/versioned" + internalinterfaces "inftyai.com/llmaz/client-go/informers/externalversions/internalinterfaces" + v1alpha1 "inftyai.com/llmaz/client-go/listers/inference/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ServiceInformer provides access to a shared informer and lister for +// Services. +type ServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ServiceLister +} + +type serviceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.InferenceV1alpha1().Services(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.InferenceV1alpha1().Services(namespace).Watch(context.TODO(), options) + }, + }, + &inferencev1alpha1.Service{}, + resyncPeriod, + indexers, + ) +} + +func (f *serviceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *serviceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&inferencev1alpha1.Service{}, f.defaultInformer) +} + +func (f *serviceInformer) Lister() v1alpha1.ServiceLister { + return v1alpha1.NewServiceLister(f.Informer().GetIndexer()) +} diff --git a/client-go/informers/externalversions/internalinterfaces/factory_interfaces.go b/client-go/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000..4958a16 --- /dev/null +++ b/client-go/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,39 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "inftyai.com/llmaz/client-go/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/client-go/listers/core/v1alpha1/expansion_generated.go b/client-go/listers/core/v1alpha1/expansion_generated.go new file mode 100644 index 0000000..044089d --- /dev/null +++ b/client-go/listers/core/v1alpha1/expansion_generated.go @@ -0,0 +1,26 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// ModelListerExpansion allows custom methods to be added to +// ModelLister. +type ModelListerExpansion interface{} + +// ModelNamespaceListerExpansion allows custom methods to be added to +// ModelNamespaceLister. +type ModelNamespaceListerExpansion interface{} diff --git a/client-go/listers/core/v1alpha1/model.go b/client-go/listers/core/v1alpha1/model.go new file mode 100644 index 0000000..833ca03 --- /dev/null +++ b/client-go/listers/core/v1alpha1/model.go @@ -0,0 +1,98 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ModelLister helps list Models. +// All objects returned here must be treated as read-only. +type ModelLister interface { + // List lists all Models in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Model, err error) + // Models returns an object that can list and get Models. + Models(namespace string) ModelNamespaceLister + ModelListerExpansion +} + +// modelLister implements the ModelLister interface. +type modelLister struct { + indexer cache.Indexer +} + +// NewModelLister returns a new ModelLister. +func NewModelLister(indexer cache.Indexer) ModelLister { + return &modelLister{indexer: indexer} +} + +// List lists all Models in the indexer. +func (s *modelLister) List(selector labels.Selector) (ret []*v1alpha1.Model, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Model)) + }) + return ret, err +} + +// Models returns an object that can list and get Models. +func (s *modelLister) Models(namespace string) ModelNamespaceLister { + return modelNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ModelNamespaceLister helps list and get Models. +// All objects returned here must be treated as read-only. +type ModelNamespaceLister interface { + // List lists all Models in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Model, err error) + // Get retrieves the Model from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Model, error) + ModelNamespaceListerExpansion +} + +// modelNamespaceLister implements the ModelNamespaceLister +// interface. +type modelNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Models in the indexer for a given namespace. +func (s modelNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Model, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Model)) + }) + return ret, err +} + +// Get retrieves the Model from the indexer for a given namespace and name. +func (s modelNamespaceLister) Get(name string) (*v1alpha1.Model, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("model"), name) + } + return obj.(*v1alpha1.Model), nil +} diff --git a/client-go/listers/inference/v1alpha1/expansion_generated.go b/client-go/listers/inference/v1alpha1/expansion_generated.go new file mode 100644 index 0000000..75ed66c --- /dev/null +++ b/client-go/listers/inference/v1alpha1/expansion_generated.go @@ -0,0 +1,34 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// PlaygroundListerExpansion allows custom methods to be added to +// PlaygroundLister. +type PlaygroundListerExpansion interface{} + +// PlaygroundNamespaceListerExpansion allows custom methods to be added to +// PlaygroundNamespaceLister. +type PlaygroundNamespaceListerExpansion interface{} + +// ServiceListerExpansion allows custom methods to be added to +// ServiceLister. +type ServiceListerExpansion interface{} + +// ServiceNamespaceListerExpansion allows custom methods to be added to +// ServiceNamespaceLister. +type ServiceNamespaceListerExpansion interface{} diff --git a/client-go/listers/inference/v1alpha1/playground.go b/client-go/listers/inference/v1alpha1/playground.go new file mode 100644 index 0000000..7312877 --- /dev/null +++ b/client-go/listers/inference/v1alpha1/playground.go @@ -0,0 +1,98 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PlaygroundLister helps list Playgrounds. +// All objects returned here must be treated as read-only. +type PlaygroundLister interface { + // List lists all Playgrounds in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Playground, err error) + // Playgrounds returns an object that can list and get Playgrounds. + Playgrounds(namespace string) PlaygroundNamespaceLister + PlaygroundListerExpansion +} + +// playgroundLister implements the PlaygroundLister interface. +type playgroundLister struct { + indexer cache.Indexer +} + +// NewPlaygroundLister returns a new PlaygroundLister. +func NewPlaygroundLister(indexer cache.Indexer) PlaygroundLister { + return &playgroundLister{indexer: indexer} +} + +// List lists all Playgrounds in the indexer. +func (s *playgroundLister) List(selector labels.Selector) (ret []*v1alpha1.Playground, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Playground)) + }) + return ret, err +} + +// Playgrounds returns an object that can list and get Playgrounds. +func (s *playgroundLister) Playgrounds(namespace string) PlaygroundNamespaceLister { + return playgroundNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PlaygroundNamespaceLister helps list and get Playgrounds. +// All objects returned here must be treated as read-only. +type PlaygroundNamespaceLister interface { + // List lists all Playgrounds in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Playground, err error) + // Get retrieves the Playground from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Playground, error) + PlaygroundNamespaceListerExpansion +} + +// playgroundNamespaceLister implements the PlaygroundNamespaceLister +// interface. +type playgroundNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Playgrounds in the indexer for a given namespace. +func (s playgroundNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Playground, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Playground)) + }) + return ret, err +} + +// Get retrieves the Playground from the indexer for a given namespace and name. +func (s playgroundNamespaceLister) Get(name string) (*v1alpha1.Playground, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("playground"), name) + } + return obj.(*v1alpha1.Playground), nil +} diff --git a/client-go/listers/inference/v1alpha1/service.go b/client-go/listers/inference/v1alpha1/service.go new file mode 100644 index 0000000..13d370f --- /dev/null +++ b/client-go/listers/inference/v1alpha1/service.go @@ -0,0 +1,98 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ServiceLister helps list Services. +// All objects returned here must be treated as read-only. +type ServiceLister interface { + // List lists all Services in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Service, err error) + // Services returns an object that can list and get Services. + Services(namespace string) ServiceNamespaceLister + ServiceListerExpansion +} + +// serviceLister implements the ServiceLister interface. +type serviceLister struct { + indexer cache.Indexer +} + +// NewServiceLister returns a new ServiceLister. +func NewServiceLister(indexer cache.Indexer) ServiceLister { + return &serviceLister{indexer: indexer} +} + +// List lists all Services in the indexer. +func (s *serviceLister) List(selector labels.Selector) (ret []*v1alpha1.Service, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Service)) + }) + return ret, err +} + +// Services returns an object that can list and get Services. +func (s *serviceLister) Services(namespace string) ServiceNamespaceLister { + return serviceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ServiceNamespaceLister helps list and get Services. +// All objects returned here must be treated as read-only. +type ServiceNamespaceLister interface { + // List lists all Services in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Service, err error) + // Get retrieves the Service from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Service, error) + ServiceNamespaceListerExpansion +} + +// serviceNamespaceLister implements the ServiceNamespaceLister +// interface. +type serviceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Services in the indexer for a given namespace. +func (s serviceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Service, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Service)) + }) + return ret, err +} + +// Get retrieves the Service from the indexer for a given namespace and name. +func (s serviceNamespaceLister) Get(name string) (*v1alpha1.Service, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("service"), name) + } + return obj.(*v1alpha1.Service), nil +} diff --git a/cmd/main.go b/cmd/main.go index ec8d23a..16e806f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -32,12 +32,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" + llmaziov1alpha1 "inftyai.com/llmaz/api/core/v1alpha1" inferencev1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" - llmaziov1alpha1 "inftyai.com/llmaz/api/v1alpha1" - "inftyai.com/llmaz/internal/cert" - "inftyai.com/llmaz/internal/controller" - inferencecontroller "inftyai.com/llmaz/internal/controller/inference" - "inftyai.com/llmaz/internal/webhook" + "inftyai.com/llmaz/pkg/cert" + "inftyai.com/llmaz/pkg/controller" + inferencecontroller "inftyai.com/llmaz/pkg/controller/inference" + "inftyai.com/llmaz/pkg/webhook" //+kubebuilder:scaffold:imports ) diff --git a/config/crd/bases/inference.llmaz.io_playgrounds.yaml b/config/crd/bases/inference.llmaz.io_playgrounds.yaml index 69933b6..04d890a 100644 --- a/config/crd/bases/inference.llmaz.io_playgrounds.yaml +++ b/config/crd/bases/inference.llmaz.io_playgrounds.yaml @@ -220,9 +220,10 @@ spec: format: int32 type: integer minReplicas: + default: 1 description: |- MinReplicas indicates the minimum number of inference workloads based on the traffic. - Default to nil means we can scale down the instances to 0. + Default to nil means we can scale down the instances to 1. format: int32 type: integer type: object diff --git a/config/crd/bases/inference.llmaz.io_services.yaml b/config/crd/bases/inference.llmaz.io_services.yaml index 8bdf6e5..9bf5044 100644 --- a/config/crd/bases/inference.llmaz.io_services.yaml +++ b/config/crd/bases/inference.llmaz.io_services.yaml @@ -11,6 +11,8 @@ spec: kind: Service listKind: ServiceList plural: services + shortNames: + - isvc singular: service scope: Namespaced versions: @@ -54,9 +56,10 @@ spec: format: int32 type: integer minReplicas: + default: 1 description: |- MinReplicas indicates the minimum number of inference workloads based on the traffic. - Default to nil means we can scale down the instances to 0. + Default to nil means we can scale down the instances to 1. format: int32 type: integer type: object diff --git a/config/crd/bases/llmaz.io_models.yaml b/config/crd/bases/llmaz.io_models.yaml index feed1c9..cf2e38d 100644 --- a/config/crd/bases/llmaz.io_models.yaml +++ b/config/crd/bases/llmaz.io_models.yaml @@ -78,97 +78,13 @@ spec: used in model claim. type: string nodeSelector: + additionalProperties: + type: string description: |- NodeSelector defines the labels to filter specified nodes, like cloud-provider.com/accelerator: nvidia-a100. NodeSelector will be auto injected to the Pods as scheduling primitives. - items: - description: |- - A node selector represents the union of the results of one or more label queries - over a set of nodes; that is, it represents the OR of the selectors represented - by the node selector terms. - properties: - nodeSelectorTerms: - description: Required. A list of node selector terms. - The terms are ORed. - items: - description: |- - A null or empty node selector term matches no objects. The requirements of - them are ANDed. - The TopologySelectorTerm type implements a subset of the NodeSelectorTerm. - properties: - matchExpressions: - description: A list of node selector requirements - by node's labels. - items: - description: |- - A node selector requirement is a selector that contains values, a key, and an operator - that relates the key and values. - properties: - key: - description: The label key that the selector - applies to. - type: string - operator: - description: |- - Represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. - type: string - values: - description: |- - 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. If the operator is Gt or Lt, the values - array must have a single element, which will be interpreted as an integer. - This array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchFields: - description: A list of node selector requirements - by node's fields. - items: - description: |- - A node selector requirement is a selector that contains values, a key, and an operator - that relates the key and values. - properties: - key: - description: The label key that the selector - applies to. - type: string - operator: - description: |- - Represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. - type: string - values: - description: |- - 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. If the operator is Gt or Lt, the values - array must have a single element, which will be interpreted as an integer. - This array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - type: object - x-kubernetes-map-type: atomic - type: array - required: - - nodeSelectorTerms - type: object - x-kubernetes-map-type: atomic - type: array + type: object params: additionalProperties: type: string diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index a21d8ac..c09dccf 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: docker.io/inftyai/llmaz-test - newTag: 0714-03 + newName: inftyai/llmaz-test + newTag: 0716-03 diff --git a/config/samples/_v1alpha1_model.yaml b/config/samples/_v1alpha1_model.yaml index 4cf2eaf..d14f68e 100644 --- a/config/samples/_v1alpha1_model.yaml +++ b/config/samples/_v1alpha1_model.yaml @@ -11,7 +11,7 @@ metadata: spec: familyName: "llama3" dataSource: - url: https:// + modelID: "meta-llama/meta-llama-3-8b" inferenceFlavors: - name: a100 requests: diff --git a/go.mod b/go.mod index f8edade..c0fdbc4 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,11 @@ require ( k8s.io/apiextensions-apiserver v0.29.5 k8s.io/apimachinery v0.29.5 k8s.io/client-go v0.29.5 + k8s.io/code-generator v0.29.5 + k8s.io/utils v0.0.0-20230726121419-3b25d923346b sigs.k8s.io/controller-runtime v0.17.3 sigs.k8s.io/lws v0.3.0 + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 ) @@ -23,6 +26,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.8.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.4.1 // indirect @@ -56,8 +60,10 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect + golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/oauth2 v0.12.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/term v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect @@ -70,10 +76,10 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/component-base v0.29.5 // indirect + k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect + k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect - k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 81d4350..0812f98 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,7 @@ github.com/evanphx/json-patch/v5 v5.8.0 h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1 github.com/evanphx/json-patch/v5 v5.8.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= @@ -35,10 +36,12 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= @@ -53,6 +56,7 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -121,6 +125,8 @@ golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfU golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -133,6 +139,8 @@ golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -149,6 +157,7 @@ golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= @@ -164,6 +173,7 @@ google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= @@ -183,8 +193,15 @@ k8s.io/apimachinery v0.29.5 h1:Hofa2BmPfpoT+IyDTlcPdCHSnHtEQMoJYGVoQpRTfv4= k8s.io/apimachinery v0.29.5/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= k8s.io/client-go v0.29.5 h1:nlASXmPQy190qTteaVP31g3c/wi2kycznkTP7Sv1zPc= k8s.io/client-go v0.29.5/go.mod h1:aY5CnqUUvXYccJhm47XHoPcRyX6vouHdIBHaKZGTbK4= +k8s.io/code-generator v0.29.5 h1:WqSdBPVV1B3jsPnKtPS39U02zj6Q7+FsjhAj1EPBJec= +k8s.io/code-generator v0.29.5/go.mod h1:7TYnI0dYItL2cKuhhgPSuF3WED9uMdELgbVXFfn/joE= k8s.io/component-base v0.29.5 h1:Ptj8AzG+p8c2a839XriHwxakDpZH9uvIgYz+o1agjg8= k8s.io/component-base v0.29.5/go.mod h1:9nBUoPxW/yimISIgAG7sJDrUGJlu7t8HnDafIrOdU8Q= +k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks= +k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= +k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 h1:NGrVE502P0s0/1hudf8zjgwki1X/TByhmAoILTarmzo= +k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70/go.mod h1:VH3AT8AaQOqiGjMF9p0/IM1Dj+82ZwjfxUP1IxaHE+8= +k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-aggregator v0.28.1 h1:rvG4llYnQKHjj6YjjoBPEJxfD1uH0DJwkrJTNKGAaCs= @@ -201,5 +218,6 @@ sigs.k8s.io/lws v0.3.0 h1:PtjiDHZWCxAeMyrsmPNN0i7KAVf6ocVEQFcojPWeA+k= sigs.k8s.io/lws v0.3.0/go.mod h1:/R1Q2LB2eg6t9mX5M6V4HLkeucxBFgOyaKkSGh/FGAY= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/hack/e2e-test.sh b/hack/e2e-test.sh new file mode 100755 index 0000000..43f516e --- /dev/null +++ b/hack/e2e-test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Copyright 2024 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +export CWD=$(pwd) +function cleanup { + if [ $USE_EXISTING_CLUSTER == 'false' ] + then + $KIND delete cluster --name $KIND_CLUSTER_NAME + fi + (cd $CWD/config/manager && $KUSTOMIZE edit set image controller=inftyai/llmaz:main) +} +function startup { + if [ $USE_EXISTING_CLUSTER == 'false' ] + then + $KIND create cluster --name $KIND_CLUSTER_NAME --image $E2E_KIND_VERSION + fi +} +function kind_load { + $KIND load docker-image $IMAGE_TAG --name $KIND_CLUSTER_NAME +} +function deploy { + cd $CWD/config/manager && $KUSTOMIZE edit set image controller=$IMAGE_TAG + $KUSTOMIZE build $CWD/test/e2e/config | $KUBECTL apply --server-side -f - +} +trap cleanup EXIT +startup +kind_load +deploy +$GINKGO -v $CWD/test/e2e/... diff --git a/hack/internal/tools.go b/hack/internal/tools.go new file mode 100644 index 0000000..bc6d57b --- /dev/null +++ b/hack/internal/tools.go @@ -0,0 +1,22 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package internal + +import ( + // Keep a reference to the code generators so they are not removed by `go mod tidy` + _ "k8s.io/code-generator" +) diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh new file mode 100755 index 0000000..91ecbbc --- /dev/null +++ b/hack/update-codegen.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +cd "$(dirname "${0}")/.." +GO_CMD=${1:-go} +CODEGEN_PKG=${2:-bin} +REPO_ROOT="$(git rev-parse --show-toplevel)" + + +source "${CODEGEN_PKG}/kube_codegen.sh" + +# TODO: remove the workaround when the issue is solved in the code-generator +# (https://github.com/kubernetes/code-generator/issues/165). +# Here, we create the soft link named "x-k8s.io" to the parent directory of +# LeaderWorkerSet to ensure the layout required by the kube_codegen.sh script. +ln -s .. inftyai.com +trap "rm inftyai.com" EXIT + +kube::codegen::gen_helpers \ + --input-pkg-root inftyai.com/llmaz/api \ + --output-base "${REPO_ROOT}" \ + --boilerplate "${REPO_ROOT}/hack/boilerplate.go.txt" + +kube::codegen::gen_client \ + --with-watch \ + --with-applyconfig \ + --input-pkg-root inftyai.com/llmaz/api \ + --output-base "$REPO_ROOT" \ + --output-pkg-root inftyai.com/llmaz/client-go \ + --boilerplate "${REPO_ROOT}/hack/boilerplate.go.txt" diff --git a/internal/controller/inference/playground_controller.go b/internal/controller/inference/playground_controller.go deleted file mode 100644 index 1b0f6e9..0000000 --- a/internal/controller/inference/playground_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package inference - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - inferencev1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" -) - -// PlaygroundReconciler reconciles a Playground object -type PlaygroundReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -//+kubebuilder:rbac:groups=inference.llmaz.io,resources=playgrounds,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=inference.llmaz.io,resources=playgrounds/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=inference.llmaz.io,resources=playgrounds/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Playground object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile -func (r *PlaygroundReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *PlaygroundReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&inferencev1alpha1.Playground{}). - Complete(r) -} diff --git a/internal/controller/inference/service_controller.go b/internal/controller/inference/service_controller.go deleted file mode 100644 index 633710b..0000000 --- a/internal/controller/inference/service_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package inference - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - inferencev1alpha1 "inftyai.com/llmaz/api/inference/v1alpha1" -) - -// ServiceReconciler reconciles a Service object -type ServiceReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -//+kubebuilder:rbac:groups=inference.llmaz.io,resources=services,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=inference.llmaz.io,resources=services/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=inference.llmaz.io,resources=services/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Service object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile -func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *ServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&inferencev1alpha1.Service{}). - Complete(r) -} diff --git a/pkg/backend/backend.go b/pkg/backend/backend.go new file mode 100644 index 0000000..50791e8 --- /dev/null +++ b/pkg/backend/backend.go @@ -0,0 +1,50 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package backend + +import ( + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" +) + +const ( + DEFAULT_MODEL_PATH = "/workspace/models/" + DEFAULT_PORT = "8080" +) + +// Backend represents the inference engine, such as vllm. +type Backend interface { + // Name returns the inference backend name in this project. + Name() inferenceapi.BackendName + // Image returns the container image for the inference backend. + Image(version string) string + // DefaultVersion returns the default version for the inference backend. + DefaultVersion() string + // DefaultResources returns the default resources set for the container. + DefaultResources() inferenceapi.ResourceRequirements + // DefaultCommands returns the default command to start the inference backend. + DefaultCommands() []string +} + +func SwitchBackend(name inferenceapi.BackendName) Backend { + switch name { + case inferenceapi.VLLM: + return &VLLM{} + default: + // We should not reach here because apiserver already did validation. + return nil + } +} diff --git a/pkg/backend/backend_test.go b/pkg/backend/backend_test.go new file mode 100644 index 0000000..31142a2 --- /dev/null +++ b/pkg/backend/backend_test.go @@ -0,0 +1,59 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package backend + +import ( + "testing" + + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" +) + +func TestSwitchBackend(t *testing.T) { + testCases := []struct { + name string + backendName inferenceapi.BackendName + expectedBackendName inferenceapi.BackendName + shouldErr bool + }{ + { + name: "vllm should support", + backendName: inferenceapi.VLLM, + expectedBackendName: inferenceapi.VLLM, + shouldErr: false, + }, + { + name: "tgi should not support", + backendName: inferenceapi.BackendName("tgi"), + expectedBackendName: inferenceapi.BackendName(""), + shouldErr: true, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + backend := SwitchBackend(tc.backendName) + + if !tc.shouldErr && backend == nil { + t.Fatal("unexpected error") + } + + if !tc.shouldErr && backend.Name() != tc.expectedBackendName { + t.Fatalf("unexpected backend, want %s, got %s", tc.expectedBackendName, backend.Name()) + } + }) + } +} diff --git a/pkg/backend/vllm.go b/pkg/backend/vllm.go new file mode 100644 index 0000000..3fa53ae --- /dev/null +++ b/pkg/backend/vllm.go @@ -0,0 +1,72 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package backend + +import ( + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" +) + +// python -m vllm.entrypoints.openai.api_server --model NousResearch/Meta-Llama-3-8B-Instruct --dtype auto --api-key token-abc123 +// +// docker run --runtime nvidia --gpus all \ +// -v ~/.cache/huggingface:/root/.cache/huggingface \ +// --env "HUGGING_FACE_HUB_TOKEN=" \ +// -p 8000:8000 \ +// --ipc=host \ +// vllm/vllm-openai:latest \ +// --model mistralai/Mistral-7B-v0.1 + +// from transformers import AutoModel + +// access_token = "hf_..." + +// model = AutoModel.from_pretrained("private/model", token=access_token) +var _ Backend = (*VLLM)(nil) + +type VLLM struct{} + +const ( + image_registry = "vllm/vllm-openai" +) + +func (v *VLLM) Name() inferenceapi.BackendName { + return inferenceapi.VLLM +} + +func (v *VLLM) Image(version string) string { + return image_registry + ":" + version +} + +func (v *VLLM) DefaultVersion() string { + return "v0.5.1" +} + +func (v *VLLM) DefaultResources() inferenceapi.ResourceRequirements { + return inferenceapi.ResourceRequirements{ + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("4"), + corev1.ResourceMemory: resource.MustParse("8Gi"), + }, + } +} + +func (v *VLLM) DefaultCommands() []string { + return []string{"python3", "-m", "vllm.entrypoints.openai.api_server"} +} diff --git a/internal/cert/cert.go b/pkg/cert/cert.go similarity index 100% rename from internal/cert/cert.go rename to pkg/cert/cert.go diff --git a/pkg/controller/inference/playground_controller.go b/pkg/controller/inference/playground_controller.go new file mode 100644 index 0000000..c92b9cb --- /dev/null +++ b/pkg/controller/inference/playground_controller.go @@ -0,0 +1,289 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package inference + +import ( + "context" + "fmt" + + corev1 "k8s.io/api/core/v1" + apimeta "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + metaapplyv1 "k8s.io/client-go/applyconfigurations/meta/v1" + "k8s.io/client-go/tools/record" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" + "sigs.k8s.io/controller-runtime/pkg/log" + lws "sigs.k8s.io/lws/api/leaderworkerset/v1" + + core "inftyai.com/llmaz/api/core/v1alpha1" + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" + coreclientgo "inftyai.com/llmaz/client-go/applyconfiguration/core/v1alpha1" + inferenceclientgo "inftyai.com/llmaz/client-go/applyconfiguration/inference/v1alpha1" + "inftyai.com/llmaz/pkg/backend" + "inftyai.com/llmaz/pkg/util" +) + +// PlaygroundReconciler reconciles a Playground object +type PlaygroundReconciler struct { + client.Client + Scheme *runtime.Scheme + Record record.EventRecorder +} + +func NewPlaygroundReconciler(client client.Client, scheme *runtime.Scheme, record record.EventRecorder) *PlaygroundReconciler { + return &PlaygroundReconciler{ + Client: client, + Scheme: scheme, + Record: record, + } +} + +//+kubebuilder:rbac:groups=inference.llmaz.io,resources=playgrounds,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=inference.llmaz.io,resources=playgrounds/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=inference.llmaz.io,resources=playgrounds/finalizers,verbs=update + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +// For more details, check Reconcile and its Result here: +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile +func (r *PlaygroundReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := log.FromContext(ctx) + + playground := &inferenceapi.Playground{} + if err := r.Get(ctx, types.NamespacedName{Name: req.Name, Namespace: req.Namespace}, playground); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + + var serviceApplyConfiguration *inferenceclientgo.ServiceApplyConfiguration + + if playground.Spec.ModelClaim != nil { + modelName := playground.Spec.ModelClaim.ModelName + model := &core.Model{} + + if err := r.Get(ctx, types.NamespacedName{Name: string(modelName)}, model); err != nil { + log.Error(err, "model doesn't exist") + return ctrl.Result{}, err + } + serviceApplyConfiguration = buildServiceApplyConfiguration(model, playground) + } + + // TODO: handle MultiModelsClaims in the future. + + if err := setControllerReferenceForService(playground, serviceApplyConfiguration, r.Scheme); err != nil { + return ctrl.Result{}, err + } + + if err := util.Patch(ctx, r.Client, serviceApplyConfiguration); err != nil { + log.Error(err, "failed to create inferenceService") + return ctrl.Result{}, err + } + + // Handle status. + + var service *inferenceapi.Service + if err := r.Get(ctx, types.NamespacedName{Name: playground.Name, Namespace: playground.Namespace}, service); err != nil { + log.Error(err, "failed to get inferenceService") + return ctrl.Result{}, err + } + setPlaygroundCondition(playground, service) + if err := r.Status().Update(ctx, playground); err != nil { + log.Error(err, "failed to update Playground status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, nil +} + +// SetupWithManager sets up the controller with the Manager. +func (r *PlaygroundReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&inferenceapi.Playground{}). + Complete(r) +} + +func buildServiceApplyConfiguration(model *core.Model, playground *inferenceapi.Playground) *inferenceclientgo.ServiceApplyConfiguration { + // Build metadata + serviceApplyConfiguration := inferenceclientgo.Service(playground.Name, playground.Namespace) + + // Build spec. + spec := inferenceclientgo.ServiceSpec() + if playground.Spec.ElasticConfig != nil { + config := inferenceclientgo.ElasticConfig() + if max := playground.Spec.ElasticConfig.MaxReplicas; max != nil { + config.WithMaxReplicas(*max) + } + if min := playground.Spec.ElasticConfig.MinReplicas; min != nil { + config.WithMinReplicas(*min) + } + spec.WithElasticConfig(config) + } + + if playground.Spec.ModelClaim != nil { + claim := coreclientgo.MultiModelsClaim(). + WithModelNames(playground.Spec.ModelClaim.ModelName). + WithInferenceFlavors(playground.Spec.ModelClaim.InferenceFlavors...) + spec.WithMultiModelsClaims(claim) + } + + spec.WithWorkloadTemplate(buildWorkloadTemplate(model, playground)) + serviceApplyConfiguration.WithSpec(spec) + + return serviceApplyConfiguration + + // TODO: handle MultiModelsClaims in the future. +} + +// We do not want to maintain another workload like deployment for single-host cases so we choose lws here +// to cover both single-host and multi-host cases. There're some shortages for lws like can not force rolling +// update when one replica failed, we'll fix this in the kubernetes upstream. +// Model flavors will not be considered but in inferenceService controller to support accelerator fungibility. +func buildWorkloadTemplate(model *core.Model, playground *inferenceapi.Playground) lws.LeaderWorkerSetSpec { + // FIXME: this should be leaderWorkerSetTemplateSpec, we should support in the lws upstream. + workload := lws.LeaderWorkerSetSpec{} + workload.Replicas = playground.Spec.Replicas + + backendName := inferenceapi.DefaultBackend + if playground.Spec.BackendConfig != nil && playground.Spec.BackendConfig.Name != nil { + backendName = *playground.Spec.BackendConfig.Name + } + bkd := backend.SwitchBackend(backendName) + + version := bkd.DefaultVersion() + if playground.Spec.BackendConfig != nil && playground.Spec.BackendConfig.Version != nil { + version = *playground.Spec.BackendConfig.Version + } + + // TODO: should we also support secret here? + args := []string{ + "--model", backend.DEFAULT_MODEL_PATH + model.Name, + "--port", backend.DEFAULT_PORT, + } + var envs []corev1.EnvVar + if playground.Spec.BackendConfig != nil { + args = append(args, playground.Spec.BackendConfig.Args...) + envs = playground.Spec.BackendConfig.Envs + } + + resources := corev1.ResourceRequirements{ + Limits: bkd.DefaultResources().Limits, + Requests: bkd.DefaultResources().Requests, + } + if playground.Spec.BackendConfig != nil && playground.Spec.BackendConfig.Resources != nil { + // FIXME: we should merge the resources rather than simply replace. + resources = corev1.ResourceRequirements{ + Limits: playground.Spec.BackendConfig.Resources.Limits, + Requests: playground.Spec.BackendConfig.Resources.Requests, + } + } + + // TODO: handle multi-host scenarios, e.g. nvidia.com/gpu: 32, means we'll split into 4 hosts. + // Do we need another configuration for playground for multi-host use case? I guess no currently. + workload.LeaderWorkerTemplate.WorkerTemplate = corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + core.ModelNameLabelKey: string(model.Name), + core.ModelFamilyNameLabelKey: string(model.Spec.FamilyName), + }, + }, + Spec: corev1.PodSpec{ + // FIXME: add initContainer to handler data source + // TODO: should we support image pull secret here? + // TODO: support readiness/liveness + Containers: []corev1.Container{ + { + Name: string(bkd.Name()), + Image: bkd.Image(version), + Resources: resources, + Command: bkd.DefaultCommands(), + Args: args, + Env: envs, + }, + }, + }, + } + + return workload +} + +func setPlaygroundCondition(playground *inferenceapi.Playground, service *inferenceapi.Service) { + // For the start up. + if len(playground.Status.Conditions) == 0 { + condition := metav1.Condition{ + Type: inferenceapi.PlaygroundProgressing, + Status: metav1.ConditionTrue, + Reason: "Pending", + Message: "Waiting for inferenceService ready", + } + apimeta.SetStatusCondition(&playground.Status.Conditions, condition) + return + } + + if apimeta.IsStatusConditionTrue(service.Status.Conditions, inferenceapi.ServiceAvailable) { + condition := metav1.Condition{ + Type: inferenceapi.PlaygroundAvailable, + Status: metav1.ConditionTrue, + Reason: "PlaygroundReady", + Message: "Playground is ready", + } + apimeta.SetStatusCondition(&service.Status.Conditions, condition) + } else { + // Still in starting up, no need to populate the condition. + if apimeta.FindStatusCondition(playground.Status.Conditions, inferenceapi.PlaygroundAvailable) == nil { + return + } + + condition := metav1.Condition{ + Type: inferenceapi.PlaygroundProgressing, + Status: metav1.ConditionTrue, + Reason: "PlaygroundInProgress", + Message: "Playground is progressing", + } + apimeta.SetStatusCondition(&service.Status.Conditions, condition) + + // Set the available to false + new_condition := metav1.Condition{ + Type: inferenceapi.PlaygroundAvailable, + Status: metav1.ConditionFalse, + } + apimeta.SetStatusCondition(&playground.Status.Conditions, new_condition) + } +} + +// setControllerReferenceForService set playground as the owner reference for inferenceService. +func setControllerReferenceForService(owner metav1.Object, saf *inferenceclientgo.ServiceApplyConfiguration, scheme *runtime.Scheme) error { + // Validate the owner. + ro, ok := owner.(runtime.Object) + if !ok { + return fmt.Errorf("%T is not a runtime.Object, cannot call SetOwnerReference", owner) + } + gvk, err := apiutil.GVKForObject(ro, scheme) + if err != nil { + return err + } + saf.WithOwnerReferences(metaapplyv1.OwnerReference(). + WithAPIVersion(gvk.GroupVersion().String()). + WithKind(gvk.Kind). + WithName(owner.GetName()). + WithUID(owner.GetUID()). + WithBlockOwnerDeletion(true). + WithController(true)) + return nil +} diff --git a/pkg/controller/inference/service_controller.go b/pkg/controller/inference/service_controller.go new file mode 100644 index 0000000..dfbb71c --- /dev/null +++ b/pkg/controller/inference/service_controller.go @@ -0,0 +1,137 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package inference + +import ( + "context" + + apimeta "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/tools/record" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/log" + lws "sigs.k8s.io/lws/api/leaderworkerset/v1" + + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" + "inftyai.com/llmaz/pkg/util" +) + +// ServiceReconciler reconciles a Service object +type ServiceReconciler struct { + client.Client + Scheme *runtime.Scheme + Record record.EventRecorder +} + +func NewServiceReconciler(client client.Client, scheme *runtime.Scheme, record record.EventRecorder) *ServiceReconciler { + return &ServiceReconciler{ + Client: client, + Scheme: scheme, + Record: record, + } +} + +//+kubebuilder:rbac:groups=inference.llmaz.io,resources=services,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=inference.llmaz.io,resources=services/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=inference.llmaz.io,resources=services/finalizers,verbs=update + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +// For more details, check Reconcile and its Result here: +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile +func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := log.FromContext(ctx) + + service := &inferenceapi.Service{} + if err := r.Get(ctx, types.NamespacedName{Name: req.Name, Namespace: req.Namespace}, service); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + + workload := buildWorkload(service) + if err := ctrl.SetControllerReference(service, workload, r.Scheme); err != nil { + return ctrl.Result{}, err + } + + // TODO: handle fungibility + + if err := util.Patch(ctx, r.Client, workload); err != nil { + log.Error(err, "failed to create leaderworkerset") + return ctrl.Result{}, err + } + + // Handle status. + + workload = &lws.LeaderWorkerSet{} + if err := r.Get(ctx, types.NamespacedName{Name: service.Name, Namespace: service.Namespace}, workload); err != nil { + log.Error(err, "failed to get leaderworkerset") + return ctrl.Result{}, err + } + setServiceCondition(service, workload) + if err := r.Status().Update(ctx, service); err != nil { + log.Error(err, "failed to update Service status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, nil +} + +// SetupWithManager sets up the controller with the Manager. +func (r *ServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&inferenceapi.Service{}). + Complete(r) +} + +func buildWorkload(service *inferenceapi.Service) *lws.LeaderWorkerSet { + workload := &lws.LeaderWorkerSet{} + workload.Kind = "LeaderWorkerSet" + workload.APIVersion = lws.GroupVersion.Group + "/" + lws.GroupVersion.Version + workload.Name = service.Name + workload.Namespace = service.Namespace + workload.Spec = service.Spec.WorkloadTemplate + return workload +} + +func setServiceCondition(service *inferenceapi.Service, workload *lws.LeaderWorkerSet) { + if apimeta.IsStatusConditionTrue(workload.Status.Conditions, string(lws.LeaderWorkerSetAvailable)) { + condition := metav1.Condition{ + Type: inferenceapi.ServiceAvailable, + Status: metav1.ConditionTrue, + Reason: "ServiceReady", + Message: "InferenceService is ready", + } + apimeta.SetStatusCondition(&service.Status.Conditions, condition) + } else { + condition := metav1.Condition{ + Type: inferenceapi.ServiceProgressing, + Status: metav1.ConditionTrue, + Reason: "ServiceInProgress", + Message: "InferenceService is progressing", + } + apimeta.SetStatusCondition(&service.Status.Conditions, condition) + + // Set the available to false + new_condition := metav1.Condition{ + Type: inferenceapi.ServiceAvailable, + Status: metav1.ConditionFalse, + } + apimeta.SetStatusCondition(&service.Status.Conditions, new_condition) + } +} diff --git a/internal/controller/inference/suite_test.go b/pkg/controller/inference/suite_test.go similarity index 100% rename from internal/controller/inference/suite_test.go rename to pkg/controller/inference/suite_test.go diff --git a/internal/controller/model_controller.go b/pkg/controller/model_controller.go similarity index 85% rename from internal/controller/model_controller.go rename to pkg/controller/model_controller.go index 892b0c0..f1dda10 100644 --- a/internal/controller/model_controller.go +++ b/pkg/controller/model_controller.go @@ -20,17 +20,27 @@ import ( "context" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/tools/record" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - api "inftyai.com/llmaz/api/v1alpha1" + api "inftyai.com/llmaz/api/core/v1alpha1" ) // ModelReconciler reconciles a Model object type ModelReconciler struct { client.Client Scheme *runtime.Scheme + Record record.EventRecorder +} + +func NewModelReconciler(client client.Client, scheme *runtime.Scheme, record record.EventRecorder) *ModelReconciler { + return &ModelReconciler{ + Client: client, + Scheme: scheme, + Record: record, + } } //+kubebuilder:rbac:groups=llmaz.io,resources=models,verbs=get;list;watch;create;update;patch;delete diff --git a/internal/controller/suite_test.go b/pkg/controller/suite_test.go similarity index 96% rename from internal/controller/suite_test.go rename to pkg/controller/suite_test.go index f8d050b..c41e1d9 100644 --- a/internal/controller/suite_test.go +++ b/pkg/controller/suite_test.go @@ -32,7 +32,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - llmaziov1alpha1 "inftyai.com/llmaz/api/v1alpha1" + api "inftyai.com/llmaz/api/core/v1alpha1" //+kubebuilder:scaffold:imports ) @@ -72,7 +72,7 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - err = llmaziov1alpha1.AddToScheme(scheme.Scheme) + err = api.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme diff --git a/pkg/util/client.go b/pkg/util/client.go new file mode 100644 index 0000000..e52214f --- /dev/null +++ b/pkg/util/client.go @@ -0,0 +1,49 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package util + +import ( + "context" + + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/ptr" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +const ( + fieldManager = "llmaz" +) + +// Patch operation should be idempotent. +func Patch(ctx context.Context, k8sClient client.Client, pointerObj interface{}) error { + obj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(pointerObj) + if err != nil { + return err + } + patch := &unstructured.Unstructured{ + Object: obj, + } + if err := k8sClient.Patch(ctx, patch, client.Apply, &client.PatchOptions{ + FieldManager: fieldManager, + Force: ptr.To[bool](true), + }); err != nil { + return err + } + + return nil +} diff --git a/internal/webhook/model_webhook.go b/pkg/webhook/model_webhook.go similarity index 98% rename from internal/webhook/model_webhook.go rename to pkg/webhook/model_webhook.go index c1e7f5c..79c9a28 100644 --- a/internal/webhook/model_webhook.go +++ b/pkg/webhook/model_webhook.go @@ -25,7 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - api "inftyai.com/llmaz/api/v1alpha1" + api "inftyai.com/llmaz/api/core/v1alpha1" ) type ModelWebhook struct{} diff --git a/internal/webhook/playground_webhook.go b/pkg/webhook/playground_webhook.go similarity index 100% rename from internal/webhook/playground_webhook.go rename to pkg/webhook/playground_webhook.go diff --git a/test/e2e/config/image_pull_policy.yaml b/test/e2e/config/image_pull_policy.yaml new file mode 100644 index 0000000..cd7ae12 --- /dev/null +++ b/test/e2e/config/image_pull_policy.yaml @@ -0,0 +1,11 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: controller-manager + namespace: system +spec: + template: + spec: + containers: + - name: manager + imagePullPolicy: IfNotPresent diff --git a/test/e2e/config/kustomization.yaml b/test/e2e/config/kustomization.yaml new file mode 100644 index 0000000..1bacd46 --- /dev/null +++ b/test/e2e/config/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../../config/default + +patches: +- path: image_pull_policy.yaml diff --git a/test/e2e/model_test.go b/test/e2e/model_test.go new file mode 100644 index 0000000..67a636b --- /dev/null +++ b/test/e2e/model_test.go @@ -0,0 +1,32 @@ +/* +Copyright 2024 The Kubernetes Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + "inftyai.com/llmaz/test/util" +) + +var _ = ginkgo.Describe("model e2e tests", func() { + + ginkgo.It("Can deploy a normal model", func() { + model := util.MockASampleModel() + gomega.Expect(k8sClient.Create(ctx, model)).To(gomega.Succeed()) + // cleanup + gomega.Expect(k8sClient.Delete(ctx, model)).To(gomega.Succeed()) + }) +}) diff --git a/test/e2e/playground_test.go b/test/e2e/playground_test.go new file mode 100644 index 0000000..5c46114 --- /dev/null +++ b/test/e2e/playground_test.go @@ -0,0 +1,57 @@ +/* +Copyright 2024 The Kubernetes Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + testing "sigs.k8s.io/lws/test/testutils" + + api "inftyai.com/llmaz/api/core/v1alpha1" + "inftyai.com/llmaz/test/util" +) + +var _ = ginkgo.Describe("playground e2e tests", func() { + + // Each test runs in a separate namespace. + var ns *corev1.Namespace + var model *api.Model + + ginkgo.BeforeEach(func() { + // Create test namespace before each test. + ns = &corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "test-ns-", + }, + } + gomega.Expect(k8sClient.Create(ctx, ns)).To(gomega.Succeed()) + model = util.MockASampleModel() + gomega.Expect(k8sClient.Create(ctx, model)).To(gomega.Succeed()) + }) + + ginkgo.AfterEach(func() { + gomega.Expect(testing.DeleteNamespace(ctx, k8sClient, ns)).To(gomega.Succeed()) + gomega.Expect(k8sClient.Delete(ctx, model)).To(gomega.Succeed()) + }) + + ginkgo.It("Can deploy a normal playground", func() { + playground := util.MockASamplePlayground(ns.Name) + gomega.Expect(k8sClient.Create(ctx, playground)).To(gomega.Succeed()) + // TODO: validate the corresponding inferenceService + }) +}) diff --git a/test/e2e/suit_test.go b/test/e2e/suit_test.go new file mode 100644 index 0000000..02eb3ad --- /dev/null +++ b/test/e2e/suit_test.go @@ -0,0 +1,107 @@ +/* +Copyright 2024 The Kubernetes Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "context" + "testing" + "time" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + admissionv1 "k8s.io/api/admission/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/config" + "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/log/zap" + "sigs.k8s.io/lws/client-go/clientset/versioned/scheme" + + api "inftyai.com/llmaz/api/core/v1alpha1" + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" + "inftyai.com/llmaz/test/util" +) + +const ( + timeout = 30 * time.Second + interval = time.Millisecond * 250 +) + +var cfg *rest.Config +var k8sClient client.Client +var ctx context.Context +var cancel context.CancelFunc + +func TestE2E(t *testing.T) { + RegisterFailHandler(Fail) + + RunSpecs(t, "E2E Suite") +} + +var _ = BeforeSuite(func() { + log.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) + ctx, cancel = context.WithCancel(context.TODO()) + + By("bootstrapping test environment") + + // cfg is defined in this file globally. + cfg = config.GetConfigOrDie() + Expect(cfg).NotTo(BeNil()) + + err := api.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + err = inferenceapi.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + err = admissionv1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + err = corev1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).NotTo(HaveOccurred()) + Expect(k8sClient).NotTo(BeNil()) + + readyForTesting(k8sClient) +}) + +var _ = AfterSuite(func() { + cancel() +}) + +func readyForTesting(client client.Client) { + By("waiting for webhooks to ready") + + // To verify that webhooks are ready, let's create a simple model. + model := util.MockASampleModel() + + // Once the creation succeeds, that means the webhooks are ready + // and we can begin testing. + Eventually(func() error { + return client.Create(ctx, model) + }, timeout, interval).Should(Succeed()) + + // Delete this model before beginning tests. + Expect(client.Delete(ctx, model)) + Eventually(func() error { + return client.Get(ctx, types.NamespacedName{Name: model.Name, Namespace: model.Namespace}, &api.Model{}) + }).ShouldNot(Succeed()) +} diff --git a/test/integration/controller/inference/playground_test.go b/test/integration/controller/inference/playground_test.go new file mode 100644 index 0000000..187c33b --- /dev/null +++ b/test/integration/controller/inference/playground_test.go @@ -0,0 +1,72 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package inference + +import ( + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + api "inftyai.com/llmaz/api/core/v1alpha1" + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" + "inftyai.com/llmaz/test/util" + "inftyai.com/llmaz/test/util/wrapper" +) + +var _ = ginkgo.Describe("playground controller test", func() { + // Each test runs in a separate namespace. + var ns *corev1.Namespace + var model *api.Model + + ginkgo.BeforeEach(func() { + // Create test namespace before each test. + ns = &corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "test-ns-", + }, + } + gomega.Expect(k8sClient.Create(ctx, ns)).To(gomega.Succeed()) + model = util.MockASampleModel() + gomega.Expect(k8sClient.Create(ctx, model)).To(gomega.Succeed()) + }) + ginkgo.AfterEach(func() { + gomega.Expect(k8sClient.Delete(ctx, ns)).To(gomega.Succeed()) + gomega.Expect(k8sClient.Delete(ctx, model)).To(gomega.Succeed()) + }) + + type testValidatingCase struct { + playground func() *inferenceapi.Playground + failed bool + } + // TODO: Add more testCases to cover updating. + ginkgo.DescribeTable("test validating", + func(tc *testValidatingCase) { + if tc.failed { + gomega.Expect(k8sClient.Create(ctx, tc.playground())).To(gomega.HaveOccurred()) + } else { + gomega.Expect(k8sClient.Create(ctx, tc.playground())).To(gomega.Succeed()) + } + }, + ginkgo.Entry("normal playground creation", &testValidatingCase{ + playground: func() *inferenceapi.Playground { + return wrapper.MakePlayground("test-playground", ns.Name).Replicas(1).ModelClaim("llama3-8b").Obj() + }, + failed: false, + }), + ) +}) diff --git a/test/integration/controller/inference/suit_test.go b/test/integration/controller/inference/suit_test.go new file mode 100644 index 0000000..29da0c1 --- /dev/null +++ b/test/integration/controller/inference/suit_test.go @@ -0,0 +1,129 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package inference + +import ( + "context" + "fmt" + "path/filepath" + "runtime" + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + //+kubebuilder:scaffold:imports + + corev1 "k8s.io/api/core/v1" + "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme" + "k8s.io/client-go/rest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/log/zap" + + // lws "sigs.k8s.io/lws/api/leaderworkerset/v1" + + api "inftyai.com/llmaz/api/core/v1alpha1" + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" + "inftyai.com/llmaz/pkg/controller" + inferencecontroller "inftyai.com/llmaz/pkg/controller/inference" +) + +// These tests use Ginkgo (BDD-style Go testing framework). Refer to +// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. + +var cfg *rest.Config +var k8sClient client.Client +var testEnv *envtest.Environment +var ctx context.Context +var cancel context.CancelFunc + +func TestAPIs(t *testing.T) { + RegisterFailHandler(Fail) + + RunSpecs(t, "Inference Controller Suite") +} + +var _ = BeforeSuite(func() { + logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) + + ctx, cancel = context.WithCancel(context.TODO()) + + By("bootstrapping test environment") + + // Webhook not installed. + testEnv = &envtest.Environment{ + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crd", "bases")}, + ErrorIfCRDPathMissing: true, + + // The BinaryAssetsDirectory is only required if you want to run the tests directly + // without call the makefile target test. If not informed it will look for the + // default path defined in controller-runtime which is /usr/local/kubebuilder/. + // Note that you must have the required binaries setup under the bin directory to perform + // the tests directly. When we run make test it will be setup and used automatically. + BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", + fmt.Sprintf("1.30.0-%s-%s", runtime.GOOS, runtime.GOARCH)), + } + + var err error + // cfg is defined in this file globally. + cfg, err = testEnv.Start() + Expect(err).NotTo(HaveOccurred()) + Expect(cfg).NotTo(BeNil()) + + err = api.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + err = inferenceapi.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + err = corev1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + // err = lws.AddToScheme(scheme.Scheme) + // Expect(err).NotTo(HaveOccurred()) + + //+kubebuilder:scaffold:scheme + + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).NotTo(HaveOccurred()) + Expect(k8sClient).NotTo(BeNil()) + + mgr, err := ctrl.NewManager(cfg, ctrl.Options{ + Scheme: scheme.Scheme, + }) + Expect(err).ToNot(HaveOccurred()) + + modelController := controller.NewModelReconciler(mgr.GetClient(), mgr.GetScheme(), mgr.GetEventRecorderFor("model")) + modelController.SetupWithManager(mgr) + playgroundController := inferencecontroller.NewPlaygroundReconciler(mgr.GetClient(), mgr.GetScheme(), mgr.GetEventRecorderFor("playground")) + playgroundController.SetupWithManager(mgr) + serviceController := inferencecontroller.NewServiceReconciler(mgr.GetClient(), mgr.GetScheme(), mgr.GetEventRecorderFor("service")) + serviceController.SetupWithManager(mgr) + + go func() { + defer GinkgoRecover() + err = mgr.Start(ctx) + Expect(err).NotTo(HaveOccurred()) + }() +}) + +var _ = AfterSuite(func() { + cancel() + By("tearing down the test environment") + err := testEnv.Stop() + Expect(err).NotTo(HaveOccurred()) +}) diff --git a/test/integration/webhook/model_test.go b/test/integration/webhook/model_test.go index f4d7a1c..6767a9e 100644 --- a/test/integration/webhook/model_test.go +++ b/test/integration/webhook/model_test.go @@ -22,7 +22,7 @@ import ( "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "inftyai.com/llmaz/api/v1alpha1" + api "inftyai.com/llmaz/api/core/v1alpha1" "inftyai.com/llmaz/test/util/wrapper" ) @@ -52,10 +52,10 @@ var _ = ginkgo.Describe("model default and validation", func() { }, ginkgo.Entry("apply model family name", &testDefaultingCase{ model: func() *api.Model { - return wrapper.MakeModel("llama3-8b").DataSourceWithModel("meta-llama/meta-llama-3-8b", "Huggingface").FamilyName("llama3").Obj() + return wrapper.MakeModel("llama3-8b").DataSourceWithModelID("meta-llama/meta-llama-3-8b").FamilyName("llama3").Obj() }, wantModel: func() *api.Model { - return wrapper.MakeModel("llama3-8b").DataSourceWithModel("meta-llama/meta-llama-3-8b", "Huggingface").FamilyName("llama3").Label(api.ModelFamilyNameLabelKey, "llama3").Obj() + return wrapper.MakeModel("llama3-8b").DataSourceWithModelID("meta-llama/meta-llama-3-8b").DataSourceWithModelHub("Huggingface").FamilyName("llama3").Label(api.ModelFamilyNameLabelKey, "llama3").Obj() }, }), ) @@ -75,7 +75,7 @@ var _ = ginkgo.Describe("model default and validation", func() { }, ginkgo.Entry("normal model creation", &testValidatingCase{ model: func() *api.Model { - return wrapper.MakeModel("llama3-8b").FamilyName("llama3").DataSourceWithModel("meta-llama/meta-llama-3-8b", "Huggingface").Obj() + return wrapper.MakeModel("llama3-8b").FamilyName("llama3").DataSourceWithModelID("meta-llama/meta-llama-3-8b").Obj() }, failed: false, }), diff --git a/test/integration/webhook/suit_test.go b/test/integration/webhook/suit_test.go index ccd20a2..b1bc633 100644 --- a/test/integration/webhook/suit_test.go +++ b/test/integration/webhook/suit_test.go @@ -43,9 +43,9 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" + api "inftyai.com/llmaz/api/core/v1alpha1" inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" - api "inftyai.com/llmaz/api/v1alpha1" - apiwebhook "inftyai.com/llmaz/internal/webhook" + apiwebhook "inftyai.com/llmaz/pkg/webhook" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -80,7 +80,7 @@ var _ = BeforeSuite(func() { // Note that you must have the required binaries setup under the bin directory to perform // the tests directly. When we run make test it will be setup and used automatically. BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.28.3-%s-%s", runtime.GOOS, runtime.GOARCH)), + fmt.Sprintf("1.30.0-%s-%s", runtime.GOOS, runtime.GOARCH)), WebhookInstallOptions: envtest.WebhookInstallOptions{ Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, @@ -95,13 +95,10 @@ var _ = BeforeSuite(func() { err = api.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = inferenceapi.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = admissionv1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = corev1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) @@ -127,7 +124,6 @@ var _ = BeforeSuite(func() { err = apiwebhook.SetupModelWebhook(mgr) Expect(err).NotTo(HaveOccurred()) - err = apiwebhook.SetupPlaygroundWebhook(mgr) Expect(err).NotTo(HaveOccurred()) diff --git a/test/util/mock.go b/test/util/mock.go new file mode 100644 index 0000000..70554ba --- /dev/null +++ b/test/util/mock.go @@ -0,0 +1,34 @@ +/* +Copyright 2024 The Kubernetes Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package util + +import ( + api "inftyai.com/llmaz/api/core/v1alpha1" + inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" + "inftyai.com/llmaz/test/util/wrapper" +) + +const ( + sampleModelName = "llama3-8b" +) + +func MockASampleModel() *api.Model { + return wrapper.MakeModel(sampleModelName).FamilyName("llama3").DataSourceWithModelID("meta-llama/meta-llama-3-8b").Obj() +} + +func MockASamplePlayground(ns string) *inferenceapi.Playground { + return wrapper.MakePlayground("playground-llama3-8b", ns).ModelClaim(sampleModelName).Obj() +} diff --git a/test/util/wrapper/model.go b/test/util/wrapper/model.go index 2cd778c..1523585 100644 --- a/test/util/wrapper/model.go +++ b/test/util/wrapper/model.go @@ -21,7 +21,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "inftyai.com/llmaz/api/v1alpha1" + api "inftyai.com/llmaz/api/core/v1alpha1" ) type ModelWrapper struct { @@ -47,10 +47,14 @@ func (w *ModelWrapper) FamilyName(name string) *ModelWrapper { return w } -func (w *ModelWrapper) DataSourceWithModel(modelID, modelHub string) *ModelWrapper { +func (w *ModelWrapper) DataSourceWithModelID(modelID string) *ModelWrapper { if modelID != "" { w.Spec.DataSource.ModelID = &modelID } + return w +} + +func (w *ModelWrapper) DataSourceWithModelHub(modelHub string) *ModelWrapper { if modelHub != "" { w.Spec.DataSource.ModelHub = &modelHub } @@ -87,8 +91,11 @@ func (w *FlavorWrapper) SetRequest(r, v string) *api.Flavor { return &w.Flavor } -func (w *FlavorWrapper) SetNodeSelector(selector v1.NodeSelector) *api.Flavor { - w.NodeSelector = append(w.NodeSelector, selector) +func (w *FlavorWrapper) SetNodeSelector(k, v string) *api.Flavor { + if w.NodeSelector == nil { + w.NodeSelector = map[string]string{} + } + w.NodeSelector[k] = v return &w.Flavor } diff --git a/test/util/wrapper/playground.go b/test/util/wrapper/playground.go index 6b69831..ad0b275 100644 --- a/test/util/wrapper/playground.go +++ b/test/util/wrapper/playground.go @@ -17,8 +17,8 @@ limitations under the License. package wrapper import ( + api "inftyai.com/llmaz/api/core/v1alpha1" inferenceapi "inftyai.com/llmaz/api/inference/v1alpha1" - api "inftyai.com/llmaz/api/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" )