Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update v1alpha1 RayCluster CRD and controllers #22

Merged
merged 5 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

build:
env:
working-directory: ./msft-operator/ray-operator
working-directory: ./ray-operator
name: Build
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions ray-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Image URL to use all building/pushing image targets
IMG ?= ray-controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
CRD_OPTIONS ?= "crd:maxDescLen=100,trivialVersions=true,preserveUnknownFields=false"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -67,7 +67,7 @@ ifeq (, $(shell which controller-gen))
CONTROLLER_GEN_TMP_DIR="$$(mktemp -d)" ;\
cd "$$CONTROLLER_GEN_TMP_DIR" ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.2 ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.5.0 ;\
rm -rf "$$CONTROLLER_GEN_TMP_DIR" ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
Expand Down
37 changes: 28 additions & 9 deletions ray-operator/api/v1alpha1/raycluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v1alpha1
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// appsv1 "k8s.io/api/apps/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand All @@ -13,18 +12,22 @@ import (
type RayClusterSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// HeadService is service to abstract the head pod. it will be used by the workers to connect to the head pod
HeadService v1.Service `json:"headService"`
// HeadGroupSpecs are the spec for the head pod
HeadGroupSpec HeadGroupSpec `json:"headGroupSpec"`
// WorkerGroupSpecs are the specs for the worker pods
WorkerGroupsSpec []WorkerGroupSpec `json:"workerGroupsSpec,omitempty"`
WorkerGroupSpecs []WorkerGroupSpec `json:"workerGroupSpecs,omitempty"`
// RayVersion is the version of ray being used. this affects the command used to start ray
RayVersion string `json:"rayVersion,omitempty"`
// EnableInTreeAutoscaling indicates whether operator should create in tree autoscaling configs
EnableInTreeAutoscaling *bool `json:"enableInTreeAutoscaling,omitempty"`
}

// HeadGroupSpec are the spec for the head pod
type HeadGroupSpec struct {
// ServiceType is Kubernetes service type of the head service. it will be used by the workers to connect to the head pod
ServiceType v1.ServiceType `json:"serviceType"`
// EnableIngress indicates whether operator should create ingress object for head service or not.
EnableIngress *bool `json:"enableIngress,omitempty"`
// Number of desired pods in this pod group. This is a pointer to distinguish between explicit
// zero and not specified. Defaults to 1.
Replicas *int32 `json:"replicas"`
Expand Down Expand Up @@ -59,13 +62,30 @@ type ScaleStrategy struct {
WorkersToDelete []string `json:"workersToDelete,omitempty"`
}

// The overall state of the Ray cluster.
type ClusterState string

const (
Ready ClusterState = "ready"
UnHealthy ClusterState = "unHealthy"
Failed ClusterState = "failed"
)

// RayClusterStatus defines the observed state of RayCluster
type RayClusterStatus struct {

// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Status reflects the status of the cluster
AvailableReplicas int32 `json:"availableReplicas,omitempty"`
State ClusterState `json:"state,omitempty"`
// AvailableWorkerReplicas indicates how many replicas are available in the cluster
AvailableWorkerReplicas int32 `json:"availableWorkerReplicas,omitempty"`
// DesiredWorkerReplicas indicates overall desired replicas claimed by the user at the cluster level.
DesiredWorkerReplicas int32 `json:"desiredWorkerReplicas,omitempty"`
// MinWorkerReplicas indicates sum of minimum replicas of each node group.
MinWorkerReplicas int32 `json:"minWorkerReplicas,omitempty"`
// MaxWorkerReplicas indicates sum of maximum replicas of each node group.
MaxWorkerReplicas int32 `json:"maxWorkerReplicas,omitempty"`
// LastUpdateTime indicates last update timestamp for this cluster status.
// +nullable
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
}
Expand All @@ -80,12 +100,11 @@ const (
WorkerNode RayNodeType = "worker"
)

// RayCluster is the Schema for the RayClusters API
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +kubebuilder:object:root=true

// RayCluster is the Schema for the RayClusters API
// +kubebuilder:subresource:status
type RayCluster struct {
// Standard object metadata.
metav1.TypeMeta `json:",inline"`
Expand Down
19 changes: 1 addition & 18 deletions ray-operator/api/v1alpha1/raycluster_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
)
Expand All @@ -18,22 +17,6 @@ var myRayCluster = &RayCluster{
},
Spec: RayClusterSpec{
RayVersion: "1.0",
HeadService: v1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "head-svc",
Namespace: "default",
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{Name: "redis", Port: int32(6379)}},
// Use a headless service, meaning that the DNS record for the service will
// point directly to the head node pod's IP address.
ClusterIP: corev1.ClusterIPNone,
// This selector must match the label of the head node.
Selector: map[string]string{
"identifier": "raycluster-sample-head",
},
},
},
HeadGroupSpec: HeadGroupSpec{
Replicas: pointer.Int32Ptr(1),
RayStartParams: map[string]string{
Expand Down Expand Up @@ -74,7 +57,7 @@ var myRayCluster = &RayCluster{
},
},
},
WorkerGroupsSpec: []WorkerGroupSpec{
WorkerGroupSpecs: []WorkerGroupSpec{
WorkerGroupSpec{
Replicas: pointer.Int32Ptr(3),
MinReplicas: pointer.Int32Ptr(0),
Expand Down
15 changes: 12 additions & 3 deletions ray-operator/api/v1alpha1/zz_generated.deepcopy.go

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

Loading