Kubernetes 服务 etcd 参考

Kubernetes 服务 etcd 参考

如果有人对 kubernetes 服务有很好的了解,可以向我确认,一旦你需要创建一个新的服务,kubernetes 就会在 etcd 数据库上推送它的引用,以及请求它的 URL 是什么,那就太好了!!!

答案1

所有数据均由 apiserver 保存在 etcd 中。

您可以使用以下方式获取服务列表:

kubectl get services

如果你想从 etcd 获取定义:

    # etcdctl --peers http://$(hostname):2379 ls
    /coreos.com
    /registry
    # etcdctl --peers http://$(hostname):2379 ls /registry
    /registry/namespaces
    /registry/pods
    /registry/ranges
    /registry/serviceaccounts
    /registry/services
    /registry/controllers
    /registry/events
    /registry/minions
    # etcdctl --peers http://$(hostname):2379 ls /registry/services
    /registry/services/endpoints
    /registry/services/specs
    # etcdctl --peers http://$(hostname):2379 ls /registry/services/endpoints
    /registry/services/endpoints/default
    # etcdctl --peers http://$(hostname):2379 ls /registry/services/endpoints/default
    /registry/services/endpoints/default/kube-dns
    /registry/services/endpoints/default/kubernetes
    # etcdctl --peers http://$(hostname):2379 get /registry/services/endpoints/default/kube-dns
    {"kind":"Endpoints","apiVersion":"v1","metadata":{"name":"kube-dns","namespace":"default","selfLink":"/api/v1/namespaces/default/endpoints/kube-dns","uid":"194eacb0-8465-11e5-ab8c-005056a3274a","resourceVersion":"4787638","creationTimestamp":"2015-11-06T09:02:25Z","labels":{"k8s-app":"kube-dns","kubernetes.io/cluster-service":"true","kubernetes.io/name":"KubeDNS"}},"subsets":[]}

相关内容