calicoctl get
이 문서는 calicoctl get 명령어를 설명해요. 리소스를 일반 표(table), YAML, JSON, 또는 넓은(wide) 형식으로 조회할 수 있는 명령어예요. calicoctl 명령어 전체 목록은 사용자 레퍼런스 문서에서 확인할 수 있어요.
출처: 문서
본문
이 섹션은 calicoctl get 명령어를 설명해요.
calicoctl 명령어 전체 목록은 calicoctl 명령줄 인터페이스 사용자 레퍼런스에서 확인하세요.
SECONDARY: 특정 리소스 타입에서 사용할 수 있는 액션은 Calico가 사용하는 데이터스토어(etcdv3 / Kubernetes API)에 따라 제한될 수 있어요. 각 리소스 타입에 대한 자세한 내용은 Resources 섹션을 참고하세요.
'calicoctl get' 명령어 도움말 표시하기
calicoctl get --help를 실행하면 다음과 같은 도움말 메뉴가 표시돼요.
Get one or more Calico resources - all resources of a type, specific ones by
name, or those described in a file. Output can be a table (the default), YAML,
JSON, or a custom template; the YAML and JSON output can be fed back into apply
or replace.
Usage:
calicoctl get [KIND [NAME...]] [flags]
Examples:
# List all network policies.
calicoctl get networkpolicy
# Get specific policies as YAML.
calicoctl get networkpolicy my-policy-1 my-policy-2 -o yaml
Flags:
-A, --all-namespaces List the requested object(s) across all namespaces.
-c, --config string Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")
--export Strip cluster-specific information from the output.
-f, --filename string Filename to use to create/apply/replace/delete the resource. Use '-' for stdin.
-h, --help help for get
-n, --namespace string Namespace of the resource.
-o, --output string Output format: yaml, json, ps, wide, custom-columns=..., go-template=..., go-template-file=... (default "ps")
-R, --recursive Process the filename specified in -f recursively.
--skip-empty Do not error if files contain no data.
Global Flags:
--allow-version-mismatch Allow client and cluster versions mismatch
--context string The name of the kubeconfig context to use
-l, --log-level string Set the log level (panic, fatal, error, warn, info, debug) (default "panic")
옵션
-h, --help help for get
-f, --filename string Filename to use to create/apply/replace/delete the resource. Use '-' for stdin.
-o, --output string Output format: yaml, json, ps, wide, custom-columns=..., go-template=..., go-template-file=... (default "ps")
-n, --namespace string Namespace of the resource.
-A, --all-namespaces List the requested object(s) across all namespaces.
--export Strip cluster-specific information from the output.
일반 옵션
-c, --config string Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")
출력 옵션
ps
기본 출력 형식이에요. ps 스타일 표 형태로 출력하며, 리소스를 고유하게 식별할 수 있을 만큼의 컬럼을 보여줘요.
리소스 타입별로 표시되는 헤더는 고정되어 있어요. 대신 추가 컬럼을 표시하려면 wide 옵션을, 표시할 컬럼을 직접 고르려면 custom-columns를 사용하면 돼요.
예시:
calicoctl get hostEndpoint
응답:
NAME NODE
endpoint1 host1
myhost-eth0 myhost
wide
ps 형식과 비슷하게, wide 옵션도 ps 스타일 표로 출력하지만 컬럼이 더 많아요.
리소스 타입별로 표시되는 헤더는 고정되어 있어요. 표시할 컬럼을 고르는 방법은 custom-columns를 참고하세요.
예시:
calicoctl get hostEndpoint --output=wide
응답:
NAME NODE INTERFACE IPS PROFILES
endpoint1 host1 1.2.3.4,0:bb::aa prof1,prof2
myhost-eth0 myhost profile1
custom-columns
ps 형식과 비슷하지만, custom-columns 옵션은 출력에 표시할 컬럼을 순서대로 쉼표로 나열해 지정할 수 있어요. 각 리소스 타입의 유효한 헤더 이름은 Resources 가이드에 정리되어 있어요.
예시:
calicoctl get hostEndpoint --output=custom-columns=NAME,IPS
응답:
NAME IPS
endpoint1 1.2.3.4,0:bb::aa
myhost-eth0
yaml / json
yaml과 json 옵션은 출력을 YAML 문서 목록 또는 JSON 딕셔너리 형태로 보여줘요. 리소스 타입별 필드는 Resources 가이드에 문서화되어 있어요.
이 형식들의 출력은 모든 리소스 관리 명령어의 입력으로 사용할 수 있어요.
예시:
calicoctl get hostEndpoint --output=yaml
응답:
- apiVersion: projectcalico.org/v3
kind: HostEndpoint
metadata:
labels:
type: database
name: endpoint1
spec:
node: host1
expectedIPs:
- 1.2.3.4
- 0:bb::aa
profiles:
- prof1
- prof2
- apiVersion: projectcalico.org/v3
kind: HostEndpoint
metadata:
name: myhost-eth0
spec:
node: myhost
profiles:
- profile1
go-template / go-template-file
go-template와 go-template-file 옵션은 CLI에서 문자열로 지정하거나 별도 파일에 정의한 golang 템플릿을 사용해 출력을 보여줘요. 템플릿을 작성할 때는 템플릿에 전달되는 데이터가 resource-list의 golang 슬라이스라는 점을 유의하세요. resource-list는 libcalico API에 정의되어 있고, 리소스 타입마다 하나의 resource-list가 존재해요. resource-list는 그 자체가 리소스 슬라이스인 Items 필드를 담고 있어요. 따라서 전달된 데이터에서 "Name" 필드를 출력하려면 resource-list 슬라이스와 그 안의 items를 모두 순회해야 해요.
예시:
bin/calicoctl get hostEndpoint --output=go-template="{{range .}}{{range .Items}}{{.ObjectMeta.Name}},{{end}}{{end}}"
endpoint1,eth0,
더 보기
- calicoctl 설치하기
- 파일 형식과 스키마를 포함한 모든 유효한 리소스의 자세한 내용은 Resources를 참고하세요
- Calico 셀렉터 기반 정책 모델의 자세한 내용은 NetworkPolicy를 참고하세요
더 알아보기 (Learn more)
calicoctl get은 Calico 리소스를 조회하는 가장 기본적인 명령어예요. -o 플래그로 출력 형식을 바꿔가며 리소스를 확인해 보세요. 리소스 타입별 필드와 유효한 헤더 이름은 Resources 문서에서 확인할 수 있어요.