쿠버네티스

MetalLB 설치 오류 해결 (kyverno 정책)

황동리 2024. 10. 15. 17:27
반응형

오류 현상

MetalLB 공식 홈페이지에 나와있는 설치 방법대로 설치를 하던 도중

아래와 같은 에러가 나왔습니다.

 

Error from server: error when creating "https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml": admission webhook "validate.kyverno.svc-fail" denied the request:

resource DaemonSet/metallb-system/speaker was blocked due to the following policies

disallow-capabilities:
  autogen-adding-capabilities: Any capabilities added beyond the allowed list (AUDIT_WRITE,
    CHOWN, DAC_OVERRIDE, FOWNER, FSETID, KILL, MKNOD, NET_BIND_SERVICE, SETFCAP, SETGID,
    SETPCAP, SETUID, SYS_CHROOT) are disallowed.
disallow-host-namespaces:
  autogen-host-namespaces: 'validation error: Sharing the host namespaces is disallowed.
    The fields spec.hostNetwork, spec.hostIPC, and spec.hostPID must be unset or set
    to `false`. rule autogen-host-namespaces failed at path /spec/template/spec/hostNetwork/'
disallow-host-ports:
  autogen-host-ports-none: 'validation error: Use of host ports is disallowed. The
    fields spec.containers[*].ports[*].hostPort , spec.initContainers[*].ports[*].hostPort,
    and spec.ephemeralContainers[*].ports[*].hostPort must either be unset or set
    to `0`. rule autogen-host-ports-none failed at path /spec/template/spec/containers/0/ports/0/hostPort/'

 

오류 원인

그래서 찾아보니 ClusterPolicy에 있는

  • disallow-capabilities
  • disallow-host-namespaces
  • disallow-host-ports

해당 정책들에서 metallb-system 네임스페이스를 예외처리 해주면 된다는 것을 알았습니다.


해결 방법

따라서 각 정책에서 exclude 부분의 namespace에 metallb-system 을 추가해줍니다.

# kubectl edit clusterpolicy disallow-capabilities

 

아래 이미지에서 나온 것 처럼 exclude 부분 밑에 namespaces 밑에 metallb-system 을 넣어주면 됩니다.

 

그러면 이제 정상적으로 설치가 됩니다.

반응형