doc/user/workspace/configuration.md
{{< details >}}
{{< /details >}}
{{< history >}}
remote_development_feature_flag enabled on GitLab.com and GitLab Self-Managed in GitLab 16.0.remote_development_feature_flag removed.{{< /history >}}
You can use workspaces to create and manage isolated development environments for your GitLab projects. Each workspace includes its own set of dependencies, libraries, and tools, which you can customize to meet the specific needs of each project.
Before you create a workspace, you must set up your infrastructure only once. To set up infrastructure for workspaces, regardless of cloud provider, you must:
If you use AWS, you can use our OpenTofu tutorial. For more information, see the set up workspaces infrastructure on AWS tutorial.
{{< history >}}
{{< /history >}}
[!warning] Create a workspace only from trusted projects.
Prerequisites:
{{< tabs >}}
{{< tab title="From a project" >}}
{{< /tab >}}
{{< tab title="From a merge request" >}}
{{< /tab >}}
{{< /tabs >}}
The workspace might take a few minutes to start. To open the workspace, under Preview, select the workspace. You also have access to the terminal and can install any necessary dependencies.
When you start a workspace, you can monitor the progress of initialization tasks and postStart
events by checking the workspace logs.
For more information, see the workspace logs directory.
The platform requirements for workspaces depend on your development needs.
For basic workspace functionality, workspaces run on any linux/amd64 Kubernetes cluster that supports
the GitLab agent for Kubernetes, regardless of the underlying operating system.
To choose a method that fits your platform requirements, see configure sudo access for a workspace.
{{< history >}}
{{< /history >}}
Development environments often require building and running containers to manage and use dependencies during runtime. To build and run containers in a workspace, see configure sudo access for a workspace.
{{< history >}}
{{< /history >}}
To use images from private container registries:
name and namespace of this secret to the GitLab agent for Kubernetes configuration.For more information, see image_pull_secrets.
{{< history >}}
{{< /history >}}
Development environments often require sudo permissions to install, configure, and use dependencies during runtime. Choose the method that fits your platform requirements:
| Method | Platform requirements | Usage |
|---|---|---|
| Sysbox | For up-to-date information, see the Sysbox distribution compatibility matrix. | Improves container isolation and enables containers to run the same workloads as virtual machines. |
| Kata Containers | For up-to-date information, see the Kata Containers installation guides. | Lightweight VMs perform like containers but provide enhanced workload isolation and security. |
| User namespaces | Kubernetes version 1.33 or later have the user namespaces enabled behind a Kubernetes feature gate which is enabled by default. For up-to-date information, see the Kubernetes Feature Gates. | No additional runtime installation required. Isolates container users from host users for improved security. |
Prerequisites:
0.Sysbox is a container runtime that improves container isolation and enables containers to run the same workloads as virtual machines.
To configure sudo access with Sysbox:
In your Kubernetes cluster, install Sysbox.
Configure the GitLab agent for Kubernetes:
default_runtime_class,
enter the runtime class for Sysbox. For example, sysbox-runc.allow_privilege_escalation to true.annotations to
{"io.kubernetes.cri-o.userns-mode": "auto:size=65536"}.Kata Containers is a standard implementation of lightweight virtual machines that perform like containers but provide the workload isolation and security of virtual machines.
To configure sudo access with Kata Containers:
In your Kubernetes cluster, install Kata Containers.
Configure the GitLab agent for Kubernetes:
default_runtime_class,
enter the runtime class for Kata Containers. For example, kata-qemu.allow_privilege_escalation to true.User namespaces isolate container users from host users.
To configure sudo access with user namespaces:
In your Kubernetes cluster, configure user namespaces.
Configure the GitLab agent for Kubernetes:
use_kubernetes_user_namespaces to true.allow_privilege_escalation to true.{{< history >}}
{{< /history >}}
Prerequisites:
To connect to a workspace with an SSH client:
Get the external IP address of your gitlab-workspaces-proxy-ssh service:
kubectl -n gitlab-workspaces get service gitlab-workspaces-proxy-ssh
Get the name of the workspace:
Run this command:
ssh <workspace_name>@<ssh_proxy_IP_address>
For the password, enter your personal access token with at least the read_api scope.
When you connect to gitlab-workspaces-proxy through the TCP load balancer,
gitlab-workspaces-proxy examines the username (workspace name) and interacts with GitLab to verify:
You can update your custom workspace images in two ways.
If your workspace image is based on the workspace base image, SSH support is already configured and ready to use. This approach ensures your image has all necessary workspace configurations. For more information, see create a custom workspace image.
If you prefer not to use the workspace base image, you can build from your own base image. If you do this, configure SSH support manually in your runtime images:
sshd in your runtime images.gitlab-workspaces to allow access to your container without a password.The following is an SSH configuration example:
FROM golang:1.20.5-bullseye
# Install `openssh-server` and other dependencies
RUN apt update \
&& apt upgrade -y \
&& apt install openssh-server sudo curl git wget software-properties-common apt-transport-https --yes \
&& rm -rf /var/lib/apt/lists/*
# Permit empty passwords
RUN sed -i 's/nullok_secure/nullok/' /etc/pam.d/common-auth
RUN echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
# Generate a workspace host key
RUN ssh-keygen -A
RUN chmod 775 /etc/ssh/ssh_host_rsa_key && \
chmod 775 /etc/ssh/ssh_host_ecdsa_key && \
chmod 775 /etc/ssh/ssh_host_ed25519_key
# Create a `gitlab-workspaces` user
RUN useradd -l -u 5001 -G sudo -md /home/gitlab-workspaces -s /bin/bash gitlab-workspaces
RUN passwd -d gitlab-workspaces
ENV HOME=/home/gitlab-workspaces
WORKDIR $HOME
RUN mkdir -p /home/gitlab-workspaces && chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home
# Allow sign-in access to `/etc/shadow`
RUN chmod 775 /etc/shadow
USER gitlab-workspaces