4.3.2. Pod 유사성 규칙 구성
다음 단계에서는 라벨이 있는 Pod 및 유사성을 사용하여 해당 Pod에 예약할 수 있는 Pod를 생성하는 간단한 2-Pod 구성을 보여줍니다.
참고
예약된 Pod에 선호도를 직접 추가할 수 없습니다.
프로세스
Pod 사양에서 특정 라벨을 사용하여 Pod를 생성합니다.
다음 콘텐츠를 사용하여 YAML 파일을 생성합니다.
apiVersion: v1 kind: Pod metadata: name: security-s1 labels: security: S1 spec: securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault containers: - name: security-s1 image: docker.io/ocpqe/hello-pod securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefaultPod를 생성합니다.
$ oc create -f <pod-spec>.yaml
다른 Pod를 생성할 때 유사성을 추가하도록 다음 매개변수를 구성합니다.
다음 콘텐츠를 사용하여 YAML 파일을 생성합니다.
apiVersion: v1 kind: Pod metadata: name: security-s1-east # ... spec: affinity:1 podAffinity: requiredDuringSchedulingIgnoredDuringExecution:2 - labelSelector: matchExpressions: - key: security3 values: - S1 operator: In4 topologyKey: topology.kubernetes.io/zone5 # ...- 1
- Pod 유사성을 추가합니다.
- 2
requiredDuringSchedulingIgnoredDuringExecution매개변수 또는preferredDuringSchedulingIgnoredDuringExecution매개변수를 구성합니다.- 3
- 충족해야 하는
키와값을지정합니다. 새 Pod를 다른 Pod와 함께 예약하려면 첫 번째 Pod의 라벨과 동일한key및values매개변수를 사용합니다. - 4
연산자를 지정합니다. 연산자는In,NotIn,Exists또는DoesNotExist일 수 있습니다. 예를 들어 노드에 라벨이 있어야 하는 경우 연산자In을 사용합니다.- 5
- 이러한 토폴로지 도메인을 나타내기 위해 사용하며 미리 채워져 있는 Kubernetes 라벨인
topologyKey를 지정합니다.
Pod를 생성합니다.
$ oc create -f <pod-spec>.yaml