This is a cache of https://docs.okd.io/latest/applications/projects/working-with-projects.html. It is a snapshot of the page at 2024-11-23T18:50:12.677+0000.
Working with projects - Projects | Building applications | OKD 4
×

A project allows a community of users to organize and manage their content in isolation from other communities.

Projects starting with openshift- and kube- are default projects. These projects host cluster components that run as pods and other infrastructure components. As such, OKD does not allow you to create projects starting with openshift- or kube- using the oc new-project command. Cluster administrators can create these projects using the oc adm new-project command.

Do not run workloads in or share access to default projects. Default projects are reserved for running core cluster components.

The following default projects are considered highly privileged: default, kube-public, kube-system, openshift, openshift-infra, openshift-node, and other system-created projects that have the openshift.io/run-level label set to 0 or 1. Functionality that relies on admission plugins, such as pod security admission, security context constraints, cluster resource quotas, and image reference resolution, does not work in highly privileged projects.

Creating a project

You can use the OKD web console or the OpenShift cli (oc) to create a project in your cluster.

Creating a project by using the web console

You can use the OKD web console to create a project in your cluster.

Projects starting with openshift- and kube- are considered critical by OKD. As such, OKD does not allow you to create projects starting with openshift- using the web console.

Prerequisites
  • Ensure that you have the appropriate roles and permissions to create projects, applications, and other workloads in OKD.

Procedure
  • If you are using the Administrator perspective:

    1. Navigate to HomeProjects.

    2. click Create Project:

      1. In the Create Project dialog box, enter a unique name, such as myproject, in the Name field.

      2. Optional: Add the Display name and Description details for the project.

      3. click Create.

        The dashboard for your project is displayed.

    3. Optional: Select the Details tab to view the project details.

    4. Optional: If you have adequate permissions for a project, you can use the Project Access tab to provide or revoke admin, edit, and view privileges for the project.

  • If you are using the Developer perspective:

    1. click the Project menu and select Create Project:

      odc create project
      Figure 1. Create project
      1. In the Create Project dialog box, enter a unique name, such as myproject, in the Name field.

      2. Optional: Add the Display name and Description details for the project.

      3. click Create.

    2. Optional: Use the left navigation panel to navigate to the Project view and see the dashboard for your project.

    3. Optional: In the project dashboard, select the Details tab to view the project details.

    4. Optional: If you have adequate permissions for a project, you can use the Project Access tab of the project dashboard to provide or revoke admin, edit, and view privileges for the project.

Creating a project by using the cli

If allowed by your cluster administrator, you can create a new project.

Projects starting with openshift- and kube- are considered critical by OKD. As such, OKD does not allow you to create Projects starting with openshift- or kube- using the oc new-project command. Cluster administrators can create these projects using the oc adm new-project command.

Procedure
  • Run:

    $ oc new-project <project_name> \
        --description="<description>" --display-name="<display_name>"

    For example:

    $ oc new-project hello-openshift \
        --description="This is an example project" \
        --display-name="Hello OpenShift"

The number of projects you are allowed to create might be limited by the system administrator. After your limit is reached, you might have to delete an existing project in order to create a new one.

Viewing a project

You can use the OKD web console or the OpenShift cli (oc) to view a project in your cluster.

Viewing a project by using the web console

You can view the projects that you have access to by using the OKD web console.

Procedure
  • If you are using the Administrator perspective:

    1. Navigate to HomeProjects in the navigation menu.

    2. Select a project to view. The Overview tab includes a dashboard for your project.

    3. Select the Details tab to view the project details.

    4. Select the YAML tab to view and update the YAML configuration for the project resource.

    5. Select the Workloads tab to see workloads in the project.

    6. Select the RoleBindings tab to view and create role bindings for your project.

  • If you are using the Developer perspective:

    1. Navigate to the Project page in the navigation menu.

    2. Select All Projects from the Project drop-down menu at the top of the screen to list all of the projects in your cluster.

    3. Select a project to view. The Overview tab includes a dashboard for your project.

    4. Select the Details tab to view the project details.

    5. If you have adequate permissions for a project, select the Project access tab view and update the privileges for the project.

Viewing a project using the cli

When viewing projects, you are restricted to seeing only the projects you have access to view based on the authorization policy.

Procedure
  1. To view a list of projects, run:

    $ oc get projects
  2. You can change from the current project to a different project for cli operations. The specified project is then used in all subsequent operations that manipulate project-scoped content:

    $ oc project <project_name>

Providing access permissions to your project using the Developer perspective

You can use the Project view in the Developer perspective to grant or revoke access permissions to your project.

Prerequisites
  • You have created a project.

Procedure

To add users to your project and provide Admin, Edit, or View access to them:

  1. In the Developer perspective, navigate to the Project page.

  2. Select your project from the Project menu.

  3. Select the Project Access tab.

  4. click Add access to add a new row of permissions to the default ones.

    odc project permissions
    Figure 2. Project permissions
  5. Enter the user name, click the Select a role drop-down list, and select an appropriate role.

  6. click Save to add the new permissions.

You can also use:

  • The Select a role drop-down list, to modify the access permissions of an existing user.

  • The Remove Access icon, to completely remove the access permissions of an existing user to the project.

Advanced role-based access control is managed in the Roles and Roles Binding views in the Administrator perspective.

Customizing the available cluster roles using the web console

In the Developer perspective of the web console, the ProjectProject access page enables a project administrator to grant roles to users in a project. By default, the available cluster roles that can be granted to users in a project are admin, edit, and view.

As a cluster administrator, you can define which cluster roles are available in the Project access page for all projects cluster-wide. You can specify the available roles by customizing the spec.customization.projectAccess.availableClusterRoles object in the Console configuration resource.

Prerequisites
  • You have access to the cluster as a user with the cluster-admin role.

Procedure
  1. In the Administrator perspective, navigate to AdministrationCluster settings.

  2. click the Configuration tab.

  3. From the Configuration resource list, select Console operator.openshift.io.

  4. Navigate to the YAML tab to view and edit the YAML code.

  5. In the YAML code under spec, customize the list of available cluster roles for project access. The following example specifies the default admin, edit, and view roles:

    apiVersion: operator.openshift.io/v1
    kind: Console
    metadata:
      name: cluster
    # ...
    spec:
      customization:
        projectAccess:
          availableClusterRoles:
          - admin
          - edit
          - view
  6. click Save to save the changes to the Console configuration resource.

Verification
  1. In the Developer perspective, navigate to the Project page.

  2. Select a project from the Project menu.

  3. Select the Project access tab.

  4. click the menu in the Role column and verify that the available roles match the configuration that you applied to the Console resource configuration.

Adding to a project

You can add items to your project by using the +Add page in the Developer perspective.

Prerequisites
  • You have created a project.

Procedure
  1. In the Developer perspective, navigate to the +Add page.

  2. Select your project from the Project menu.

  3. click on an item on the +Add page and then follow the workflow.

You can also use the search feature in the Add* page to find additional items to add to your project. click * under Add at the top of the page and type the name of a component in the search field.

Checking the project status

You can use the OKD web console or the OpenShift cli (oc) to view the status of your project.

Checking project status by using the web console

You can review the status of your project by using the web console.

Prerequisites
  • You have created a project.

Procedure
  • If you are using the Administrator perspective:

    1. Navigate to HomeProjects.

    2. Select a project from the list.

    3. Review the project status in the Overview page.

  • If you are using the Developer perspective:

    1. Navigate to the Project page.

    2. Select a project from the Project menu.

    3. Review the project status in the Overview page.

Checking project status by using the cli

You can review the status of your project by using the OpenShift cli (oc).

Prerequisites
  • You have installed the OpenShift cli (oc).

  • You have created a project.

Procedure
  1. Switch to your project:

    $ oc project <project_name> (1)
    1 Replace <project_name> with the name of your project.
  2. Obtain a high-level overview of the project:

    $ oc status

Deleting a project

You can use the OKD web console or the OpenShift cli (oc) to delete a project.

When you delete a project, the server updates the project status to Terminating from Active. Then, the server clears all content from a project that is in the Terminating state before finally removing the project. While a project is in Terminating status, you cannot add new content to the project. Projects can be deleted from the cli or the web console.

Deleting a project by using the web console

You can delete a project by using the web console.

Prerequisites
  • You have created a project.

  • You have the required permissions to delete the project.

Procedure
  • If you are using the Administrator perspective:

    1. Navigate to HomeProjects.

    2. Select a project from the list.

    3. click the Actions drop-down menu for the project and select Delete Project.

      The Delete Project option is not available if you do not have the required permissions to delete the project.

      1. In the Delete Project? pane, confirm the deletion by entering the name of your project.

      2. click Delete.

  • If you are using the Developer perspective:

    1. Navigate to the Project page.

    2. Select the project that you want to delete from the Project menu.

    3. click the Actions drop-down menu for the project and select Delete Project.

      If you do not have the required permissions to delete the project, the Delete Project option is not available.

      1. In the Delete Project? pane, confirm the deletion by entering the name of your project.

      2. click Delete.

Deleting a project by using the cli

You can delete a project by using the OpenShift cli (oc).

Prerequisites
  • You have installed the OpenShift cli (oc).

  • You have created a project.

  • You have the required permissions to delete the project.

Procedure
  1. Delete your project:

    $ oc delete project <project_name> (1)
    1 Replace <project_name> with the name of the project that you want to delete.