Warning
This page was translated from the original Japanese version by PLaMo Translate. The Japanese version is authoritative; the English translation may contain inaccuracies.
Creating Interactive Work Environments
To create an interactive work environment on a cluster, use the Workspace feature. Workspaces are interactive work environments accessible via web browsers. They allow you to utilize PFCP’s computational resources through interfaces like JupyterLab.
Workspace Isolation
There are two isolation units for individual workspace instances: individual users and namespaces. When creating a workspace, you can select either isolation type.
Individual Users
Workspaces isolated by individual users are accessible only by the user who created the workspace. This makes them ideal for securely storing personal credentials such as SSH private keys.
Other users, including organization administrators, cannot access these workspaces. However, organization administrators can still suspend or delete workspaces.
Below is a list of available operations:
| Operation | User who created the workspace | Organization Administrators | Other Users |
|---|---|---|---|
| Access workspace via browser | o | ||
| Update workspace | o | ||
| Suspend running workspace | o | o | |
| Resume suspended workspace | o | ||
| Delete workspace | o | o |
Namespaces
Workspaces isolated by namespaces are accessible to users with the org-edit Role in the namespace where the workspace was created.
This enables sharing workspaces among users with appropriate namespace permissions.
Users without the org-edit Role for the namespace cannot access these workspaces.
Warning
Communication with workspace Pods is not allowed, even from Pods within the same namespace or from other workspaces. For inter-Pod communication, create Pods outside the workspace.
Create a Workspace
Note
Workspaces utilize the compute resources of your organization. If compute resources are insufficient, workspace creation may fail.
Note
Workspaces isolated at the individual user level can only be created in the root namespace. Therefore, creation requires granting either the
org-editororg-workspace-editClusterRole for the root namespace. For information on granting ClusterRoles, see Creating RoleBindings.
- Navigate to the Workspaces page in the portal and click the Create New button.
- Fill out the form and click the Create button.
Accessing a Workspace
- Access the Workspaces page in the portal.
- Click the link in the URL column of the workspace you wish to access.
Suspending and Resuming Workspaces
Warning
Suspending a workspace will delete all data within the workspace. Data stored in PersistentVolumes will be preserved during the suspension period.
Suspending unused workspaces can help conserve compute resources.
- Access the Workspaces page in the portal.
- Select the workspace to suspend and click the Suspend button.
Suspending a workspace can be reversed using the same procedure.
- Access the Workspaces page in the portal.
- Select the workspace to resume and click the Resume button.
Deleting a Workspace
Warning
Deleting a workspace will permanently remove all data within the workspace and any PersistentVolumes created from it.
- Access the Workspaces page in the portal.
- Select the workspace to delete and click the Delete button.
Managing Workspaces Using Kubernetes Manifests
Workspaces can be managed not only through the portal but also using Kubernetes manifests. Using manifests enables automated workspace management and ensures consistent workspace configurations.
Workspace Custom Resource
Each instance of a workspace is represented by a Workspace custom resource.
The Workspace resource creates the actual Pod that constitutes the workspace. You can manage workspaces by creating, updating, or deleting Workspace resources.
Below is an example of a workspace that is isolated at the namespace level, is allocated one MN-Core 2 device, and mounts a 10GiB PersistentVolume at /root/data.
Replace <organization-name> with your actual organization name.
apiVersion: preferred.jp/v1alpha1
kind: Workspace
metadata:
name: my-workspace
namespace: org-<organization-name>
spec:
owner:
type: Namespace
podTemplate:
spec:
containers:
- name: workspace
resources:
requests:
cpu: "4"
limits:
memory: 16Gi
preferred.jp/mncore2: 1
volumeMounts:
- name: data
mountPath: /root/data
volumes:
- name: data
persistentVolumeClaim:
claimName: data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
storageClassName: standard-rwo-<organization-name>
resources:
requests:
storage: 10Gi
In this example, the spec.presetRef field is omitted, applying the default ClusterWorkspacePreset to launch JupyterLab with the MN-Core SDK container image.
Since JupyterLab’s root directory is /root, files saved to /root/data will be accessible from JupyterLab and preserved even when the workspace is suspended.
Apply the manifest to create the workspace.
kubectl apply -f workspace.yaml
The workspace URL can be found in the URLS column of the kubectl get workspace command output.
kubectl -n org-<organization-name> get workspace my-workspace
Tip
You can also check field descriptions by running
kubectl explain workspace.
spec.owner Field
- Specifies the isolation type for the workspace using
spec.owner.type:- Use
Individualfor user-level isolation orNamespacefor namespace-level isolation. - Individual workspaces can only be created in the root namespace (
org-<organization-name>).
- Use
- For
Individualtype,spec.owner.individual.usernamewill be automatically set to the creating user. - This field cannot be modified after creation.
spec.presetRef Field
- Specifies the preset to apply to your workspace.
- If omitted, the
defaultClusterWorkspacePreset will be applied by default.
spec.podTemplate Field
The spec.podTemplate field specifies the configuration for the Pod that will serve as the workspace’s core component in PodTemplateSpec format.
PodTemplateSpec follows the same format as Deployment’s spec.template, corresponding to the metadata and spec sections of a Pod manifest.
Therefore, any content you would normally write in the Pod manifest’s spec (such as container resource requests, volumes, environment variables, and priorityClassName) can be directly specified in spec.podTemplate.spec.
The value in the spec.podTemplate field will override any values specified in the preset.
Unspecified fields will retain their preset values.
Since containers are matched by name, to modify settings for preset containers (workspace in the default preset), define a container with the same name.
Specifying a different named container will result in the container being added instead.
Note
spec.podTemplate.metadata.nameandspec.podTemplate.metadata.namespacecannot be specified.
In the first example, resources and volumeMounts are specified for the workspace container to add resource requests and a PersistentVolume mount to the container defined in the default preset.
spec.volumeClaimTemplates Field
- Specifies a list of PersistentVolumeClaims to be created from the workspace.
metadata.nameis required. - The created PersistentVolumeClaim names will follow the pattern
<metadata.name>-ws-<Workspace Name>. If you specify themetadata.namevalue inspec.podTemplate.spec.volumes[].persistentVolumeClaim.claimName, it is automatically replaced with this name. - Created PersistentVolumeClaims will be deleted when the workspace is deleted.
- To use an existing PersistentVolumeClaim, specify the name of a PersistentVolumeClaim in the same namespace as the Workspace in
claimName. However,Individualtype workspaces cannot use existing PersistentVolumeClaims, so usespec.volumeClaimTemplatesinstead. - For StorageClass, you can specify either block storage’s
standard-rwo-<organization-name>or file storage’sstandard-rwx-<organization-name>(ReadWriteMany).
spec.suspend Field
- Setting to
truewill suspend the workspace, and setting back tofalsewill resume it.
Presets
You can pre-define configurations for the actual Pods that form workspaces as presets. Defining presets simplifies management of workspaces with similar configurations.
Presets define default values for the spec.podTemplate field that will be applied to workspaces.
When creating the actual Pods for a workspace from the Workspace resource, any fields not specified in the spec.podTemplate field of the Workspace resource will be inherited from the preset.
Fields specified in the spec.podTemplate field will override these values and the Pod will be created accordingly.
There are two types of presets: ClusterWorkspacePreset Custom Resource and WorkspacePreset Custom Resource.
ClusterWorkspacePreset Custom Resource
ClusterWorkspacePreset Custom Resources are shared presets available across PFCP-managed clusters. They are usable by workspaces across all organizations.
Available ClusterWorkspacePreset resources can be checked using the kubectl get clusterworkspacepreset command (or kubectl get cwspreset).
You can select the desired ClusterWorkspacePreset by configuring the spec.presetRef field in the Workspace resource as follows:
apiVersion: preferred.jp/v1alpha1
kind: Workspace
spec:
presetRef:
apiVersion: preferred.jp/v1alpha1
kind: ClusterWorkspacePreset
name: NAME
If the spec.presetRef field is omitted, the default ClusterWorkspacePreset will be applied.
Excerpting some values from the default ClusterWorkspacePreset, it looks like this:
apiVersion: preferred.jp/v1alpha1
kind: ClusterWorkspacePreset
metadata:
name: default
spec:
podTemplate:
spec:
containers:
- name: workspace
image: registry.pfcomputing.internal/mncore-sdk/mncore-sdk-full
command:
- /app/jupyter/bin/jupyter
- lab
If the spec.podTemplate field in the Workspace resource is not specified, a Pod will be created with a workspace container that launches JupyterLab using the MN-Core SDK container image according to these values.
You can override this default configuration by specifying container images, commands, etc. in the spec.podTemplate field.
Additionally, you can configure resource requests for the workspace container and add containers other than the workspace container.
WorkspacePreset Custom Resource
WorkspacePreset Custom Resources are shared presets available at the namespace level.
Users with the org-edit Role for the namespace can create, update, or delete these resources.
WorkspacePreset resources present in the namespace can be checked using the kubectl get workspacepreset command (or kubectl get wspreset).
You can select the desired WorkspacePreset by configuring the spec.presetRef field in the Workspace resource as follows:
apiVersion: preferred.jp/v1alpha1
kind: Workspace
spec:
presetRef:
apiVersion: preferred.jp/v1alpha1
kind: WorkspacePreset
name: NAME
Note
For a Workspace to reference a WorkspacePreset, the Workspace and WorkspacePreset must reside in the same namespace.