Skip to content
Draft
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
27 changes: 27 additions & 0 deletions api/pkg/apiserver/api/generated/openapi/zz_generated.openapi.go

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

1 change: 1 addition & 0 deletions api/subresources/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var (
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&VirtualMachineConsole{},
&VirtualMachineUsbRedir{},
&VirtualMachineVNC{},
&VirtualMachinePortForward{},
&VirtualMachineAddVolume{},
Expand Down
8 changes: 8 additions & 0 deletions api/subresources/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ import (
// +genclient:readonly
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type VirtualMachineUsbRedir struct {
metav1.TypeMeta
}

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

type VirtualMachineConsole struct {
metav1.TypeMeta
}
Expand Down
1 change: 1 addition & 0 deletions api/subresources/v1alpha2/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var (
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&VirtualMachineConsole{},
&VirtualMachineUsbRedir{},
&VirtualMachineVNC{},
&VirtualMachinePortForward{},
&VirtualMachineAddVolume{},
Expand Down
9 changes: 9 additions & 0 deletions api/subresources/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:conversion-gen:explicit-from=net/url.Values

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

// +genclient
// +genclient:readonly
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:conversion-gen:explicit-from=net/url.Values

type VirtualMachineConsole struct {
metav1.TypeMeta `json:",inline"`
}
Expand Down
44 changes: 44 additions & 0 deletions api/subresources/v1alpha2/zz_generated.conversion.go

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

25 changes: 25 additions & 0 deletions api/subresources/v1alpha2/zz_generated.deepcopy.go

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

25 changes: 25 additions & 0 deletions api/subresources/zz_generated.deepcopy.go

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

4 changes: 3 additions & 1 deletion images/virt-artifact/werf.inc.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# Source https://github.com/kubevirt/kubevirt/blob/v1.3.1/hack/dockerized#L15
{{- $version := "v1.3.1" }}
{{- $tag := print $version "-v12n.7"}}
{{- $tag := print $version "-virtualization-hotplug-experiments"}}

{{- $name := print $.ImageName "-dependencies" -}}
{{- define "$name" -}}
Expand Down Expand Up @@ -43,8 +43,10 @@ shell:

{{- include "alt packages clean" . | nindent 2 }}

installCacheVersion: "{{ now | date "Mon Jan 2 15:04:05 MST 2006" }}" # <--- для пересборки
install:
- |
echo $date
mkdir -p ~/.ssh && echo "StrictHostKeyChecking accept-new" > ~/.ssh/config
git config --global --add advice.detachedHead false
git clone --depth=1 $(cat /run/secrets/SOURCE_REPO)/deckhouse/3p-kubevirt --branch {{ $tag }} /kubevirt
Expand Down
2 changes: 1 addition & 1 deletion images/virt-handler/werf.inc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
image: {{ $.ImageName }}
fromImage: distroless
fromImage: BASE_ALT_P11
import:
- image: {{ $.ImageName }}-bins
add: /relocate
Expand Down
20 changes: 20 additions & 0 deletions images/virt-launcher/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ packages:
- policycoreutils
- psmisc
- msulogin
- usbutils
- htop
- iproute2
binaries:
# Gnu utils (requared for swtpm)
Expand All @@ -128,6 +130,22 @@ binaries:
- /usr/bin/ocsptool
- /usr/bin/p11tool
- /usr/bin/psktool
# Debug
- /usr/bin/usbhid-dump
# Debug2
- /usr/bin/pgrep
- /usr/bin/bash
- /usr/bin/ls
- /usr/bin/lsusb
- /usr/bin/lspci
- /usr/bin/htop
- /usr/bin/ps
- /usr/bin/cat
- /usr/bin/grep
- /usr/bin/mkdir
- /usr/bin/mount
- /usr/bin/chmod
- /usr/bin/mknod
# Xorriso (Creates an image of an ISO9660 filesystem)
- /usr/bin/xorriso-dd-target /usr/bin/xorrisofs /usr/bin/xorriso
# Swtpm
Expand Down Expand Up @@ -310,6 +328,8 @@ shell:
LIBS+=" /usr/lib64/libtpms* /usr/lib64/libjson* /usr/lib64/libfuse*"
LIBS+=" /usr/lib64/libxml2.s* /usr/lib64/libgcc_s* /usr/lib64/libaudit*"
LIBS+=" /usr/lib64/libisoburn.s*"
LIBS+=" /usr/lib64/libgbm.s*"
LIBS+=" /usr/lib64/libusbredirparser.s*"

echo "Relocate additional libs for files in /VBINS"
./relocate_binaries.sh -i "$FILES" -o /VBINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func Build(store *storage.VirtualMachineStorage) genericapiserver.APIGroupInfo {
resources := map[string]rest.Storage{
"virtualmachines": store,
"virtualmachines/console": store.ConsoleREST(),
"virtualmachines/usbredir": store.UsbRedirREST(),
"virtualmachines/vnc": store.VncREST(),
"virtualmachines/portforward": store.PortForwardREST(),
"virtualmachines/addvolume": store.AddVolumeREST(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
Copyright 2024 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 rest

import (
"context"
"fmt"
"net/http"
"net/url"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"

"github.com/deckhouse/virtualization-controller/pkg/tls/certmanager"
virtlisters "github.com/deckhouse/virtualization/api/client/generated/listers/core/v1alpha2"
"github.com/deckhouse/virtualization/api/subresources"
)

type UsbRedirREST struct {
vmLister virtlisters.VirtualMachineLister
proxyCertManager certmanager.CertificateManager
kubevirt KubevirtAPIServerConfig
}

var (
_ rest.Storage = &UsbRedirREST{}
_ rest.Connecter = &UsbRedirREST{}
)

func NewUsbRedirREST(vmLister virtlisters.VirtualMachineLister, kubevirt KubevirtAPIServerConfig, proxyCertManager certmanager.CertificateManager) *UsbRedirREST {
return &UsbRedirREST{
vmLister: vmLister,
kubevirt: kubevirt,
proxyCertManager: proxyCertManager,
}
}

// New implements rest.Storage interface
func (r UsbRedirREST) New() runtime.Object {
return &subresources.VirtualMachineUsbRedir{}
}

// Destroy implements rest.Storage interface
func (r UsbRedirREST) Destroy() {
}

func (r UsbRedirREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
usbRedirOpts, ok := opts.(*subresources.VirtualMachineUsbRedir)
if !ok {
return nil, fmt.Errorf("invalid options object: %#v", opts)
}
location, transport, err := UsbRedirLocation(ctx, r.vmLister, name, usbRedirOpts, r.kubevirt, r.proxyCertManager)
transport.ReadBufferSize = 32 * 1024
transport.WriteBufferSize = 32 * 1024
if err != nil {
return nil, err
}
handler := newThrottledUpgradeAwareProxyHandler(location, transport, true, responder, r.kubevirt.ServiceAccount)
return handler, nil
}

// NewConnectOptions implements rest.Connecter interface
func (r UsbRedirREST) NewConnectOptions() (runtime.Object, bool, string) {
return &subresources.VirtualMachineUsbRedir{}, false, ""
}

// ConnectMethods implements rest.Connecter interface
func (r UsbRedirREST) ConnectMethods() []string {
return upgradeableMethods
}

func UsbRedirLocation(
ctx context.Context,
getter virtlisters.VirtualMachineLister,
name string,
opts *subresources.VirtualMachineUsbRedir,
kubevirt KubevirtAPIServerConfig,
proxyCertManager certmanager.CertificateManager,
) (*url.URL, *http.Transport, error) {
return streamLocation(
ctx,
getter,
name,
newKVVMIPather("usbredir"),
kubevirt,
proxyCertManager,
virtualMachineNeedRunning,
)
}
Loading
Loading