A project is a group of namespaces, and it is a concept introduced by Rancher. Projects allow you to manage multiple namespaces as a group and perform Kubernetes operations in them. You can use projects to support multi-tenancy, so that a team can access a project within a cluster without having access to other projects in the same cluster.
This section describes how projects and namespaces work with Rancher. It covers the following topics:
About Namespaces
A namespace is a concept introduced by Kubernetes. According to the
Namespaces provide the following functionality:
- Providing a scope for names: Names of resources need to be unique within a namespace, but not across namespaces. Namespaces can not be nested inside one another and each Kubernetes resource can only be in one namespace.
You can assign resources at the project level so that each namespace in the project can use them. You can also bypass this inheritance by assigning resources explicitly to a namespace.
You can assign the following resources directly to namespaces:
To manage permissions in a vanilla Kubernetes cluster, cluster admins configure role-based access policies for each namespace. With Rancher, user permissions are assigned on the project level instead, and permissions are automatically inherited by any namespace owned by the particular project.
For more information on creating and moving namespaces, see Namespaces.
Because projects are a concept introduced by Rancher, kubectl does not have the capability to restrict the creation of namespaces to a project the creator has access to.
This means that when standard users with project-scoped permissions create a namespaces with , it may be unusable because kubectl
doesn’t require the new namespace to be scoped within a certain project.
If your permissions are restricted to the project level, it is better to to ensure that you will have permission to access the namespace.
If a standard user is a project owner, the user will be able to create namespaces within that project. The Rancher UI will prevent that user from creating namespaces outside the scope of the projects they have access to.
About Projects
- Clusters contain projects
- Projects contain namespaces
You can use projects to support multi-tenancy, so that a team can access a project within a cluster without having access to other projects in the same cluster.
In the base version of Kubernetes, features like role-based access rights or cluster resources are assigned to individual namespaces. A project allows you to save time by giving an individual or a team access to multiple namespaces simultaneously.
You can use projects to perform actions such as:
- Assign users to a group of namespaces (i.e., ).
- Assign users specific roles in a project. A role can be owner, member, read-only, or custom.
- Assign resources to the project.
- Assign Pod Security Policies.
When you create a cluster, two projects are automatically created within it:
The Cluster’s Default Project
When you provision a cluster with Rancher, it automatically creates a default
project for the cluster. This is a project you can use to get started with your cluster, but you can always delete it and replace it with projects that have more descriptive names.
If you don’t have a need for more than the default namespace, you also do not need more than the Default project in Rancher.
If you require another level of organization beyond the Default project, you can create more projects in Rancher to isolate namespaces, applications and resources.
When troubleshooting, you can view the system
project to check if important namespaces in the Kubernetes system are working properly. This easily accessible project saves you from troubleshooting individual system namespace containers.
To open it, open the Global menu, and then select the system
project for your cluster.
The project:
- Is automatically created when you provision a cluster.
- Lists all namespaces that exist in
v3/settings/system-namespaces
, if they exist. - Allows you to add more namespaces or move its namespaces to other projects.
- Cannot be deleted because it’s required for cluster operations.
Project Authorization
Standard users are only authorized for project access in two situations:
- An administrator, cluster owner or cluster member explicitly adds the standard user to the project’s Members tab.
Pod Security Policies
Rancher extends Kubernetes to allow the application of Pod Security Policies at the in addition to the cluster level. However, as a best practice, we recommend applying Pod Security Policies at the cluster level.
Creating Projects
1. Name a New Project
From the Global view, choose Clusters from the main menu. From the Clusters page, open the cluster from which you want to create a project.
From the main menu, choose Projects/Namespaces. Then click Add Project.
Enter a Project Name.
This option is only available if you’ve already created a Pod Security Policy. For instruction, see .
Assigning a PSP to a project will:
- Override the cluster’s default PSP.
- Apply the PSP to the project.
- Apply the PSP to any namespaces you add to the project later.
3. Recommended: Add Project Members
Use the Members section to provide other users with project access and roles.
By default, your user is added as the project Owner
.
To add members:
- Click Add Member.
- From the Name combo box, search for a user or group that you want to assign project access. Note: You can only search for groups if external authentication is enabled.
- From the Role drop-down, choose a role. For more information, refer to the
Resource quotas limit the resources that a project (and its namespaces) can consume. For more information, see Resource Quotas.
To add a resource quota,
- Click Add Quota.
- Select a Resource Type. For more information, see .
- Enter values for the Project Limit and the Namespace Default Limit.
- Optional: Specify Container Default Resource Limit, which will be applied to every container started in the project. The parameter is recommended if you have CPU or Memory limits set by the Resource Quota. It can be overridden on per an individual namespace or a container level. For more information, see Container Default Resource Limit
- Click Create.
Result: Your project is created. You can view it from the cluster’s Projects/Namespaces view.
Switching between Clusters and Projects
To switch between clusters and projects, use the Global drop-down available in the main menu.
Alternatively, you can switch between projects and clusters using the main menu.
- To switch between clusters, open the Global view and select Clusters from the main menu. Then open a cluster.