mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #7872 from caesarxuchao/nodeselector-example
update node-selector example to API v1beta3
This commit is contained in:
commit
0f7ef8ecab
@ -23,37 +23,34 @@ You can verify that it worked by re-running `kubectl get nodes` and checking tha
|
|||||||
Take whatever pod config file you want to run, and add a nodeSelector section to it, like this. For example, if this is my pod config:
|
Take whatever pod config file you want to run, and add a nodeSelector section to it, like this. For example, if this is my pod config:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
apiVersion: v1beta1
|
apiVersion: v1beta3
|
||||||
desiredState:
|
|
||||||
manifest:
|
|
||||||
containers:
|
|
||||||
- image: nginx
|
|
||||||
name: nginx
|
|
||||||
id: nginx
|
|
||||||
version: v1beta1
|
|
||||||
id: nginx
|
|
||||||
kind: Pod
|
kind: Pod
|
||||||
labels:
|
metadata:
|
||||||
env: test
|
labels:
|
||||||
|
env: test
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
Then add a nodeSelector like so:
|
Then add a nodeSelector like so:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
apiVersion: v1beta1
|
apiVersion: v1beta3
|
||||||
desiredState:
|
|
||||||
manifest:
|
|
||||||
containers:
|
|
||||||
- image: nginx
|
|
||||||
name: nginx
|
|
||||||
id: nginx
|
|
||||||
version: v1beta1
|
|
||||||
id: nginx
|
|
||||||
kind: Pod
|
kind: Pod
|
||||||
labels:
|
metadata:
|
||||||
env: test
|
labels:
|
||||||
<b>nodeSelector:
|
env: test
|
||||||
disktype: ssd</b>
|
name: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
name: nginx
|
||||||
|
<b>nodeSelector:
|
||||||
|
disktype: ssd</b>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
When you then run `kubectl create -f pod.yaml`, the pod will get scheduled on the node that you attached the label to! You can verify that it worked by running `kubectl get pods` and looking at the "host" that the pod was assigned to.
|
When you then run `kubectl create -f pod.yaml`, the pod will get scheduled on the node that you attached the label to! You can verify that it worked by running `kubectl get pods` and looking at the "host" that the pod was assigned to.
|
||||||
|
13
examples/node-selection/pod.yaml
Normal file
13
examples/node-selection/pod.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: v1beta3
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
env: test
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
name: nginx
|
||||||
|
nodeSelector:
|
||||||
|
disktype: ssd
|
Loading…
Reference in New Issue
Block a user