본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

calicoctl apply

원문 보기 위키 갱신

calicoctl apply 명령어는 파일, 디렉터리, 또는 표준 입력(stdin)에서 YAML 또는 JSON 형식으로 Calico 리소스를 생성하거나 갱신해요. 존재하지 않는 리소스는 추가하고 존재하는 리소스는 업데이트하기 때문에, 리소스가 이미 있는지 신경 쓰지 않아도 될 때 적합합니다. 이 문서에서는 도움말, 예제, 옵션을 소개해요.

출처: 문서

본문

이 문서는 calicoctl apply 명령어를 설명합니다.

calicoctl 명령어 전체 목록은 calicoctl 커맨드라인 인터페이스 사용자 참조를 읽어보세요.

참고: 리소스 타입별로 사용할 수 있는 작업은 Calico가 사용하는 데이터스토어(etcdv3 / Kubernetes API)에 따라 제한될 수 있어요. 각 리소스 타입의 자세한 내용은 리소스 섹션을 참고하세요.

'calicoctl apply' 명령어 도움말 표시하기

calicoctl apply --help를 실행하면 명령어의 다음 도움말 메뉴가 표시돼요.

Create or update one or more Calico resources from a file, directory, or stdin,
in YAML or JSON format. Apply adds resources that don't exist yet and updates
those that do, so it's the right choice when you don't care whether the resource
is already present.

Usage:
  calicoctl apply [flags]

Examples:
  # Apply resources from a file.
  calicoctl apply -f ./policy.yaml

  # Apply resources from stdin.
  cat policy.json | calicoctl apply -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 apply
  -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.

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")

예제

  1. resources.yaml의 데이터를 사용해 (타입이 섞인) 리소스 세트를 적용합니다.

    calicoctl apply -f ./resources.yaml
    

    8개의 리소스가 성공적으로 적용되었다는 결과가 표시돼요.

    Successfully applied 8 resource(s)
    
  2. 표준 입력으로 넘긴 JSON을 기반으로 두 개의 정책 리소스를 적용합니다.

    cat policy.json | calicoctl apply -f -
    

    성공했다는 결과가 표시됩니다.

    Successfully applied 2 'policy' resource(s)
    

옵션

  -f, --filename string    Filename to use to create/apply/replace/delete the resource. Use '-' for stdin.
  -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")

함께 보기

더 알아보기 (Learn more)

apply는 "없으면 만들고 있으면 갱신"이라는 멱등한 동작이라 CI/CD에서 반복 적용하기 좋아요. 존재하지 않으면 실패해야 하는 경우에는 create를, 반대로 반드시 존재해야만 하는 경우에는 replace를 쓰세요.