Add Kaniko (K8s native image build) document
This commit is contained in:
59
infra/kaniko.md
Normal file
59
infra/kaniko.md
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: Kaniko - K8s 네이티브 컨테이너 이미지 빌드
|
||||
updated: 2026-04-12
|
||||
tags:
|
||||
- k8s
|
||||
- image-build
|
||||
- kaniko
|
||||
---
|
||||
|
||||
## 개요
|
||||
|
||||
Kaniko는 Google에서 만든 Kubernetes 네이티브 컨테이너 이미지 빌드 도구. Docker 데몬 없이 컨테이너 내부에서 Dockerfile을 빌드하고 레지스트리에 푸시할 수 있다.
|
||||
|
||||
- 프로젝트: [googlecontainertools/kaniko](https://github.com/GoogleContainerTools/kaniko)
|
||||
- 이미지: `gcr.io/kaniko-project/executor`
|
||||
|
||||
## 도입 배경
|
||||
|
||||
- K3s 클러스터에서 컨테이너 이미지를 빌드하기 위해 호스트(incus-kr1)에 Docker CE를 설치해 사용했으나, Kaniko 발견 후 Docker CE 제거 (2026-04-12)
|
||||
- Docker 데몬 불필요 → 호스트에 Docker 설치할 필요 없음
|
||||
- K8s Job/Pod으로 빌드 실행 가능
|
||||
|
||||
## 사용 방법
|
||||
|
||||
K8s Job으로 실행하는 기본 예시:
|
||||
|
||||
```yaml
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: kaniko-build
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: kaniko
|
||||
image: gcr.io/kaniko-project/executor:latest
|
||||
args:
|
||||
- "--dockerfile=Dockerfile"
|
||||
- "--context=git://github.com/user/repo.git"
|
||||
- "--destination=registry.example.com/image:tag"
|
||||
restartPolicy: Never
|
||||
```
|
||||
|
||||
## 컨텍스트 소스
|
||||
|
||||
- Git 저장소: `git://`
|
||||
- S3/GCS 버킷
|
||||
- 로컬 디렉토리 (PVC 마운트)
|
||||
- tar 파일
|
||||
|
||||
## 레지스트리 인증
|
||||
|
||||
- K8s Secret을 `/kaniko/.docker/config.json`에 마운트
|
||||
- 또는 `--registry-mirror`, `--insecure-registry` 플래그 사용
|
||||
|
||||
## 관련 문서
|
||||
|
||||
- [[infra-hosts]] - K3s 클러스터 구성
|
||||
Reference in New Issue
Block a user