kube/labels,selectors
This commit is contained in:
parent
f048e2e665
commit
c420721e09
1 changed files with 82 additions and 0 deletions
|
@ -536,3 +536,85 @@ Write
|
|||
secretKeyRef:
|
||||
name: username
|
||||
key: username
|
||||
|
||||
Labels & Selectors
|
||||
==================
|
||||
|
||||
Labels
|
||||
------
|
||||
|
||||
* Key/Value pairs
|
||||
* attached to objects
|
||||
|
||||
Reserved key prefixes:
|
||||
|
||||
* kubernetes.io
|
||||
* k8s.io
|
||||
|
||||
Selectors
|
||||
---------
|
||||
|
||||
* use labels
|
||||
* filter/select objects
|
||||
|
||||
Types:
|
||||
|
||||
* matchLabels: =, ==, !=
|
||||
* matchExpressions: exists, in, notin
|
||||
|
||||
Commands
|
||||
--------
|
||||
|
||||
.. code:: shell
|
||||
|
||||
kubectl \
|
||||
get pod \
|
||||
--show-labels \
|
||||
-n my-namespace
|
||||
|
||||
.. code:: shell
|
||||
|
||||
kubectl \
|
||||
get pod \
|
||||
-l app=my-app,version=1.0 \
|
||||
-n my-namespace
|
||||
|
||||
.. code:: shell
|
||||
|
||||
kubectl \
|
||||
get pod \
|
||||
-l app=my-app,version in (1.0,1.1,1.2) \
|
||||
-n my-namespace
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: my-pod
|
||||
labels:
|
||||
app: my-app
|
||||
version: 1.0
|
||||
spec:
|
||||
containers:
|
||||
- name: my-container
|
||||
image: my-image
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: my-deployment
|
||||
labels:
|
||||
app: my-app
|
||||
spec:
|
||||
containers:
|
||||
- name: my-container
|
||||
image: my-image
|
||||
selector:
|
||||
matchLabels:
|
||||
app: my-app
|
||||
matchExpressions:
|
||||
- {key: version, operator: In, values: ["1.0","1.1","1.2"]}
|
||||
|
||||
|
|
Loading…
Reference in a new issue