calicoctl create
calicoctl create 명령어는 파일, 디렉터리, 또는 표준 입력(stdin)에서 YAML 또는 JSON 형식으로 Calico 리소스를 생성해요. 이미 존재하는 리소스가 있으면 명령이 실패하므로, 없으면 만들고 있으면 갱신하는 동작을 원한다면 apply를 사용하세요. 이 문서에서는 명령어의 도움말, 예제, 옵션을 소개합니다.
출처: 문서
본문
이 문서는 calicoctl create 명령어를 설명합니다.
calicoctl 명령어 전체 목록은 calicoctl 커맨드라인 인터페이스 사용자 참조를 읽어보세요.
참고: 리소스 타입별로 사용할 수 있는 작업은 Calico가 사용하는 데이터스토어(etcdv3 / Kubernetes API)에 따라 제한될 수 있어요. 각 리소스 타입의 자세한 내용은 리소스 섹션을 참고하세요.
'calicoctl create' 명령어 도움말 표시하기
calicoctl create --help를 실행하면 명령어의 다음 도움말 메뉴가 표시돼요.
Create one or more Calico resources from a file, directory, or stdin, in YAML
or JSON format. Use create when you want the command to fail if a resource
already exists; use apply if you'd rather create-or-update.
Usage:
calicoctl create [flags]
Examples:
# Create resources from a file.
calicoctl create -f ./policy.yaml
# Create resources from stdin.
cat policy.json | calicoctl create -f -
Flags:
-c, --config string Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")
-f, --filename string Filename to use to create/apply/replace/delete the resource. Use '-' for stdin.
-h, --help help for create
-n, --namespace string Namespace of the resource.
-R, --recursive Process the filename specified in -f recursively.
--skip-empty Do not error if files contain no data.
--skip-exists Skip over resources that already exist.
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")
예제
-
resources.yaml의 데이터를 사용해 (타입이 섞인) 리소스 세트를 생성합니다.
calicoctl create -f ./resources.yaml8개의 리소스가 성공적으로 생성되었다는 결과가 표시돼요.
Successfully created 8 resource(s) -
같은 리소스 세트를 표준 입력에서 읽어 생성합니다.
cat resources.yaml | calicoctl create -f -첫 번째 리소스(여기서는 Profile)가 이미 존재하기 때문에 실패했다는 결과가 표시돼요.
Failed to create any resources: resource already exists: Profile(name=profile1)
옵션
-f, --filename string Filename to use to create/apply/replace/delete the resource. Use '-' for stdin.
--skip-exists Skip over resources that already exist.
-n, --namespace string Namespace of the resource.
일반 옵션
-c, --config string Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")
함께 보기
- calicoctl 설치하기
- 파일 형식과 스키마를 포함한 모든 유효한 리소스의 자세한 내용은 리소스(Resources)
- Calico의 셀렉터 기반 정책 모델에 대한 자세한 내용은 NetworkPolicy
더 알아보기 (Learn more)
create는 리소스가 이미 있으면 실패하고, apply는 없으면 만들고 있으면 갱신한다는 차이를 기억해두면 좋아요. 데이터스토어 종류에 따라 사용 가능한 작업이 다르니 Resources 문서도 함께 확인하세요.