ry's Tech blog

Cloud Native技術などについて書いていきます。

Kubenews #4

2020-12-18

配信URL

youtu.be

各タイトルを押していただくことで、実際の記事に飛びます。

Efficient Multi-Zone Networking with Topology Aware Routing

Topology Aware Routing of Services: topologyKeysを用いてトラフィックを細かく分割する方法

  • Kubernetes v1.17 alpha機能であり、影響範囲はPod-Pod間の通信
  • TopologyKeyにおいて、Nodeのlabelを設定することで、上から書かれている順番に応じて、優先的に指定Labelを持つNode上で動くPodに通信が流れるように設定できる。
    • 例えばマルチAZ構成において、クライアントと同一ノードまたは同一AZのようなネットワーク的に近いエンドポイントにトラフィックが優先的にルーティングされるように指定できる。
  • 1Serviceに複数Endpointがひも付く構成になる。

以下のマニフェストでは、 1. kubernetes.io/hostnameより、同一Node 2. topology.kubernetes.io/zoneより、同一Zone 3. topology.kubernetes.io/regionより、同一region 4. *より、その他全て

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
  topologyKeys:
    - "kubernetes.io/hostname"
    - "topology.kubernetes.io/zone"
    - "topology.kubernetes.io/region"
    - "*"

OPA The Easy Way

無料オンライントレーニングと[Styra DAS Free](https://www.styra.com/pricing)の宣伝。

[VScode OPA Plugin](https://marketplace.visualstudio.com/items?itemName=tsandall.opa)もあるらしい。

  • Styra DAS Freeへのアクセス
  • 自分のk8s clusterの登録
  • 各種ルールの作成
  • ルールのテスト
  • etc

自分的に一番嬉しいのが、AddmissionReviewの取得ができるらしい!

Automating Volume Expansion Management

Persistent Volumeを用いる際は、PrometheusにこのAlertを入れたほうがいい。

    - alert: "Storage Saturation"
      labels:
        severity: critical
      annotations:
        summary: Storage usage over 75%
        persistentvolumeclaim: 
        namespace: 
      expr: kubelet_volume_stats_used_bytes / kubelet_volume_stats_capacity_bytes > 0.75
      for: 1m
 ```

という前置きの元、PVの拡張を自動化するソリューションとして、volume-expander-operatorに関する紹介が始まる。

- 監視したいPVCのannotationに`volume-expander-operator.redhat-cop.io/autoexpand:true”`を設定が必要。
  - Once enabled, the volume-expander-operator will start polling the platform Prometheus instance that is part of OpenShift Monitoringとあり、OpenShiftでしかできなそう??
- `kubelet_volume_stats_used_bytes`と`kubelet_volume_stats_capacity_bytes`の2つのメトリックより判断。
- その他設定するannotaionは以下
  - volume-expander-operator.redhat-c<200b><200b>op.io/expand-threshold-percent: ボリュームの拡張をトリガーする閾値
  - volume-expander-operator.redhat-c<200b><200b>op.io/expand-by-percent: 拡張される既存ボリュームのサイズに基づくパーセンテージ
  - volume-expander-operator.redhat-c<200b><200b>op.io/expand-up-to: ボリュームの上限
  - volume-expander-operator.redhat-c<200b><200b>op.io/polling-frequency: ポーリングする頻度

参考manifest

kind: PersistentVolumeClaim apiVersion: v1 metadata: annotations: volume-expander-operator.redhat-cop.io/autoexpand: 'true' volume-expander-operator.redhat-cop.io/expand-threshold-percent: "85" volume-expander-operator.redhat-cop.io/expand-by-percent: "20" volume-expander-operator.redhat-cop.io/polling-frequency: "1m" volume-expander-operator.redhat-cop.io/expand-up-to: "20Gi" name: to-be-expanded spec: accessModes: - ReadWriteOnce resources: requests: storage: "1Gi"