• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. User Guide 2.0
  4. Cluster Management
  5. Managing Namespaces

Managing Namespaces

Namespaces enable division of cluster resources and objects among multiple users. Typically, namespaces are best suited for scenarios where a large number of users work across multiple projects. Multiple namespaces can be created in a single cluster with the data isolated from each other. This enables namespaces to share the services of the same cluster without affecting each other.

For example, you can deploy applications in a development environment in one namespace, and deploy applications in a test environment in another namespace.

Prerequisites

You have created at least one cluster. For details, see Creating a VM Cluster.

Namespace Types

Namespaces can be created automatically or manually.

  • Created automatically by a cluster: When the cluster is started, the default, kube-public, and kube-system namespaces are created by default.
    • default: Used by default if no namespace is specified.
    • kube-public: Used for deploying public plug-ins and container templates.
    • kube-system: Used for deploying the Kubernetes system components.
  • Created manually: You can create namespaces as required. For example, you can create different namespaces for a development environment, joint debugging environment, and test environment. You can also create namespaces for different applications. For example, you can create one namespace for login services and one for game services.

Creating a Namespace

  1. Log in to the CCE console. In the navigation pane, choose Resource Management > Namespaces, and click Create Namespace.
  2. Set the parameters for creating a namespace listed in Table 1. The parameters marked with an asterisk (*) are mandatory.

    Table 1 Parameters for creating a namespace

    Parameter

    Description

    * Namespace

    Name of the namespace, which must be unique in a cluster.

    * Cluster

    Cluster to which the namespace belongs.

    Description

    Description of the namespace.

  3. Click OK.

Using Namespaces

  • When you create an application, you can select a namespace for it.
  • When you query applications, select a namespace to view all applications in the namespace.

Namespace Application Scenarios

  • Dividing applications into namespaces by environment type

    Before being released, an application generally goes through the phases of development, joint debugging, testing, and production. You can create different clusters or different namespaces in the same cluster.

    • Creating clusters for different environments:

      Resources cannot be shared among different clusters. A load balancer is required in order to enable mutual access between services in different environments.

    • Creating namespaces in the same cluster for different environments:

      Applications in the same namespace access each other using service names, while applications in different namespaces access each other using service names and namespace names.

      Figure 1 shows namespaces respectively created for the development, joint debugging, and testing environments.

      Figure 1 Dividing applications into namespaces by environment type
  • Dividing applications into namespaces by application type

    You are advised to use this method if a large number of applications are deployed in the same environment. As shown in the following figure, different namespaces are created for App 1 and App 2. Applications in a namespace are managed as an application group. Applications in the same namespace access each other using service names, while applications in different namespaces access each other using service names and namespace names.

    Figure 2 Dividing applications into namespaces by application type

Deleting a Namespace

If a namespace is deleted, all resources (such as applications, one-off jobs, and ConfigMaps) in this namespace will be also deleted. Exercise caution when deleting a namespace.

  1. In the navigation pane, choose Resource Management > Namespaces. The Namespaces page is displayed.
  2. In the Clusters drop-down list, select the cluster where the namespace to be deleted is located.
  3. Select the namespace to be deleted and click Delete.

    Follow the prompts to delete the namespace. The built-in namespaces of the system cannot be deleted.