Ubuntu 22.04 部署 Apache Solr Operator(Kind 集群)安装指南
Ubuntu 22.04 从零部署 Apache Solr Operator 0.9.1 全流程:kubectl/kind/helm 安装、Kind 集群与镜像加速配置、cert-manager、helm 安装与三大排障实录(hook 超时、CRD 缺失、镜像注入)
Ubuntu 22.04 部署 Apache Solr Operator(Kind 集群)安装指南
目标:在 Ubuntu 22.04 服务器上从零搭一套可用的 Apache Solr Operator 0.9.1 环境:Kind 单节点 Kubernetes 1.32 集群 → cert-manager → Solr Operator,并覆盖国内网络环境下全部实测排障(镜像加速、helm hook 超时、ZookeeperCluster CRD 缺失)。装完即可按《Apache Solr Operator CRD 详解与调谐实测》部署 SolrCloud。
一、环境与目标
- 操作系统:Ubuntu 22.04(x86_64),
root密码q1w2e3r4 - Docker:29.8.1(Kind 依赖)
- 目标版本:Solr Operator 0.9.1(helm chart 与 app 同版)、cert-manager v1.16.2、ZooKeeper Operator 0.2.15(随 chart 安装)
- 完成后:
kubectl get crd出现 3 个 Solr CRD,operator 双 Deployment Running
$ docker --version
Docker version 29.8.1, build ...
$ free -g | head -2
total used free
Mem: 31 6 2
二、安装 kubectl / kind / helm
root@server:~# mkdir -p /root/.local/bin && cd /tmp
root@server:~# curl -sSL -o kubectl https://dl.k8s.io/release/$(curl -sSL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl
root@server:~# chmod +x kubectl && mv kubectl /root/.local/bin/
root@server:~# curl -sSL -o kind https://kind.sigs.k8s.io/dl/v0.25.0/kind-linux-amd64
root@server:~# chmod +x kind && mv kind /root/.local/bin/
root@server:~# curl -sSL -o helm.tgz https://mirrors.huaweicloud.com/helm/v3.17.1/helm-v3.17.1-linux-amd64.tar.gz
root@server:~# tar -xzf helm.tgz && mv linux-amd64/helm /root/.local/bin/
实测版本:
$ kubectl version --client
Client Version: v1.37.1
$ kind version
kind v0.25.0 go1.22.9 linux/amd64
$ helm version
version.BuildInfo{Version:"v3.17.1", ...}
下载源提示:
dl.k8s.io直连可用;kind 二进制经 GitHub release 分发,若直连失败用镜像代理;helm 用华为云镜像mirrors.huaweicloud.com/helm/(实测 17MB 下载正常,get.helm.sh在本环境不可达)。
三、创建 Kind 集群(关键:节点内镜像加速)
3.1 为什么要配 containerd mirror
Kind 节点是独立容器,内部的 containerd 不会继承宿主机 docker 的 registry-mirrors 配置。Solr Operator 全家桶镜像都在 Docker Hub,不配加速必然 ImagePullBackOff(实测报 dial tcp 174.37.175.229:443: connect: connection refused,域名解析被污染)。
写 /opt/kind/kind-config.yaml:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://docker.1ms.run", "https://docker.m.daocloud.io"]
3.2 创建集群
root@server:~# kind create cluster --name solr-op --image kindest/node:v1.32.0 --config /opt/kind/kind-config.yaml --wait 300s
实测输出(节点 18 秒就绪):
• Starting control-plane 🕹️ ...
✓ Starting control-plane 🕹️
• Installing CNI 🔌 ...
✓ Installing StorageClass 💾 ...
✓ Waiting ≤ 5m0s for control-plane = Ready ⏳ ...
✓ Ready after 18s 💚
Set kubectl context to "kind-solr-op"
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
solr-op-control-plane Ready control-plane 21s v1.32.0
验证 patch 生效(节点内 containerd 配置):
$ docker exec solr-op-control-plane grep -A2 "docker.io" /etc/containerd/config.toml
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://docker.1ms.run", "https://docker.m.daocloud.io"]
四、安装 cert-manager
Solr Operator 依赖 cert-manager 管理 TLS。下载 v1.16.2 静态清单并应用:
root@server:~# curl -sSL -o cert-manager.yaml https://<github代理>/cert-manager/cert-manager/releases/download/v1.16.2/cert-manager.yaml
root@server:~# kubectl apply -f cert-manager.yaml
root@server:~# kubectl -n cert-manager wait --for=condition=Available deployment --all --timeout=300s
实测等待结果:
deployment.apps/cert-manager condition met
deployment.apps/cert-manager-cainjector condition met
deployment.apps/cert-manager-webhook condition met
五、安装 Solr Operator
5.1 添加 chart 仓库
官方文档的 https://solr.apache.org/operator/chart 已 404(实测),现地址为 https://solr.apache.org/charts(302 到 nightlies.apache.org):
root@server:~# helm repo add apache-solr https://solr.apache.org/charts
"apache-solr" has been added to your repositories
root@server:~# helm search repo apache-solr
NAME CHART VERSION APP VERSION DESCRIPTION
apache-solr/solr 0.9.1 8.11.1 A SolrCloud cluster running on Kubernetes ...
apache-solr/solr-operator 0.9.1 v0.9.1 The Solr Operator enables easy management ...
5.2 安装(含两个关键参数)
root@server:~# helm install solr-operator apache-solr/solr-operator --version 0.9.1 --set zookeeper-operator.crd.create=true --timeout 12m
NAME: solr-operator
LAST DEPLOYED: Thu Oct 15 13:12:28 2026
STATUS: deployed
NOTES:
Solr-Operator successfully installed!
两个参数的来历(实测排障结论):
--set zookeeper-operator.crd.create=true:主 chart 默认 不注册zookeeperclusters.zookeeper.pravega.ioCRD(注释原文:"Otherwise the ZookeeperCluster CRD will be deleted when deleting the Solr Operator helm chart release")。不开启时 operator 会陷入重启循环,日志反复报:
{"level":"error",..."msg":"if kind is a CRD, it should be installed before calling Start",
"kind":"ZookeeperCluster.zookeeper.pravega.io",
"error":"no matches for kind \"ZookeeperCluster\" in version \"zookeeper.pravega.io/v1beta1\""}
--timeout 12m:chart 的 post-install hook 会等 operator 就绪,默认 5 分钟在慢网络下不够(详见第 8 节排障)。
5.3 验证安装
$ kubectl get crd | grep -E "solr|zookeeper"
solrbackups.solr.apache.org 2026-10-15T04:33:13Z
solrclouds.solr.apache.org 2026-10-15T04:33:13Z
solrprometheusexporters.solr.apache.org 2026-10-15T04:33:13Z
zookeeperclusters.zookeeper.pravega.io 2026-10-15T05:12:29Z
$ kubectl get pods | grep operator
solr-operator-f696f489f-c2c7q 1/1 Running 0 42s
solr-operator-zookeeper-operator-7f884cf47f-hfn7m 1/1 Running 0 42s
$ helm list
NAME NAMESPACE REVISION STATUS CHART APP VERSION
solr-operator default 1 deployed solr-operator-0.9.1 v0.9.1
operator 启动日志确认 4 类控制器注册(实测节选):
INFO Starting Controller {"controller": "solrcloud", "controllerGroup": "solr.apache.org", ...}
INFO Starting workers {"controller": "solrbackup", ..., "worker count": 1}
INFO Starting workers {"controller": "solrprometheusexporter", ..., "worker count": 1}
operator Deployment 实际启动参数(实测):
["-zk-operator=true","--tls-skip-verify-server=true","--tls-watch-cert=true",
"--health-probe-bind-address=:8081","--metrics-bind-address=:8080","--leader-elect=true"]
六、升级与卸载
# 升级(同版本重装或升 chart 版本)
root@server:~# helm upgrade solr-operator apache-solr/solr-operator --version <新版本> --reuse-values
# 卸载(CRD 由 chart crds/ 安装,helm 不会自动删,需手动清理)
root@server:~# helm uninstall solr-operator
root@server:~# kubectl delete crd solrbackups.solr.apache.org solrclouds.solr.apache.org solrprometheusexporters.solr.apache.org
# 若开启过 zookeeper-operator.crd.create,还应处理 zookeeperclusters CRD
七、离线/受限网络下的镜像预注入(实测可靠路径)
若节点内 mirror 也不稳(实测出现过加速站 CDN TLS handshake timeout),最可靠的方式是宿主机拉取 → 注入节点:
# 1) 宿主机经自身镜像加速拉取
root@server:~# docker pull apache/solr-operator:v0.9.1
root@server:~# docker pull pravega/zookeeper-operator:0.2.15
root@server:~# docker pull lachlanevenson/k8s-kubectl:v1.23.2
# 2) 导出 tar 并灌入节点 containerd(k8s.io 命名空间)
root@server:~# docker save apache/solr-operator:v0.9.1 pravega/zookeeper-operator:0.2.15 lachlanevenson/k8s-kubectl:v1.23.2 -o /tmp/op-images.tar
root@server:~# cat /tmp/op-images.tar | docker exec -i solr-op-control-plane sh -c 'cat > /tmp/op-images.tar'
root@server:~# docker exec solr-op-control-plane ctr --namespace k8s.io images import /tmp/op-images.tar
实测导入结果:
unpacking docker.io/apache/solr-operator:v0.9.1 (...)...done
unpacking docker.io/pravega/zookeeper-operator:0.2.15 (...)...done
unpacking docker.io/lachlanevenson/k8s-kubectl:v1.23.2 (...)...done
注意:
kind load docker-image在 Docker 29 + kind 0.25 组合下实测报content digest ... not found,用上面的docker save + ctr import管道更稳。
部署 SolrCloud 前还需预注入(镜像名实测取自 pod spec):
root@server:~# docker pull solr:8.11 # operator 默认 Solr 镜像(spec.solrImage 可覆盖)
root@server:~# docker pull pravega/zookeeper:0.2.15
root@server:~# docker pull busybox:1.28.0-glibc # Solr pod init 容器镜像,不预注入会卡 Init:0/1
个别 tar 导入失败时(实测 busybox 镜像 ctr import 报 content digest not found),改在节点内用镜像站完整路径拉取再打标签:
root@server:~# docker exec solr-op-control-plane sh -c \
'crictl pull docker.1ms.run/library/busybox:1.28.0-glibc && \
ctr --namespace k8s.io images tag docker.1ms.run/library/busybox:1.28.0-glibc docker.io/library/busybox:1.28.0-glibc'
八、排障实录速查
| 现象 | 根因 | 解法 |
|---|---|---|
helm install 报 failed post-install: timed out waiting for the condition | hook 等 operator 就绪超时(镜像没就位) | 先解决镜像(第 7 节),再 helm upgrade --reuse-values 或带 --timeout 12m 重装 |
operator pod 反复重启,日志 no matches for kind "ZookeeperCluster" | 主 chart 默认不注册 zk CRD | --set zookeeper-operator.crd.create=true 重装 |
operator pod ImagePullBackOff | Kind 节点内 containerd 无加速/加速站不稳 | kind-config 配 mirror 重建集群,或 docker save + ctr import |
SolrCloud pods 卡 Init:0/1 | init 容器镜像 library/busybox:1.28.0-glibc 未预注入 | 按第 7 节注入 busybox |
helm search 无 apache-solr | 用了已失效的 /operator/chart 旧地址 | helm repo add apache-solr https://solr.apache.org/charts |
kind load docker-image 报 content digest not found | Docker 29 与 kind 0.25 导出格式兼容问题 | 用 docker save 管道 + ctr import |
九、小结
- 安装链路:Kind 集群(containerd mirror)→ cert-manager →
helm install apache-solr/solr-operator --version 0.9.1 --set zookeeper-operator.crd.create=true; - 三大实测坑:旧 chart 地址 404 / ZookeeperCluster CRD 默认不装 / post-install hook 超时;
- 国内受限网络的最稳路径:宿主机 docker pull(走宿主加速)→ docker save → ctr import 进节点,SolrCloud 相关 6 个镜像(solr-operator、zookeeper-operator、k8s-kubectl、solr、zookeeper、busybox)一次备齐。