Illumina Innovates with Rancher and Kubernetes
A namespace is a Kubernetes concept that allows a virtual cluster within a cluster, which is useful for dividing the cluster into separate “virtual clusters” that each have their own access control and resource quotas.
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:
A namespace is a concept introduced by Kubernetes. According to the official Kubernetes documentation on namespaces,
Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces. […] Namespaces are intended for use in environments with many users spread across multiple teams, or projects. For clusters with a few to tens of users, you should not need to create or think about namespaces at all.
Namespaces provide the following functionality:
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 kubectl, it may be unusable because kubectl doesn’t require the new namespace to be scoped within a certain project.
kubectl
If your permissions are restricted to the project level, it is better to create a namespace through Rancher 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.
In terms of hierarchy:
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:
When you create a cluster, two projects are automatically created within it:
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.
default
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.
Available as of v2.0.7
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.
system
To open it, open the Global menu, and then select the system project for your cluster.
The system project:
v3/settings/system-namespaces
Note: In clusters where both: The Canal network plug-in is in use. The Project Network Isolation option is enabled. The system project overrides the Project Network Isolation option so that it can communicate with other projects, collect logs, and check health.
Note: In clusters where both:
The system project overrides the Project Network Isolation option so that it can communicate with other projects, collect logs, and check health.
Standard users are only authorized for project access in two situations:
Rancher extends Kubernetes to allow the application of Pod Security Policies at the project level in addition to the cluster level. However, as a best practice, we recommend applying Pod Security Policies at the cluster level.
This section describes how to create a new project with a name and with optional pod security policy, members, and resource quotas.
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 Creating Pod Security Policies.
Assigning a PSP to a project will:
Use the Members section to provide other users with project access and roles.
By default, your user is added as the project Owner.
Owner
Notes on Permissions: Users assigned the Owner or Member role for a project automatically inherit the namespace creation role. However, this role is a Kubernetes ClusterRole, meaning its scope extends to all projects in the cluster. Therefore, users explicitly assigned the Owner or Member role for a project can create namespaces in other projects they’re assigned to, even with only the Read Only role assigned. Choose Custom to create a custom role on the fly: Custom Project Roles.
Notes on Permissions:
Member
namespace creation
Read Only
Custom
To add members:
Available as of v2.1.0
Resource quotas limit the resources that a project (and its namespaces) can consume. For more information, see Resource Quotas.
To add a resource quota,
Result: Your project is created. You can view it from the cluster’s Projects/Namespaces view.
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.