kubectl create ns <YOUR_ENVIRONMENT_NAME>
kubectl label ns <YOUR_ENVIRONMENT_NAME> rtf.mulesoft.com/role=workers rtf.mulesoft.com/envId=<YOUR_ANYPOINT_PLATFORM_ENVIRONMENT_ID>
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
-
As a user with permissions to create a namespace, log in to a Kubernetes workstation.
-
Run the following commands:
-
Replace
<YOUR_ENVIRONMENT_NAME>
with the name of your namespace. -
Replace
<YOUR_ANYPOINT_PLATFORM_ENVIRONMENT_ID>
with the correct ID for your environment.
-
After you run these commands, any application deployed into an Anypoint Platform environment identified by <YOUR_ANYPOINT_PLATFORM_ENVIRONMENT_ID>
is created inside the <YOUR_ENVIRONMENT_NAME>
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
$ kubectl get ns custom-namespace-2 -oyaml
labels:
rtf.mulesoft.com/envId: b164ad54-7e15-4c8b-a7ab-18011a361d81
rtf.mulesoft.com/role: workers
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.