zoukankan      html  css  js  c++  java
  • 在Google的GKE上创建支持Internal Load Balancer的Service

    GoogleKubernetes Engine上发布service,可以采用除On-Promise相同的Cluster IPNodePort两种方式外,还可以创建LoadBalanerService

      

    其中Load Balancer可以调用Google Cloud的接口创建GoogleLoad Balancer。比如下面这个Nginx-1service,采用的就是Load Balancer

     

    Google Cloud为这个service创建了一个TCP的负载均衡,具体如下:

     

    但在实际使用场景中,负载均衡会有要求采用内部IP地址的情况,比如backendcluster。前端调用的时候,采用Internal IP,且这个服务不能暴露到外部网络。这时,就需要创建的serviceIP地址采用内网IP

    可以用下面的命令实现前面的需求:

     

    #在gcloud下,获得GKE cluster的credential:
    gcloud container clusters get-credentials standard-cluster-1 --zone=asia-east1-a
    
    #创建image为nginx的deployment
    kubectl run web --image=nginx:latest --port=80
    
    #查看pods
    kubectl get pods
    
    #发布为Service
    kubectl create -f internal.yaml
    
    #查看Service
    kubectl get svc 

    Internal.yaml

    apiVersion: v1
    kind: Service
    metadata:
      annotations:
        cloud.google.com/load-balancer-type: Internal
      labels:
        run: web
      name: web-internal
    spec:
      ports:
      - port: 80
        protocol: TCP
        targetPort: 80
      selector:
        run: web
      sessionAffinity: None
      type: LoadBalancer

     

    再查看Service的信息,可以看到两个service都是Load Balancer类型的,但一个是公网IP,一个是内网IP。且内网IPVPC的子网地址网段:

     

     

    查看Service的详细信息:

     

    可以看到也创建了一个Load Balancer,查看Load Balancer信息,发现是一个InternalLoad Balancer

     

    查看Internal Load Balancer信息:

     

    通过这个Internal Load Balancer地址去访问服务:

     

    可以看到标准Nginx的欢迎页面。

  • 相关阅读:
    sublime text3 常用插件安装
    eclipse 快捷键
    数组去重及数组的prototype原型
    如何用angularjs给从后台传来数据添加链接
    【转载】Java Web的web.xml文件作用及基本配置
    【转】数据库几种范式
    Socket编程
    进程间的五种通信方式介绍
    进程与线程的区别
    【转载】程序员必知之浮点数运算原理详解
  • 原文地址:https://www.cnblogs.com/hengwei/p/9804041.html
Copyright © 2011-2022 走看看