gpt4 book ai didi

Docker Swarm、Kubernetes 和 Compose

转载 作者:IT老高 更新时间:2023-10-28 21:22:16 28 4
gpt4 key购买 nike

我刚刚听说在未来的 Docker 版本中支持原生 Kubernetes。我以前从未使用过 Kubernetes,所以我开始阅读它。但我有点困惑:Kubernetes 被描述为 编排 工具,也是 Dockers swarm mode 的替代品。

那么如果 Kubernetes 做编排,它也是 docker-compose 的替代品吗?或者可以组合Kubernetes一起使用吗?

一些具体问题:假设我想(或必须)使用 Kubernetes:

  • 我有一个包含多个微服务的 docker-compose 文件,但它们在单台机器上作为独立应用程序运行。它可以(或应该)被 Kubernetes 取代吗?
  • 我有一个 docker-compose 文件,其中包含以集群模式配置的多个服务(在多台机器上运行)。哪个部分必须被 Kubernetes 替换?整个撰写文件?或者是否可以在 compose 文件中定义基本配置(env_var、volumes、command,...)并仅使用 Kubernetes 来编排集群?

最佳答案

So if Kubernetes does orchestration, is it also an alternative to docker-compose?

简短回答:否

这不仅仅是编排,本质上 Kubernetes 是一个生产级容器编排和调度引擎。它比 docker-compose 本身要先进得多。我会说 docker swarmkubernetesamazon ecs 属于同一类别。

Or can compose and Kubernetes be used together?

在 docker 引擎的下一个版本中,您将能够使用 docker-compose 创建 kubernetes 对象。但目前你还不能。

I have a docker-compose file containing multiple microservices, but they are running as a standalone app on a single machine. Can (or should) it be replaced by Kubernetes?

好的,在生产环境中,我会说绝对,您绝对应该将应用程序托管在 kubernetes 集群上,因为它提供了 p>

  • 弹性(如果 Pod 死亡,重新安排它们的时间)
  • 缩放(根据 cpu 或任何其他指标缩放 pod)
  • 负载平衡(提供 VIP 知道服务并将所有 pod 附加到它)
  • secret 和配置管理
  • 命名空间(kubernetes 对象的逻辑分组)
  • 网络策略(控制 pod 之间流量的自定义策略)

还有更多开箱即用的功能。而当你声明一个状态时,kubernetes 总是会尝试去实现和维护那个状态。

I have a docker-compose file with multiple services configured in swarm mode (running on multiple machines). Which part has to be replaced by Kubernetes? The whole compose file? Or is it somehow possible to define basic configuration (env_var, volumes, command, ...) within compose file and use Kubernetes only to orchestrate the clustering?

我会用 kubernetes 集群和对象定义 yaml 替换整个 swarm 集群并编写文件结构。话虽如此,根据我的经验,那些 yamls 可能会有点冗长,所以如果你热衷于查看 Helm .它是 kubernetes 的包管理器,你没有可以使用,但我认为它是 kubernetes 生态系统中最好的工具之一目前有很多开源图表可供使用。

我强烈建议您在本地系统上使用 minikube 来玩弄 kubernetes,以熟悉一般概念。然后你就可以自己回答上面的问题了。

关于Docker Swarm、Kubernetes 和 Compose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46846729/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com