본문 바로가기
IT & Tech 정보

Feature Store CI/CD as Code

by 지식과 지혜의 나무 2025. 5. 30.
반응형


Feast + Hopsworks Feature Store + Kubeflow Pipelines + OPA Gatekeeper + Seldon + Argo CD를 연동해, 특성 정의→엔ジン 실행→バリデーション→서ービング→モニタ링→자가 복구까지 모두 코드로 선언·자동화하는 Feature Store CI/CD 파이프라인을 구축합니다.



🎯 목표
1. Git에 FeatureSet CRD로 특성(Feature) 스키마·인그레스 조인 쿼리·유효성 검사 로직 선언
2. Argo CD Sync → Feast Core 및 Hopsworks Project에 FeatureSet 자동 등록
3. Kubeflow Pipelines로 배치·스트리밍 조인 작업(Beam/Spark) 실행→Offline Store 적재
4. Feature Validation: 유효성 검사(Null율·분포·Drift) → 에러 시 CI 실패(OPA Gatekeeper 차단)
5. Seldon Core로 Feature Serving API 자동 배포→Online Store 조회
6. Prometheus + Grafana로 특성 Freshness·유효성 메트릭 수집 → Alertmanager 알림
7. Argo CD Self-Heal로 FeatureSet·Pipeline·Serving Manifest 드리프트 자동 복구
8. GitOps 이력으로 모든 특성 변경·배치 결과·검증·배포 상태 투명 기록



⚙️ 핵심 구성 요소

계층 도구/CRD 역할
Feature 선언 FeatureSet CRD 특성 스키마, 데이터 소스, 조인 키, 유효성 규칙 선언
레지스트리 & 메타데이터 Feast Core + Hopsworks Project Feature 집계·메타데이터 카탈로그 관리
배치/스트리밍 처리 Kubeflow Pipelines (Beam/Spark) 정기 배치/실시간 스트리밍 조인 작업 실행 → Offline Store 적재
정책 검증 OPA Gatekeeper 유효성 검사 실패 시 배포 차단
Serving Seldon Core Online Store 조회 기반 Feature Serving API 자동 생성
GitOps 배포·자가 치유 Argo CD Application & Self-Heal CRD·Pipeline·Serving Manifest 자동 동기화·복구
모니터링 & 알림 Prometheus + Alertmanager + Grafana Freshness, Null Rate, Drift 지표 감시 및 알림




🏗️ 파이프라인 워크플로우

flowchart TD
  A[Git Push: features/ my-app-feature-set.yaml]
    --> B[Argo CD Sync FeatureSet CRD]
    --> C[OPA Gatekeeper Validate FeatureSet]
    --> D[Feast Core · Hopsworks에 등록]

  subgraph Data Ingestion
    D --> E[Kubeflow Pipelines: batch_ingest & stream_ingest]
    E --> F[Offline Store 적재]
  end

  subgraph Validation
    F --> G[ValidateJob CR: NullRate, Distribution]
    G --> H{Validation Passed?}
    H -- No  --> I[CI Fail & Slack Alert]
    H -- Yes --> J[Proceed]
  end

  subgraph Serving
    J --> K[Generate Seldon Deployment CR]
    K --> L[Argo CD Sync → Feature API 생성]
  end

  subgraph Monitoring & Healing
    L --> M[Prometheus scrape: feature_freshness_seconds, null_rate]
    M --> N[Grafana Dashboard & Alertmanager Alerts]
    B --> O[Argo CD Self-Heal: drift된 CR/Manifests 자동 복구]
  end




🧪 예시 매니페스트

1) FeatureSet CRD & Sample

apiVersion: features.example.com/v1alpha1
kind: FeatureSet
metadata:
  name: user-churn-features
spec:
  project: my-analytics
  entities:
    - name: user_id
      type: string
  features:
    - name: total_sessions
      dtype: int64
      source: online_events
      transform: count(session_id) over window(30d)
    - name: avg_session_duration
      dtype: float
      source: online_events
      transform: avg(duration) over window(30d)
  validation:
    null_threshold: 0.01
    drift_threshold: 0.1
  batchSchedule: "0 2 * * *"
  stream:
    kafkaTopic: "user-events"
    timestampField: "event_time"

2) OPA Gatekeeper ConstraintTemplate

package features.validation

violation[{"msg": msg}] {
  fs := input.review.object.spec
  fs.validation.null_threshold > 0.05
  msg := sprintf("null_threshold(%.2f) 너무 높음. 5%% 이하로 설정하세요.", [fs.validation.null_threshold])
}

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: NullThresholdPolicy
metadata:
  name: enforce-null-threshold
spec:
  match:
    kinds:
      - apiGroups: ["features.example.com"]
        kinds: ["FeatureSet"]

3) Kubeflow Pipeline Template (batch_ingest)

@dsl.pipeline(name='feature-ingest-pipeline')
def ingest_pipeline(featureset: str):
    ingest = dsl.ContainerOp(
        name='batch-ingest',
        image='myorg/feature-ingestor:latest',
        arguments=['--fs', featureset],
        file_outputs={'ingest_path':'/data/output'}
    )
    validate = dsl.ContainerOp(
        name='validate',
        image='myorg/feature-validator:latest',
        arguments=['--path', ingest.outputs['ingest_path'], '--null_thresh', '0.01','--drift_thresh','0.1']
    ).after(ingest)

4) Seldon Deployment for Serving

apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: user-churn-features
spec:
  predictors:
  - graph:
      name: feast-server
      implementation: CUSTOM
      modelUri: s3://feast-online-store/user-churn-features
      env:
        - name: FEAST_CORE_URL
          value: "feast-core.my-analytics.svc:6565"
    replicas: 2




✅ 기대 효과
• 특성 일관성 보장: 스키마·변환·유효성 로직을 Git 선언
• 신속한 배치·실시간 조인: Kubeflow Pipelines로 자동 스케줄·적재
• 품질 게이트: 유효성 검사 실패 시 CI 차단
• Serve & Scale: Seldon으로 Low-latency Feature API 제공
• 모니터링·자가 치유: Freshness·Drift 지표 감시 및 자동 복구
• 완전한 GitOps: FeatureSet부터 Serving까지 모든 매니페스트·이력 투명 관리

반응형