2017-03-14 04:32:17 +00:00
|
|
|
---
|
|
|
|
title: Federated Namespaces
|
2017-04-26 21:13:54 +00:00
|
|
|
redirect_from:
|
|
|
|
- "/docs/user-guide/federation/namespaces/"
|
|
|
|
- "/docs/user-guide/federation/namespaces.html"
|
2017-03-14 04:32:17 +00:00
|
|
|
---
|
|
|
|
|
2017-04-20 19:55:32 +00:00
|
|
|
{% capture overview %}
|
|
|
|
This guide explains how to use Namespaces in Federation control plane.
|
2017-03-14 04:32:17 +00:00
|
|
|
|
2017-04-20 19:55:32 +00:00
|
|
|
Namespaces in federation control plane (referred to as "federated Namespaces" in
|
2017-03-14 04:32:17 +00:00
|
|
|
this guide) are very similar to the traditional [Kubernetes
|
2017-04-19 17:56:47 +00:00
|
|
|
Namespaces](/docs/concepts/overview/working-with-objects/namespaces/) providing the same functionality.
|
2017-03-14 04:32:17 +00:00
|
|
|
Creating them in the federation control plane ensures that they are synchronized
|
|
|
|
across all the clusters in federation.
|
2017-04-20 19:55:32 +00:00
|
|
|
{% endcapture %}
|
2017-03-14 04:32:17 +00:00
|
|
|
|
2017-04-20 19:55:32 +00:00
|
|
|
{% capture prerequisites %}
|
|
|
|
|
|
|
|
* {% include federated-task-tutorial-prereqs.md %}
|
|
|
|
* You are also expected to have a basic
|
|
|
|
[working knowledge of Kubernetes](/docs/setup/pick-right-solution/) in
|
|
|
|
general and [Namespaces](/docs/concepts/overview/working-with-objects/namespaces/) in particular.
|
|
|
|
|
|
|
|
{% endcapture %}
|
|
|
|
|
|
|
|
{% capture steps %}
|
2017-03-14 04:32:17 +00:00
|
|
|
|
|
|
|
## Creating a Federated Namespace
|
|
|
|
|
|
|
|
The API for Federated Namespaces is 100% compatible with the
|
2017-04-20 19:55:32 +00:00
|
|
|
API for traditional Kubernetes Namespaces. You can create a Namespace by sending
|
2017-03-14 04:32:17 +00:00
|
|
|
a request to the federation apiserver.
|
|
|
|
|
|
|
|
You can do that using kubectl by running:
|
|
|
|
|
|
|
|
``` shell
|
|
|
|
kubectl --context=federation-cluster create -f myns.yaml
|
|
|
|
```
|
|
|
|
|
|
|
|
The '--context=federation-cluster' flag tells kubectl to submit the
|
|
|
|
request to the Federation apiserver instead of sending it to a Kubernetes
|
|
|
|
cluster.
|
|
|
|
|
2017-04-20 19:55:32 +00:00
|
|
|
Once a federated Namespace is created, the federation control plane will create
|
|
|
|
a matching Namespace in all underlying Kubernetes clusters.
|
2017-03-14 04:32:17 +00:00
|
|
|
You can verify this by checking each of the underlying clusters, for example:
|
|
|
|
|
|
|
|
``` shell
|
|
|
|
kubectl --context=gce-asia-east1a get namespaces myns
|
|
|
|
```
|
|
|
|
|
|
|
|
The above assumes that you have a context named 'gce-asia-east1a'
|
|
|
|
configured in your client for your cluster in that zone. The name and
|
2017-04-20 19:55:32 +00:00
|
|
|
spec of the underlying Namespace will match those of
|
2017-03-14 04:32:17 +00:00
|
|
|
the Federated Namespace that you created above.
|
|
|
|
|
|
|
|
|
|
|
|
## Updating a Federated Namespace
|
|
|
|
|
2017-04-20 19:55:32 +00:00
|
|
|
You can update a federated Namespace as you would update a Kubernetes
|
|
|
|
Namespace, just send the request to federation apiserver instead of sending it
|
2017-03-14 04:32:17 +00:00
|
|
|
to a specific Kubernetes cluster.
|
2017-04-20 19:55:32 +00:00
|
|
|
Federation control plan will ensure that whenever the federated Namespace is
|
|
|
|
updated, it updates the corresponding Namespaces in all underlying clusters to
|
2017-03-14 04:32:17 +00:00
|
|
|
match it.
|
|
|
|
|
|
|
|
## Deleting a Federated Namespace
|
|
|
|
|
2017-04-20 19:55:32 +00:00
|
|
|
You can delete a federated Namespace as you would delete a Kubernetes
|
|
|
|
Namespace, just send the request to federation apiserver instead of sending it
|
2017-03-14 04:32:17 +00:00
|
|
|
to a specific Kubernetes cluster.
|
|
|
|
|
|
|
|
For example, you can do that using kubectl by running:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
kubectl --context=federation-cluster delete ns myns
|
|
|
|
```
|
|
|
|
|
2017-04-20 19:55:32 +00:00
|
|
|
As in Kubernetes, deleting a federated Namespace will delete all resources in that
|
|
|
|
Namespace from the federation control plane.
|
2017-03-14 04:32:17 +00:00
|
|
|
|
2017-04-20 19:55:32 +00:00
|
|
|
Note that at this point, deleting a federated Namespace will not delete the
|
|
|
|
corresponding Namespace and resources in those Namespaces from underlying clusters.
|
2017-03-14 04:32:17 +00:00
|
|
|
Users are expected to delete them manually.
|
|
|
|
We intend to fix this in the future.
|
2017-04-20 19:55:32 +00:00
|
|
|
|
|
|
|
{% endcapture %}
|
|
|
|
|
2017-04-26 21:13:54 +00:00
|
|
|
{% include templates/task.md %}
|