1.2. 튜닝 CNI를 사용하여 모든 멀티 캐스트 모드 활성화
OpenShift Container Platform의 네트워크 인터페이스에서 all-multicast 모드를 활성화하려면 네트워크 연결 정의에서 CNI(Container Network Interface) 메타 플러그인을 사용할 수 있습니다. 활성화하면 인터페이스에서 네트워크의 모든 멀티 캐스트 패킷을 수신합니다.
프로세스
다음 콘텐츠를 사용하여
tuning-example.yaml과 같은 네트워크 연결 정의를 생성합니다.apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: <name> namespace: default spec: config: '{ "cniVersion": "0.4.0", "name": "<name>", "plugins": [{ "type": "<main_CNI_plugin>" }, { "type": "tuning", "allmulti": true } } ] }다음과 같습니다.
<name>- 생성할 추가 네트워크 연결의 이름을 지정합니다. 이름은 지정된 네임스페이스 내에서 고유해야 합니다.
default- 오브젝트가 연결된 네임스페이스를 지정합니다.
"0.4.0"- CNI 사양 버전을 지정합니다.
"<name>"- 구성 이름을 지정합니다. 구성 이름을 네트워크 연결 정의의 name 값과 일치시킵니다.
"<main_CNI_plugin>"- 구성할 기본 CNI 플러그인의 이름을 지정합니다.
"tuning"- CNI 메타 플러그인의 이름을 지정합니다.
"true"- 인터페이스의 all-multicast 모드를 지정합니다. 활성화하면 네트워크의 모든 멀티 캐스트 패킷이 인터페이스에서 수신됩니다.
네트워크 연결 정의 예
apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: setallmulti namespace: default spec: config: '{ "cniVersion": "0.4.0", "name": "setallmulti", "plugins": [ { "type": "bridge" }, { "type": "tuning", "allmulti": true } ] }'다음 명령을 실행하여 YAML 파일에 지정된 설정을 적용합니다.
$ oc apply -f tuning-allmulti.yaml출력 예
networkattachmentdefinition.k8s.cni.cncf.io/setallmulti created다음
examplepod.yaml샘플 파일에 지정된 것과 유사한 네트워크 연결 정의를 사용하여 Pod를 생성합니다.apiVersion: v1 kind: Pod metadata: name: allmultipod namespace: default annotations: k8s.v1.cni.cncf.io/networks: setallmulti spec: containers: - name: podexample image: centos command: ["/bin/bash", "-c", "sleep INF"] securityContext: runAsUser: 2000 runAsGroup: 3000 allowPrivilegeEscalation: false capabilities: drop: ["ALL"] securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault다음과 같습니다.
metadata.annotations.k8s.v1.cni.cncf.io/networks-
구성된
NetworkAttachmentDefinition의 이름을 지정합니다. spec.containers.securityContext.runAsUser- 컨테이너가 실행되는 사용자 ID를 지정합니다.
spec.containers.securityContext.runAsGroup- 컨테이너가 실행되는 기본 그룹 ID를 지정합니다.
spec.containers.securityContext.allowPrivilegeEscalation-
Pod에서 권한 에스컬레이션을 허용하도록 요청할 수 있는지 여부를 지정합니다. 지정되지 않은 경우 기본값은 true입니다. 이 부울은
no_new_privs플래그가 컨테이너 프로세스에 설정되는지 여부를 직접 제어합니다. spec.containers.securityContext.capabilities- 전체 루트 액세스 권한을 부여하지 않고 권한 있는 작업을 지정합니다. 이 정책은 모든 기능이 Pod에서 삭제되도록 합니다.
spec.containers.securityContext.runAsNonRoot: true- 컨테이너가 0 이외의 UID가 있는 사용자로 실행되도록 지정합니다.
spec.containers.securityContext.seccompProfile- Pod 또는 컨테이너 워크로드에 대한 기본 seccomp 프로필을 지정합니다.
다음 명령을 실행하여 YAML 파일에 지정된 설정을 적용합니다.
$ oc apply -f examplepod.yaml다음 명령을 실행하여 Pod가 생성되었는지 확인합니다.
$ oc get pod출력 예
NAME READY STATUS RESTARTS AGE allmultipod 1/1 Running 0 23s다음 명령을 실행하여 Pod에 로그인합니다.
$ oc rsh allmultipod다음 명령을 실행하여 Pod와 관련된 모든 인터페이스를 나열합니다.
sh-4.4# ip link출력 예
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0@if22: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8901 qdisc noqueue state UP mode DEFAULT group default link/ether 0a:58:0a:83:00:10 brd ff:ff:ff:ff:ff:ff link-netnsid 0 3: net1@if24: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default link/ether ee:9b:66:a4:ec:1d brd ff:ff:ff:ff:ff:ff link-netnsid 0다음과 같습니다.
eth0@if22- 기본 인터페이스를 지정합니다.
net1@if24- all-multicast 모드(ALLMULTI 플래그)를 지원하는 network-attachment-definition으로 구성된 보조 인터페이스를 지정합니다.