Files
kuboard-press/learning/k8s-intermediate/workload/wl-daemonset/communicate.md
huanqing.shao 1b69a42777 vssue
2019-09-22 21:56:32 +08:00

17 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
vssueId: 49
layout: LearningLayout
description: 本文描述了 Kubernetes DaemonSet 的概念、行为及用法
---
# 与 DaemonSet 通信
> 参考文档 Kubernetes 官网文档 [Communicating with Daemon Pods](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/#communicating-with-daemon-pods)
与 DaemonSet 容器组通信的模式有:
* **Push** DaemonSet 容器组用来向另一个服务推送信息,例如数据库的统计信息。这种情况下 DaemonSet 容器组没有客户端
* **NodeIP + Port** DaemonSet 容器组可以使用 `hostPort`,此时可通过节点的 IP 地址直接访问该容器组。客户端需要知道节点的 IP 地址,以及 DaemonSet 容器组的 端口号
* **DNS** 创建一个 [headless service](https://kubernetes.io/docs/concepts/services-networking/service/#headless-services),且该 Service 与 DaemonSet 有相同的 Pod Selector。此时客户端可通过该 Service 的 DNS 解析到 DaemonSet 的 IP 地址
* **Service** 创建一个 Service且该 Service 与 DaemonSet 有相同的 Pod Selector客户端通过该 Service可随机访问到某一个节点上的 DaemonSet 容器组