Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 views
in Technique[技术] by (71.8m points)

Kubernetes create an endpoint with DNS instead IP

I need to create an endpoint with DNS instead of IP

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  ports:
    - port: 5432
      targetPort: 5432
      nodePort: 30004
---
apiVersion: v1
kind: Endpoints
metadata:
  name: my-service 
subsets:
  - addresses:
      - ip: **111.111.111.111** ** < need change this to DNS
    ports:
      - port: 5432


Everything works fine with numerical IP, but I need to put my Postgres DNS instead, something like:

subsets:
  - addresses:
      - ip: mypostgres.com
    ports:
      - port: 5432

But "addresses" only support numerical IP. I need some workaround to make this work.

question from:https://stackoverflow.com/questions/65672151/kubernetes-create-an-endpoint-with-dns-instead-ip

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

if you want to connect to a remotely hosted database URI instead of IP you can use ExternalName

kind: Service
apiVersion: v1
metadata:
 name: mongo
spec:
 type: ExternalName
 externalName: ds149763.mlab.com

Please check out more : https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-mapping-external-services


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...