• K8S 之使用Capabilities与限制网络带宽


    默认情况下,容器都是以非特权容器的方式运行。比如,不能在容器中创建虚拟网卡、配置虚拟网络。

    Kubernetes提供了修改Capabilities的机制,可以按需要给给容器增加或删除。比如下面的配置给容器增加了CAP_NET_ADMIN并删除了CAP_KILL

    apiVersion: v1
    kind: Pod
    metadata:
      name: hello-world
    spec:
      containers:
      - name: friendly-container
        image: "alpine:3.4"
        command: ["/bin/echo", "hello", "world"]
        securityContext:
          capabilities:
            add:
            - NET_ADMIN
            drop:
            - KILL
    

    限制网络带宽

    可以通过给Pod增加kubernetes.io/ingress-bandwidthkubernetes.io/egress-bandwidth这两个annotation来限制Pod的网络带宽

     

    apiVersion: v1
    kind: Pod
    metadata:
      name: qos
      annotations:
        kubernetes.io/ingress-band 3M
        kubernetes.io/egress-band 4M
    spec:
      containers:
      - name: iperf3
        image: networkstatic/iperf3
        command:
        - iperf3
        - -s
    

      

  • 相关阅读:
    hdu-1114
    hdu2546
    POJ-3126
    POJ-1915
    ZOJ-1709
    Codeforces 847H
    Codeforces 847C
    Codeforces 847I
    Codeforces 847E
    算法笔记--矩阵及矩阵快速幂
  • 原文地址:https://www.cnblogs.com/NGU-PX/p/14235817.html
Copyright © 2020-2023  润新知