mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Improve markdown highlighting in namespaces user guide.
This commit is contained in:
parent
14aa9d8c77
commit
0435f1c333
@ -58,7 +58,7 @@ services, and replication controllers used by the cluster.
|
|||||||
|
|
||||||
Assuming you have a fresh cluster, you can introspect the available namespace's by doing the following:
|
Assuming you have a fresh cluster, you can introspect the available namespace's by doing the following:
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl get namespaces
|
$ kubectl get namespaces
|
||||||
NAME LABELS
|
NAME LABELS
|
||||||
default <none>
|
default <none>
|
||||||
@ -83,7 +83,7 @@ Let's create two new namespaces to hold our work.
|
|||||||
|
|
||||||
Use the file [`namespace-dev.json`](namespace-dev.json) which describes a development namespace:
|
Use the file [`namespace-dev.json`](namespace-dev.json) which describes a development namespace:
|
||||||
|
|
||||||
```js
|
```json
|
||||||
{
|
{
|
||||||
"kind": "Namespace",
|
"kind": "Namespace",
|
||||||
"apiVersion": "v1",
|
"apiVersion": "v1",
|
||||||
@ -98,19 +98,19 @@ Use the file [`namespace-dev.json`](namespace-dev.json) which describes a develo
|
|||||||
|
|
||||||
Create the development namespace using kubectl.
|
Create the development namespace using kubectl.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl create -f docs/user-guide/namespaces/namespace-dev.json
|
$ kubectl create -f docs/user-guide/namespaces/namespace-dev.json
|
||||||
```
|
```
|
||||||
|
|
||||||
And then lets create the production namespace using kubectl.
|
And then lets create the production namespace using kubectl.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl create -f docs/user-guide/namespaces/namespace-prod.json
|
$ kubectl create -f docs/user-guide/namespaces/namespace-prod.json
|
||||||
```
|
```
|
||||||
|
|
||||||
To be sure things are right, let's list all of the namespaces in our cluster.
|
To be sure things are right, let's list all of the namespaces in our cluster.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl get namespaces
|
$ kubectl get namespaces
|
||||||
NAME LABELS STATUS
|
NAME LABELS STATUS
|
||||||
default <none> Active
|
default <none> Active
|
||||||
@ -129,7 +129,7 @@ To demonstrate this, let's spin up a simple replication controller and pod in th
|
|||||||
|
|
||||||
We first check what is the current context:
|
We first check what is the current context:
|
||||||
|
|
||||||
```shell
|
```yaml
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
clusters:
|
clusters:
|
||||||
- cluster:
|
- cluster:
|
||||||
@ -158,7 +158,7 @@ users:
|
|||||||
|
|
||||||
The next step is to define a context for the kubectl client to work in each namespace. The value of "cluster" and "user" fields are copied from the current context.
|
The next step is to define a context for the kubectl client to work in each namespace. The value of "cluster" and "user" fields are copied from the current context.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl config set-context dev --namespace=development --cluster=lithe-cocoa-92103_kubernetes --user=lithe-cocoa-92103_kubernetes
|
$ kubectl config set-context dev --namespace=development --cluster=lithe-cocoa-92103_kubernetes --user=lithe-cocoa-92103_kubernetes
|
||||||
$ kubectl config set-context prod --namespace=production --cluster=lithe-cocoa-92103_kubernetes --user=lithe-cocoa-92103_kubernetes
|
$ kubectl config set-context prod --namespace=production --cluster=lithe-cocoa-92103_kubernetes --user=lithe-cocoa-92103_kubernetes
|
||||||
```
|
```
|
||||||
@ -168,14 +168,17 @@ wish to work against.
|
|||||||
|
|
||||||
Let's switch to operate in the development namespace.
|
Let's switch to operate in the development namespace.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl config use-context dev
|
$ kubectl config use-context dev
|
||||||
```
|
```
|
||||||
|
|
||||||
You can verify your current context by doing the following:
|
You can verify your current context by doing the following:
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl config view
|
$ kubectl config view
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
clusters:
|
clusters:
|
||||||
- cluster:
|
- cluster:
|
||||||
@ -216,13 +219,13 @@ At this point, all requests we make to the Kubernetes cluster from the command l
|
|||||||
|
|
||||||
Let's create some content.
|
Let's create some content.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl run snowflake --image=kubernetes/serve_hostname --replicas=2
|
$ kubectl run snowflake --image=kubernetes/serve_hostname --replicas=2
|
||||||
```
|
```
|
||||||
|
|
||||||
We have just created a replication controller whose replica size is 2 that is running the pod called snowflake with a basic container that just serves the hostname.
|
We have just created a replication controller whose replica size is 2 that is running the pod called snowflake with a basic container that just serves the hostname.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl get rc
|
$ kubectl get rc
|
||||||
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
||||||
snowflake snowflake kubernetes/serve_hostname run=snowflake 2
|
snowflake snowflake kubernetes/serve_hostname run=snowflake 2
|
||||||
@ -237,13 +240,13 @@ And this is great, developers are able to do what they want, and they do not hav
|
|||||||
|
|
||||||
Let's switch to the production namespace and show how resources in one namespace are hidden from the other.
|
Let's switch to the production namespace and show how resources in one namespace are hidden from the other.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl config use-context prod
|
$ kubectl config use-context prod
|
||||||
```
|
```
|
||||||
|
|
||||||
The production namespace should be empty.
|
The production namespace should be empty.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl get rc
|
$ kubectl get rc
|
||||||
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
||||||
|
|
||||||
@ -253,7 +256,7 @@ NAME READY STATUS RESTARTS AGE
|
|||||||
|
|
||||||
Production likes to run cattle, so let's create some cattle pods.
|
Production likes to run cattle, so let's create some cattle pods.
|
||||||
|
|
||||||
```shell
|
```console
|
||||||
$ kubectl run cattle --image=kubernetes/serve_hostname --replicas=5
|
$ kubectl run cattle --image=kubernetes/serve_hostname --replicas=5
|
||||||
|
|
||||||
$ kubectl get rc
|
$ kubectl get rc
|
||||||
|
Loading…
Reference in New Issue
Block a user