简体   繁体   English

K8s 服务作为 DaemonSet

[英]K8s Service as DaemonSet

Is there a possibility to have a service in all namespaces of k8s dynamically deployed?是否有可能在 k8s 的所有命名空间中动态部署服务?

Right now, glusterFS endpoint(ns dependent) is being deleted by k8s if the port is not in use anymore.现在,如果端口不再使用,glusterFS 端点(依赖于 ns)将被 k8s 删除。 Ex:前任:

{
  "kind": "Endpoints",
  "apiVersion": "v1",
  "metadata": {
    "name": "glusterfs"
  },
  "subsets": [
    {
      "addresses": [
        {
          "ip": "172.0.0.1"
        }
      ],
      "ports": [
        {
          "port": 1
        }
      ]
    }
  ]
}

So I made a svc for port 1 to be used all the time, so I dont end up with a missing/deleted endpoint in any ns.所以我为端口 1 制作了一个 svc,以便一直使用,所以我最终不会在任何 ns 中出现丢失/删除的端点。

apiVersion: v1
kind: Service
metadata:
  name: glusterfs
spec:
  ports:
  - port: 1

It would be interesting to have the above service deployed dynamically every time someone creates a new namespace.每次有人创建新命名空间时动态部署上述服务会很有趣。

DaemonSet is used to deploy Exactly one replica per node. DaemonSet 用于为每个节点部署一个副本。

coming to your question, why do you need to create same service across namespaces?提出您的问题,为什么需要跨命名空间创建相同的服务? It is not supported out of box though.但它不支持开箱即用。 However, you can create a custom script to achieve it.但是,您可以创建自定义脚本来实现它。

K8s doesn't have any replication of services, pods, deployments, secrets, etc across namespaces... out of the box. K8s 没有跨命名空间的任何服务、Pod、部署、秘密等复制……开箱即用。

Introducing...The Kubernetes Controller/Operator Pattern.介绍...... Kubernetes 控制器/操作员模式。

Deploy a controller pod that has a read/list permissions on the namespaces resource.部署一个对命名空间资源具有读取/列表权限的控制器 pod。 This controller will "watch" the namespaces and deploy whatever resources you want when they show up or change.该控制器将“监视”命名空间并在它们出现或更改时部署您想要的任何资源。

To get started building your own operator or controller please look at kubebuilder.要开始构建您自己的操作员或控制器,请查看 kubebuilder。 https://book.kubebuilder.io/ https://book.kubebuilder.io/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM