이 문서는 Pulumi를 사용하여 Oracle Cloud Infrastructure(OCI)에서 Oracle Kubernetes Engine(OKE) 클러스터를 생성하고, Cluster API를 통해 전체 인프라를 관리하는 방법을 설명합니다.
- 수동 관리의 한계: 웹 콘솔을 통한 수동 인프라 관리로 인한 실수와 일관성 부족
- 환경 간 불일치: 개발, 스테이징, 프로덕션 환경 간의 설정 차이
- 복잡한 멀티 클러스터 관리: 여러 Kubernetes 클러스터의 생명주기 관리 복잡성
- Infrastructure as Code: 모든 인프라를 코드로 정의하여 버전 관리 및 재현 가능한 배포
- 자동화된 워크플로우: Pulumi + Cluster API를 통한 선언적 인프라 관리
- 표준화된 환경: 동일한 템플릿으로 일관된 클러스터 환경 제공
시간 단축: 클러스터 생성 4-6시간 → 15-30분
운영 효율: 수동 작업 최소화 및 자동화된 장애 복구
비용 절감: 리소스 최적화 및 운영 인력 절약
- macOS/Linux/Windows
- Python 3.8 이상
- Node.js 14 이상
- Docker (선택사항)
- Pulumi CLI
- OCI CLI
- kubectl
- Python 가상환경 (venv)
# macOS (Homebrew 사용)
brew install pulumi/tap/pulumi
# Linux
curl -fsSL https://get.pulumi.com | sh
# Windows (Chocolatey 사용)
choco install pulumi# 기본 조직 설정
pulumi org set-default <your-organization-name># Terraform을 Pulumi Python 코드로 변환
pulumi convert --from terraform --language python
⚠️ 주의: 이 명령어는pulumi new python과 유사한 효과를 발생시켜 기존 파일(__main__.py,.gitignore등)을 덮어쓸 수 있습니다.
# macOS (Homebrew 사용)
brew install oci-cli
# Linux/Windows
bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"# OCI 설정 초기화
oci setup config
# 설정 파일 확인
cat ~/.oci/config# 기본 프로필을 'os'로 변경
vi ~/.oci/oci_cli_rcoci_cli_rc 파일 내용:
[OCI_CLI_SETTINGS]
default_profile=os# 프로필 변경 확인
echo $OCI_CLI_PROFILE
# 사용자 정보 확인
oci iam user get --user-id $(oci iam user list --query "data[?\"lifecycle-state\"=='ACTIVE'].id | [0]" --raw-output)
# 세션 유효성 검증
oci session validate# make를 사용한 가상환경 생성 및 활성화
make venv
# 또는
# 가상환경 생성
python -m venv venv
# 가상환경 활성화 (macOS/Linux)
source venv/bin/activate
# 가상환경 활성화 (Windows)
venv\Scripts\activate# Make를 사용한 설치
make installCmd + Shift + P(macOS) 또는Ctrl + Shift + P(Windows/Linux)Python: Select Interpreter선택venv환경 선택
# 프로덕션 스택 초기화
pulumi stack init prodchmod +x ./setup_config.sh
./setup_config.sh📝 참고: 이 스크립트를 실행하면
Pulumi.prod.yaml파일에 설정값이 저장됩니다.
# 모든 스택 확인
pulumi stack ls -a
# 스택 삭제 (필요한 경우)
pulumi stack rm prod# 모든 리소스 배포
make up
# 또는 직접 Pulumi 명령 사용
pulumi up# 스택 상태 확인
pulumi stack
# 출력 값 확인
pulumi stack output
# 리소스 상태 확인
pulumi stack export# OKE 클러스터의 kubeconfig 획득
oci ce cluster create-kubeconfig \
--cluster-id $(pulumi stack output cluster_id) \
--file ~/.kube/config \
--region ap-osaka-1 \
--token-version 2.0.0
# kubectl 연결 확인
kubectl get nodes# OKE 클러스터 상태 확인
oci ce cluster get --cluster-id $(pulumi stack output cluster_id)
# 노드 풀 상태 확인
oci ce node-pool get --node-pool-id $(pulumi stack output node_pool_id)# Pulumi 로그 확인
pulumi logs
# OCI 감사 로그 확인 (웹 콘솔)
# OCI Console > Governance & Administration > Audit# 모든 리소스 삭제
pulumi destroy
# 확인 후 실행
pulumi destroy --yes# 스택 삭제
pulumi stack rm dev# OCI 설정 확인
oci setup repair-file-permissions --file ~/.oci/config
oci setup repair-file-permissions --file ~/.oci/oci_api_key.pem# 상태 새로고침
pulumi refresh
# 상태 복구
pulumi stack import# kubeconfig 재생성
oci ce cluster create-kubeconfig \
--cluster-id <cluster-id> \
--file ~/.kube/config \
--region ap-osaka-1 \
--overwrite# Pulumi 디버그 모드
pulumi up --debug
이 프로젝트는 MIT 라이선스를 따릅니다.
버그 리포트, 기능 요청, 풀 리퀘스트는 언제든지 환영합니다!
작성자: Flexyz
이메일: contact@flexyz.work
깃헙: https://github.com/flexyzwork
웹사이트: https://flexyz.work
최종 업데이트: 2025년 6월 2일
버전: 1.0.0
This document explains how to create Oracle Kubernetes Engine (OKE) clusters on Oracle Cloud Infrastructure (OCI) using Pulumi and manage the entire infrastructure through Cluster API.
- Manual Management Limitations: Errors and lack of consistency due to manual infrastructure management through web console
- Environment Inconsistency: Configuration differences between development, staging, and production environments
- Complex Multi-Cluster Management: Complexity in managing the lifecycle of multiple Kubernetes clusters
- Infrastructure as Code: Define all infrastructure as code for version control and reproducible deployments
- Automated Workflows: Declarative infrastructure management through Pulumi + Cluster API
- Standardized Environments: Consistent cluster environments using identical templates
Time Reduction: Cluster creation 4-6 hours → 15-30 minutes
Operational Efficiency: Minimize manual work and automated failure recovery
Cost Savings: Resource optimization and operational workforce reduction
- Prerequisites
- Pulumi Installation and Setup
- OCI CLI Setup
- Python Environment Setup
- Pulumi Stack Configuration
- Infrastructure Deployment
- Troubleshooting
- macOS/Linux/Windows
- Python 3.8 or higher
- Node.js 14 or higher
- Docker (optional)
- Pulumi CLI
- OCI CLI
- kubectl
- Python virtual environment (venv)
# macOS (using Homebrew)
brew install pulumi/tap/pulumi
# Linux
curl -fsSL https://get.pulumi.com | sh
# Windows (using Chocolatey)
choco install pulumi# Set default organization
pulumi org set-default codelab-kr# Convert Terraform to Pulumi Python code
pulumi convert --from terraform --language python
⚠️ Warning: This command has a similar effect topulumi new pythonand may overwrite existing files (__main__.py,.gitignore, etc.).
# macOS (using Homebrew)
brew install oci-cli
# Linux/Windows
bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"# Initialize OCI configuration
oci setup config
# Check configuration file
cat ~/.oci/config# Change default profile to 'os'
vi ~/.oci/oci_cli_rcoci_cli_rc file content:
[OCI_CLI_SETTINGS]
default_profile=os# Check profile change
echo $OCI_CLI_PROFILE
# Check user information
oci iam user get --user-id $(oci iam user list --query "data[?\"lifecycle-state\"=='ACTIVE'].id | [0]" --raw-output)
# Validate session
oci session validate# Create and activate virtual environment using make
make venv
# Or manually
# Create virtual environment
python -m venv venv
# Activate virtual environment (macOS/Linux)
source venv/bin/activate
# Activate virtual environment (Windows)
venv\Scripts\activate# Install using Make
make install- Press
Cmd + Shift + P(macOS) orCtrl + Shift + P(Windows/Linux) - Select
Python: Select Interpreter - Choose the
venvenvironment
# Initialize production stack
pulumi stack init prodchmod +x ./setup_config.sh
./setup_config.sh📝 Note: These settings are stored in the
Pulumi.prod.yamlfile.
# Check all stacks
pulumi stack ls -a
# Delete stack (if needed)
pulumi stack rm dev# Deploy all resources
make up
# Or use Pulumi command directly
pulumi up# Check stack status
pulumi stack
# Check output values
pulumi stack output
# Check resource status
pulumi stack export# Obtain kubeconfig for OKE cluster
oci ce cluster create-kubeconfig \
--cluster-id $(pulumi stack output cluster_id) \
--file ~/.kube/config \
--region ap-osaka-1 \
--token-version 2.0.0
# Verify kubectl connection
kubectl get nodes# Check OKE cluster status
oci ce cluster get --cluster-id $(pulumi stack output cluster_id)
# Check node pool status
oci ce node-pool get --node-pool-id $(pulumi stack output node_pool_id)# Check Pulumi logs
pulumi logs
# Check OCI audit logs (web console)
# OCI Console > Governance & Administration > Audit# Delete all resources
pulumi destroy
# Execute with confirmation
pulumi destroy --yes# Delete stack
pulumi stack rm dev# Check OCI configuration
oci setup repair-file-permissions --file ~/.oci/config
oci setup repair-file-permissions --file ~/.oci/oci_api_key.pem# Refresh state
pulumi refresh
# Recover state
pulumi stack import# Regenerate kubeconfig
oci ce cluster create-kubeconfig \
--cluster-id <cluster-id> \
--file ~/.kube/config \
--region ap-osaka-1 \
--overwrite# Pulumi debug mode
pulumi up --debug- Pulumi Kubernetes Provider
- Pulumi OCI Provider
- OCI Container Engine for Kubernetes
- OCI CLI Official Documentation
This project is licensed under the MIT License.
Bug reports, feature requests, and pull requests are always welcome!
Author: flexyz
Email: contact@flexyz.work
GitHub: https://github.com/flexyzwork
Website: https://flexyz.work
Last Updated: 2th June 2025
Version: 1.0.0