-
Notifications
You must be signed in to change notification settings - Fork 698
add skeleton code for cache pod manager #4474
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
lw309637554
wants to merge
6
commits into
ray-project:master
Choose a base branch
from
lw309637554:podpool-vk-init
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.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f6a0d56
[PodPool-VK] add podpool vk README (#4250)
lw309637554 a3fcb9e
Fix lint
rueian c70db70
Update podpool-vk/README.md
rueian e934c48
fix lint
rueian d91f9a5
rename podpool-vk to podpool
lw309637554 58fc8cd
feat(cache-pod-manager): add skeleton code for cache pod manager
hzyfox 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "flag" | ||
| "os" | ||
| "os/signal" | ||
| "syscall" | ||
|
|
||
| corev1 "k8s.io/api/core/v1" | ||
| "github.com/spf13/cobra" | ||
| "k8s.io/client-go/kubernetes" | ||
| "k8s.io/client-go/tools/clientcmd" | ||
| "k8s.io/klog/v2" | ||
|
|
||
| "github.com/ray-project/kuberay/podpool/manager" | ||
| ) | ||
|
|
||
| var ( | ||
| kubeconfig string | ||
| nodeName string | ||
| operatingSys string | ||
| arch string | ||
| ) | ||
|
|
||
| func init() { | ||
| flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig file") | ||
| flag.StringVar(&nodeName, "node-name", "cache-pod-node", "Name of the virtual node") | ||
| flag.StringVar(&operatingSys, "os", "linux", "Operating system of the virtual node") | ||
| flag.StringVar(&arch, "arch", "amd64", "Architecture of the virtual node") | ||
| } | ||
|
|
||
| func main() { | ||
| // Create a Cobra command to handle command line arguments | ||
| cmd := &cobra.Command{ | ||
| Use: "cache-pod-manager", | ||
| Short: "Virtual Kubelet-based Cache Pod Manager", | ||
| Long: "A Virtual Kubelet implementation that manages cached pods", | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| run(cmd.Context()) | ||
| }, | ||
| } | ||
|
|
||
| // Execute the command | ||
| if err := cmd.Execute(); err != nil { | ||
| klog.Fatalf("Command execution failed: %v", err) | ||
| } | ||
| } | ||
|
|
||
| func run(ctx context.Context) { | ||
| // Load the Kubernetes configuration | ||
| var config *clientcmd.ClientConfig | ||
| if kubeconfig != "" { | ||
| // Use the provided kubeconfig file | ||
| configOverride := &clientcmd.ConfigOverrides{} | ||
| config = &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig}.ClientConfig() | ||
| } else { | ||
| // Use in-cluster config if available, otherwise fall back to default config | ||
| config = clientcmd.NewNonInteractiveDeferredLoadingClientConfig( | ||
| clientcmd.NewDefaultClientConfigLoadingRules(), | ||
| &configOverride, | ||
| ) | ||
| } | ||
|
|
||
| restConfig, err := config.ClientConfig() | ||
| if err != nil { | ||
| klog.Fatalf("Failed to create Kubernetes client config: %v", err) | ||
| } | ||
|
|
||
| // Create the Kubernetes client | ||
| clientset, err := kubernetes.NewForConfig(restConfig) | ||
| if err != nil { | ||
| klog.Fatalf("Failed to create Kubernetes client: %v", err) | ||
| } | ||
|
|
||
| // Create the CachePodManager | ||
| cachePodManager, err := manager.NewCachePodManager(nodeName, operatingSys, arch, clientset) | ||
| if err != nil { | ||
| klog.Fatalf("Failed to create CachePodManager: %v", err) | ||
| } | ||
|
|
||
| // Set up signal handling for graceful shutdown | ||
| ctx, cancel := context.WithCancel(ctx) | ||
| sigCh := make(chan os.Signal, 1) | ||
| signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) | ||
|
|
||
| // Start the CachePodManager | ||
| if err := cachePodManager.Start(ctx); err != nil { | ||
| klog.Fatalf("Failed to start CachePodManager: %v", err) | ||
| } | ||
|
|
||
| // Set up the pod notifier | ||
| cachePodManager.NotifyPods(ctx, func(pod *corev1.Pod) { | ||
| // Handle pod notifications | ||
| klog.Infof("Received pod notification for %s/%s", pod.Namespace, pod.Name) | ||
| }) | ||
|
|
||
| // Wait for shutdown signal | ||
| select { | ||
| case <-sigCh: | ||
| klog.Info("Received shutdown signal") | ||
| case <-ctx.Done(): | ||
| klog.Info("Context cancelled") | ||
| } | ||
|
|
||
| cancel() | ||
| } | ||
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,21 @@ | ||
| # KubeRay Pod Pool Virtual Kubelet | ||
|
|
||
| KubeRay Pod Pool Virtual Kubelet is an optional and standalone component of the KubeRay Ecosystem. | ||
| It provides warmed-up pod pools by registering itself as a virtual kubelet to a Kubernetes cluster. | ||
| When KubeRay requests pods from the virtual kubelet, | ||
| the actual pods are taken from one of the pod pools specified by the users and effectively skip: | ||
|
|
||
| * resource scheduling time | ||
| * image pulling time | ||
| * volume preparation time | ||
| because those pods are already active and waiting in pools. | ||
|
|
||
| <!-- TODO: Add docs for local development --> | ||
|
|
||
| ## controller | ||
|
|
||
| pod pool controller | ||
|
|
||
| ## manager | ||
|
|
||
| watch pod which scheduled by kubernetes, pick and sync pod status from pod pool to kubernetes |
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,3 @@ | ||
| package main | ||
|
|
||
| func main() {} |
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 @@ | ||
| package controller |
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,50 @@ | ||
| module github.com/ray-project/kuberay/podpool | ||
|
|
||
| go 1.22.0 | ||
|
|
||
| toolchain go1.24.8 | ||
|
|
||
| require ( | ||
| github.com/virtual-kubelet/virtual-kubelet v1.11.0 | ||
| k8s.io/api v0.29.1 | ||
| k8s.io/apimachinery v0.29.1 | ||
| k8s.io/client-go v0.29.1 | ||
| ) | ||
|
|
||
| require ( | ||
| github.com/davecgh/go-spew v1.1.1 // indirect | ||
| github.com/emicklei/go-restful/v3 v3.11.0 // indirect | ||
| github.com/go-logr/logr v1.4.1 // indirect | ||
| github.com/go-openapi/jsonpointer v0.19.6 // indirect | ||
| github.com/go-openapi/jsonreference v0.20.2 // indirect | ||
| github.com/go-openapi/swag v0.22.3 // indirect | ||
| github.com/gogo/protobuf v1.3.2 // indirect | ||
| github.com/golang/protobuf v1.5.4 // indirect | ||
| github.com/google/gnostic-models v0.6.8 // indirect | ||
| github.com/google/go-cmp v0.6.0 // indirect | ||
| github.com/google/gofuzz v1.2.0 // indirect | ||
| github.com/google/uuid v1.3.1 // indirect | ||
| github.com/josharian/intern v1.0.0 // indirect | ||
| github.com/json-iterator/go v1.1.12 // indirect | ||
| github.com/mailru/easyjson v0.7.7 // indirect | ||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
| github.com/modern-go/reflect2 v1.0.2 // indirect | ||
| github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
| golang.org/x/net v0.23.0 // indirect | ||
| golang.org/x/oauth2 v0.11.0 // indirect | ||
| golang.org/x/sys v0.18.0 // indirect | ||
| golang.org/x/term v0.18.0 // indirect | ||
| golang.org/x/text v0.14.0 // indirect | ||
| golang.org/x/time v0.3.0 // indirect | ||
| google.golang.org/appengine v1.6.7 // indirect | ||
| google.golang.org/protobuf v1.33.0 // indirect | ||
| gopkg.in/inf.v0 v0.9.1 // indirect | ||
| gopkg.in/yaml.v2 v2.4.0 // indirect | ||
| gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| k8s.io/klog/v2 v2.130.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.3.0 // indirect | ||
| ) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Command-line flags never parsed or connected to Cobra
High Severity
The flags (
kubeconfig,node-name,os,arch) are defined using the standardflagpackage ininit(), but themain()function uses Cobra for command execution without integrating these flags. Since neitherflag.Parse()is called norcmd.Flags().AddGoFlagSet(flag.CommandLine)is used to connect the standard library flags to Cobra, all command-line arguments will be ignored. The variables will always have their default values regardless of user input.