Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ const (

// ProjectCloneDisable specifies that project cloning should be disabled.
ProjectCloneDisable = "disable"

// DefaultHostUsers is the default value for spec.hostUsers in pod security context.
// When true (default), containers run in the host's user namespace. When false,
// Kubernetes creates a dedicated user namespace for the pod (requires user namespace support).
// See: https://kubernetes.io/docs/concepts/workloads/pods/user-namespaces/
DefaultHostUsers = true
)

const (
Expand Down
6 changes: 6 additions & 0 deletions pkg/constants/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const (
// DevWorkspaceIdleTimeout contains env var name which value is the suggested idle timeout
DevWorkspaceIdleTimeout = "DEVWORKSPACE_IDLE_TIMEOUT"

// DevWorkspaceHostUsers contains the env var name whose value indicates whether the container
// runs in the host's user namespace. When set to "false", container images should adjust their
// logic to work in a dedicated user namespace (e.g., file permissions, UID/GID handling).
// See: https://github.com/devfile/developer-images/pull/232
DevWorkspaceHostUsers = "HOST_USERS"

// DevWorkspaceComponentName contains env var name which indicates from which devfile container component
// the container is created from. Note the flattened devfile is used to evaluate it.
DevWorkspaceComponentName = "DEVWORKSPACE_COMPONENT_NAME"
Expand Down
12 changes: 10 additions & 2 deletions pkg/library/env/workspaceenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (
"fmt"
"os"

"github.com/devfile/devworkspace-operator/pkg/provision/workspace"

dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
devfileConstants "github.com/devfile/devworkspace-operator/pkg/library/constants"
"github.com/devfile/devworkspace-operator/pkg/provision/workspace"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"

"github.com/devfile/devworkspace-operator/pkg/common"
"github.com/devfile/devworkspace-operator/pkg/constants"
Expand Down Expand Up @@ -84,6 +84,14 @@ func commonEnvironmentVariables(workspaceWithConfig *common.DevWorkspaceWithConf
},
}

hostUsers := pointer.BoolDeref(workspaceWithConfig.Config.Workspace.HostUsers, constants.DefaultHostUsers)
if !hostUsers {
envvars = append(envvars, corev1.EnvVar{
Name: constants.DevWorkspaceHostUsers,
Value: "false",
})
}

envvars = append(envvars, getProxyEnvVars(workspaceWithConfig.Config.Routing.ProxyConfig)...)
envvars = append(envvars, getSshAskPassEnvVars()...)

Expand Down
Loading