Skip to content

Latest commit

 

History

History
91 lines (63 loc) · 2.98 KB

README.md

File metadata and controls

91 lines (63 loc) · 2.98 KB

Dancing with GitOps

Dancing with GitOps

Prerequisites

需要安裝以下工具:

需要有 DigitalOcean 帳號,並且建立一組 Personal Access Token,再將 Token 設定到 Terraform 變數中:

MY_DO_TOKEN="YOUR_DIGITALOCEAN_PERSONAL_ACCESS_TOKEN"
echo 'do_token = "$MY_DO_TOKEN"' > 01-terraform/terraform.tfvars

Setup

01. Create Kubernetes Clusters

透過 Terraform 在 DigitalOcean 上建立兩組 Kubernetes Cluster,用於模擬 Dev 與 Prod 環境:

terraform -chdir=01-terraform init
terraform -chdir=01-terraform apply

02. Install Required Applications

Install ArgoCD

依據 ArgoCD 官方文件安裝 ArgoCD:

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/core-install.yaml

Install Nginx Ingress Controller

依據 Nginx Ingress Controller 官方文件 安裝 Nginx Ingress Controller:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.9.5/deploy/static/provider/do/deploy.yaml

# Dev 環境
kubectl apply -f 02-argocd-ingress/dev/argocd-ingress.yaml
# Prod 環境
kubectl apply -f 02-argocd-ingress/dev/argocd-ingress.yaml

Install Reloader

由於 ConfigMap 的變更不會觸發 Pod 重啟,因此需要安裝 Reloader 來監控 ConfigMap 的變更, 依據 Reloader 官方文件 安裝 Reloader:

helm repo add stakater https://stakater.github.io/stakater-charts
helm repo update
kubectl create namespace reloader
helm install -n reloader reloader stakater/reloader

03. Deploy Example Application Manually

手動部署 Example Application:

# Dev 環境
kubectl apply -k 03-kustomize-example/overlays/dev
# Prod 環境
kubectl apply -k 03-kustomize-example/overlays/prod

04. Deploy Example Application with ArgoCD

手動建立 ArgoCD Application(CRD),再由 ArgoCD 自動化部署 Example Application:

# Dev 環境
kubectl apply -f 04-argocd-crd/argocd-applications-dev.yaml
# Prod 環境
kubectl apply -f 04-argocd-crd/argocd-applications-prod.yaml