如何从另一台计算机上获得Kubernetes服务?

时间:2015-12-16 12:33:58

标签: networking docker kubernetes coreos

我的IP地址:

DNS_SERVICE_IP:10.3.0.10 SERVICE_IP_RANGE 10.3.0.0/16

#include <sys/time.h> #include <stdio.h> int main() { unsigned int ms, oldms = 0,dif; struct timeval tv; while(1) { gettimeofday(&tv, NULL); ms=tv.tv_sec; //printf("%d\n",ms-oldms ); dif=ms-oldms; if(dif>3) { printf("3 seconds up"); oldms=ms; } } } 返回:

kubectl get svc

Kubernetes掌握IP:192.168.0.139 我的本地IP:192.168.0.157

NAME           LABELS                                    SELECTOR                IP(S)        PORT(S)
guestbook      app=guestbook                             app=guestbook           10.3.0.72    3000/TCP
kubernetes     component=apiserver,provider=kubernetes   <none>                  10.3.0.1     443/TCP
mongodb        app=mongodb                               app=mongodb             10.3.0.223   27017/TCP
redis-master   app=redis,role=master                     app=redis,role=master   10.3.0.178   6379/TCP

如何联系该服务?

1 个答案:

答案 0 :(得分:0)

@ mark.zupan建议:

apiVersion: v1
kind: Service
metadata:
  name: devcenter-ui-green
  namespace: devcenter
  labels:
    name: devcenter-ui-green
spec:
  type: NodePort
  ports:
  - port: 9000
    nodePort: 30011
  selector:
    name: devcenter-ui-green