• k8s 修改 pod 内容器内核参数


    k8s 修改 pod 内容器内核参数

    容器的本质是一个进程,共享宿主机的内核。原以为修改了宿主机的内核参数容器中也会改,但实际上并不是这样,容器的内核参数可以和宿主机不同。

    docker 修改内核参数

    docker run -it --rm --sysctl net.core.somaxconn=65535 busybox cat /proc/sys/net/core/somaxconn
    

    多个参数:

    docker run -itd --restart=always --net=host 
    --name=centos01 --hostname=centos01 
    --sysctl kernel.msgmnb=13107200 
    --sysctl kernel.msgmni=256 
    --sysctl kernel.msgmax=65536 
    --sysctl kernel.shmmax=69719476736 
    --sysctl kernel.sem='500 256000 250 1024' 
    -v /mnt:/update 
    centos /bin/bash
     
     
    docker exec centos01 sysctl -a |grep -E 
    'kernel.msgmnb|kernel.msgmni|kernel.msgmax|kernel.shmmax|kernel.sem'
    

    kubernetes 修改内核参数

    使用 pod 的 initContainers:

          initContainers:
          - command:
            - sysctl
            - -w
            - net.ipv4.tcp_keepalive_time=180
            image: busybox:1.27
            name: init-sysctl
            securityContext:
              privileged: true
    

    或者

          initContainers:
          - command:
            - /bin/sh
            - -c
            - |
              ulimit -n 65536
              mount -o remount rw /sys
              echo never > /sys/kernel/mm/transparent_hugepage/enabled
              mount -o remount rw /proc/sys
              echo 2000 > /proc/sys/net/core/somaxconn
              echo 1 > /proc/sys/vm/overcommit_memory
            image: registry.cn-beijing.aliyuncs.com/acs/busybox:v1.29.2
            imagePullPolicy: IfNotPresent
            name: init-redis
            resources: {}
            securityContext:
              privileged: true
              procMount: Default
    
  • 相关阅读:
    hdu 刷题记录
    HDU step by step
    Codeforces Round #260 (Div. 2) B. Fedya and Maths
    Codeforces Round #260 (Div. 2) A. Laptops
    UVALive 6662 TheLastAnt
    UVALive 6661 Equal Sum Sets
    Codeforces Round #253 (Div. 2) A. Anton and Letters
    wikioi 3130 CYD刷题(背包)
    wikioi 1014 装箱问题(背包)
    [转]很特别的一个动态规划入门教程
  • 原文地址:https://www.cnblogs.com/leffss/p/14832023.html
Copyright © 2020-2023  润新知