K8s
  • Amazon EKS
  • 1.EKS 환경 구성
    • IDE 환경 구성
    • 인증/자격증명 및 환경 구성
  • 3.VPC구성과 eksctl 기반 설치
    • Cloudformation 구성
    • eksctl 구성
    • EKS 구성확인
  • 4.EKS Service 이해
    • Cluster IP 기반 배포
    • NodePort 기반 배포
    • Loadbalancer 기반 배포
  • 5.EKS Ingress
    • AWS Load Balancer Controller
  • 6.EKS 기반 관리
    • 패키지 관리 - Helm
    • 고가용성 Health Check 구성
    • 고가용성 Health Check 구성 (작업중)
    • Assign
    • 테인트와 톨러레이션
    • Pod 오버헤드 (Pod Overhead)
  • 7.Scheduling
    • 스케쥴링 - AutoScaling 구성
    • 스케쥴링-Karpenter
      • Basic Node Pool
        • Scaling Application
        • Limit Resources
        • Disruption
        • Drift
        • RightSizing
      • Multi NodePools
        • Team Based NodePool
        • Weighting NodePool
      • Cost Optimization
        • Consolidation
          • Single Node Consolidation
          • Multi Node Consolidation
          • Using Spot Instance
          • Spot to Spot Consolidation
        • Using Graviton
        • On-Demand & Spot Ratio Split
      • Scheduling Constraints
        • Node Affinity
        • Taints and Toleration
        • Topology Spread
        • Pod Affinity
        • Persistence Volume Topology
        • Pod Disruption Budget
        • Disruption Control
        • NodePool Disruption Budgets
        • Instance type and AZ
        • Multi-Arch
      • Control Pod Density
        • Static Pod Density
        • Dynamic Pod Density
        • Restrict Instance Type
      • EC2 Node Class
        • EC2 Node Classes
        • Custom AMI
        • Node Volumes
      • Observability
      • Migrating from Cluster Autoscaler
        • Install Cluster AutoScaler (CAS)
        • AutoScaling using Cluster AutoScaler (CAS)
        • Migrate from CAS to Karpenter
    • 스케쥴링-Karpenter (Old)
    • EKS Fargate (New)
    • EKS Fargate (old)
  • 8.Observability
    • K8s Dashboard 배포
    • Prometheus-Grafana
    • EFK기반 로깅
    • Container Insights
    • X-Ray기반 추적
    • Loki
  • 9. EKS Networking
    • Multus
    • VPC Advanced
    • External SNAT (TBD)
  • 10.EKS Storage
    • 볼륨/CSI
    • Stateful Container-EBS
    • Stateful Container-EFS
  • 11.EKS Security
    • 이미지 보안
    • OPA Gatekeeper
    • Kyverno
    • RBAC
    • IAM 그룹 기반 관리
    • IRSA (IAM Roles for Service Account)
    • Pod Security (TBD)
    • KMS 기반 암호화 (TBD)
    • Calico 네트워크 정책
  • 12.EKS CI/CD
    • Code Pipeline기반 CI/CD
    • Jenkins 기반 CI
    • WEAVE Flux 기반 GitOps (TBD)
    • Argo 기반 CD
    • Github Action & ArgoCD 기반 CI/CD
  • 13.EKS Service Mesh
    • Istio
      • Istio 소개
      • istio 설치와 구성
      • istio 트래픽 관리 1
      • istio 모니터링
      • Page 1
    • App Mesh (TBD)
  • Tip
    • Kubernetes 개념
      • Overview
      • Cluster Architecture
        • 노드
        • 컨트롤플레인과 노드간 통신
        • 컨트롤러
        • 클라우드 컨트롤러 매니저
      • Containers
        • 이미지
        • 컨테이너 소개
        • 런타임클래스
        • 컨테이너 환경변수
        • 컨테이너 라이프사이클 훅
      • Workloads
        • Pod
          • Pod 개요
          • Pod
          • Pod LifeCycle
          • 컨테이너 초기화
          • Pod 프리셋
          • 파드 토폴로지 분배 제약 조건
          • Untitled
        • Controller
      • Service-LB-Networking
      • Storage
      • Configuration
      • Security
      • Policies
      • Scheduling and Eviction
      • Cluster Admin
      • Extending Kubernetes
    • shell
    • git_source
    • aws cli
    • eksctl command
    • kubectl Command
    • helm command
    • Useful URL
Powered by GitBook
On this page
  • Kyverno 소개
  • Kyverno 설치

Was this helpful?

  1. 11.EKS Security

Kyverno

Update : 2024-04-15

Kyverno 소개

쿠버네티스 클러스터에서 수행되는 작업의 범위 또는 허용 여부를 결정하기 위해 정의된 규칙을 Policy라고 합니다. Kyverno는 정책을 관리하고 쿠버네티스 클러스터에 적용하는 도구 입니다. Kyverno를 통해 이미지의 특정 Tag 제한, Host의 포트 사용 제한, 사용할 수 있는 이미지 레지스트리 제한을 설정할수 있습니다. 또한 적용할 수 있는 정책들은 매우 다양합니다.

OPA 과 같은 정책도구들이 있지만, 정책적용을 위해 별도의 언어를 학습해야하는 러닝커브가 존재합니다.

Kyverno는 쿠버네티스 YAML을 그대로 사용하기 때문에 사용자 친화적으로 사용이 가능하며, 가장 널리 사용하는 방법 중 하나입니다.

Kyverno(그리스어 "통치")는 Kubernetes를 위해 특별히 설계된 정책 엔진입니다.

  • Kubernetes 리소스로서의 정책(새로운 언어를 배울 필요가 없습니다!)

  • 모든 리소스의 유효성 검사, 변형, 생성 또는 정리(제거)

  • 소프트웨어 공급망 보안을 위한 컨테이너 이미지 확인

  • 이미지 메타데이터 검사

  • Label Selector와 와일드카드를 사용하여 리소스 일치

  • 오버레이를 사용하여 유효성을 검사하고 변경합니다(예: Kustomize!)

  • 네임스페이스 전체에서 구성 동기화

  • 를 a사m용. 하 여 비준수 리소스를 차단하거나 정책 위반을 보고합니다.

  • 셀프 서비스 보고서(독점 감사 로그 없음!)

  • 셀프 서비스 정책 예외

  • 클러스터에 적용하기 전에 CI/CD 파이프라인에서 Kyverno CLI를 사용하여 정책을 테스트하고 리소스를 검증합니다.

  • git및 같은 친숙한 도구를 사용하여 코드로 정책을 관리합니다.

Kyverno 설치

Helm을 기반으로 Kyverno를 설치합니다.

# kyverno 레포지토리 추가
helm repo add kyverno https://kyverno.github.io/kyverno/
helm repo update

Kyverno를 설치합니다.

#Kyverno 설치
helm install kyverno kyverno/kyverno -n kyverno --create-namespace \
--set admissionController.replicas=3 \
--set backgroundController.replicas=2 \
--set cleanupController.replicas=2 \
--set reportsController.replicas=2

#kyverno가 정상적으로 설치되었는지 확인합니다.
kubectl -n kyverno get pods

#default namespace를 사용할때 정책 위반 이벤트가 발생하도록 설정합니다.
kubectl apply -f ~/environment/myeks/kyverno/policy/disallow-default-namespace.yaml

#default namespace를 사용할때 정책 위반 이벤트가 발생합니다.
kubectl create deployment nginx --image=nginx:latest
kubectl describe pods nginx-xxxx --show-events=true

# 정책 위반을 확인해 봅니다.
kubectl describe pods nginx-xxxx --show-events=true

#아래와 같이 정책 위반을 확인 할 수 있습니다.
  Warning  PolicyViolation  3m45s  kyverno-admission  policy disallow-default-namespace/validate-namespace fail: validation error: Using 'default' namespace is not allowed. rule validate-namespace failed at path /metadata/namespace/
  Warning  PolicyViolation  3m15s  kyverno-scan       policy disallow-default-namespace/validate-namespace fail: validation error: Using 'default' namespace is not allowed. rule validate-namespace failed at path /metadata/namespace/
  Normal   Scheduled        3m45s  default-scheduler  Successfully assigned default/nginx-6d666844f6-jfcd6 to ip-10-11-41-182.ap-northeast-2.compute.internal

~/environment/kyverno/test-disallow-default-namespace.yaml 에서 validationFailureAction: audit 을 validationFailureAction: enforce 로 변경합니다.

validationFailureAction: enforce

생성된 nginx pod를 삭제하고, 다시 생성해 봅니다.

kubectl delete pods nginx-xxxx
kubectl create deployment nginx --image=nginx:latest

아래와 같은 메세지가 발생하면서, 생성되지 않습니다.

$ kubectl create deployment nginx --image=nginx:latest
error: failed to create deployment: admission webhook "validate.kyverno.svc-fail" denied the request: 

resource Deployment/default/nginx was blocked due to the following policies 

disallow-default-namespace:
  validate-podcontroller-namespace: 'validation error: Using ''default'' namespace
    is not allowed for pod controllers. rule validate-podcontroller-namespace failed
    at path /metadata/namespace/'

PreviousOPA GatekeeperNextRBAC

Last updated 1 year ago

Was this helpful?