mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Merge pull request #11531 from satnam6502/doc26
Fix console output formatting for namespaces doc
This commit is contained in:
commit
f2425f34fb
@ -77,8 +77,8 @@ Look [here](namespaces/) for an in depth example of namespaces.
|
|||||||
|
|
||||||
You can list the current namespaces in a cluster using:
|
You can list the current namespaces in a cluster using:
|
||||||
|
|
||||||
```sh
|
```console
|
||||||
$> kubectl get namespaces
|
$ kubectl get namespaces
|
||||||
NAME LABELS STATUS
|
NAME LABELS STATUS
|
||||||
default <none> Active
|
default <none> Active
|
||||||
kube-system <none> Active
|
kube-system <none> Active
|
||||||
@ -90,14 +90,14 @@ Kubernetes starts with two initial namespaces:
|
|||||||
|
|
||||||
You can also get the summary of a specific namespace using:
|
You can also get the summary of a specific namespace using:
|
||||||
|
|
||||||
```
|
```console
|
||||||
kubectl get namespaces <name>
|
$ kubectl get namespaces <name>
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can get detailed information with:
|
Or you can get detailed information with:
|
||||||
|
|
||||||
```sh
|
```console
|
||||||
$> kubectl describe namespaces <name>
|
$ kubectl describe namespaces <name>
|
||||||
Name: default
|
Name: default
|
||||||
Labels: <none>
|
Labels: <none>
|
||||||
Status: Active
|
Status: Active
|
||||||
@ -143,8 +143,8 @@ More information on the ```finalizers``` field can be found in the namespace [de
|
|||||||
|
|
||||||
Then run:
|
Then run:
|
||||||
|
|
||||||
```
|
```console
|
||||||
kubectl create -f ./my-namespace.yaml
|
$ kubectl create -f ./my-namespace.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
### Setting the namespace for a request
|
### Setting the namespace for a request
|
||||||
@ -153,9 +153,9 @@ To temporarily set the namespace for a request, use the ```--namespace``` flag.
|
|||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```
|
```console
|
||||||
kubectl --namespace=<insert-namespace-name-here> run nginx --image=nginx
|
$ kubectl --namespace=<insert-namespace-name-here> run nginx --image=nginx
|
||||||
kubectl --namespace=<insert-namespace-name-here> get pods
|
$ kubectl --namespace=<insert-namespace-name-here> get pods
|
||||||
```
|
```
|
||||||
|
|
||||||
### Setting the namespace preference
|
### Setting the namespace preference
|
||||||
@ -165,22 +165,22 @@ context.
|
|||||||
|
|
||||||
First get your current context:
|
First get your current context:
|
||||||
|
|
||||||
```sh
|
```console
|
||||||
export CONTEXT=$(kubectl config view | grep current-context | awk '{print $2}')
|
$ export CONTEXT=$(kubectl config view | grep current-context | awk '{print $2}')
|
||||||
```
|
```
|
||||||
|
|
||||||
Then update the default namespace:
|
Then update the default namespace:
|
||||||
|
|
||||||
```sh
|
```console
|
||||||
kubectl config set-context $(CONTEXT) --namespace=<insert-namespace-name-here>
|
$ kubectl config set-context $(CONTEXT) --namespace=<insert-namespace-name-here>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deleting a namespace
|
### Deleting a namespace
|
||||||
|
|
||||||
You can delete a namespace with
|
You can delete a namespace with
|
||||||
|
|
||||||
```
|
```console
|
||||||
kubectl delete namespaces <insert-some-namespace-name>
|
$ kubectl delete namespaces <insert-some-namespace-name>
|
||||||
```
|
```
|
||||||
|
|
||||||
**WARNING, this deletes _everything_ under the namespace!**
|
**WARNING, this deletes _everything_ under the namespace!**
|
||||||
|
Loading…
Reference in New Issue
Block a user