0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Container Engine for Kubernetes (OKE)のLoadBalancerサービスをフレキシブル・シェイプで作成する

Last updated at Posted at 2022-01-01

はじめに

以前、OKEのLoadBalancerサービスの設定を確認した時は、特に何もオプションを指定しなかったので、OCIのロードバランサーは帯域が固定の動的シェイプとしてデプロイされていました。

このシェイプは古い仕様のロードバランサーなので、今回は帯域の最小と最大を指定する「フレキシブル・シェイプ」の作成方法を確認したいと思います。

環境確認

Kubernetesクラスタ、LoadBalancerのエンドポイントになるPodは事前に作成済みです。

$ kubectl get node
NAME          STATUS   ROLES   AGE    VERSION
10.0.10.152   Ready    node    2d1h   v1.21.5
10.0.10.187   Ready    node    2d1h   v1.21.5
10.0.10.253   Ready    node    2d1h   v1.21.5

$ kubectl get pod -L run
NAME    READY   STATUS    RESTARTS   AGE   RUN
nginx   1/1     Running   0          65m   nginx

LoadBalancerのデプロイ

マニフェスト

フレキシブル・シェイプを指定するには、マニフェストで annotations を指定します。
フレキシブル・シェイプ以外にも指定できる annotations は、こちらに書かれています。

今回用意したマニフェストは以下になります。
マニュアルにもサンプルが書かれていますが、マニュアル通りのマニフェストだとエラーになりました。
「oci-load-balancer-shape-flex-min」と「oci-load-balancer-shape-flex-max」で指定する値はダブルクォーテーション「"」で囲う必要があります。

flex-lb.yaml
apiVersion: v1
kind: Service
metadata:
  name: flex-nginx-lb
  labels:
    run: nginx
  annotations:
    service.beta.kubernetes.io/oci-load-balancer-shape: "flexible"
    service.beta.kubernetes.io/oci-load-balancer-shape-flex-min: "10"
    service.beta.kubernetes.io/oci-load-balancer-shape-flex-max: "50"
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
  selector:
    run: nginx

LoadBalancerのデプロイ

マニフェストをapplyしてLoadBalancerをデプロイします。

$ kubectl apply -f flex-lb.yaml 
service/flex-nginx-lb created

少し待って、確認します。

$ kubectl get svc
NAME            TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)        AGE
flex-nginx-lb   LoadBalancer   10.96.251.231   152.70.204.12   80:30990/TCP   95s

OCIのコンソールでも確認すると、フレキシブル・シェイプでロードバランサーが作成されています。

image.png

最小帯域幅、最大帯域幅も annotations で指定した値になっています。

image.png

疎通確認

LoadBalancerの External-IPにアクセスして、疎通を確認します。

$ curl 152.70.204.12 |grep nginx!
<title>Welcome to nginx!</title>
<h1>Welcome to nginx!</h1>

削除

Kubernetes上でLoadBalancerを削除すると、OCIのロードバランサーも削除されます。

$ kubectl delete -f flex-lb.yaml 
service "flex-nginx-lb" deleted
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?