k8s pods

应该把pods视为一个分离的机器,并在上面只运行一个app,kubernetes不能水平扩展单个container,但它能扩展整个pods,所以如果在单个pods上运行前端和后端两个app,扩展到两个pod之后,会有两个前端和后端程序在跑,但一般情况下前端和后端对扩展的要求是不一样的,所以前端和后端程序也是分别放在单个的pod上的。

 

那又是什么时候需要在单个pod上部署多个container呢:只有在一个主进程需要多个补充进程时,才会在一个pod上部署多个这样的关联紧密的container。比如一个pod 中的main container提供一个certain file directory的web server,然后需要另一个container去定时下载资源并存进这个web server的directory里面。

 

判断两个container是否应该放在一个pod里面的标准:

  • Do they need to be run together or can they run on different hosts?
  • Do they represent a single whole or are they independent components?
  • Must they be scaled together or individually?

不应该在一个container上运行多个process,如果多个containers不需要运行在同一个机器上,那么他们就不需要运行在同一个pod上。

对于在pod上运行的单个app,可以通过port forwarding的方式来对外开放服务。

对于微服务而言,过多的pods可以通过label来管理。labels不光可以管理pods,还可以管理kubernetes的各类资源。如下唯labels的使用后的微服务结构图

 

app:该微服务的功能。。。。。。rel:版本状态(公测版本,正式版本或者是部分公测版本(canary)等)

 

node labels 和node label selectors可以帮助你让你在部署app到pod到哪个node时加上你想要的配置文件,里面可以包含你所需要的各类要求。

 

kubernetes还提供了namespace来groups objects into namespace,这个namespace和之前的linux里的namespace不同(用于分离进程),Kubernetes namespaces provide a scope for objects names. Instead of having all your resources in one single namespace, you can split them into multiple name-spaces, which also allows you to use the same resource names multiple times (across different namespaces).

 

比如namespace可以用来区分production,development,和QA environments等,可以用来group资源,同一个资源可以在不同namespace中。

 

If several users or groups of users are using the same Kubernetes cluster, and they each manage their own distinct set of resources, they should each use their own namespace. This way, they don’t need to take any special care not to inadvertently modify or delete the other users’ resources and don’t need to concern themselves with name conflicts, because namespaces provide a scope for resource names, as has already been mentioned.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值