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

feat: devbox websocket. #5348

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 9 additions & 4 deletions controllers/devbox/api/v1alpha1/devbox_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ const (
type NetworkType string

const (
NetworkTypeNodePort NetworkType = "NodePort"
NetworkTypeTailnet NetworkType = "Tailnet"
NetworkTypeNodePort NetworkType = "NodePort"
NetworkTypeTailnet NetworkType = "Tailnet"
NetworkTypeWebSocket NetworkType = "WebSocket"
)

type RuntimeRef struct {
Expand All @@ -54,8 +55,9 @@ type RuntimeRef struct {

type NetworkSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=NodePort;Tailnet
// +kubebuilder:validation:Enum=NodePort;Tailnet;WebSocket
Type NetworkType `json:"type"`

// +kubebuilder:validation:Optional
ExtraPorts []corev1.ContainerPort `json:"extraPorts"`
}
Expand Down Expand Up @@ -137,12 +139,15 @@ type DevboxSpec struct {

type NetworkStatus struct {
// +kubebuilder:default=NodePort
// +kubebuilder:validation:Enum=NodePort;Tailnet
// +kubebuilder:validation:Enum=NodePort;Tailnet;WebSocket
Type NetworkType `json:"type"`

// +kubebuilder:validation:Optional
NodePort int32 `json:"nodePort"`

// +kubebuilder:validation:Optional
WebSocket string `json:"webSocket"`

// todo TailNet
// +kubebuilder:validation:Optional
TailNet string `json:"tailnet"`
Expand Down
16 changes: 13 additions & 3 deletions controllers/devbox/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func main() {
var enablePodEnvMatcher bool
var enablePodPortMatcher bool
var enablePodEphemeralStorageMatcher bool
// websocket flag
var webSocketImage string
var websocketProxyDomain string
var ingressClass string

flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
Expand Down Expand Up @@ -113,7 +117,10 @@ func main() {
flag.BoolVar(&enablePodEnvMatcher, "enable-pod-env-matcher", true, "If set, pod env matcher will be enabled")
flag.BoolVar(&enablePodPortMatcher, "enable-pod-port-matcher", true, "If set, pod port matcher will be enabled")
flag.BoolVar(&enablePodEphemeralStorageMatcher, "enable-pod-ephemeral-storage-matcher", false, "If set, pod ephemeral storage matcher will be enabled")

//websocket flag
flag.StringVar(&webSocketImage, "websocket-image", "cbluebird/wst:v0.0.4", "The image name of devbox websocket proxy pod.")
flag.StringVar(&websocketProxyDomain, "websocket-proxy-domain", "sealoshzh.site", "The websocket proxy domain of devbox ingress.")
flag.StringVar(&ingressClass, "ingress-class", "nginx", "The ingress class name.")
opts := zap.Options{
Development: true,
}
Expand Down Expand Up @@ -231,8 +238,11 @@ func main() {
DefaultLimit: resource.MustParse(limitEphemeralStorage),
MaximumLimit: resource.MustParse(maximumLimitEphemeralStorage),
},
PodMatchers: podMatchers,
DebugMode: debugMode,
PodMatchers: podMatchers,
DebugMode: debugMode,
WebSocketImage: webSocketImage,
WebsocketProxyDomain: websocketProxyDomain,
IngressClass: ingressClass,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Devbox")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,7 @@ spec:
enum:
- NodePort
- Tailnet
- WebSocket
type: string
required:
- type
Expand Down Expand Up @@ -2988,6 +2989,9 @@ spec:
enum:
- NodePort
- Tailnet
- WebSocket
type: string
webSocket:
type: string
required:
- type
Expand Down
Loading
Loading