当前位置:  首页>> 技术小册>> Kubernets合辑6-服务发现

大部分情况下,不需要指定vip,因为内部pod通过域名的方式访问service,此处只是作为演示。

  1. # svc-vip.yaml
  2. apiVersion: v1
  3. kind: Service
  4. metadata:
  5. name: slb-s2
  6. namespace: default
  7. spec:
  8. selector:
  9. app: nginx
  10. release: stable
  11. partition: website
  12. tier: slb
  13. clusterIP: 10.100.138.12
  14. ports:
  15. - name: http
  16. port: 80
  17. targetPort: 80
  1. [root@maxiaoke nginx-01]# kubectl get svc
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 13d
  4. slb-s1 ClusterIP 10.100.138.11 <none> 80/TCP 64m
  5. slb-s2 ClusterIP 10.100.138.12 <none> 80/TCP 7s
  6. [root@maxiaoke nginx-01]# kubectl describe svc slb-s2
  7. Name: slb-s2
  8. Namespace: default
  9. Labels: <none>
  10. Annotations: <none>
  11. Selector: app=nginx,partition=website,release=stable,tier=slb
  12. Type: ClusterIP
  13. IP Families: <none>
  14. IP: 10.100.138.12
  15. IPs: 10.100.138.12
  16. Port: http 80/TCP
  17. TargetPort: 80/TCP
  18. Endpoints: 10.200.3.10:80,10.200.4.8:80,10.200.4.9:80 + 2 more...
  19. Session Affinity: None
  20. Events: <none>

该分类下的相关小册推荐: