- Translate reference/command-line-tools-reference/feature-gates.md int… (#22240) - Fix issue of broken links to translated docs (#22105) - Fix issue of document link in some ko documents (#22379) - Translate tasks/administer-cluster/access-cluster-services.md into Ko… (#21776) - Fix issue with 'Linux' and 'Windows' notation in Korean docs (#22362) - Fix issue of broken links to translated docs #2 (#22270) - Fix issue with k8s.io/ko/docs/concepts/overview/kubernetes-api.md (#22261) - Fix issue with k8s.io/ko/docs/concepts/overview/working-with-objects/ (#22263) - Fix incorrect notation of 'directory' into Korean (#22155) - Fix issue with k8s.io/ko/docs/concepts/overview/components.md (#22232) - Update outdated files in dev-1.18-ko.7 (#22128) - Modify spacing term ReplicaSet in Korean (#22148) - Translate tasks/administer-cluster/extended-resource-node.md into Korean (#21849) - Translate tasks/administer-cluster/access-cluster-api.md into Korean (#21730) Co-authored-by: Jerry Park <jaehwa@gmail.com> Co-authored-by: woopyoung <ywp041@gmail.com> Co-authored-by: coolguyhong <podolsmith@naver.com> Co-authored-by: PyungHo Yoon <learder@gmail.com> Co-authored-by: Seokho Son <shsongist@gmail.com> Co-authored-by: jmyung <jesang.myung@gmail.com> Co-authored-by: Ian Y. Choi <ianyrchoi@gmail.com>
2.8 KiB
title, weight
| title | weight |
|---|---|
| 필드 셀렉터 | 60 |
필드 셀렉터 는 한 개 이상의 리소스 필드 값에 따라 쿠버네티스 리소스를 선택하기 위해 사용된다. 필드 셀렉터 쿼리의 예시는 다음과 같다.
metadata.name=my-servicemetadata.namespace!=defaultstatus.phase=Pending
다음의 kubectl 커맨드는 status.phase 필드의 값이 Running 인 모든 파드를 선택한다.
kubectl get pods --field-selector status.phase=Running
{{< note >}}
필드 셀렉터는 본질적으로 리소스 필터 이다. 기본적으로 적용되는 셀렉터나 필드는 없으며, 이는 명시된 종류의 모든 리소스가 선택된다는 것을 의미한다. 여기에 따라오는 kubectl 쿼리인 kubectl get pods 와 kubectl get pods --field-selector "" 는 동일하다.
{{< /note >}}
사용 가능한 필드
사용 가능한 필드는 쿠버네티스의 리소스 종류에 따라서 다르다. 모든 리소스 종류는 metadata.name 과 metadata.namespace 필드 셀렉터를 사용할 수 있다. 사용할 수 없는 필드 셀렉터를 사용하면 다음과 같이 에러를 출력한다.
kubectl get ingress --field-selector foo.bar=baz
Error from server (BadRequest): Unable to find "ingresses" that match label selector "", field selector "foo.bar=baz": "foo.bar" is not a known field selector: only "metadata.name", "metadata.namespace"
사용 가능한 연산자
필드 셀렉터에서 =, ==, != 연산자를 사용할 수 있다 (=와 ==는 동일한 의미이다). 예를 들면, 다음의 kubectl 커맨드는 default 네임스페이스에 속해있지 않은 모든 쿠버네티스 서비스를 선택한다.
kubectl get services --all-namespaces --field-selector metadata.namespace!=default
연계되는 셀렉터
레이블을 비롯한 다른 셀렉터처럼, 쉼표로 구분되는 목록을 통해 필드 셀렉터를 연계해서 사용할 수 있다. 다음의 kubectl 커맨드는 status.phase 필드가 Running 이 아니고, spec.restartPolicy 필드가 Always 인 모든 파드를 선택한다.
kubectl get pods --field-selector=status.phase!=Running,spec.restartPolicy=Always
여러 개의 리소스 종류
필드 셀렉터를 여러 개의 리소스 종류에 걸쳐 사용할 수 있다. 다음의 kubectl 커맨드는 default 네임스페이스에 속해있지 않은 모든 스테이트풀셋(StatefulSet)과 서비스를 선택한다.
kubectl get statefulsets,services --all-namespaces --field-selector metadata.namespace!=default