Skip to content

Commit f971fd0

Browse files
authored
chore(core): move deckhouse-cli v command into v12n repo (#1045)
Move virtualization subcommand to virtualization repository from deckhouse/deckhouse-cli. --------- Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
1 parent d840e0c commit f971fd0

31 files changed

Lines changed: 3853 additions & 0 deletions

src/cli/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Virtualization
2+
Subcommand for the command line client for Deckhouse.
3+
Manages virtual machine-related operations in your Kubernetes cluster.
4+
5+
### Available Commands:
6+
* console - Connect to a console of a virtual machine.
7+
* port-forward - Forward local ports to a virtual machine
8+
* scp - SCP files from/to a virtual machine.
9+
* ssh - Open an ssh connection to a virtual machine.
10+
* vnc - Open a vnc connection to a virtual machine.
11+
* start - Start a virtual machine.
12+
* stop - Stop a virtual machine.
13+
* restart - Restart a virtual machine.
14+
* evict - Evict a virtual machine.
15+
16+
### Examples
17+
#### console
18+
```shell
19+
d8 virtualization console myvm
20+
d8 virtualization console myvm.mynamespace
21+
```
22+
#### port-forward
23+
```shell
24+
d8 virtualization port-forward myvm tcp/8080:8080
25+
d8 virtualization port-forward --stdio=true myvm.mynamespace 22
26+
```
27+
#### scp
28+
```shell
29+
d8 virtualization scp myfile.bin user@myvm:myfile.bin
30+
d8 virtualization scp user@myvm:myfile.bin ~/myfile.bin
31+
```
32+
#### ssh
33+
```shell
34+
d8 virtualization --identity-file=/path/to/ssh_key ssh user@myvm.mynamespace
35+
d8 virtualization ssh --local-ssh=true --namespace=mynamespace --username=user myvm
36+
```
37+
#### vnc
38+
```shell
39+
d8 virtualization vnc myvm.mynamespace
40+
d8 virtualization vnc myvm -n mynamespace
41+
```
42+
#### start
43+
```shell
44+
d8 virtualization start myvm.mynamespace --wait
45+
d8 virtualization start myvm -n mynamespace
46+
```
47+
#### stop
48+
```shell
49+
d8 virtualization stop myvm.mynamespace --force
50+
d8 virtualization stop myvm -n mynamespace
51+
```
52+
#### restart
53+
```shell
54+
d8 virtualization restart myvm.mynamespace --timeout=1m
55+
d8 virtualization restart myvm -n mynamespace
56+
```
57+
#### evict
58+
```shell
59+
d8 virtualization evict myvm.mynamespace
60+
d8 virtualization evict myvm -n mynamespace
61+
```

src/cli/Taskfile.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://taskfile.dev
2+
3+
version: "3"
4+
5+
silent: true
6+
7+
tasks:
8+
build:
9+
cmds:
10+
- go build -o out/d8v cmd/main.go
11+
install:
12+
deps: [build]
13+
cmds:
14+
- echo "Check that ~/.local/bin in your PATH"
15+
- echo "Installing d8v to ~/.local/bin"
16+
- mkdir -p ~/.local/bin
17+
- cp out/d8v ~/.local/bin/d8v
18+
- task: clean
19+
clean:
20+
cmds:
21+
- rm -rf out

src/cli/cmd/main.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright 2024 Flant JSC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"os"
21+
22+
"github.com/deckhouse/virtualization/src/cli/pkg/command"
23+
)
24+
25+
func main() {
26+
virtCmd, _ := command.NewCommand(os.Args[0])
27+
if err := virtCmd.Execute(); err != nil {
28+
os.Exit(1)
29+
}
30+
}

src/cli/go.mod

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
module github.com/deckhouse/virtualization/src/cli
2+
3+
go 1.23.6
4+
5+
toolchain go1.24.0
6+
7+
require (
8+
github.com/deckhouse/deckhouse-cli v0.12.1
9+
github.com/deckhouse/virtualization/api v0.15.0
10+
github.com/gorilla/websocket v1.5.3
11+
github.com/povsister/scp v0.0.0-20250504051308-e467f71ea63c
12+
github.com/spf13/cobra v1.8.1
13+
github.com/spf13/pflag v1.0.5
14+
golang.org/x/crypto v0.33.0
15+
golang.org/x/sys v0.30.0
16+
golang.org/x/term v0.29.0
17+
golang.org/x/text v0.22.0
18+
k8s.io/apimachinery v0.32.2
19+
k8s.io/client-go v0.32.2
20+
k8s.io/component-base v0.29.3
21+
k8s.io/klog/v2 v2.130.1
22+
)
23+
24+
require github.com/golang/protobuf v1.5.4 // indirect
25+
26+
require (
27+
github.com/beorn7/perks v1.0.1 // indirect
28+
github.com/blang/semver/v4 v4.0.0 // indirect
29+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
30+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
31+
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
32+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
33+
github.com/go-logr/logr v1.4.2 // indirect
34+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
35+
github.com/go-openapi/jsonreference v0.21.0 // indirect
36+
github.com/go-openapi/swag v0.23.0 // indirect
37+
github.com/gogo/protobuf v1.3.2 // indirect
38+
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
39+
github.com/google/go-cmp v0.6.0 // indirect
40+
github.com/google/gofuzz v1.2.0 // indirect
41+
github.com/google/uuid v1.6.0 // indirect
42+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
43+
github.com/josharian/intern v1.0.0 // indirect
44+
github.com/json-iterator/go v1.1.12 // indirect
45+
github.com/klauspost/compress v1.17.11 // indirect
46+
github.com/mailru/easyjson v0.7.7 // indirect
47+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
48+
github.com/modern-go/reflect2 v1.0.2 // indirect
49+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
50+
github.com/openshift/api v0.0.0-20230503133300-8bbcb7ca7183 // indirect
51+
github.com/openshift/custom-resource-status v1.1.2 // indirect
52+
github.com/prometheus/client_golang v1.20.4 // indirect
53+
github.com/prometheus/client_model v0.6.1 // indirect
54+
github.com/prometheus/common v0.60.1 // indirect
55+
github.com/prometheus/procfs v0.15.1 // indirect
56+
github.com/x448/float16 v0.8.4 // indirect
57+
golang.org/x/net v0.35.0 // indirect
58+
golang.org/x/oauth2 v0.25.0 // indirect
59+
golang.org/x/time v0.9.0 // indirect
60+
google.golang.org/protobuf v1.36.5 // indirect
61+
gopkg.in/inf.v0 v0.9.1 // indirect
62+
gopkg.in/yaml.v2 v2.4.0 // indirect
63+
gopkg.in/yaml.v3 v3.0.1 // indirect
64+
k8s.io/api v0.32.2 // indirect
65+
k8s.io/apiextensions-apiserver v0.29.3 // indirect
66+
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
67+
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
68+
kubevirt.io/api v1.2.0 // indirect
69+
kubevirt.io/containerized-data-importer-api v1.57.0-alpha1 // indirect
70+
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 // indirect
71+
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
72+
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
73+
sigs.k8s.io/yaml v1.4.0 // indirect
74+
)

0 commit comments

Comments
 (0)