Red Hat OpenShift on IBM Cloud(VPC): Service(type:LoadBalancer)を作成してみる


結論

  • type:LoadBalancerのServiceを作る度に、VPC Load Balancerが1つ注文される(別途費用が発生する)。
  • VPC Load Balancerは各ノードのNodePortに割り振りを行う。
  • (Classic Infrastructureの時とは異なり)VPC Load Balancerが提供するFQDNがZoneまたぎで割り振りができる。つまり、VPC Load Balancer=Multizone Load Balancerである。

参考資料
https://cloud.ibm.com/docs/openshift?topic=openshift-loadbalancer-qs#lb_qs_vpc
https://cloud.ibm.com/docs/openshift?topic=openshift-vpc-lbaas

確認

$ oc new-app --name hello-world https://github.com/IBM/container-service-getting-started-wt --context-dir="Lab 1"
$ oc expose service hello-world

のようにrouteを作成した状態で、type:LoadBalancerのServiceを作ってみた。

$ oc expose dc  hello-world --port=80 --target-port=8080 --type=LoadBalancer --name hello-world-lb
$ oc expose dc  hello-world --port=8080 --target-port=8080 --type=LoadBalancer --name hello-world-lb
4e5d1726


#しばらく待って再度確認した結果
$ oc get services
NAME              TYPE           CLUSTER-IP      EXTERNAL-IP                            PORT(S)          AGE
hello-world       ClusterIP      172.21.14.37    <none>                                 8080/TCP         36h
hello-world-lb    LoadBalancer   172.21.82.182   xxxxxxxx-us-south.lb.appdomain.cloud   80:32737/TCP     54m
hello-world-lb2   LoadBalancer   172.21.93.55    yyyyyyyy-us-south.lb.appdomain.cloud   8080:32532/TCP   31s

$ oc describe service hello-world-lb
Name:                     hello-world-lb
Namespace:                syasuda
Labels:                   app=hello-world
                          app.kubernetes.io/component=hello-world
                          app.kubernetes.io/instance=hello-world
Annotations:              <none>
Selector:                 deploymentconfig=hello-world
Type:                     LoadBalancer
IP:                       172.21.82.182
LoadBalancer Ingress:     xxxxxxxx-us-south.lb.appdomain.cloud
Port:                     <unset>  80/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  32737/TCP
Endpoints:                172.17.111.9:8080,172.17.115.137:8080,172.17.123.76:8080 + 2 more...
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason                           Age   From                Message
  ----    ------                           ----  ----                -------
  Normal  EnsuringLoadBalancer             17m   service-controller  Ensuring load balancer
  Normal  EnsuredLoadBalancer              17m   service-controller  Ensured load balancer
  Normal  CloudVPCLoadBalancerNormalEvent  11m   ibm-cloud-provider  Event on cloud load balancer hello-world-lb for service syasuda/hello-world-lb with UID 12b7ca92-aad5-42d7-b0fa-eac967b1192d: The VPC load balancer that routes requests to this Kubernetes LoadBalancer service is currently online/active.

上記のイベントログにも記載があるように、ibm-cloud-providerによってVPC Load Balancerが作成されている。
実際に、IBM Cloud Portalで確認してみると・・・確かに新たにVPC Load Balancerが作成されている!(もう一つのLoad BalancerはRoute用のものです)


アクセステスト
$ curl xxxxxx-us-south.lb.appdomain.cloud:80
Hello world from hello-world-1-rb8nt! Your app is up and running in a cluster!
$ curl yyyyyy-us-south.lb.appdomain.cloud:8080
Hello world from hello-world-1-rb8nt! Your app is up and running in a cluster!