Kubernetes Newbie here.
我正在跟随Marc Lamberti的youtube教程,关于如何使用Kubernetes在本地安装气流-使用Kind。我可以使用以下命令创建k8s集群:
kind create cluster --name airflow-cluster --config kind-cluster.yaml
helm repo add apache-airflow https://airflow.apache.org
helm repo update
kubectl create namespace airflow
helm install airflow apache-airflow/airflow --namespace airflow --debug
# Port forward
kubectl port-forward svc/airflow-webserver 8080:8080 -n airflow --context kind-airflow-cluster
下一步是升级生成值。Yaml使用下面的命令
helm show values apache-airflow/airflow > values.yaml
下一步是修改这些值。但是,如果我修改了这些值,就会运行helm upgrade
。无论是否使用yaml文件,我都得到以下错误:
helm upgrade --install airflow apache-airflow/airflow -n airflow -f values.yaml --debug
history.go:56: [debug] getting history for release airflow
upgrade.go:144: [debug] preparing upgrade for airflow
Error: UPGRADE FAILED: execution error at (airflow/charts/postgresql/templates/secrets.yaml:20:15):
PASSWORDS ERROR: The secret "airflow-postgresql" does not contain the key "password"
helm.go:84: [debug] execution error at (airflow/charts/postgresql/templates/secrets.yaml:20:15):
PASSWORDS ERROR: The secret "airflow-postgresql" does not contain the key "password"
UPGRADE FAILED
main.newUpgradeCmd.func2
helm.sh/helm/v3/cmd/helm/upgrade.go:203
github.com/spf13/cobra.(*Command).execute
github.com/spf13/cobra@v1.6.1/command.go:916
github.com/spf13/cobra.(*Command).ExecuteC
github.com/spf13/cobra@v1.6.1/command.go:1044
github.com/spf13/cobra.(*Command).Execute
github.com/spf13/cobra@v1.6.1/command.go:968
main.main
helm.sh/helm/v3/cmd/helm/helm.go:83
runtime.main
runtime/proc.go:250
runtime.goexit
runtime/asm_arm64.s:1172
在检查秘密airflow-postgresql
时,我发现它的数据中有postgres-password
,但没有password
,所以我添加了它。
$ k describe secret airflow-postgresql
Name: airflow-postgresql
Namespace: airflow
Labels: app.kubernetes.io/instance=airflow
app.kubernetes.io/managed-by=Helm
app.kubernetes.io/name=postgresql
helm.sh/chart=postgresql-12.1.9
Annotations: meta.helm.sh/release-name: airflow
meta.helm.sh/release-namespace: airflow
Type: Opaque
Data
====
postgres-password: 8 bytes
如何添加密码-
export POSTGRES_PASS=$(kubectl get secret airflow-postgresql -o jsonpath="{.data.postgres-password}" | base64 --decode)
k create secret generic airflow-postgresql --from-literal=password=$POSTGRES_PASS --dry-run=client -o yaml | k apply -f -
我将密码数据添加到secret中并重试。这次我没有同样的错误,但是postgres pod进入CrashLoop Backoff
,我可以在pod的日志中看到pod正在关闭。
│ postgresql 23:36:12.33 INFO ==> ** Starting PostgreSQL ** ││ 2023-04-04 23:36:12.348 GMT [1] LOG: pgaudit extension initialized │
│ 2023-04-04 23:36:12.349 GMT [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 ││ 2023-04-04 23:36:12.349 GMT [1] LOG: listening on IPv6 address "::", port 5432 │
│ 2023-04-04 23:36:12.350 GMT [1] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" ││ 2023-04-04 23:36:12.356 GMT [95] LOG: database system was shut down at 2023-04-04 23:36:12 GMT │
│ 2023-04-04 23:36:12.360 GMT [1] LOG: database system is ready to accept connections ││ 2023-04-04 23:37:42.055 GMT [1] LOG: received smart shutdown request │
│ 2023-04-04 23:37:42.066 GMT [1] LOG: background worker "logical replication launcher" (PID 101) exited with exit c ││ 2023-04-04 23:37:42.066 GMT [96] LOG: shutting down │
│ 2023-04-04 23:37:42.076 GMT [1] LOG: database system is shut down ││ Stream closed EOF for airflow/airflow-postgresql-0 (postgresql) │
由于上述原因,其他pod - scheduler, webserver无法连接到DB,并且也处于CrashLoopBackoff
状态。(我可以在他们的日志中看到最后一次尝试连接到DB)
我不确定我需要做什么才能使用值。
非常感谢您的阅读。任何指导将是非常感激的谢谢你!
根据官方手册https://helm.sh/docs/helm/helm_show_values/,helm show values
只显示其原始chart
的原始值
由于您没有指定图表版本,您的install
命令可能使用与install --upgrade
命令不同的版本。
升级安装的正确方法是从安装中获取helm release
值,并将compare
与新的chart version
中的values.yaml
一起获取,并调整新的所需value
。
有些步骤可能会有帮助:
Step1:获取你已经安装的图表版本:helm -n airflow list
,你会看到如下内容(以我的tooljet
版本为例):
tooljet it 12 2023-03-17 21:03:42.9213007 +0800 CST deployed app-0.7.7 0.1.0
这里
app-0.7.7
表示图表名称为app
,图表版本为0.7.7
。
Step2:获取您之前安装的helm版本的图表值:helm show values apache-airflow/airflow --version=0.7.7 > values-old.yaml
(记住将0.7.7
更改为helm release
版本,如step1
所示)
Step3:获取最新的图表值:helm show values apache-airflow/airflow > values-new.yaml
Step4:比较values-old.yaml
和values-new.yaml
,从新的图表中找出values
是新需要的。现在您可以在values-old.yaml
中添加缺失的值,并在helm upgrade --install airflow apache/airflow -f values-old.yaml
命令中使用它。
警告如果你改变了图表值,你最好从你的helm release
中合并values.yaml
,你可以从命令:helm -n airflow get values airflow > values-effect.yaml
中得到它的有效values
。现在你的最终值应该包含values-old.yaml
,values-effect.yaml
和missing new required values
的合并值。
谢谢。我和你有同样的问题。我还解决了这个问题,将版本从1.8.0更改为1.7.0。:)