For the latest Namespaces CLI information, see the Namespaces CLI topic.
The RCTL utility provides the means to manage the lifecycle of namespaces across the fleet of managed clusters. The following operations can be performed on namespaces managed by the controller on the fleet of clusters.
Deploying the namespace can be done for a specific cluster or by cluster labels.
For placement on specific cluster use placementType: ClusterSpecific
For labels use placementType: ClusterLabels
Create a new "managed" namespace in the current Project using the Yaml config spec
The below command is to retrieve/list all "managed namespaces" in the currently specified "Project".
./rctl get namespace
The below command is to retrieve a specific namespace from a project. When viewing a specific namespace, labels and annotations associated with the namespace are also shown
Delete a "managed namespace" in the current project context using the following command. Users are allowed to delete one or more namespaces at once. Below is an example of multiple namespace deletion
Deleting a namespace will also delete the namespace from the clusters where the namespace is published.
./rctl delete ns <ns-name1> <ns-name2>
Important
Managed namespaces cannot be deleted if they are in active use by workloads or blueprints
RCTL provides an option for the users to wait and block the long running operations. When an automation pipeline logic becomes extremely convoluted, enabling the --wait flag helps to block and keep pulling the namespace publish status (example: success/failure)
Once a namespace is created or updated and has all the placement information to publish it on the cluster, the wait flag helps to get the backend information of a namespace creation process flow upto the publishing stage. This get operation continues to wait and show the details and status until the publishing is successful. To view the entire operation details, use the below wait command
rctl publish ns <ns-name> --wait
Note: Use the --wait flag only when publishing the namespace
Example Output
1.643112860864668e+09 debug commands/common.go:126 Prerun
1.643112860864764e+09 info context/context.go:58 Context: {"config_dir":"/Users/gajanan/.rafay/cli","config_file":"config.json","verbose":true,"debug":true,"structured_output":false,"v3":false}
1.643112860864789e+09 debug config/config.go:156 Config path: /Users/gajanan/.rafay/cli/config.json
1.64311286086537e+09 info authprofile/key_profile.go:33 creating headers
1.643112862399913e+09 debug authprofile/key_profile.go:100 GET https://console.stage.rafay.dev/auth/v1/projects/kj3ry4m/
1.643112862400091e+09 debug authprofile/key_profile.go:105 http response ok: {"id":"kj3ry4m","name":"test","description":"","created_at":"2021-09-01T10:19:03.070746Z","modified_at":"2021-09-01T10:19:03.070773Z","partner_id":"rx28oml","organization_id":"g29xn20","default":false}
1.643112862400206e+09 info config/config.go:268 Config: {"profile":"staging","skip_server_cert_check":"false","rest_endpoint":"console.stage.rafay.dev","ops_endpoint":"ops.stage.rafay.dev","project_id":"kj3ry4m","project_name":"test"}
1.64311286240023e+09 debug commands/publish_namespace.go:28 Start [%s %s]rctl publish namespacens-wait-publish-1
1.643112862400266e+09 info authprofile/key_profile.go:33 creating headers
1.643112863502969e+09 debug authprofile/key_profile.go:100 POST https://console.stage.rafay.dev/v2/config/project/kj3ry4m/namespace/ns-wait-publish-1/publish
1.643112863503087e+09 debug authprofile/key_profile.go:105 http response ok: {"metadata":{"name":"ns-wait-publish-1","displayName":"ns-wait-publish-1","createdAt":"2022-01-25T12:14:06.419778Z","modifiedAt":"2022-01-25T12:14:23.676415116Z","annotations":{"a1":"v3","a2":"v4","rafay.dev/resource-hash":"5df8724b27344854b46a991381bc150af680e3df2f97c6f9b541784f95ec4797"},"organizationID":206,"partnerID":1,"projectID":18158,"namespaces":null,"id":"mpxgv52"},"spec":{"metadata":{"name":"ns-wait-publish-1","creationTimestamp":null,"annotations":{"a1":"v3","a2":"v4"}},"spec":{"namespaceMeta":{"name":"ns-wait-publish-1","creationTimestamp":null}},"resourceQuota":{},"limitRange":{},"placement":{"placementType":"ClusterSpecific","clusterSelector":"","driftAction":"DriftReconcillationActionNotSet","clusterLabels":[{"key":"rafay.dev/clusterName","value":"gajanan-test-mks-1"}],"nodeGroupingKeys":null},"type":"RafayWizard","repoArtifactMeta":{}},"status":{"generatedName":"ns-wait-publish-1","publishPending":false,"assignedClusters":null,"deployedClusters":null,"failedClusters":null,"readyClusters":null,"driftedClusters":null,"isDirty":false}}
1.643112863503128e+09 info authprofile/key_profile.go:33 creating headers
1.643112864585084e+09 debug authprofile/key_profile.go:100 GET https://console.stage.rafay.dev/v2/config/project/kj3ry4m/namespace/ns-wait-publish-1
1.643112864585252e+09 debug authprofile/key_profile.go:105 http response ok: {"apiVersion":"config.rafay.dev/v2","kind":"Namespace","metadata":{"name":"ns-wait-publish-1","displayName":"ns-wait-publish-1","createdAt":"2022-01-25T12:14:06.419778Z","modifiedAt":"0001-01-01T00:00:00Z","annotations":{"a1":"v3","a2":"v4"},"organizationID":206,"partnerID":1,"projectID":18158,"namespaces":null,"id":"mpxgv52"},"spec":{"metadata":{"name":"ns-wait-publish-1","creationTimestamp":null,"annotations":{"a1":"v3","a2":"v4"}},"spec":{"namespaceMeta":{"name":"ns-wait-publish-1","creationTimestamp":null}},"resourceQuota":{},"limitRange":{},"placement":{"placementType":"ClusterSpecific","clusterSelector":"","driftAction":"DriftReconcillationActionNotSet","clusterLabels":[{"key":"rafay.dev/clusterName","value":"gajanan-test-mks-1"}],"nodeGroupingKeys":null},"type":"RafayWizard","repoArtifactMeta":{}},"status":{"generatedName":"ns-wait-publish-1","publishPending":false,"assignedClusters":[{"clusterID":"kedy6qm","clusterName":"gajanan-test-mks-1","reason":"assigned"}],"deployedClusters":null,"failedClusters":null,"readyClusters":null,"driftedClusters":null,"conditions":[{"type":"WorkloadSnapshotSchedule","status":"Success","lastUpdated":"2022-01-25T12:14:23.810665771Z","reason":"assigned"},{"type":"WorkloadSnapshotClusterDeployed","status":"Pending","lastUpdated":"2022-01-25T12:14:23.810666056Z","reason":"assigned"}],"isDirty":false}}
1.6431128818360388e+09 info authprofile/key_profile.go:33 creating headers
1.6431128829355211e+09 debug authprofile/key_profile.go:100 GET https://console.stage.rafay.dev/v2/config/project/kj3ry4m/namespace/ns-wait-publish-1
1.643112882935703e+09 debug authprofile/key_profile.go:105 http response ok: {"apiVersion":"config.rafay.dev/v2","kind":"Namespace","metadata":{"name":"ns-wait-publish-1","displayName":"ns-wait-publish-1","createdAt":"2022-01-25T12:14:06.419778Z","modifiedAt":"0001-01-01T00:00:00Z","annotations":{"a1":"v3","a2":"v4"},"organizationID":206,"partnerID":1,"projectID":18158,"namespaces":null,"id":"mpxgv52"},"spec":{"metadata":{"name":"ns-wait-publish-1","creationTimestamp":null,"annotations":{"a1":"v3","a2":"v4"}},"spec":{"namespaceMeta":{"name":"ns-wait-publish-1","creationTimestamp":null}},"resourceQuota":{},"limitRange":{},"placement":{"placementType":"ClusterSpecific","clusterSelector":"","driftAction":"DriftReconcillationActionNotSet","clusterLabels":[{"key":"rafay.dev/clusterName","value":"gajanan-test-mks-1"}],"nodeGroupingKeys":null},"type":"RafayWizard","repoArtifactMeta":{}},"status":{"generatedName":"ns-wait-publish-1","publishPending":false,"assignedClusters":[{"clusterID":"kedy6qm","clusterName":"gajanan-test-mks-1","reason":"assigned"}],"deployedClusters":[{"clusterID":"kedy6qm","clusterName":"gajanan-test-mks-1","reason":"deployed"}],"failedClusters":null,"readyClusters":[{"clusterID":"kedy6qm","clusterName":"gajanan-test-mks-1","reason":"ready"}],"driftedClusters":null,"conditions":[{"type":"WorkloadSnapshotSchedule","status":"Success","lastUpdated":"2022-01-25T12:14:23.810665771Z","reason":"assigned"},{"type":"WorkloadSnapshotClusterDeployed","status":"Success","lastUpdated":"2022-01-25T12:14:40.087796077Z","reason":"deployed"},{"type":"WorkloadSnapshotClusterReady","status":"Success","lastUpdated":"2022-01-25T12:14:42.919541196Z","reason":"ready"}],"isDirty":false}}
1.6431128829358678e+09 debug commands/publish_namespace.go:38 End [rctl publish namespace ns-wait-publish-1]
1.6431128829359019e+09 debug output/exit.go:23 Exit 0