gitlab
CICD 與 Helm command line 設定
Table Of Content
CI/CD 統一管理專案: Gitlab CI/CD 抓案 部署 GKE 的動作,我是將其寫成 Module 連結在此 reference name: deploy-helm
deploy gke by helm 的 module 寫法:
重點在:
upgrade --install
更多資訊:Helm Upgrade
建立或是更新 Deployment
helm upgrade --install
deploy-helm:
- !reference [.get-timestamp, convert-time]
- export TESTVAR=$CI_COMMIT_SHORT_SHA
- kubectl config set-context --current --namespace=$NAMESPACE
- helm upgrade --install "$DEPLOYMENT_NAME" oci://${REGISTRY_REGION}/${RPA_PROJECT_ID}/bi-rpa-helm/$HELM_VERSION --namespace ${NAMESPACE} --reuse-values -f helm_value/"$TARGET_ENV".yaml --set deployment.container.image=${REGISTRY_REGION}/${RPA_PROJECT_ID}/"$REGISTRY_FOLDER"/"$REGISTRY_FILE":"$TARGET_ENV"_"$TIMESTAMP" --atomic
Deploy Job 的設定
deploy-dev-gke:
<<: *deploy_gke_template ## 會去跑上面的.deploy_gke_template: &deploy_gke_template 部分
variables:
TARGET_ENV: "dev" # 環境名稱
CLUSTER: ${DEV_CLUSTER} # GKE Cluster 名稱
NAMESPACE: ${PLATFORM} # Namespace 名稱
REGISTRY_FOLDER : ${PLATFORM} # Artifact Registry 資料夾名稱
DEPLOYMENT_NAME: ${PLATFORM}-f2e # GKE Deployment 名稱
HELM_VERSION: "app-dev" # helm chart 在 Artifact Registry 名稱
rules: # regular expression
- !reference [.reference, rules, deploy_dev]