Skip to content
Merged
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
61 changes: 61 additions & 0 deletions src/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Virtualization
Subcommand for the command line client for Deckhouse.
Manages virtual machine-related operations in your Kubernetes cluster.

### Available Commands:
* console - Connect to a console of a virtual machine.
* port-forward - Forward local ports to a virtual machine
* scp - SCP files from/to a virtual machine.
* ssh - Open an ssh connection to a virtual machine.
* vnc - Open a vnc connection to a virtual machine.
* start - Start a virtual machine.
* stop - Stop a virtual machine.
* restart - Restart a virtual machine.
* evict - Evict a virtual machine.

### Examples
#### console
```shell
d8 virtualization console myvm
d8 virtualization console myvm.mynamespace
```
#### port-forward
```shell
d8 virtualization port-forward myvm tcp/8080:8080
d8 virtualization port-forward --stdio=true myvm.mynamespace 22
```
#### scp
```shell
d8 virtualization scp myfile.bin user@myvm:myfile.bin
d8 virtualization scp user@myvm:myfile.bin ~/myfile.bin
```
#### ssh
```shell
d8 virtualization --identity-file=/path/to/ssh_key ssh user@myvm.mynamespace
d8 virtualization ssh --local-ssh=true --namespace=mynamespace --username=user myvm
```
#### vnc
```shell
d8 virtualization vnc myvm.mynamespace
d8 virtualization vnc myvm -n mynamespace
```
#### start
```shell
d8 virtualization start myvm.mynamespace --wait
d8 virtualization start myvm -n mynamespace
```
#### stop
```shell
d8 virtualization stop myvm.mynamespace --force
d8 virtualization stop myvm -n mynamespace
```
#### restart
```shell
d8 virtualization restart myvm.mynamespace --timeout=1m
d8 virtualization restart myvm -n mynamespace
```
#### evict
```shell
d8 virtualization evict myvm.mynamespace
d8 virtualization evict myvm -n mynamespace
```
21 changes: 21 additions & 0 deletions src/cli/Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# https://taskfile.dev

version: "3"

silent: true

tasks:
build:
cmds:
- go build -o out/d8v cmd/main.go
install:
deps: [build]
cmds:
- echo "Check that ~/.local/bin in your PATH"
- echo "Installing d8v to ~/.local/bin"
- mkdir -p ~/.local/bin
- cp out/d8v ~/.local/bin/d8v
- task: clean
clean:
cmds:
- rm -rf out
30 changes: 30 additions & 0 deletions src/cli/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
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 main

import (
"os"

"github.com/deckhouse/virtualization/src/cli/pkg/command"
)

func main() {
virtCmd, _ := command.NewCommand(os.Args[0])
if err := virtCmd.Execute(); err != nil {
os.Exit(1)
}
}
74 changes: 74 additions & 0 deletions src/cli/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module github.com/deckhouse/virtualization/src/cli

go 1.23.6

toolchain go1.24.0

require (
github.com/deckhouse/deckhouse-cli v0.12.1
github.com/deckhouse/virtualization/api v0.15.0
github.com/gorilla/websocket v1.5.3
github.com/povsister/scp v0.0.0-20250504051308-e467f71ea63c
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
golang.org/x/crypto v0.33.0
golang.org/x/sys v0.30.0
golang.org/x/term v0.29.0
golang.org/x/text v0.22.0
k8s.io/apimachinery v0.32.2
k8s.io/client-go v0.32.2
k8s.io/component-base v0.29.3
k8s.io/klog/v2 v2.130.1
)

require github.com/golang/protobuf v1.5.4 // indirect

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.11 // 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
github.com/openshift/api v0.0.0-20230503133300-8bbcb7ca7183 // indirect
github.com/openshift/custom-resource-status v1.1.2 // indirect
github.com/prometheus/client_golang v1.20.4 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/protobuf v1.36.5 // 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/api v0.32.2 // indirect
k8s.io/apiextensions-apiserver v0.29.3 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
kubevirt.io/api v1.2.0 // indirect
kubevirt.io/containerized-data-importer-api v1.57.0-alpha1 // indirect
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading
Loading