kubernetes中跨namespace的服务调用 & 外部服务调用 & host配置 (待研究)

/etc# cat resolv.conf
nameserver 10.96.0.10
search *****.svc.cluster.local svc.cluster.local cluster.local chn.gbl
options ndots:5

方式一(集群内的服务调用,)

集群内不同namespace中的调用

http://[serviceName][*****.svc.cluster.local]
[*****.svc.cluster.local]:通过进入pods的etc目录查看

 

方式二(添加服务,充当host重定向 & 添加ingress外部可访问)

# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Service
metadata:
  name: mail-api
  namespace: test
spec:
  externalName: 172.16.10.39
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  sessionAffinity: None
  type: ExternalName
status:
  loadBalancer: {}

  

 

猜你喜欢

转载自www.cnblogs.com/panpanwelcome/p/12769742.html