Skip to content

Commit 51895d0

Browse files
committed
content temporary token VNC
1 parent 67804e8 commit 51895d0

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

modules/virt-temporary-token-VNC.adoc

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/virt-accessing-vm-consoles.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="virt-temporary-token-VNC_{context}"]
7+
= Generating a temporary token for the VNC console
8+
9+
Generate a temporary authentication bearer token for the Kubernetes API to access the VNC of a virtual machine (VM).
10+
11+
[NOTE]
12+
====
13+
Kubernetes also supports authentication using client certificates, instead of a bearer token, by modifying the curl command.
14+
====
15+
16+
.Prerequisites
17+
18+
* A running virtual machine with {VirtProductName} 4.14 or later and xref:../../virt/about-virt/virt-architecture#virt-about-ssp-operator_virt-architecture[`ssp-operator`] 4.14 or later
19+
20+
.Procedure
21+
22+
. Enable the feature gate in the HyperConverged (`HCO`) custom resource (CR):
23+
+
24+
[source,terminal,subs="attributes+"]
25+
----
26+
$ oc patch hyperconverged kubevirt-hyperconverged -n {CNVNamespace} --type json -p '[{"op": "replace", "path": "/spec/featureGates/deployVmConsoleProxy", "value": true}]'
27+
# ...
28+
----
29+
30+
. Generate a token by running the following command:
31+
+
32+
[source,terminal]
33+
----
34+
$ curl --header "Authorization: Bearer ${TOKEN}" \
35+
"https://api.<cluster_fqdn>/apis/token.kubevirt.io/v1alpha1/namespaces/<namespace>/virtualmachines/<vm_name>/vnc?duration=<duration>" <1>
36+
----
37+
<1> Duration can be in hours and minutes, with a minimum duration of 10 minutes. Example: `5h30m`. The token is valid for 10 minutes by default if this parameter is not set.
38+
+
39+
Sample output:
40+
+
41+
[source,terminal]
42+
----
43+
{ "token": "eyJhb..." }
44+
----
45+
46+
. Optional: Use the token provided in the output to create a variable:
47+
+
48+
[source,terminal]
49+
----
50+
$ export VNC_TOKEN="<token>"
51+
----
52+
53+
You can now use the token to access the VNC console of a VM.
54+
55+
.Verification
56+
57+
. Log in to the cluster by running the following command:
58+
+
59+
[source,terminal]
60+
----
61+
$ oc login --token ${VNC_TOKEN}
62+
----
63+
64+
. Use `virtctl` to test access to the VNC console of the VM by running the following command:
65+
+
66+
[source,terminal]
67+
----
68+
$ virtctl vnc <vm_name> -n <namespace>
69+
----

virt/virtual_machines/virt-accessing-vm-consoles.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ include::modules/virt-connecting-to-vm-console-web.adoc[leveloffset=+2]
2323
include::modules/virt-connecting-vm-virtctl.adoc[leveloffset=+2]
2424
:!vnc-console:
2525

26+
:context: vnc-console
27+
include::modules/virt-temporary-token-VNC.adoc[leveloffset=+2]
28+
:!vnc-console:
29+
2630
[id="serial-console_virt-accessing-vm-consoles"]
2731
== Connecting to the serial console
2832

0 commit comments

Comments
 (0)