Velero 보안 및 모니터링
9️⃣ Velero 보안 및 모니터링
1. Velero 백업 데이터 암호화 및 접근 제어
Velero를 사용하여 Kubernetes 클러스터의 데이터를 백업할 때, 보안은 중요한 요소입니다.
스토리지에 저장되는 데이터는 암호화해야 하며, 접근 권한을 제한하여 보안성을 강화해야 합니다.
✅ AWS S3에서 데이터 암호화 적용
aws s3 cp my-backup s3://my-bucket/ --sse AES256
--sse AES256
옵션을 사용하여 AES256 알고리즘으로 암호화
✅ Google Cloud Storage에서 KMS(Key Management Service)로 암호화 적용
gcloud kms keys create velero-key \
--location global \
--keyring velero-keyring \
--purpose encryption
- KMS 키를 활용하여 백업 데이터 암호화 가능
✅ Azure Blob Storage에서 암호화 적용
az storage blob upload \
--account-name veleroaccount \
--container-name backups \
--name backup.tar.gz \
--file backup.tar.gz \
--encryption-scope my-encryption-scope
encryption-scope
를 사용하여 저장 시 자동 암호화
2. 백업 및 복구 시 RBAC(Role-Based Access Control) 적용
Velero의 ServiceAccount
가 모든 리소스를 접근하는 것이 아니라, 필요한 권한만 최소한으로 부여해야 합니다.
✅ 최소 권한을 부여하는 RBAC 설정 예제
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: velero-backup-role
namespace: velero
rules:
- apiGroups: [""]
resources: ["pods", "services", "configmaps", "secrets", "persistentvolumeclaims"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: velero-backup-binding
namespace: velero
subjects:
- kind: ServiceAccount
name: velero
namespace: velero
roleRef:
kind: Role
name: velero-backup-role
apiGroup: rbac.authorization.k8s.io
✅ 백업 복구 시 관리 권한을 부여하는 RBAC 설정 예제
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: velero-restore-admin
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: velero-restore-binding
subjects:
- kind: ServiceAccount
name: velero
namespace: velero
roleRef:
kind: ClusterRole
name: velero-restore-admin
apiGroup: rbac.authorization.k8s.io
- 백업 데이터를 복구할 때만 ClusterRole을 사용하도록 설정
3. Prometheus 및 Grafana를 이용한 Velero 모니터링
Velero의 백업 상태 및 성능을 모니터링하려면 Prometheus 및 Grafana를 활용하면 됩니다.
✅ Velero 메트릭 활성화
Velero에서 Prometheus 메트릭을 활성화하려면 --features=EnableMetrics
옵션을 추가해야 합니다.
spec:
template:
spec:
containers:
- name: velero
args:
- server
- --features=EnableMetrics
✅ Prometheus ServiceMonitor 설정 예제
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: velero-monitor
namespace: monitoring
spec:
selector:
matchLabels:
app: velero
endpoints:
- port: http-metrics
interval: 30s
- Prometheus에서 Velero의 메트릭을 수집할 수 있도록
ServiceMonitor
설정
✅ Grafana에서 Velero 대시보드 설정
- Grafana에서 Prometheus 데이터 소스 추가
- Velero 공식 Grafana 대시보드 ID:
12156
추가 - 백업 성공률, 백업 크기, 수행 시간 등을 모니터링
4. Velero 로그 분석 및 알림 시스템 구축 (AlertManager 연동)
백업이 실패했을 때 빠르게 대응할 수 있도록 알림 시스템을 설정하는 것이 중요합니다.
✅ Velero 로그 확인 명령어
kubectl logs deployment/velero -n velero
- Velero의 실행 로그를 실시간으로 확인 가능
✅ AlertManager를 이용한 백업 실패 알림 설정
AlertManager는 Prometheus와 함께 동작하며, 특정 조건이 충족되었을 때 알림을 보낼 수 있습니다.
groups:
- name: velero-alerts
rules:
- alert: VeleroBackupFailed
expr: rate(velero_backup_total{phase="Failed"}[5m]) > 0
for: 5m
labels:
severity: critical
annotations:
summary: "Velero 백업 실패 발생"
description: "백업 작업이 연속적으로 실패하고 있습니다. 로그를 확인하세요."
velero_backup_total{phase="Failed"}
메트릭을 기반으로 백업 실패 시 알림 전송
5. 백업 데이터 무결성 검증 방법
백업 데이터가 손상되지 않았는지 검증하는 것이 중요합니다.
✅ Velero에서 복구 테스트 수행
백업 데이터가 정상적으로 저장되었는지 확인하기 위해 테스트 복구를 수행합니다.
velero restore create --from-backup my-backup
- 특정 백업에서 데이터 복구 테스트 수행
✅ Velero 백업 목록 확인
velero backup get
- 현재 저장된 모든 백업 리스트 확인
✅ 특정 백업의 세부 정보 확인
velero backup describe my-backup --details
- 특정 백업의 상태 및 무결성 확인
마지막 수정일자