kubernetes services debug

Services FAQ

Brendan Burns edited this page on 4 Feb 2015 · 2 revisions

 Pages 15

Clone this wiki locally

 

 Clone in Desktop

How should I think of Services and the kube-proxy binary?

Think of Services and kube-proxy as a distributed multi-tenant load-balancer. Each node load balances traffic from clients on that node. The way it is implemented is with iptables and userspace (for now). The portal IPs are virtual and should never hit a physical network EVER.

From what I read, the kube-proxy service is used mostly (only?) for the service piece of things. Is that accurate? If so, does this service act like, provide, the iptables service on the host?

The kube proxy generates iptables rules which map portal_ips such that the traffic gets to the local kube-proxy daemon. The kube-proxy then does the equivalent of a NAT to the actual pod address.

The docker network config seems a little hit and miss. My docker install was through yum so it was a base install. Should I need to tell docker not to install the default masquerade rule to hide the bridge space behind the host IP? If I tell docker to not run iptables wont that break some of the port mapping required by kubernetes?

The rule should be off, but in most cases it doesn't matter. Connecting via services means that the pod IP will get (equivalent of) SNAT to the ip of the minion. So you never hit the docker rule. If you actually were connecting directly from a pod to a pod, that docker/iptables translation might bad... If you are trying to talk from a pod to the outside of the cluster, you may or may not want the rule...

We turn Docker iptables networking off with --iptables=false --ip-masq=false on the Docker dameon, but it should not trigger anyway.

To summarize some of this, is iptables required? If so, where do the rules come from? Maybe Im missing something but I cant find the iptables service on the host so Im not sure where it even comes from.

Yes, kube-proxy

How should the service (portal) routing work?

Do not configure any portal routing

Is the kube-proxy service only used for services?

Yes.

Am I correct in saying that any of the minions running the proxy service can answer for portal IPs?

Yes.

I think part of what Im missing is the distinction between portal and public IPs. If you configure a publicIP in a service, that address must be assigned to a real computer and must be routed to that machine which will respond to that address. The kube proxy must also be running on that machine.

Are portal IPs meant to be used for inter container access?

Yes

AKA - I shouldnt be hitting them from outside the kubernetes cloud.

Yes

If that's the case then I dont need to be routing them anywhere on the physical switch layer.

You don't even need them ON the switch layer, the portal_ips never leave a single host.

A container running on a minion can try and hit that pod through the portal IP (ENV variable too? Does this mean I need the service up before the container?).

In kube itself, yes. Although there is some DNS integration options (skydns), which should allow for non-ENV and thus non-runtime dependent changes to services.

By default, the container will hit its default gateway (the host) when looking for the portal IP. The portal IP is referenced in the iptables rule which sends that traffic to the host IP on a particular port. The kube-proxy (running locally) is listening on that port, picks up that traffic, and then load balances it round robin to a pod IP address. That pod can be running on any other host across the kubernetes cluster. Is that right? Am I close?

Sounds good.

Is the random port used by iptables and the kube-proxy just a means to track different portals? AKA, I'm redirecting traffic with iptables to the same destination so I need a means to know which back end pods I should l be load balancing to?

Pretty much, yes, you got it. The kube proxy opens one random port for each portal. Traffic on that port will only go to the associated backends.

I'm now looking to use external IPs. AKA - I'd like to provide an IP accessible from outside the kubernetes cluster that users can hit to access a service. It looks like there's a 'publicIP' variable in the service definition but I think think it works the way that I think it does. I assumed I could set the public IP I wanted to use for the service (AKA, users use 10.20.30.119). It would then be my job to make sure that the IP of 10.20.30.119 got routed to a minion. That doesnt seem to be how it works. Sounds like you specify the minion IP address in the publicIP field but Im not sure what that buys me...

You can specify any ip you want. But it is up to you to make sure that ip routes to a machine running kube proxy and that ip is assigned to an interface on that machine. Using minion ip means these requirement are obviously met, but you can add a second ip to a minion or to some other machine running the proxy....

If you have a "real" load balancer that can forward packets to the machine, you can use that as your PublicIP. If your minions have a public IP.

Basically, every networking install is a special snowflake, so we have to defer some of it to users. We will happily receive traffic on PublicIPs, but you need to run the plumbing from "outside" to that IP.

转载于:https://my.oschina.net/u/259976/blog/719034

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python Kubernetes客户端库是一种用于与Kubernetes集群进行交互的工具。它提供了一系列的API和功能,可以让你通过Python代码管理和操作Kubernetes集群。使用Python Kubernetes客户端库,你可以创建、删除和更新Kubernetes资源,例如Pods、Deployments、Services等。 如果你想使用Python来管理Kubernetes集群,你可以使用`kubernetes`库。这个库提供了与Kubernetes API进行通信的功能,你可以使用它来执行各种操作,比如创建和删除资源,获取集群状态等。 首先,你需要安装`kubernetes`库。你可以使用以下命令来安装它: ``` pip install kubernetes ``` 安装完成后,你可以在Python脚本中导入`kubernetes`库并开始使用它。首先,你需要创建一个`Config`对象来配置与Kubernetes集群的连接。你可以通过以下代码创建一个`Config`对象: ``` from kubernetes import client, config # 加载Kubernetes配置 config.load_kube_config() # 或者使用kubeconfig文件 # config.load_kube_config(config_file="path/to/kubeconfig") # 创建API客户端实例 api_instance = client.CoreV1Api() ``` 然后,你可以使用`api_instance`来执行各种操作。例如,如果你想获取集群中的节点信息,你可以使用以下代码: ``` # 获取节点列表 nodes = api_instance.list_node().items # 打印节点信息 for node in nodes: print("Node name: %s" % node.metadata.name) print("Node status: %s" % node.status) ``` 类似地,你可以使用`api_instance`来获取和管理其他资源,比如Pods、Deployments、Services等。 总结起来,使用Python Kubernetes客户端库,你可以通过编写Python代码来管理和操作Kubernetes集群中的资源。你可以使用`kubernetes`库来连接到Kubernetes集群,执行各种操作,例如获取节点信息、创建和删除资源等。这为使用Python进行Kubernetes集群管理提供了便利和灵活性。 : https://github.com/kubernetes-client/python : https://kubernetes.io/docs/concepts/overview/components/#kubectl : https://github.com/kubernetes/minikube

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值