본문 바로가기
★ Study/▶ Kubernetes

K8S - Trivy (11)

by lina_j 2023. 4. 14.
더보기

※ 저작권 침해가 있을 수 있어 간략한 사진이나 학습한 내용만 게시하겠습니다.

※ 해당 학습은 패스트캠퍼스 교육임을 알립니다.

 

< #11 trivy 문제 >

 

1. fastcampus 네임스페이스에 있는 모든 Pod에서 사용 중인 images를 Trivy로 스캔 후 결과를 저장하라.

2. High 또는 Critical severity 가 있는 pod는 삭제하라.

    Trivy는 master node에만 설치되어 있다.

 

 

 

< 문제풀이 >

 

0. 스캔 할 이미지 확인

$ kubectl get pod -n fastcampus
agent
cache
web


$ kubectl describe pod agent -n fastcampus | grep -i image:
Image: busybox:1.33.1

$ kubectl describe pod cache -n fastcampus | grep -i image:
Image: redis:3.2

$ kubectl describe pod web -n fastcampus | grep -i image:
Image: nginx:1.14


또는 docs 참조

$ kubectl get pod -n fastcampus --output=custom-columns="NAME:.metadata.name,IMAGE:.spec.containers[*].image"
Name          IMAGE
agent         busybox:1.33.1
cache         redis:3.2
web           nginx:1.14

 

docs - kubectl

 

 

 

 

1. SCAN

$ trivy image busybox:1.33.1
취약점 발견 안됨

$ trivy image redis:3.2
취약점 발견

$ trivy image nginx:1.14
취약점 발견


또는
$ trivy image -s HIGH busybox:1.33.1            <- 발견X
$ trivy image -s CRITICAL busybox:1.33.1        <- 발견X 
$ trivy image -s HIGH redis:3.2                 <- 발견
$ trivy image -s CRITICAL redis:3.2             <- 발견
$ kubectl delete pod -n fastcampus cache --force
$ trivy image -s HIGH nginx:1.14                <- 발견
$ trivy image -s CRITICAL nginx:1.14            <- 발견
$ kubectl delete pod -n fastcampus web --force

 

trivy buxybox:1.33.1

 

trivy redis
trivy nginx

 

2. 취약점 발견 pod 삭제

$ kubectl delete pod cache -n fastcampus --force
$ kubectl delete pod web -n fastcampus --force

 

결과

 

'★ Study > ▶ Kubernetes' 카테고리의 다른 글

K8S - sysdig/falco (13)  (0) 2023.04.27
K8S - webhook (12)  (0) 2023.04.26
K8S - Ingress_add TLS (10)  (0) 2023.04.14
K8S - AppArmor (9)  (0) 2023.04.11
K8S - Runtime Sandbox (8)  (0) 2023.04.09

댓글