我正在嘗試通過 AKS 集群中的 Terraform 部署 ArgoCD 和位于子檔案夾中的應用程式。
這是我的檔案夾結構樹:
我正在使用應用程式方法,所以首先我將部署 ArgoCD(這也將自行管理),稍后 ArgoCD 將讓我在安裝后手動同步集群插件和應用程式。
apps
cluster-addons
AKV2K8S
Cert-Manager
Ingress-nginx
application
application-A
argocd
override-values.yaml
Chart
當我在 AKS 集群中手動運行命令“helm install ...”時,一切都安裝得很好。ArgoCD 已安裝,后來當我訪問 ArgoCD 時,我發現其余的應用程式丟失了,我可以手動同步它們。
但是,如果我想通過 Terraform 安裝它,則只安裝 ArgoCD,但看起來它沒有“檢測”到 override_values.yaml 檔案:
我的意思是,ArgoCD 和 ArgoCD 應用程式集控制器安裝在集群中,但 ArgoCD 不會“檢測”為我的 AKS 集群定制的 values.yaml 檔案。如果我在集群上手動運行“helm install”,一切正常,但不能通過 Terraform
resource "helm_release" "argocd_applicationset" {
name = "argocd-applicationset"
repository = https://argoproj.github.io/argo-helm
chart = "argocd-applicationset"
namespace = "argocd"
version = "1.11.0"
}
resource "helm_release" "argocd" {
name = "argocd"
repository = https://argoproj.github.io/argo-helm
chart = "argo-cd"
namespace = "argocd"
version = "3.33.6"
values = [
"${file("values.yaml")}"
]
values.yaml 檔案位于我有用于安裝 argocd 和 argocd 應用程式集的 TF 代碼的檔案夾中。
我試圖將檔案“values.yaml”的名稱更改為“override_values.yaml”,但同樣的問題。
我在 override_values.yaml 檔案中更改了很多東西,所以我不能在 TF 代碼中使用“set”...
另外,我嘗試添加:
values = [
"${yamlencode(file("values.yaml"))}"
]
但我在管道中的“應用”步驟中收到此錯誤:
error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {} "argo-cd:\r\n ## ArgoCD configuration\r\n ## Ref: https://github.com/argoproj/argo-cd\r\n
可能是因為不是 JSON 檔案?將此檔案轉換為 JSON 檔案是否有意義?
Any idea if I can pass this override values yaml file through terraform?
If not, please may you post a clear/full example with mock variables on how to do that using Azure pipeline?
Thanks in advance!
uj5u.com熱心網友回復:
問題在于 TF 代碼中的值標識。
當我解決這個問題時,問題就解決了:
resource "helm_release" "argocd_applicationset" {
name = "argocd-applicationset"
repository = https://argoproj.github.io/argo-helm
chart = "argocd-applicationset"
namespace = "argocd"
version = "1.11.0"
}
resource "helm_release" "argocd" {
name = "argocd"
repository = https://argoproj.github.io/argo-helm
chart = "argo-cd"
namespace = "argocd"
version = "3.33.6"
values = [file("values.yaml")]
參考也可以正常作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/439788.html
標籤:azure kubernetes azure-devops terraform argocd
