Wener Notes

Kubernetes Services

约 1 分钟阅读
标签:DevOpsKubernetes网络服务DNS

Service Types

ExternalName

  • CNAME redirection at the kernel level.
  • Cannot do port remapping.

DNS for Services and Pods

  • DNS for Services and Pods Reference
  • Service Domain: my-svc.my-namespace.svc.cluster-domain.example
  • SRV Record: _my-port-name._my-port-protocol.my-svc.my-namespace.svc.cluster-domain.example
  • Pod Domain: pod-ip-address.my-namespace.pod.cluster-domain.example
  • Example: 172-17-0-3.default.pod.cluster.local

Configuration Examples

External Database (IP)

yaml
kind: Service
apiVersion: v1
metadata:
  name: mongo
spec:
  type: ClusterIP
  ports:
    - port: 27017
      targetPort: 27017
---
kind: Endpoints
apiVersion: v1
metadata:
  name: mongo
subsets:
  - addresses:
      - ip: 10.240.0.4
    ports:
      - port: 27017

External Database (URI)

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

External Database (Port Remapping)

yaml
kind: Service
apiVersion: v1
metadata:
  name: mongo
spec:
  ports:
    - port: 27017
      targetPort: 49763
---
kind: Endpoints
apiVersion: v1
metadata:
  name: mongo
subsets:
  - addresses:
      - ip: 35.188.8.12
    ports:
      - port: 49763

关联信息

反向链接、本文链接的其他页面和外部资料。

References

其他外链3 条
最近更新commit 906e816Edit

On this page