-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Console Access for KubeVirt VMs #268
Comments
Hi @agrare, From the Readme of the KubeVirt provider, it appears that we can connect to the console of VMs (VNC is used in our OpenShift environment). However, on the VM detail page, the In this WIP PR I have added the As a result, the VM Console option is now visible. How should I proceed further from here? Please provide your insights on the next steps or any improvements required. Thank You! |
It looks like there is an API to get a web socket for a VNC console, https://kubevirt.io/api-reference/v1.4.0/operations.html#_v1vnc And the web socket template is |
You'll need to implement the |
Hi @agrare, I used this API: KubeVirt v1.4.0 API Reference I have the following method: def remote_console_acquire_ticket(_userid, _originating_server, _console_type)
url = ext_management_system.with_provider_connection(:namespace => location) do |connection|
Rails.logger.info("Provider connection established: #{connection.inspect}")
token = connection.instance_variable_get(:@conn).instance_variable_get(:@kubevirt_token)
# Construct OpenShift console URL
host = connection.instance_variable_get(:@conn).instance_variable_get(:@host)
base_url = "https://#{host}:6443"
vm_path = "/apis/subresources.kubevirt.io/v1/namespaces/#{location}/virtualmachineinstances/#{name}/vnc"
"#{base_url}#{vm_path}"
end
Rails.logger.info("Generated console URL: #{url}")
{:remote_url => url, :proto => 'remote'}
end The request is sent to this URL correctly from ManageIQ: However, I got the following error:
|
I tested the WebSocket request using Postman by sending it to the same URL: And it successfully connected with the following details:
Could you please confirm if this approach aligns with what’s needed for VNC console access? Let me know if there’s a better way to handle this. |
Console access in MIQ is brokered through the Remote Console Worker so that a user is able to access a console even if they don't have access to the underlying provider. https://www.manageiq.org/docs/guides/remote_consoles I believe you would return that url from the |
Hi @agrare, thanks for your support. How to proceed further |
I would start by implementing the methods described above, running the remote console worker per the docs and testing it out |
Hi @agrare, Is this the correct approach to open a WebSocket request and access the console? def remote_console_acquire_ticket(_userid, _originating_server, _console_type)
begin
kubevirt = ext_management_system.parent_manager.connect(:service => "kubernetes",
:path => "/apis/subresources.kubevirt.io",
:version => "v1")
api_url = kubevirt.rest_client.url
ws_url = api_url.sub('http:', 'wss:').sub('https:', 'wss:')
console_url = "#{ws_url}/namespaces/#{location}/virtualmachineinstances/#{name}/vnc"
Rails.logger.info("Generated WebSocket console URL: #{console_url}")
# Return with additional connection info
{
:remote_url => console_url,
:proto => 'wss',
:token => kubevirt.get_headers[:Authorization],
:connection_options => {
:headers => {
'Origin' => 'https://console-openshift-console.apps.ocp4.int:6443',
'Sec-WebSocket-Protocol' => 'base64.binary.k8s.io',
'Sec-WebSocket-Version' => '13',
'Sec-WebSocket-Key' => 'QTGSxn3c63B53SMw==',
'Connection' => 'Upgrade',
'Upgrade' => 'websocket',
'Sec-WebSocket-Extensions' => 'permessage-deflate; client_max_window_bits',
'Host' => 'console-openshift-console.apps.ocp4.int:6443'
}
}
}
rescue => e
Rails.logger.error("Failed to generate console URL: #{e.message}")
raise MiqException::RemoteConsoleNotSupportedError, "Failed to generate console URL: #{e.message}"
end
end From this code, I generated the following log:
Could you provide guidance on how to proceed further? Specifically:
Thank you! |
ManageIQ currently does not support console access for KubeVirt VMs, a feature that is available for OpenStack instances. Enabling this functionality would allow users to interact directly with their KubeVirt VMs for troubleshooting, configuration and recovery. Please provide your suggestions on how to implement this feature. Thank you for your consideration!
The text was updated successfully, but these errors were encountered: