A development namespace for me, and a production namespace for the world.
Run a kubectl apply -f dev-prod-namespaces.yaml
or split them into two files and kubectl
apply both of them which look like the following:
apiVersion: v1
kind: Namespace
metadata:
name: development
labels:
name: development
---
```yml
apiVersion: v1
kind: Namespace
metadata:
name: production
labels:
name: production
Now to use these namespaces, simply set the namespace:
in the metadata line 5:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: development
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
To switch namespaces use:
kubectl config set-context --current --namespace=<namespace>