Skip to content

Commit

Permalink
fix: Update example-client to use VMI/vnc endpoint
Browse files Browse the repository at this point in the history
The example client connects to the kubevirt VMI/vnc endpoint.

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
  • Loading branch information
akrejcir committed Jun 29, 2023
1 parent 2758195 commit b89264e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions example-client/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Example VNC client

**This example client currently does not work. It will be fixed in the future.**

This directory contains an example page that uses noVNC library
to connect to the `vn-console-proxy` running on a cluster.

Expand All @@ -9,14 +11,15 @@ make serve-client
```

The client page takes these URL parameters:
- `host` - Hostname for the route. For CRC it will be: `vm-console-kubevirt.apps-crc.testing`
- `host` - Hostname for kubevirt API. For CRC it will be: `api.crc.testing`.
- `port` - Port for kubevirt API. For CRC it will be `6443`.
- `namspace` - Namespace where the VM is.
- `name` - Name of the VM.
- `token` - Token generated using the `/token` endpoint.

For example, the following URL will point the client to a VM after substituting variables:
```
http://localhost:8000/?host=vm-console-kubevirt.apps-crc.testing&namespace=${VM_NAMESPACE}&name=${VM_NAME}&token=${TOKEN}
http://localhost:8000/?host=api.crc.testing&port=6443&namespace=${VM_NAMESPACE}&name=${VM_NAME}&token=${TOKEN}
```

**Note:** If the browser does not trust the TLS certificate from the cluster, only a generic
Expand Down
4 changes: 2 additions & 2 deletions example-client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
.onclick = sendCtrlAltDel;

// Read parameters specified in the URL query string
// By default, use the host and port of server that served this file
const host = readQueryVariable('host');
let port = readQueryVariable('port');

Expand All @@ -153,14 +152,15 @@
if(port) {
url += ':' + port;
}
url += '/api/v1alpha1/' + vmNamespace + '/' + vmName + '/vnc'
url += '/apis/subresources.kubevirt.io/v1/namespaces/' + vmNamespace + '/virtualmachineinstances/'+ vmName +'/vnc'

// Creating a new RFB object will start a new connection
rfb = new RFB(
document.getElementById('screen'),
url,
{
wsProtocols: [
// TODO: Investigate why the web socket request returns 401 Unauthorized.
"base64url.bearer.authorization.k8s.io." + vncToken,
"base64.binary.k8s.io"
]
Expand Down

0 comments on commit b89264e

Please sign in to comment.