-
Notifications
You must be signed in to change notification settings - Fork 539
[apiserver] Start apiserver v2 in apiserver/cmd/main.go #3603
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
Open
troychiu
wants to merge
12
commits into
ray-project:master
Choose a base branch
from
troychiu:use-apiserversdk
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+465
−1
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4d95645
use apiserversdk
troychiu e43cd01
code review
troychiu 316f317
fix go.mod
troychiu 4e56ed8
add e2e test
troychiu be260a3
go.mod
troychiu c3fc87c
add flag --enable-api-server-v2
troychiu 8f7dafe
lint
troychiu 74d6ea1
code review
troychiu 39f469f
merge master
troychiu 7dcd8cc
remove dependency to apiserver v1
troychiu c0ed20e
refine
troychiu 27266a4
restore not needed
troychiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package apiserversdk | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1" | ||
) | ||
|
||
func TestCreateCluster(t *testing.T) { | ||
tCtx, err := NewEnd2EndTestingContext(t) | ||
require.NoError(t, err, "No error expected when creating testing context") | ||
rayClient := tCtx.GetRayHttpClient() | ||
rayCluster := &rayv1.RayCluster{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: tCtx.GetRayClusterName(), | ||
Namespace: tCtx.GetNamespaceName(), | ||
}, | ||
Spec: rayv1.RayClusterSpec{ | ||
HeadGroupSpec: rayv1.HeadGroupSpec{ | ||
RayStartParams: map[string]string{}, | ||
Template: corev1.PodTemplateSpec{ | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
{Name: "test", Image: "test"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
_, err = rayClient.RayClusters(tCtx.GetNamespaceName()).Create(tCtx.GetCtx(), rayCluster, metav1.CreateOptions{}) | ||
require.NoError(t, err) | ||
|
||
actualCluster, err := rayClient.RayClusters(tCtx.GetNamespaceName()).Get(tCtx.GetCtx(), tCtx.GetRayClusterName(), metav1.GetOptions{}) | ||
require.NoError(t, err) | ||
require.Equal(t, tCtx.GetRayClusterName(), actualCluster.Name) | ||
require.Equal(t, rayCluster.Spec, actualCluster.Spec) | ||
|
||
err = rayClient.RayClusters(tCtx.GetNamespaceName()).Delete(tCtx.GetCtx(), tCtx.GetRayClusterName(), metav1.DeleteOptions{}) | ||
require.NoError(t, err) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package apiserversdk | ||
|
||
const ( | ||
RayImage = "rayproject/ray:2.9.0" | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package apiserversdk | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/onsi/gomega" | ||
"github.com/stretchr/testify/require" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/ray-project/kuberay/apiserver/test/e2e" | ||
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1" | ||
) | ||
|
||
func TestGetRayClusterEvent(t *testing.T) { | ||
tCtx, err := NewEnd2EndTestingContext(t) | ||
require.NoError(t, err, "No error expected when creating testing context") | ||
rayClient := tCtx.GetRayHttpClient() | ||
rayCluster := &rayv1.RayCluster{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: tCtx.GetRayClusterName(), | ||
Namespace: tCtx.GetNamespaceName(), | ||
}, | ||
Spec: rayv1.RayClusterSpec{ | ||
HeadGroupSpec: rayv1.HeadGroupSpec{ | ||
RayStartParams: map[string]string{}, | ||
Template: corev1.PodTemplateSpec{ | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
{Name: "test", Image: "test"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
_, err = rayClient.RayClusters(tCtx.GetNamespaceName()).Create(tCtx.GetCtx(), rayCluster, metav1.CreateOptions{}) | ||
require.NoError(t, err) | ||
|
||
k8sClient := tCtx.GetK8sHttpClient() | ||
g := gomega.NewWithT(t) | ||
g.Eventually(func() bool { | ||
events, err := k8sClient.CoreV1().Events(tCtx.GetNamespaceName()).List(tCtx.GetCtx(), metav1.ListOptions{}) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
for _, e := range events.Items { | ||
if e.InvolvedObject.Name == tCtx.GetRayClusterName() && e.InvolvedObject.Kind == "RayCluster" { | ||
return true | ||
} | ||
} | ||
return false | ||
}, e2e.TestTimeoutShort, e2e.TestPollingInterval).Should(gomega.BeTrue(), "Expected to see RayCluster event in the list of events") | ||
|
||
err = rayClient.RayClusters(tCtx.GetNamespaceName()).Delete(tCtx.GetCtx(), tCtx.GetRayClusterName(), metav1.DeleteOptions{}) | ||
require.NoError(t, err) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package apiserversdk | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1" | ||
) | ||
|
||
func TestGetRayClusterProxy(t *testing.T) { | ||
tCtx, err := NewEnd2EndTestingContext(t) | ||
require.NoError(t, err, "No error expected when creating testing context") | ||
rayClient := tCtx.GetRayHttpClient() | ||
rayCluster := &rayv1.RayCluster{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: tCtx.GetRayClusterName(), | ||
Namespace: tCtx.GetNamespaceName(), | ||
}, | ||
Spec: rayv1.RayClusterSpec{ | ||
HeadGroupSpec: rayv1.HeadGroupSpec{ | ||
RayStartParams: map[string]string{}, | ||
Template: corev1.PodTemplateSpec{ | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
{ | ||
Name: "ray-head", | ||
Image: tCtx.GetRayImage(), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
_, err = rayClient.RayClusters(tCtx.GetNamespaceName()).Create(tCtx.GetCtx(), rayCluster, metav1.CreateOptions{}) | ||
require.NoError(t, err) | ||
|
||
// Wait for the Ray cluster's head pod to be ready so that we can access the dashboard | ||
waitForClusterConditions(t, tCtx, tCtx.GetRayClusterName(), []rayv1.RayClusterConditionType{rayv1.HeadPodReady}) | ||
|
||
k8sClient := tCtx.GetK8sHttpClient() | ||
serviceName := tCtx.GetRayClusterName() + "-head-svc" | ||
r := k8sClient.CoreV1().Services(tCtx.GetNamespaceName()).ProxyGet("http", serviceName, "8265", "", nil) | ||
resp, err := r.DoRaw(tCtx.GetCtx()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(resp), "Ray Dashboard") | ||
|
||
err = rayClient.RayClusters(tCtx.GetNamespaceName()).Delete(tCtx.GetCtx(), tCtx.GetRayClusterName(), metav1.DeleteOptions{}) | ||
require.NoError(t, err) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to update Helm chart's RBAC? If you plan to open a follow up PR for Helm chart, can you open an issue to track the progress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think we should. Thank you for catching this. Let me create an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #3648