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

calicoctl replace

원문 보기 위키 갱신

calicoctl replace 명령어는 파일, 디렉터리, 또는 표준 입력(stdin)에서 YAML 또는 JSON 형식으로 기존 Calico 리소스를 교체해요. 교체하려는 리소스가 존재하지 않으면 실패하므로, 그 경우에도 생성을 원한다면 apply를 사용하세요. 이 문서에서는 도움말, 예제, 옵션을 소개합니다.

출처: 문서

본문

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

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

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

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

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

Replace one or more existing Calico resources from a file, directory, or stdin,
in YAML or JSON format. Replace fails if a resource doesn't already exist; use
apply if you want it created in that case.

Usage:
  calicoctl replace [flags]

Examples:
  # Replace resources from a file.
  calicoctl replace -f ./policy.yaml

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 replace
  -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 replace -f ./resources.yaml
    

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

    Successfully replaced 8 resource(s)
    
  2. 표준 입력으로 넘긴 JSON을 기반으로 정책을 교체합니다.

    cat policy.json | calicoctl replace -f -
    

    정책이 존재하지 않는다는 결과가 표시돼요.

    Failed to replace any 'policy' resources: resource does not exist: Policy(name=dbPolicy)
    

옵션

  -f, --filename string    Filename to use to create/apply/replace/delete the resource. Use '-' for stdin.

일반 옵션

  -c, --config string      Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")

함께 보기

더 알아보기 (Learn more)

replace는 리소스가 반드시 존재해야 성공하고, apply는 없으면 새로 만들어요. 리소스 전체를 통째로 바꾸는 replace와 일부 필드만 고치는 patch의 차이도 함께 기억해두세요.