headless

一旦创建了 headless ,在 k8s 里便是全局的

root@spark-worker-dcpmm-statefulset-aep1-2:/# getent hosts  sparkthrift-headless
10.60.218.26    sparkthrift-headless.spark-project.svc.cluster.local
root@spark-worker-dcpmm-statefulset-aep1-2:/#
root@spark-worker-dcpmm-statefulset-aep1-2:/#
root@spark-worker-dcpmm-statefulset-aep1-2:/# getent hosts  worker-dcpmm-service
10.60.154.147   worker-dcpmm-service.spark-project.svc.cluster.local
10.60.171.234   worker-dcpmm-service.spark-project.svc.cluster.local
10.60.219.144   worker-dcpmm-service.spark-project.svc.cluster.local
10.60.219.147   worker-dcpmm-service.spark-project.svc.cluster.local
10.60.222.181   worker-dcpmm-service.spark-project.svc.cluster.local
10.60.222.182   worker-dcpmm-service.spark-project.svc.cluster.local
非 headless

看下普通service 的 情况

$ oc get svc
NAME                            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)             AGE
nginx                           ClusterIP   None           <none>        80/TCP              73d
spark-master-dcpmm              ClusterIP   10.60.27.191   <none>        7077/TCP,8080/TCP   1d
spark-master-dcpmm-nodeport     NodePort    10.60.74.159   <none>        7077:32100/TCP      23h
worker-dcpmm-service            ClusterIP   None           <none>        1888/TCP            20h

getent ,获取的是 CLUSTER-IP

bash-4.4# getent hosts spark-master-dcpmm
10.60.27.191      spark-master-dcpmm.spark-project.svc.cluster.local  spark-master-dcpmm.spark-project.svc.cluster.local spark-master-dcpmm
bash-4.4#
bash-4.4# getent hosts spark-master-dcpmm-nodeport
10.60.74.159      spark-master-dcpmm-nodeport.spark-project.svc.cluster.local  spark-master-dcpmm-nodeport.spark-project.svc.cluster.local spark-master-dcpmm-nodeport

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐