Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b2fe74f
add dra usbip
yaroslavborbat Dec 18, 2025
79b5c77
add
yaroslavborbat Dec 29, 2025
96bd388
fix templates
yaroslavborbat Jan 13, 2026
5d19d3a
fix json patch
yaroslavborbat Jan 13, 2026
c2d0344
fix load modules
yaroslavborbat Jan 13, 2026
a7b93c1
fix map nil panic
yaroslavborbat Jan 13, 2026
747d9c9
fix loading modules for fresh kernels
yaroslavborbat Jan 13, 2026
194656f
fix loading modules for fresh kernels
yaroslavborbat Jan 13, 2026
e17000a
fix loading modules for fresh kernels
yaroslavborbat Jan 13, 2026
6eacc3a
go tidy
yaroslavborbat Jan 13, 2026
d2bcb2d
fix pointer resourceSlice
yaroslavborbat Jan 13, 2026
2f93669
enable USBGateway featureGate
yaroslavborbat Jan 13, 2026
116b827
fix dra feature-gates flags
yaroslavborbat Jan 13, 2026
c66f6b6
support NodeSelector in ResourceSlice
yaroslavborbat Jan 13, 2026
b6f3b08
fix nodeSelector operator
yaroslavborbat Jan 13, 2026
be2fb23
fix poolname
yaroslavborbat Jan 13, 2026
1afdc8c
add new publisher
yaroslavborbat Jan 13, 2026
ccf5a56
fix usb gateway status
yaroslavborbat Jan 14, 2026
9c7c2bb
fix dra usbgateway devices
yaroslavborbat Jan 14, 2026
2dd6552
improve attach
yaroslavborbat Jan 14, 2026
d4df853
fix store empty record
yaroslavborbat Jan 14, 2026
0f17e13
fix recordManager panic
yaroslavborbat Jan 14, 2026
4bb332a
refactor attach
yaroslavborbat Jan 14, 2026
ff2ee73
use sets util
yaroslavborbat Jan 15, 2026
7b76b10
add bindinfo
yaroslavborbat Jan 15, 2026
f40cc55
add license
yaroslavborbat Jan 15, 2026
a11a8b0
fix long
yaroslavborbat Jan 15, 2026
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
36 changes: 35 additions & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,39 @@ tasks:
}
}
}'
kubectl -n d8-virtualization port-forward deploy/virtualization-dra 2345:2345
kubectl -n d8-virtualization port-forward pod/<virtualization-dra-pod> 2345:2345
EOF

dlv:virtualization-dra-usb-gateway:build:
desc: "Build image virtualization-dra-usb-gateway with dlv"
cmds:
- docker build --build-arg BRANCH=$BRANCH -f ./images/virtualization-dra-usb-gateway/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 .

dlv:virtualization-dra-usb-gateway:build-push:
desc: "Build and Push image virtualization-dra-usb-gateway with dlv"
cmds:
- task: dlv:virtualization-dra-usb-gateway:build
- docker push "{{ .DLV_IMAGE }}"
- task: dlv:virtualization-dra-usb-gateway:print

dlv:virtualization-dra-usb-gateway:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
cmd: |
cat <<EOF
kubectl -n d8-virtualization patch ds virtualization-dra-usb-gateway --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [ {
"name": "virtualization-dra-usb-gateway",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ]
}]
}
}
}
}'
kubectl -n d8-virtualization port-forward pod/<virtualization-dra-usb-gateway-pod> 2345:2345
EOF
5 changes: 3 additions & 2 deletions images/virtualization-dra-plugin/debug/dlv.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.24.7-bookworm@sha256:2c5f7a0c252a17cf6aa30ddee15caa0f485ee29410a6ea64cddb62eea2b07bdf AS builder
FROM golang:1.25-bookworm@sha256:019c22232e57fda8ded2b10a8f201989e839f3d3f962d4931375069bbb927e03 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand All @@ -13,13 +13,14 @@ RUN go mod download
COPY ./images/virtualization-dra/cmd /app/images/virtualization-dra/cmd
COPY ./images/virtualization-dra/internal /app/images/virtualization-dra/internal
COPY ./images/virtualization-dra/pkg /app/images/virtualization-dra/pkg
COPY ./images/virtualization-dra/api /app/images/virtualization-dra/api

ENV GO111MODULE=on
ENV GOOS=${TARGETOS:-linux}
ENV GOARCH=${TARGETARCH:-amd64}
ENV CGO_ENABLED=0

RUN go build -tags EE -gcflags "all=-N -l" -a -o virtualization-dra-plugin ./cmd/virtualization-dra-plugin
RUN go build -gcflags "all=-N -l" -a -o virtualization-dra-plugin ./cmd/virtualization-dra-plugin/main.go

FROM busybox:1.36.1-glibc

Expand Down
10 changes: 5 additions & 5 deletions images/virtualization-dra-plugin/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import:
to: /app/virtualization-dra-plugin
after: install
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-plugin" }}
- image: debugger
add: /app/dlv
to: /app/dlv
after: install
- image: debugger
add: /app/dlv
to: /app/dlv
after: install
{{- end }}
imageSpec:
config:
Expand All @@ -22,7 +22,7 @@ imageSpec:
env:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/dlv"
XDG_CONFIG_HOME: "/tmp"
entrypoint: ["/app/dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "/app/virtualization-dra-plugin", "--", "--leader-election=false"]
entrypoint: ["/app/dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "/app/virtualization-dra-plugin", "--"]
{{- else }}
entrypoint: ["/app/virtualization-dra-plugin"]
{{- end }}
32 changes: 32 additions & 0 deletions images/virtualization-dra-usb-gateway/debug/dlv.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM golang:1.25-bookworm@sha256:019c22232e57fda8ded2b10a8f201989e839f3d3f962d4931375069bbb927e03 AS builder
ARG TARGETOS
ARG TARGETARCH

WORKDIR /app/images/virtualization-dra
RUN go install github.com/go-delve/delve/cmd/dlv@latest

COPY ./images/virtualization-dra/go.mod /app/images/virtualization-dra/
COPY ./images/virtualization-dra/go.sum /app/images/virtualization-dra/

RUN go mod download

COPY ./images/virtualization-dra/cmd /app/images/virtualization-dra/cmd
COPY ./images/virtualization-dra/internal /app/images/virtualization-dra/internal
COPY ./images/virtualization-dra/pkg /app/images/virtualization-dra/pkg
COPY ./images/virtualization-dra/api /app/images/virtualization-dra/api

ENV GO111MODULE=on
ENV GOOS=${TARGETOS:-linux}
ENV GOARCH=${TARGETARCH:-amd64}
ENV CGO_ENABLED=0

RUN go build -gcflags "all=-N -l" -a -o virtualization-dra-usb-gateway ./cmd/usb-gateway/main.go

FROM busybox:1.36.1-glibc

WORKDIR /app
COPY --from=builder /go/bin/dlv /app/dlv
COPY --from=builder /app/images/virtualization-dra/virtualization-dra-usb-gateway /app/virtualization-dra-usb-gateway
USER 65532:65532

ENTRYPOINT ["./dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "./virtualization-dra-usb-gateway", "--"]
5 changes: 5 additions & 0 deletions images/virtualization-dra-usb-gateway/mount-points.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# A list of pre-created mount points for containerd strict mode.

dirs:
- /var/run/usb-gateway

28 changes: 28 additions & 0 deletions images/virtualization-dra-usb-gateway/werf.inc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
image: {{ .ModuleNamePrefix }}{{ .ImageName }}
fromImage: {{ .ModuleNamePrefix }}distroless
git:
{{- include "image mount points" . }}
import:
- image: {{ .ModuleNamePrefix }}virtualization-dra-builder
add: /out/virtualization-dra-usb-gateway
to: /app/virtualization-dra-usb-gateway
after: install
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-usb-gateway" }}
- image: debugger
add: /app/dlv
to: /app/dlv
after: install
{{- end }}
imageSpec:
config:
user: 64535
workingDir: "/app"
{{- if eq $.DEBUG_COMPONENT "delve/virtualization-dra-usb-gateway" }}
env:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/dlv"
XDG_CONFIG_HOME: "/tmp"
entrypoint: ["/app/dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "/app/virtualization-dra-usb-gateway", "--"]
{{- else }}
entrypoint: ["/app/virtualization-dra-usb-gateway"]
{{- end }}
10 changes: 10 additions & 0 deletions images/virtualization-dra/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@ tasks:
cmds:
- |
golangci-lint run

build:go-usbip:
desc: "Build go-usbip binary"
cmds:
- go build -o bin/go-usbip cmd/go-usbip/main.go

api:generate:
desc: "Generate API code"
cmds:
- hack/update-codegen.sh
20 changes: 20 additions & 0 deletions images/virtualization-dra/api/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright 2025 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package
// +groupName=dra.virtualization.deckhouse.io

package api
52 changes: 52 additions & 0 deletions images/virtualization-dra/api/sheme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright 2026 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package api

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)

const Version = "v1alpha2"
const Group = "usb-gateway.virtualization.deckhouse.io"

var SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version}

var (
Scheme = runtime.NewScheme()
Codecs = serializer.NewCodecFactory(Scheme)
)

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&USBGatewayStatus{},
)
return nil
}

func init() {
metav1.AddToGroupVersion(Scheme, SchemeGroupVersion)
utilruntime.Must(AddToScheme(Scheme))
}
73 changes: 73 additions & 0 deletions images/virtualization-dra/api/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Copyright 2025 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package api

import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

const USBGatewayStatusKind = "USBGatewayStatus"

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type USBGatewayStatus struct {
metav1.TypeMeta `json:",inline"`

BusID string `json:"busID"`

RemoteIP string `json:"remoteIP"`
RemotePort int `json:"remotePort"`

Bound bool `json:"bound"`
Attached bool `json:"attached"`
}

func FromData(data *runtime.RawExtension) (*USBGatewayStatus, error) {
if data == nil {
return nil, nil
}

obj, err := runtime.Decode(Codecs.UniversalDecoder(SchemeGroupVersion), data.Raw)
if err != nil {
return nil, fmt.Errorf("failed to decode USBGatewayStatus: %w", err)
}
status, ok := obj.(*USBGatewayStatus)
if !ok {
return nil, fmt.Errorf("failed to decode USBGatewayStatus: unexpected object type: %T", obj)
}

return status, nil
}

func ToData(status *USBGatewayStatus) (*runtime.RawExtension, error) {
if status == nil {
return nil, nil
}

raw, err := runtime.Encode(Codecs.LegacyCodec(SchemeGroupVersion), status)
if err != nil {
return nil, fmt.Errorf("failed to encode USBGatewayStatus: %w", err)
}

return &runtime.RawExtension{
Raw: raw,
Object: status,
}, nil
}
51 changes: 51 additions & 0 deletions images/virtualization-dra/api/zz_generated.deepcopy.go

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

Loading
Loading