Skip to content

Commit

Permalink
fix api scheme (#674)
Browse files Browse the repository at this point in the history
* fix api scheme

Signed-off-by: kerthcet <kerthcet@gmail.com>

* Address comments

Signed-off-by: kerthcet <kerthcet@gmail.com>

* Fix pointer might be nil error

Signed-off-by: kerthcet <kerthcet@gmail.com>

---------

Signed-off-by: kerthcet <kerthcet@gmail.com>
  • Loading branch information
kerthcet authored Feb 17, 2025
1 parent 70bbce6 commit bc17678
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 19 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: update-codegen
update-codegen:
sh ./hack/update-codegen.sh
Expand Down Expand Up @@ -137,7 +137,7 @@ define push_image
endef

.PHONY: docker-build-all
docker-build-all:
docker-build-all:
make -j $(nproc) docker-build-controller-manager docker-build-gateway-plugins docker-build-runtime docker-build-metadata-service ## Build all docker images

.PHONY: docker-build-controller-manager
Expand All @@ -157,7 +157,7 @@ docker-build-metadata-service: ## Build docker image with the metadata-service.
$(call build_and_tag,metadata-service,Dockerfile.metadata)

.PHONY: docker-push-all
docker-push-all:
docker-push-all:
make -j $(nproc) docker-push-controller-manager docker-push-gateway-plugins docker-push-runtime docker-push-metadata-service ## Push all docker images

.PHONY: docker-push-controller-manager
Expand Down Expand Up @@ -212,9 +212,9 @@ endif
.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
## helm creates objects without aibrix prefix, hence deploying gateway components outside of kustomization
## helm creates objects without aibrix prefix, hence deploying gateway components outside of kustomization
$(KUBECTL) create -k config/dependency

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -k config/dependency
Expand All @@ -231,9 +231,9 @@ undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.
.PHONY: install-vke
install-vke: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
## helm creates objects without aibrix prefix, hence deploying gateway components outside of kustomization
## helm creates objects without aibrix prefix, hence deploying gateway components outside of kustomization
$(KUBECTL) create -k config/overlays/vke/dependency

.PHONY: uninstall-vke
uninstall-vke: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -k config/overlays/vke/dependency
Expand Down
6 changes: 5 additions & 1 deletion api/autoscaling/v1alpha1/podautoscaler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Expand Down Expand Up @@ -57,16 +56,19 @@ type PodAutoscalerSpec struct {
//PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"`

// MinReplicas is the minimum number of replicas to which the target can be scaled down.
// +optional
MinReplicas *int32 `json:"minReplicas,omitempty"`

// MaxReplicas is the maximum number of replicas to which the target can be scaled up.
// It cannot be less than minReplicas
MaxReplicas int32 `json:"maxReplicas"`

// MetricsSources defines a list of sources from which metrics are collected to make scaling decisions.
// +kubebuilder:validation:MinItems=1
MetricsSources []MetricSource `json:"metricsSources,omitempty"`

// ScalingStrategy defines the strategy to use for scaling.
// +kubebuilder:validation:Enum={HPA,KPA,APA}
ScalingStrategy ScalingStrategyType `json:"scalingStrategy"`
}

Expand Down Expand Up @@ -103,8 +105,10 @@ const (
// MetricSource defines an endpoint and path from which metrics are collected.
type MetricSource struct {
// access an endpoint or scan a list of k8s pod
// +kubebuilder:validation:Enum={pod,domain}
MetricSourceType MetricSourceType `json:"metricSourceType"`
// http or https
// +kubebuilder:validation:Enum={http,https}
ProtocolType ProtocolType `json:"protocolType"`
// e.g. service1.example.com. meaningless for MetricSourceType.POD
Endpoint string `json:"endpoint,omitempty"`
Expand Down
3 changes: 1 addition & 2 deletions api/model/v1alpha1/modeladapter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// ModelAdapterSpec defines the desired state of ModelAdapter
type ModelAdapterSpec struct {

// BaseModel is the identifier for the base model to which the ModelAdapter will be attached.
// +optional
BaseModel string `json:"baseModel,omitempty"`
BaseModel *string `json:"baseModel,omitempty"`

// PodSelector is a label query over pods that should match the ModelAdapter configuration.
// +kubebuilder:validation:Required
Expand Down
2 changes: 1 addition & 1 deletion api/orchestration/v1alpha1/kvcache_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ServiceConfig struct {

// NodePort specifies the port on each node on which this service is exposed when using NodePort type.
// +kubebuilder:validation:Optional
NodePort int32 `json:"nodePort,omitempty"`
NodePort *int32 `json:"nodePort,omitempty"`
}

// MetadataConfig holds the configuration about the kv cache metadata service
Expand Down
5 changes: 4 additions & 1 deletion api/orchestration/v1alpha1/rayclusterfleet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// RayClusterFleetSpec defines the desired state of RayClusterFleet
type RayClusterFleetSpec struct {
// Number of desired pods. This is a pointer to distinguish between explicit
// zero and not specified. Defaults to 1.
// +kubebuilder:default=1
// +optional
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`

Expand All @@ -55,6 +55,7 @@ type RayClusterFleetSpec struct {
// The number of old ReplicaSets to retain to allow rollback.
// This is a pointer to distinguish between explicit zero and not specified.
// Defaults to 10.
// +kubebuilder:default=10
// +optional
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,6,opt,name=revisionHistoryLimit"`

Expand All @@ -67,6 +68,8 @@ type RayClusterFleetSpec struct {
// process failed deployments and a condition with a ProgressDeadlineExceeded
// reason will be surfaced in the deployment status. Note that progress will
// not be estimated during the time a deployment is paused. Defaults to 600s.
// +kubebuilder:default=600
// +optional
ProgressDeadlineSeconds *int32 `json:"progressDeadlineSeconds,omitempty" protobuf:"varint,9,opt,name=progressDeadlineSeconds"`
}

Expand Down
2 changes: 2 additions & 0 deletions api/orchestration/v1alpha1/rayclusterreplicaset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type RayClusterReplicaSetSpec struct {
// This is a pointer to distinguish between explicit zero and unspecified.
// Defaults to 1.
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
// +kubebuilder:default=1
// +optional
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`

Expand All @@ -43,6 +44,7 @@ type RayClusterReplicaSetSpec struct {
// Label keys and values that must match in order to be controlled by this replica set.
// It must match the pod template's labels.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
// +optional
Selector *metav1.LabelSelector `json:"selector" protobuf:"bytes,2,opt,name=selector"`

// Template is the object that describes the pod that will be created if
Expand Down
7 changes: 6 additions & 1 deletion api/orchestration/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Here are some essential resources for anyone interested in AIBrix:

- **Documentation and Tutorials**: [View Tutorials](https://github.com/aibrix/aibrix/tree/main/docs/tutorial)
- **Documentation and Tutorials**: [View Tutorials](https://github.com/aibrix/aibrix/tree/main/development/tutorial)
- **Issue Tracker**: [View Issues](https://github.com/aibrix/aibrix/issues)
- **Project Roadmap**: TODO

Expand Down Expand Up @@ -43,7 +43,7 @@ Alternatively, you can use [Kind](https://kind.sigs.k8s.io/) or [Minikube](https

Navigate to the cloned directory and run:

```
```
make build
```

Expand All @@ -53,8 +53,8 @@ Build and push your image to the location specified by `IMG`:
make docker-build docker-push IMG=<some-registry>/aibrix:tag
```

> **NOTE:** This image ought to be published in the personal registry you specified.
And it is required to have access to pull the image from the working environment.
> **NOTE:** This image ought to be published in the personal registry you specified.
And it is required to have access to pull the image from the working environment.
Make sure you have the proper permission to the registry if the above commands don’t work.

Install the CRDs into the cluster:
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/modeladapter/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ func buildModelAdapterEndpointSlice(instance *modelv1alpha1.ModelAdapter, pod *c

func buildModelAdapterService(instance *modelv1alpha1.ModelAdapter) *corev1.Service {
labels := map[string]string{
"model.aibrix.ai/name": instance.Spec.BaseModel,
"adapter.model.aibrix.ai/name": instance.Name,
}
if instance.Spec.BaseModel != nil {
labels["model.aibrix.ai/name"] = *instance.Spec.BaseModel
}

ports := []corev1.ServicePort{
{
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/modeladapter/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"
)

func TestBuildModelAdapterEndpointSlice(t *testing.T) {
Expand Down Expand Up @@ -75,7 +76,7 @@ func TestBuildModelAdapterService(t *testing.T) {
Namespace: "default",
},
Spec: modelv1alpha1.ModelAdapterSpec{
BaseModel: "test-model",
BaseModel: ptr.To[string]("test-model"),
},
}

Expand Down

0 comments on commit bc17678

Please sign in to comment.