init: k8s 폴더 구조init

This commit is contained in:
donghyeon-ka
2026-07-26 17:11:25 +09:00
commit 0912b5030f
61 changed files with 2124 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
# Examples
예제는 구조와 조립 방식을 설명하기 위한 설계 참고 자료이며 실제 reconcile
대상이 아닙니다.
- [`minimal`](minimal/README.md): `kubectl kustomize`로 렌더 가능한 단일
환경·단일 클러스터의 canonical 구조
- [`scaled`](scaled/README.md): 여러 계정·환경·리전·클러스터로 확장할 때의
경로와 state 분리 기준
## 활용 순서
1. `minimal`에서 `infrastructure/live`, catalog `base`,
`gitops/clusters`의 관계를 확인합니다.
2. 규모가 커질 가능성이 있으면 `scaled`에서 account/region/environment
segment와 state 분리 기준을 선택합니다.
3. 실제 구현은 예제가 아니라 다음 `_template`을 복사해 시작합니다.
| 영역 | 복사 원본 |
|---|---|
| Infrastructure | `../infrastructure/components/_template`, `../infrastructure/stacks/_template`, `../infrastructure/live/_template` |
| GitOps | `../gitops/clusters/_template`, `../gitops/platform/_template`, `../gitops/apps/_template`, `../gitops/policies/_template`, `../gitops/tenants/_template` |
4. 실제 `live`와 cluster root가 예제와 같은 소유권·조립 경계를 유지하는지
비교하고 `make check`로 검증합니다.
예제 디렉터리를 GitOps controller root로 연결하거나 예제의 이름, namespace,
값을 production 기본값으로 재사용하지 않습니다.
+20
View File
@@ -0,0 +1,20 @@
# Minimal Example
단일 환경·단일 클러스터가 같은 경계를 어떻게 사용하는지 보여 주는 예입니다.
```text
minimal/
├── infrastructure/
│ └── live/dev/cluster/README.md
└── gitops/
├── platform/core/base/
├── apps/hello-config/base/
└── clusters/dev/main/
```
실제 cloud 리소스를 만들지 않으며, GitOps 예제는 Namespace와 ConfigMap만
렌더합니다.
```bash
kubectl kustomize examples/minimal/gitops/clusters/dev/main
```
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: hello-config
namespace: skeleton-demo
labels:
app.kubernetes.io/name: hello-config
app.kubernetes.io/part-of: skeleton-demo
app.kubernetes.io/managed-by: kustomize
data:
message: "replace this example with a real application definition"
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- config-map.yaml
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../platform/core/base
- ../../../apps/hello-config/base
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: skeleton-demo
labels:
app.kubernetes.io/part-of: skeleton-demo
app.kubernetes.io/managed-by: kustomize
@@ -0,0 +1,11 @@
# Example Live Root
실제 프로젝트에서는 이 위치가 독립 state를 갖는 실행 가능한 IaC root가 됩니다.
- Scope: local example
- Environment: dev
- Stack: cluster
- State: example에는 없음
이 예제에는 provider 또는 IaC 엔진을 선택하지 않았기 때문에 실행 코드를
포함하지 않습니다.
+48
View File
@@ -0,0 +1,48 @@
# Scaled Layout Example
계정·리전·환경·클러스터가 늘어나도 lifecycle과 entrypoint 계약은 바뀌지
않습니다.
```text
infrastructure/
├── components/
│ └── aws/
│ ├── network/
│ ├── identity/
│ └── eks/
├── stacks/
│ ├── regional-foundation/
│ └── kubernetes-cluster/
└── live/
└── aws/
├── platform-nonprod/
│ └── ap-northeast-2/
│ ├── dev/{network,cluster-a}/
│ └── staging/{network,cluster-a}/
└── platform-prod/
├── ap-northeast-2/prod/{network,cluster-a}/
└── ap-southeast-1/prod/{network,cluster-b}/
gitops/
├── platform/{core,networking,security,observability}/
├── policies/{baseline,production}/
├── tenants/{team-a,team-b}/
├── apps/{api,worker}/
└── clusters/
├── dev/ap-northeast-2/cluster-a/
├── staging/ap-northeast-2/cluster-a/
└── prod/
├── ap-northeast-2/cluster-a/
└── ap-southeast-1/cluster-b/
```
중괄호 표기는 설명을 줄이기 위한 것이며 실제 폴더명으로 사용하지 않습니다.
## 분리 기준
- `regional-foundation` network stack과 cluster는 파괴 영향이 달라 state를
분리합니다.
- production과 non-production은 account, credential과 state를 분리합니다.
- 공통 구현은 catalog에 한 번만 두고 cluster root는 선택과 patch만 가집니다.
- tenant/team별 권한이 다르면 CODEOWNERS와 repository 분리를 검토합니다.
- repository 분리는 폴더 수가 아니라 소유권과 권한 경계가 달라질 때 수행합니다.