Search

Harbor

참고
Harbor는 CNCF(클라우드 네이티브 컴퓨팅 재단)의 프로젝트 중 하나로, 자체 호스팅형 Docker 이미지 레지스트리 및 공유 서비스입니다. 이는 Docker Registry를 기반으로 하며 보안, 정책, 복제, 이미지 취약점 스캔 등을 포함한 다양한 기능을 제공합니다.
Public Domain ACM 생성 후 진행
CLUSTER_NAME="<EKS_CLUSTER_NAME>" CLUSTER_OIDC=$(aws eks describe-cluster --name $CLUSTER_NAME --query "cluster.identity.oidc.issuer" --output text | cut -c 9-100) ACCOUNT=$(aws sts get-caller-identity --query "Account" --output text)
Shell
복사
cat << EOF > aws-ebs-csi-driver-trust-policy.json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::ACCOUNT_ID:oidc-provider/OIDC" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "OIDC:aud": "sts.amazonaws.com" } } } ] } EOF
Shell
복사
sed -i "s|ACCOUNT_ID|$ACCOUNT|g" aws-ebs-csi-driver-trust-policy.json sed -i "s|OIDC|$CLUSTER_OIDC|g" aws-ebs-csi-driver-trust-policy.json
Shell
복사
aws iam create-role --role-name AmazonEKS_EBS_CSI_DriverRole --assume-role-policy-document file:///home/ec2-user/aws-ebs-csi-driver-trust-policy.json
Shell
복사
aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy --role-name AmazonEKS_EBS_CSI_DriverRole
Shell
복사
eksctl create addon --name aws-ebs-csi-driver --cluster $CLUSTER_NAME --service-account-role-arn arn:aws:iam::$ACCOUNT:role/AmazonEKS_EBS_CSI_DriverRole --force
Shell
복사
kubectl patch storageclass gp2 -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
Shell
복사
helm repo add eks https://aws.github.io/eks-charts helm repo update eks helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ -n kube-system \ --set clusterName=$CLUSTER_NAME\ --set serviceAccount.create=false \ --set serviceAccount.name=aws-load-balancer-controller
Shell
복사
helm repo add harbor https://helm.goharbor.io helm repo update kubectl create namespace harbor helm show values harbor/harbor > values.yaml
Shell
복사
values.yaml (도메인 변경 필요)
helm install harbor harbor/harbor --namespace harbor -f values.yaml
Shell
복사
기본값 : admin / Harbor12345
docker pull nginx && docker pull busybox
Shell
복사
docker tag busybox worldskills.site/worldskills/busybox:0.1 docker tag nginx worldskills.site/worldskills/nginx:0.1
Shell
복사
docker login worldskills.site -u admin -p Harbor12345
Shell
복사
docker push worldskills.site/worldskills/nginx:0.1 docker push worldskills.site/worldskills/busybox:0.1
Shell
복사
apiVersion: apps/v1 kind: Deployment metadata: name: busybox labels: app: busybox spec: replicas: 1 selector: matchLabels: app: busybox template: metadata: labels: app: busybox spec: containers: - name: busybox # image: busybox image: worldskills.site/worldskills/busybox:0.1 command: - "/bin/sh" - "-c" - "sleep inf"
YAML
복사
kubectl apply -f busybox-deploy.yaml
Shell
복사
kubectl describe pod | grep Events: -A7
Shell
복사
Harbor에서 성공적으로 이미지를 가져오는 모습 확인 가능

Triby 로 Image 취약점 Scan

수동 스캔 - 해당 이미지 선택후 Scan 클릭
자동 스캔 - Project Configuration 에서 설정 , Image Push 시 스캔