背景
ホストOS(CoreOS)のデフォルトのカーネルパラメータがいくつか渋かったのでチューニングしたかった。
kubernetesのノードレベルでオートスケールする想定なので、スケール時にチューニングされている必要があった。
kube-awsの customFiles
と customSystemdUnits
で実装することでチューニング済みのノードが生成されるようになった。
現状確認
パラメータはこちらの記事を参考にした。
Dockerホストのパフォーマンスを引き出すTCPカーネルパラメータチューニング
CoreOS Stable(1520.6.0)のデフォルトのカーネルパラメータはこんな感じ。
sysctl -a
とか sysctl net.core.somaxconn
で確認できる。記事で言われている値がけっこう渋い。
fs.file-max = 400143
net.core.somaxconn = 128
net.ipv4.tcp_max_syn_backlog = 128
net.core.netdev_max_backlog = 1000
net.ipv4.ip_local_port_range = 32768 60999
net.ipv4.tcp_tw_reuse = 0
設定
customFiles
だけでは適用されないので customSystemdUnits
の設定も使う。
実際のcluster.yamlの設定はこちら。clusterをアップデートしたらパラメータの反映を確認できた。
# User defined files that will be added to the NodePool cloud-init configuration in the "write_files:" section.
customFiles:
- path: "/etc/sysctl.d/nf.conf"
permissions: 0644
content: |
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.netdev_max_backlog = 16384
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_tw_reuse = 1
# User defined systemd units that will be added to the NodePool cluster cloud-init configuration in the "units:" section.
customSystemdUnits:
- name: update-sysctl.service
command: start
enable: true
content: |
[Unit]
Description=Update sysctl values written by customFiles
[Service]
ExecStart=/usr/lib/systemd/systemd-sysctl