Open yejeeann opened 1 year ago
EFS(Elastic File System) 사용한 Persistent Volume 설정
apiVersion: v1 kind: ServiceAccount metadata: name: efs-provisioner
kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: efs-provisioner-runner rules: - 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"] --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: run-efs-provisioner subjects: - kind: ServiceAccount name: efs-provisioner namespace: default roleRef: kind: ClusterRole name: efs-provisioner-runner apiGroup: rbac.authorization.k8s.io --- kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: name: leader-locking-efs-provisioner rules: - apiGroups: [""] resources: ["endpoints"] verbs: ["get", "list", "watch", "create", "update", "patch"] --- kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: leader-locking-efs-provisioner subjects: - kind: ServiceAccount name: efs-provisioner roleRef: kind: Role name: leader-locking-efs-provisioner apiGroup: rbac.authorization.k8s.io
apiVersion: apps/v1 kind: Deployment metadata: name: efs-provisioner namespace: mall spec: replicas: 1 strategy: type: Recreate selector: matchLabels: app: efs-provisioner template: metadata: labels: app: efs-provisioner spec: serviceAccount: efs-provisioner containers: - name: efs-provisioner image: quay.io/external_storage/efs-provisioner:latest env: - name: FILE_SYSTEM_ID value: fs-0aaccb328f84992df - name: AWS_REGION value: eu-west-3 - name: PROVISIONER_NAME value: my-aws.com/aws-efs volumeMounts: - name: pv-volume mountPath: /persistentvolumes volumes: - name: pv-volume nfs: server: fs-0aaccb328f84992df.efs.eu-west-3.amazonaws.com path: /
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: aws-efs provisioner: my-aws.com/aws-efs
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: aws-efs labels: app: test-pvc spec: accessModes: - ReadWriteMany resources: requests: storage: 1Mi storageClassName: aws-efs
volumeMounts: - mountPath: "/mnt/aws" name: volume volumes: - name: volume persistentVolumeClaim: claimName: aws-efs
livenessProbe: exec: command: - cat - /tmp/healthy initialDelaySeconds: 30 timeoutSeconds: 2 periodSeconds: 5 failureThreshold: 10
Persistent Volume
EFS(Elastic File System) 사용한 Persistent Volume 설정
1. EFS 생성
2. EFS 계정 생성 및 Role 바인딩
$ kubectl apply -f efs-sa.yaml
kubectl apply -f efs-rbac.yaml
3. EFS Provisioner 배포
kubectl apply -f efs-provisioner-deploy.yaml
4. StorageClass 생성
kubectl apply -f efs-provisioner-deploy.yaml
5. PVC(PersistentVolumeClaim) 생성
kubectl apply -f volume-PVC.yaml
6. order pod 에 pvc 적용
kubectl apply -f deployment.yaml
Self-healing (liveness probe)
order pod 실행 후 /tmp 디렉토리 healthy 체크하여 처리
/order/kubernetes/deployment.yaml
order pod 생성
order pod /tmp/health 삭제
/tmp/health 삭제 후 order pod restart 확인