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

KubeRay: kubebuilder creat RayService Controller and CR #270

Merged
merged 12 commits into from
May 31, 2022
2 changes: 1 addition & 1 deletion ray-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ help: ## Display this help.
##@ Development

manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=kuberay-operator webhook paths="./..." output:crd:artifacts:config=config/crd/bases
brucez-anyscale marked this conversation as resolved.
Show resolved Hide resolved

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
Expand Down
9 changes: 9 additions & 0 deletions ray-operator/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@ resources:
kind: RayCluster
path: github.com/ray-project/kuberay/ray-operator/apis/ray/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: io
group: ray
kind: RayService
path: github.com/ray-project/kuberay/ray-operator/apis/ray/v1alpha1
version: v1alpha1
version: "3"
45 changes: 45 additions & 0 deletions ray-operator/apis/ray/v1alpha1/rayservice_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package v1alpha1
brucez-anyscale marked this conversation as resolved.
Show resolved Hide resolved

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.

// RayServiceSpec defines the desired state of RayService
type RayServiceSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// RayServiceStatus defines the observed state of RayService
type RayServiceStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// RayService is the Schema for the rayservices API
type RayService struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RayServiceSpec `json:"spec,omitempty"`
Status RayServiceStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// RayServiceList contains a list of RayService
type RayServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RayService `json:"items"`
}

func init() {
SchemeBuilder.Register(&RayService{}, &RayServiceList{})
}
89 changes: 89 additions & 0 deletions ray-operator/apis/ray/v1alpha1/zz_generated.deepcopy.go

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

50 changes: 50 additions & 0 deletions ray-operator/config/crd/bases/ray.io_rayservices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.0
creationTimestamp: null
name: rayservices.ray.io
spec:
group: ray.io
names:
kind: RayService
listKind: RayServiceList
plural: rayservices
singular: rayservice
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: RayService is the Schema for the rayservices API
properties:
apiVersion:
description: APIVersion defines the versioned schema of this representation
of an object.
type: string
kind:
description: Kind is a string value representing the REST resource this
object represents.
type: string
metadata:
type: object
spec:
description: RayServiceSpec defines the desired state of RayService
type: object
status:
description: RayServiceStatus defines the observed state of RayService
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
1 change: 1 addition & 0 deletions ray-operator/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# It should be run by config/default
resources:
- bases/ray.io_rayclusters.yaml
- bases/ray.io_rayservices.yaml
# +kubebuilder:scaffold:crdkustomizeresource
19 changes: 19 additions & 0 deletions ray-operator/config/crd/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
DmitriGekhtman marked this conversation as resolved.
Show resolved Hide resolved
nameReference:
- kind: Service
version: v1
fieldSpecs:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/name

namespace:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false

varReference:
- path: metadata/annotations
24 changes: 24 additions & 0 deletions ray-operator/config/rbac/ray_rayservice_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# permissions for end users to edit rayservices.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: rayservice-editor-role
rules:
- apiGroups:
- ray.io
resources:
- rayservices
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ray.io
resources:
- rayservices/status
verbs:
- get
20 changes: 20 additions & 0 deletions ray-operator/config/rbac/ray_rayservice_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# permissions for end users to view rayservices.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: rayservice-viewer-role
rules:
- apiGroups:
- ray.io
resources:
- rayservices
verbs:
- get
- list
- watch
- apiGroups:
- ray.io
resources:
- rayservices/status
verbs:
- get
Loading