# CJSS Terraform 使用說明 ## 1. 環境設定 ### 安裝 Terraform 請參考 [Terraform 官方網站](https://www.terraform.io/downloads.html) 下載 Terraform 的安裝檔,並安裝到本機。 ### 安裝 AWS CLI 請參考 [AWS CLI 官方網站](https://docs.aws.amazon.com/zh_tw/cli/latest/userguide/cli-chap-install.html) 安裝 AWS CLI,並設定 AWS CLI 的使用者資訊。 ### 安裝 kubectl 請參考 [kubectl 官方網站](https://kubernetes.io/docs/tasks/tools/install-kubectl/) 安裝 kubectl。 ### 安裝 helm 請參考 [helm 官方網站](https://helm.sh/docs/intro/install/) 安裝 helm。 ## 2. AWS IAM 使用者 ### 取得 AWS IAM 使用者金鑰 請參考 [AWS IAM 使用者金鑰](https://docs.aws.amazon.com/zh_tw/IAM/latest/UserGuide/id_credentials_access-keys.html) 取得 AWS IAM 使用者金鑰。 ### 設定 AWS CLI 使用者資訊 1. 將 `./.aws` 目錄複製到使用者的家目錄。 ```bash $ cp -r .aws ~/ ``` 2. 編輯 `~/.aws/credentials` 檔案,將 `YOUR_ACCESS_KEY_ID` 和 `YOUR_SECRET_ACCESS_KEY` 替換成你的 AWS IAM 使用者金鑰。 ```bash $ vi ~/.aws/credentials ``` ### 新增 AWS IAM 使用者 切換到 `iam` 目錄。 ```bash $ cd iam ``` 編輯 `variables.tf` 檔案,新增 AWS IAM 使用者。 ```bash $ vi variables.tf ``` 執行 Terraform 初始化。 ```bash $ terraform init ``` 確認 Terraform 設定。 ```bash $ terraform plan ``` 執行 Terraform 設定。 ```bash $ terraform apply ``` ## 3. Landing Zone 建置 ### SIT / UAT / PROD 切換到對應的目錄。 ```bash $ cd sit # or uat or prod ``` 編輯 `variables.tf` 檔案。 ```bash $ vi variables.tf ``` 執行 Terraform 初始化。 ```bash $ terraform init ``` 確認 Terraform 設定。 ```bash $ terraform plan ``` 執行 Terraform 設定。 ```bash $ terraform apply ``` ## 4. Kubernetes 建置 ### 設置 ~/.kube/config #### SIT ```bash $ aws eks update-kubeconfig --region ap-southeast-1 --name cjss-sit-eks-cluster ``` #### UAT ```bash $ aws eks update-kubeconfig --region ap-southeast-1 --name cjss-uat-eks-cluster ``` #### PROD ```bash $ aws eks update-kubeconfig --region ap-southeast-1 --name cjss-prod-eks-cluster ``` ### 安裝 metrics-server ```bash $ kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/high-availability-1.21+.yaml ``` ### 安裝 secrets-store-csi-driver ```bash $ helm repo add secrets-store-csi-driver https://kubernetes-sigs.github.io/secrets-store-csi-driver/charts $ helm repo update $ helm install csi-secrets-store secrets-store-csi-driver/secrets-store-csi-driver --namespace kube-system --set syncSecret.enabled=true --set enableSecretRotation=true ``` ### 安裝 secrets-store-csi-driver-provider-aws ```bash $ kubectl apply -f https://raw.githubusercontent.com/aws/secrets-store-csi-driver-provider-aws/main/deployment/aws-provider-installer.yaml ``` ### 安裝 argocd ```bash $ kubectl create namespace argocd $ kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up