Skip to content

BE: Generate k8s service on workspace_ports db updates

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

MR: Pending

Description

We want to enable creation of a separate Service in the k8s namespace for the running workspace whenever there is a new record in the workspace_ports table or an existing port's visibility is updated.

The Service should contain relevant port mappings that enable exposure of listed ports to allow TCP traffic through the workspaces-proxy.

This issue is a pre-requisite to allow users to open/close ports from a UI within the workspace. Whenever a workspace port is opened/closed we want to update this information in the db and then either add/remove relevant ports in a Service definition that should be communicated to the gitlab-agent along with other workspace k8s resources so that it can update the Service in Kubernetes.

On workspace creation we want to add the ports defined by the user in the workspace devfile in the endpoints attribute. And these ports should then be added to a new "user-ports" Service. Whenever a port is opened/closed we need to trigger the gitlab-agent to apply these changes to the k8s Service object.

Acceptance Criteria

  • Devfile ports added to workspace_ports table on workspace creation
  • Service object created in k8s cluster that contains ports from the workspace_ports on workspace creation
  • Service object updated and port added to the object when a new workspace port is created
  • Service object updated and port removed from the object when a workspace port is deleted or a workspace is terminated.
  • New workspace_variable created on workspace creation, called GL_WORKSPACE_ID which contains the globalID of the workspace e.g ( gid://gitlab/RemoteDevelopment::Workspace/231)
  • workspace_ports records deleted when a workspace is terminated.
  • Generate URL for accessing OPEN ports
  • URL is no longer accessible after port is closed
  • Add logging/error handling for workspace port creation/update
  • Add unit tests
Edited by 🤖 GitLab Bot 🤖