Operator 安装
安装 TFRS Operator 到 Kubernetes 集群。
当前镜像
docker.cnb.cool/turingfocus/tfrs-operator:develop-0.1.1-dev3
部署前请替换为目标版本。
Kustomize 方式
前置条件
# 创建命名空间
kubectl create namespace tfrs-operator-system
# 创建镜像拉取凭证
kubectl create secret docker-registry cnb-registry-secret \
--namespace=tfrs-operator-system \
--docker-server=docker.cnb.cool \
--docker-username=<USERNAME> \
--docker-password=<PASSWORD>
部署
# 克隆仓库并切换到目标版本
git clone https://github.com/turingfocus/tfrs-operator.git
cd tfrs-operator
git checkout develop-0.1.0
# 部署
make deploy IMG=docker.cnb.cool/turingfocus/tfrs-operator:develop-0.1.0
验证
kubectl get pods -n tfrs-operator-system
# NAME READY STATUS RESTARTS AGE
# tfrs-operator-controller-manager-7bf684c9d9-lfkm6 1/1 Running 0 23s
更新镜像
kubectl set image deployment/tfrs-operator-controller-manager \
manager=docker.cnb.cool/turingfocus/tfrs-operator:<NEW_TAG> \
-n tfrs-operator-system
# deployment.apps/tfrs-operator-controller-manager image updated
卸载
make undeploy
说明
make undeploy 会删除所有 Kustomize 管理的资源(Deployment、Service、RBAC、CRD 等)。
如果使用腾讯云 TKE,namespace 删除可能被 gatekeeper 阻止,需手动删除:
kubectl delete ns tfrs-operator-system
Helm 方式
镜像版本注意事项
Helm chart 的镜像 tag 逻辑:优先使用 --set image.tag 指定的值,否则使用 Chart.yaml 中的 appVersion。
如果 appVersion 对应的镜像不存在或者部署有单独的需求,必须通过 --set image.tag=<TAG> 指定可用的镜像版本。
针对当前文档部署示例,因为部署开发镜像develop-0.1.0,因此需要使用 --set image.tag=develop-0.1.0
部署
方式一:从 OCI 仓库安装(推荐)
helm install tfrs-operator oci://helm.cnb.cool/turingfocus/tfrs-operator/tfrs-operator \
--version 0.1.0 \
--namespace tfrs-operator-system \
--create-namespace \
--set image.tag=develop-0.1.0 \
--set 'imageCredentials[0].name=cnb-registry-secret' \
--set 'imageCredentials[0].registry=docker.cnb.cool' \
--set 'imageCredentials[0].username=<USERNAME>' \
--set 'imageCredentials[0].password=<PASSWORD>'
方式二:从本地源码安装
git clone https://github.com/turingfocus/tfrs-operator.git
cd tfrs-operator
helm install tfrs-operator ./chart \
--namespace tfrs-operator-system \
--create-namespace \
--set image.tag=develop-0.1.0 \
--set 'imageCredentials[0].name=cnb-registry-secret' \
--set 'imageCredentials[0].registry=docker.cnb.cool' \
--set 'imageCredentials[0].username=<USERNAME>' \
--set 'imageCredentials[0].password=<PASSWORD>'
说明
imageCredentials 会创建 docker-registry Secret 并自动绑定到 ServiceAccount。
验证
kubectl get pods -n tfrs-operator-system
更新镜像
helm upgrade tfrs-operator oci://helm.cnb.cool/turingfocus/tfrs-operator/tfrs-operator \
--version 0.1.0 \
--namespace tfrs-operator-system \
--reuse-values \
--set image.tag=<NEW_TAG>
# Release "tfrs-operator" has been upgraded. Happy Helming!
# REVISION: 2
卸载
helm uninstall tfrs-operator -n tfrs-operator-system
# release "tfrs-operator" uninstalled
说明
Helm 卸载会清理 Deployment、Service、RBAC 等资源,但 CRD 会保留(Helm 标准行为,防止数据丢失)。
如需删除 CRD:
kubectl delete crd tfrclusters.infra.tfrobotserver.cn \
tfrtenants.infra.tfrobotserver.cn \
tfrservers.tfrobot.tfrobotserver.cn