• kata network


    https://github.com/kata-containers/runtime/issues/1876

    root@ubuntu:/etc/systemd/system/docker.service.d# docker ps -a
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS               NAMES
    d5f9427e83fd        busybox             "sh"                     4 hours ago         Up 4 hours                                   nervous_ardinghelli
    6b50edc95507        e86d342d58f4        "/bin/sh -c 'curl --…"   2 weeks ago         Exited (1) 2 weeks ago                       nice_hopper
    3281029ea007        a23842ff8e97        "/bin/sh -c 'cd /tmp…"   2 weeks ago         Exited (1) 2 weeks ago                       elated_dhawan
    bf62a95cf4ec        busybox             "sh"                     2 weeks ago         Created                                      upbeat_pare
    root@ubuntu:/etc/systemd/system/docker.service.d# cd ~
    root@ubuntu:~# docker exec -it nervous_ardinghelli ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel qlen 1000
        link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
        inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
           valid_lft forever preferred_lft forever
        inet6 fe80::42:acff:fe11:2/64 scope link 
           valid_lft forever preferred_lft forever
    root@ubuntu:~# kata-runtime kata-network list-ifaces d5f9427e83fd
    Container ID (d5f9427e83fd) does not exist
    root@ubuntu:~# kata-runtime list
    ID                                                                 PID         STATUS      BUNDLE                                                                                                                  CREATED                          OWNER
    d5f9427e83fd374e12125fb442942931fdf08c949f68e9c027592d048526b0cb   40725       running     /run/containerd/io.containerd.runtime.v1.linux/moby/d5f9427e83fd374e12125fb442942931fdf08c949f68e9c027592d048526b0cb    2020-11-03T02:05:57.193803486Z   #0
    bc6b585703b6cb29f5f1d6f5865f5eddeee474b330a08b8eac1e17a3e5f5367b   -1          running     /run/containerd/io.containerd.runtime.v2.task/k8s.io/bc6b585703b6cb29f5f1d6f5865f5eddeee474b330a08b8eac1e17a3e5f5367b   2020-10-19T03:25:09.220264337Z   #0
    17ca0dce454b1e6a29288ece07fd0c7bca4e33a32d7cca9b9a1f30f5cc38b672   -1          running     /run/containerd/io.containerd.runtime.v2.task/k8s.io/17ca0dce454b1e6a29288ece07fd0c7bca4e33a32d7cca9b9a1f30f5cc38b672   2020-10-19T03:25:21.944666114Z   #0
    6a91f780eda7a3b382bc79acec45e8905c2ee63243ba74300145a217e617bf10   -1          running     /run/containerd/io.containerd.runtime.v2.task/k8s.io/6a91f780eda7a3b382bc79acec45e8905c2ee63243ba74300145a217e617bf10   2020-10-17T02:14:04.602169815Z   #0
    64abb3931350d2762e805122d39ecbcee47e59a40331d1e09a5823dd0d11fa27   -1          running     /run/containerd/io.containerd.runtime.v2.task/k8s.io/64abb3931350d2762e805122d39ecbcee47e59a40331d1e09a5823dd0d11fa27   2020-10-17T02:13:37.762824405Z   #0
    root@ubuntu:~# kata-runtime kata-network list-ifaces d5f9427e83fd374e12125fb442942931fdf08c949f68e9c027592d048526b0cb
    [{"Device":"","Name":"lo","IPAddresses":[{"Family":2,"Address":"127.0.0.1","Mask":"8"},
    {"Family":10,"Address":"::1","Mask":"128"}],"Mtu":65536,"RawFlags":0,"HwAddr":"","PciAddr":"","LinkType":""},
    {"Device":"","Name":"eth0","IPAddresses":[{"Family":2,"Address":"172.17.0.2","Mask":"16"},{"Family":10,"Address":"fe80::42:acff:fe11:2","Mask":"64"}],"Mtu":1500,"RawFlags":0,"HwAddr":"02:42:ac:11:00:02","PciAddr":"","LinkType":""}] root@ubuntu:~#
    func createEndpoint(netInfo NetworkInfo, idx int, model NetInterworkingModel, link netlink.Link) (Endpoint, error) {
            var endpoint Endpoint
            // TODO: This is the incoming interface
            // based on the incoming interface we should create
            // an appropriate EndPoint based on interface type
            // This should be a switch
    
            // Check if interface is a physical interface. Do not create
            // tap interface/bridge if it is.
            isPhysical, err := isPhysicalIface(netInfo.Iface.Name)
            if err != nil {
                    return nil, err
            }
    
            if isPhysical {
                    networkLogger().WithField("interface", netInfo.Iface.Name).Info("Physical network interface found")
                    endpoint, err = createPhysicalEndpoint(netInfo)
            } else {
                    var socketPath string
    
                    // Check if this is a dummy interface which has a vhost-user socket associated with it
                    socketPath, err = vhostUserSocketPath(netInfo)
                    if err != nil {
                            return nil, err
                    }
    
                    if socketPath != "" {
                            networkLogger().WithField("interface", netInfo.Iface.Name).Info("VhostUser network interface found")
                            endpoint, err = createVhostUserEndpoint(netInfo, socketPath)
                    } else if netInfo.Iface.Type == "macvlan" {
                            networkLogger().Infof("macvlan interface found")
                            endpoint, err = createBridgedMacvlanNetworkEndpoint(idx, netInfo.Iface.Name, model)
                    } else if netInfo.Iface.Type == "macvtap" {
                            networkLogger().Infof("macvtap interface found")
                            endpoint, err = createMacvtapNetworkEndpoint(netInfo)
                    } else if netInfo.Iface.Type == "tap" {
                            networkLogger().Info("tap interface found")
                            endpoint, err = createTapNetworkEndpoint(idx, netInfo.Iface.Name)
                    } else if netInfo.Iface.Type == "tuntap" {
                            if link != nil {
                                    switch link.(*netlink.Tuntap).Mode {
                                    case 0:
                                            // mount /sys/class/net to get links
                                            return nil, fmt.Errorf("Network device mode not determined correctly. Mount sysfs in caller")
                                    case 1:
                                            return nil, fmt.Errorf("tun networking device not yet supported")
                                    case 2:
                                            networkLogger().Info("tuntap tap interface found")
                                            endpoint, err = createTuntapNetworkEndpoint(idx, netInfo.Iface.Name, netInfo.Iface.HardwareAddr, model)
                                    default:
                                            return nil, fmt.Errorf("tuntap network %v mode unsupported", link.(*netlink.Tuntap).Mode)
                                    }
                            }
                    } else if netInfo.Iface.Type == "veth" {
                            endpoint, err = createVethNetworkEndpoint(idx, netInfo.Iface.Name, model)
                    } else if netInfo.Iface.Type == "ipvlan" {
                            endpoint, err = createIPVlanNetworkEndpoint(idx, netInfo.Iface.Name)
                    } else {
                            return nil, fmt.Errorf("Unsupported network interface: %s", netInfo.Iface.Type)
                    }
            }
    
            return endpoint, err
    }
    root@ubuntu:~# cat kata_add_tap.json 
    {
        "device": "tap-test", 
        "name": "eth-test", 
        "IPAddresses": [
            {
                "address": "172.16.0.3", 
                "mask": "16"
            }
        ], 
        "hwAddr":"02:42:20:6f:a3:69",
        "mtu": 1500,
        "queues":5
    }
    root@ubuntu:~#  kata-runtime kata-network add-iface d5f9427e83fd374e12125fb442942931fdf08c949f68e9c027592d048526b0cb kata_add_tap.json 
    null
    Unsupported network interface: 
    root@ubuntu:~# 
    root@ubuntu:~# kata-runtime events --stats d5f9427e83fd374e12125fb442942931fdf08c949f68e9c027592d048526b0cb | jq
    {
      "type": "stats",
      "id": "d5f9427e83fd374e12125fb442942931fdf08c949f68e9c027592d048526b0cb",
      "data": {
        "cpu": {
          "usage": {
            "total": 199332040,
            "percpu": [
              199332040
            ],
            "kernel": 40000000,
            "user": 60000000
          },
          "throttling": {}
        },
        "memory": {
          "cache": 839680,
          "usage": {
            "limit": 9223372036854772000,
            "usage": 1323008,
            "max": 9490432,
            "failcnt": 0
          },
          "swap": {
            "limit": 9223372036854772000,
            "usage": 1323008,
            "max": 9490432,
            "failcnt": 0
          },
          "kernel": {
            "limit": 9223372036854772000,
            "usage": 458752,
            "max": 573440,
            "failcnt": 0
          },
          "kernelTCP": {
            "limit": 0,
            "failcnt": 0
          },
          "raw": {
            "active_anon": 135168,
            "active_file": 405504,
            "cache": 839680,
            "dirty": 0,
            "hierarchical_memory_limit": 9223372036854772000,
            "hierarchical_memsw_limit": 9223372036854772000,
            "inactive_anon": 0,
            "inactive_file": 405504,
            "mapped_file": 675840,
            "pgfault": 6105,
            "pgmajfault": 0,
            "pgpgin": 5082,
            "pgpgout": 4892,
            "rss": 172032,
            "rss_huge": 0,
            "shmem": 0,
            "swap": 0,
            "total_active_anon": 135168,
            "total_active_file": 405504,
            "total_cache": 839680,
            "total_dirty": 0,
            "total_inactive_anon": 0,
            "total_inactive_file": 405504,
            "total_mapped_file": 675840,
            "total_pgfault": 6105,
            "total_pgmajfault": 0,
            "total_pgpgin": 5082,
            "total_pgpgout": 4892,
            "total_rss": 172032,
            "total_rss_huge": 0,
            "total_shmem": 0,
            "total_swap": 0,
            "total_unevictable": 0,
            "total_writeback": 0,
            "unevictable": 0,
            "writeback": 0
          }
        },
        "pids": {
          "current": 1
        },
        "blkio": {
          "ioServiceBytesRecursive": [
            {
              "major": 254,
              "op": "Read",
              "value": 4096
            },
            {
              "major": 254,
              "op": "Write"
            },
            {
              "major": 254,
              "op": "Sync",
              "value": 4096
            },
            {
              "major": 254,
              "op": "Async"
            },
            {
              "major": 254,
              "op": "Discard"
            },
            {
              "major": 254,
              "op": "Total",
              "value": 4096
            }
          ],
          "ioServicedRecursive": [
            {
              "major": 254,
              "op": "Read",
              "value": 1
            },
            {
              "major": 254,
              "op": "Write"
            },
            {
              "major": 254,
              "op": "Sync",
              "value": 1
            },
            {
              "major": 254,
              "op": "Async"
            },
            {
              "major": 254,
              "op": "Discard"
            },
            {
              "major": 254,
              "op": "Total",
              "value": 1
            }
          ]
        },
        "hugetlb": {},
        "intel_rdt": {}
      }
    }
    root@ubuntu:~# 
  • 相关阅读:
    【t090】吉祥数
    【u221】分数
    【u212】&&【t036】最大和
    【u125】最大子树和
    【u124】环状最大两段子段和
    【u123】最大子段和
    【u122】迎接仪式
    【u121】教主的花园
    【u118】日志分析
    【u117】队列安排
  • 原文地址:https://www.cnblogs.com/dream397/p/13920106.html
Copyright © 2020-2023  润新知