Skip to content

Commit

Permalink
add devbox runtime app port. (#5099)
Browse files Browse the repository at this point in the history
* fix rbac

* add runtime app ports.
  • Loading branch information
lingdie authored Sep 24, 2024
1 parent 94d7e32 commit 103c3ac
Show file tree
Hide file tree
Showing 8 changed files with 320 additions and 47 deletions.
4 changes: 4 additions & 0 deletions controllers/devbox/api/v1alpha1/runtime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ type Config struct {
// +kubebuilder:default={/home/sealos/project/entrypoint.sh}
ReleaseArgs []string `json:"releaseArgs,omitempty"`

// TODO: in v1alpha2 api we need fix the port and app port into one field and create a new type for it.
// +kubebuilder:validation:Optional
// +kubebuilder:default={{name:"devbox-ssh-port",containerPort:22,protocol:TCP}}
Ports []corev1.ContainerPort `json:"ports,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default={{name:"devbox-app-port",port:8080,protocol:TCP}}
AppPorts []corev1.ServicePort `json:"appPorts,omitempty"`

// +kubebuilder:validation:Optional
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions controllers/devbox/api/v1alpha1/zz_generated.deepcopy.go

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

80 changes: 80 additions & 0 deletions controllers/devbox/config/crd/bases/devbox.sealos.io_runtimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,84 @@ spec:
additionalProperties:
type: string
type: object
appPorts:
default:
- name: devbox-app-port
port: 8080
protocol: TCP
items:
description: ServicePort contains information on service's port.
properties:
appProtocol:
description: |-
The application protocol for this port.
This is used as a hint for implementations to offer richer behavior for protocols that they understand.
This field follows standard Kubernetes label syntax.
Valid values are either:
* Un-prefixed protocol names - reserved for IANA standard service names (as per
RFC-6335 and https://www.iana.org/assignments/service-names).
* Kubernetes-defined prefixed names:
* 'kubernetes.io/h2c' - HTTP/2 over cleartext as described in https://www.rfc-editor.org/rfc/rfc7540
* 'kubernetes.io/ws' - WebSocket over cleartext as described in https://www.rfc-editor.org/rfc/rfc6455
* 'kubernetes.io/wss' - WebSocket over TLS as described in https://www.rfc-editor.org/rfc/rfc6455
* Other protocols should use implementation-defined prefixed names such as
mycompany.com/my-custom-protocol.
type: string
name:
description: |-
The name of this port within the service. This must be a DNS_LABEL.
All ports within a ServiceSpec must have unique names. When considering
the endpoints for a Service, this must match the 'name' field in the
EndpointPort.
Optional if only one ServicePort is defined on this service.
type: string
nodePort:
description: |-
The port on each node on which this service is exposed when type is
NodePort or LoadBalancer. Usually assigned by the system. If a value is
specified, in-range, and not in use it will be used, otherwise the
operation will fail. If not specified, a port will be allocated if this
Service requires one. If this field is specified when creating a
Service which does not need it, creation will fail. This field will be
wiped when updating a Service to no longer need it (e.g. changing type
from NodePort to ClusterIP).
More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
format: int32
type: integer
port:
description: The port that will be exposed by this service.
format: int32
type: integer
protocol:
default: TCP
description: |-
The IP protocol for this port. Supports "TCP", "UDP", and "SCTP".
Default is TCP.
type: string
targetPort:
anyOf:
- type: integer
- type: string
description: |-
Number or name of the port to access on the pods targeted by the service.
Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.
If this is a string, it will be looked up as a named port in the
target Pod's container ports. If this is not specified, the value
of the 'port' field is used (an identity map).
This field is ignored for services with clusterIP=None, and should be
omitted or set equal to the 'port' field.
More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service
x-kubernetes-int-or-string: true
required:
- port
type: object
type: array
args:
description: kubebuilder:validation:Optional
items:
Expand Down Expand Up @@ -210,6 +288,8 @@ spec:
- containerPort: 22
name: devbox-ssh-port
protocol: TCP
description: 'TODO: in v1alpha2 api we need fix the port and app
port into one field and create a new type for it.'
items:
description: ContainerPort represents a network port in a single
container.
Expand Down
10 changes: 5 additions & 5 deletions controllers/devbox/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
selector:
matchLabels:
control-plane: controller-manager
replicas: 1
replicas: 2
template:
metadata:
annotations:
Expand Down Expand Up @@ -104,10 +104,10 @@ spec:
# More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
resources:
limits:
cpu: 500m
memory: 128Mi
cpu: 1500m
memory: 2000Mi
requests:
cpu: 10m
memory: 64Mi
cpu: 100m
memory: 640Mi
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10
24 changes: 18 additions & 6 deletions controllers/devbox/config/samples/devbox_v1alpha1_runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,25 @@ metadata:
namespace: devbox-system
spec:
classRef: go
title: go1.23.0
description: go1.23.0
config:
image: ghcr.io/cbluebird/devbox/go1.23.0:2f4067
category:
- ubuntu
- go
image: ghcr.io/labring-actions/devbox/go-1.23.0:409348
ports:
- containerPort: 22
name: devbox-ssh-port
protocol: TCP
appPorts:
- name: devbox-app-port
port: 8080
protocol: TCP
user: sealos
workingDir: /home/sealos/project
releaseCommand:
- /bin/bash
- -c
releaseArgs:
- /home/sealos/project/entrypoint.sh
description: go 1.23.0
version: "1.23.0"
---
apiVersion: devbox.sealos.io/v1alpha1
kind: Runtime
Expand Down
Loading

0 comments on commit 103c3ac

Please sign in to comment.