Contact Us 1-800-596-4880

Creating Namespaces for Application Deployments

Anypoint Runtime Fabric version 1.12 or later enables you to create your own namespaces for application deployments.

When you deploy an application into an Anypoint Platform environment, Runtime Fabric creates a new default namespace using the identifier of the environment. However, if you can create or modify a namespace with the appropriate Kubernetes labels, Runtime Fabric deploys applications into that namespace instead of into the default namespace.

Create A Namespace

  1. As a user with permissions to create a namespace, log in to a Kubernetes workstation.

  2. Run the following commands:

    kubectl create ns <app_namespace>
    kubectl label ns <app_namespace> rtf.mulesoft.com/agentNamespace=<rtf_namespace> rtf.mulesoft.com/role=workers rtf.mulesoft.com/envId=<environment_id> rtf.mulesoft.com/org=<org_id>
    • Replace <app_namespace> with the name of your namespace.

    • Replace <rtf_namespace> with the name of the namespace containing the RTF agent.

    • Replace <environment_id> with the correct ID for your environment.

    • Replace <org_id> with the correct ID for your Business Group.

After you run these commands, any application deployed into an Anypoint Platform environment identified by <environment_id> and <org_id> is created inside the <app_namespace> namespace by the RTF agent running in the <rtf_namespace>. Before you deploy any applications into the new namespace, delete any autogenerated namespaces and any applications in them that use the same environment ID as the new namespace.

Troubleshooting Custom Namespaces

If you encounter errors when attempting to create namespaces for Runtime Fabric, troubleshoot them as follows.

More Than One Namespace Uses the Same Environment ID

Imagine that you created more than one namespace using the same environment ID, as shown in the following example:

$ kubectl get ns custom-namespace-1 -oyaml
labels:
    rtf.mulesoft.com/envId: b164ad54-7e15-4c8b-a7ab-18011a361d81
    rtf.mulesoft.com/role: workers
    rtf.mulesoft.com/agentNamespace=rtf
    rtf.mulesoft.com/org=70be136d-28ec-4395-883f-e5b777a00abc

$ kubectl get ns custom-namespace-2 -oyaml
labels:
    rtf.mulesoft.com/envId: b164ad54-7e15-4c8b-a7ab-18011a361d81
    rtf.mulesoft.com/role: workers
    rtf.mulesoft.com/agentNamespace=rtf
    rtf.mulesoft.com/org=70be136d-28ec-4395-883f-e5b777a00abc

In such cases, Runtime Fabric fails the deployment and creates an error message in Runtime Manager.

Before you delete a namespace, ensure that you have not deployed any production applications into that namespace.