通过 Altinity Operator for ClickHouse 部署,部署清单文件如下:
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "clickhouse"
spec:
defaults:
templates:
dataVolumeClaimTemplate: data-volume-template
logVolumeClaimTemplate: log-volume-template
configuration:
clusters:
- name: "analytics"
layout:
shardsCount: 1
replicasCount: 1
templates:
volumeClaimTemplates:
- name: data-volume-template
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- name: log-volume-template
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
部署命令
kubectl apply --namespace=clickhouse -f clickhouse-analytics.yaml
部署过程中 pod 出现 CrashLoopBackOff
NAME READY STATUS RESTARTS AGE
pod/chi-clickhouse-analytics-0-0-0 1/2 CrashLoopBackOff 2 (26s ago) 81s
对应的错误日志
注:下面的错误信息是输出命命令导致的,kubectl describe pod pod/chi-clickhouse-analytics-0-0-0 -n clickhouse
中多了 pod/
error: there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'kubectl get resource/<resource_name>' instead of 'kubectl get resource resource/<resource_name>'
然后这个部署被 clickhouse-operator 删除,请问如何解决这个问题?
kubectl describe pod
相关信息
Containers:
clickhouse:
Last State: Terminated
Reason: Error
Exit Code: 70
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 51s default-scheduler 0/17 nodes are available: 17 pod has unbound immediate PersistentVolumeClaims. preemption: 0/17 nodes are available: 17 Preemption is not helpful for scheduling.
通过下面的命令
kubectl logs chi-clickhouse-analytics-0-0-0 -n clickhouse
发现引起问题的错误日志
<Error> Application: DB::Exception: Either 'password' or 'password_sha256_hex' or 'password_double_sha1_hex' or 'no_password' or 'ldap' or 'kerberos' must be specified for user clickhouse_operator.: while parsing user 'clickhouse_operator' in users configuration file: while loading configuration file '/etc/clickhouse-server/users.xml'
清单文件中添加 users 配置后问题依旧
configuration:
users:
admin/password: ******
default/password: ******
解决了,原来需要给 clickhouse_operator
账号设置密码
configuration:
users:
clickhouse_operator/password: ******
admin/password: ******
如果使用 secret 保存密码,则使用下面的清单
spec:
configuration:
users:
clickhouse_operator/k8s_secret_password: clickhouse-credentials/admin
admin/k8s_secret_password: clickhouse-credentials/clickhouse_operator