티스토리 뷰

728x90
반응형

정상적으로 동작하던 Dynamic NFS Provisioning에서 오류가 발생하는 문제 해결

참고


쿠버네티스 Kubernetes 클러스터에 동적으로 NFS Network File System Provisioning 에 대한 글은 아래 게시글 참고

상황

위의 게시글을 기준으로 NFS Provisioning 을 잘 사용하고 있었다. 추가로 쿠버네티스 클러스터를 구성해서 테스트를 해야하는 작업이 생겼고, 최신 버전의 쿠버네티스로 설치를 진행했다.

동일하게 NFS Provisioning 설정을 했고, 애플리케이션을 배포했을 때 계속 Pending 상태로 진행되지 않는 상황이 발생해서 로그 정보들을 통해서 검증하기 시작했다.

결론은 아래와 같이 nfs-client-provisioner 파드에서 오류가 발생하는 것으로 확인할 수 있었다.

2021-06-09T06:31:34.335294986Z  E0609 06:31:34.335012       1 controller.go:682] Error watching for provisioning success, can't provision for claim "default/test-web-0": events is forbidden: User "system:serviceaccount:default:nfs-provisioner" cannot list resource "events" in API group "" in the namespace "default"
2021-06-09T06:31:34.335430080Z  I0609 06:31:34.335031       1 leaderelection.go:156] attempting to acquire leader lease...
2021-06-09T06:31:34.362925534Z  I0609 06:31:34.362178       1 leaderelection.go:178] successfully acquired lease to provision for pvc default/test-web-0
2021-06-09T06:31:34.363014753Z  I0609 06:31:34.362277       1 controller.go:1068] scheduleOperation[provision-default/test-web-0[6ebb2da5-4c46-451a-ad82-f60c8e524bf8]]
2021-06-09T06:31:34.369124223Z  E0609 06:31:34.368990       1 controller.go:766] Unexpected error getting claim reference to claim "default/test-web-0": selfLink was empty, can't make reference

원인

우선 ... cannot list resource "events" in API group "" in the namespace "default” 오류는 권한과 관련된 부분이니 설정을 조정하면 되지만

selfLink was empty, can't make reference

오류는 기존에 보지 못했던 것이라 이 부분을 확인해야 한다.

관련된 검색을 진행한 결과

KEP-1164: Deprecate and Remove SelfLink

에 다음과 같은 내용이 존재한다.

In v1.16, we will deprecate the SelfLink field in both ObjectMeta and ListMeta objects by: documenting in field definition that it is deprecated and is going to be removed adding a release-note about field deprecation We will also introduce a feature gate to allow disabling setting SelfLink fields and opaque the logic setting it behind this feature gate.

In v1.20 (12 months and 4 release from v1.16) we will switch off the feature gate which will automatically disable setting SelfLinks. However it will still be possible to revert the behavior by changing value of a feature gate.

In v1.21, we will get rid of the whole code propagating those fields and fields themselves. In the meantime, we will go over places referencing that field (see below) and get rid of those too.

즉, v1.16 부터 ObjectMeta와 ListMeta 객체 모두에서 SelfLink 필드를 더 이상 사용하지 않기 때문에 삭제될 기능이며, v1.20 부터는 SelfLink 값을 자동으로 해제하는 기능이 동작한다.

해결 방법

제시하고 있는 것과 같이 SelfLink를 사용하지 않는 것이 정상이지만, 현재 구성한 NFS Provisioner에서 SelfLink를 참조해서 처리하고 있기 때문에 다음과 같이 처리해서 정상적으로 동작할 수 있도록 해야 한다.

  • FeatureGate 우회하는 방법 (권장하지 않음)쿠버네티스 클러스터의 마스터 노드에서 /etc/kubernetes/manifests/kube-apiserver.yaml 파일을 열고 아래와 같이 --feature-gates=RemoveSelfLink=false Command Option을 설정하고 재 시작하면 된다.
  • ... spec: containers: - command: - kube-apiserver - --feature-gates=RemoveSelfLink=false ...
  • 실제 SelfLink를 자동으로 해제하는 것은 FeaturGate - RemoveSelfLink 와 관련된 부분이므로 이를 해제하면 된다.
  • Provisioner를 교체하는 방법 (권장)아래와 같이 NFS Provisioning 관련 매니페스트 파일을 조정하고 배포하면 된다. (nfs_setup.yaml)
  • # ServiceAccount apiVersion: v1 kind: ServiceAccount metadata: name: nfs-client-provisioner namespace: default --- # ClusterRole kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: nfs-client-provisioner-runner rules: - apiGroups: [""] resources: ["nodes"] verbs: ["get", "list", "watch"] - apiGroups: [""] resources: ["persistentvolumes"] verbs: ["get", "list", "watch", "create", "delete"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "watch", "update"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] - apiGroups: [""] resources: ["events"] verbs: ["create", "update", "patch"] --- # ClusterRoleBinding kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: run-nfs-client-provisioner subjects: - kind: ServiceAccount name: nfs-client-provisioner namespace: default roleRef: kind: ClusterRole name: nfs-client-provisioner-runner apiGroup: rbac.authorization.k8s.io --- # leader locking Role kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: name: leader-locking-nfs-client-provisioner rules: - apiGroups: [""] resources: ["endpoints"] verbs: ["get", "list", "watch", "create", "update", "patch"] --- # leader locking RoleBinding apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: leader-locking-nfs-client-provisioner subjects: - kind: ServiceAccount name: nfs-client-provisioner namespace: default # provisioner가 배포될 네임스페이스 roleRef: kind: Role name: leader-locking-nfs-client-provisioner apiGroup: rbac.authorization.k8s.io --- # Deployment kind: Deployment apiVersion: apps/v1 metadata: name: nfs-client-provisioner labels: app: nfs-client-provisioner namespace: default spec: replicas: 1 strategy: type: Recreate selector: matchLabels: app: nfs-client-provisioner template: metadata: labels: app: nfs-client-provisioner spec: serviceAccount: nfs-client-provisioner containers: - name: nfs-client-provisioner image: k8s.gcr.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2 # 이미지 교체 volumeMounts: - name: nfs-client-root mountPath: /persistentvolumes env: - name: PROVISIONER_NAME value: k8s-sigs.io/nfs-subdir-external-provisioner # Provisioner Env 변경 - name: NFS_SERVER value: <nfs server ip> - name: NFS_PATH value: <nfs server volume path> volumes: - name: nfs-client-root nfs: server: <nfs server ip> path: <nfs server volume path> --- # StorageClass kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: annotations: storageclass.kubernetes.io/is-default-class: "true" name: managed-nfs-storage provisioner: k8s-sigs.io/nfs-subdir-external-provisioner # Provisioner 변경 parameters: archiveOnDelete: "false"
  • v1.21 버전에서는 완전히 SelfLink가 삭제
    된다고 하니 이 방법을 사용하는 것이 좋다.

참고 자료

728x90
반응형
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함