LoginSignup
11
4

More than 3 years have passed since last update.

GKE でカーネルパラメータの設定

Last updated at Posted at 2019-05-28

GKE でカーネルパラメータを設定したい。

Using sysctls in a Kubernetes Cluster を参考にすると

  • Pod オブジェクトの spec.securityContext.sysctls[] で設定できる
  • 許可をだすために PodSecurityPolicy オブジェクトを作る
  • 許可をだすために kubelet に --allowed-unsafe-sysctls オプションを指定する

とあるが、GKE では kubelet にオプションを渡せない。

initContainers を使う

代わりに initContainers で起動時に sysctl -w コマンドで設定してあげればできる。

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      initContainers:
      - name: sysctl
        image: busybox
        command:
        - "/bin/sh"
        - "-c"
        - "sysctl -w net.core.somaxconn=65535"
        imagePullPolicy: IfNotPresent
        securityContext:
          privileged: true

参考: https://stackoverflow.com/questions/41278519/set-vm-max-map-count-on-cluster-nodes?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

おまけ

ulimit -u や ulimit -n の値も大きくしておこうかと思ったが kubectl exec でコンテナに入って確認してみると最初から大きい値になっていた。

root@xxx-6864b9df86-sn5rt:/app# ulimit -n
1048576
root@xxx-6864b9df86-sn5rt:/app# ulimit -u
unlimited
11
4
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
11
4