You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于k3d的本地Kubernetes部署:Docker镜像推送及相关操作疑问

Proto.Actor示例项目部署到k3d集群完整指南

核心疑问解答

1. 镜像推送目标选择

  • k3d本地仓库:纯本地测试首选,无需外网、额外账号,速度最快
  • Docker Hub/GitHub Container Registry:如果要和团队共享镜像,或后续部署到外部集群可选,但需要注册对应平台账号并获取推送权限

2. k3d本地仓库的Helm values配置

k3d创建集群时自带的本地镜像仓库地址格式为 k3d-<集群名称>-registry:5000。比如你集群名叫proto-actor-cluster,values.yaml里的repository字段就填 k3d-proto-actor-registry:5000/proto-cluster-tutorial(对应第一个镜像),tag保持1.0.0即可。

3. 切换kubectl的集群上下文

先查看所有可用集群上下文:

kubectl config get-contexts

找到k3d集群对应的上下文(名字一般是k3d-<集群名称>),然后切换:

kubectl config use-context k3d-proto-actor-cluster

之后kubectl的所有操作都会指向k3d集群,不再访问Docker Desktop的K8s集群。

完整部署步骤(k3d + Helm + kubectl)

步骤1:创建带本地仓库的k3d集群

直接创建带内置镜像仓库的k3d集群,方便本地镜像推送:

k3d cluster create proto-actor-cluster --registry-create k3d-proto-actor-registry:5000

步骤2:推送本地镜像到k3d仓库

先给已构建的镜像打k3d仓库的标签,再推送:

# 处理proto-cluster-tutorial镜像
docker tag proto-cluster-tutorial:1.0.0 k3d-proto-actor-registry:5000/proto-cluster-tutorial:1.0.0
docker push k3d-proto-actor-registry:5000/proto-cluster-tutorial:1.0.0

# 处理smart-bulb-simulator-app镜像
docker tag smart-bulb-simulator-app:1.0.0 k3d-proto-actor-registry:5000/smart-bulb-simulator-app:1.0.0
docker push k3d-proto-actor-registry:5000/smart-bulb-simulator-app:1.0.0

步骤3:配置Helm Chart的values.yaml

修改Helm chart配置文件,替换镜像地址为k3d仓库地址:

# proto-cluster-tutorial的镜像配置
protoClusterTutorial:
  image:
    repository: k3d-proto-actor-registry:5000/proto-cluster-tutorial
    tag: 1.0.0
    pullPolicy: IfNotPresent

# smart-bulb-simulator-app的镜像配置
smartBulbSimulator:
  image:
    repository: k3d-proto-actor-registry:5000/smart-bulb-simulator-app
    tag: 1.0.0
    pullPolicy: IfNotPresent

提示:把pullPolicy设为IfNotPresent,避免重复拉取本地已有的镜像

步骤4:切换kubectl到k3d集群上下文

执行命令切换上下文,确保kubectl操作指向k3d集群:

kubectl config use-context k3d-proto-actor-cluster

步骤5:安装Helm Chart

假设你的Helm chart目录名为proto-actor-chart,执行安装命令:

helm install proto-actor-deploy ./proto-actor-chart

步骤6:验证部署状态

# 查看所有Pod状态,确认都处于Running状态
kubectl get pods
# 查看服务信息
kubectl get services
# 若有异常,查看Pod日志排查
kubectl logs <你的Pod名称>

内容的提问来源于stack exchange,提问作者nop

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 15:25:18