func generateNicName(containerID, ifname string) (string, string) {
if ifname == "eth0" {
return fmt.Sprintf("%s_h", containerID[0:12]), fmt.Sprintf("%s_c", containerID[0:12])
}
return fmt.Sprintf("%s_%s_h", containerID[0:12-len(ifname)], ifname), fmt.Sprintf("%s_%s_c", containerID[0:12-len(ifname)], ifname)
}
# containerID 这里的containerID 其实应该是pod id
![image.png](https://upload-images.jianshu.io/upload_images/8091046-935d5c968bd5d06e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
以containerd 为例
# k get po pc-node-1-vlan -o yaml | grep "containerd://"
- containerID: containerd://5b1e8061a96e72f49d1cf343a9b985a1015aca901bb4e53a9109d590b5450e15
前12位: 5b1e8061a96e
[root@pc-node-1 zbb]# k ko vsctl pc-node-1 show | grep 5b1e8061a
[root@pc-node-1 zbb]#
[root@pc-node-1 zbb]# crictl ps -a | grep 5b1e8061a96e
5b1e8061a96e7 4c6674e846d68 22 minutes ago Running busybox 0 0acba1b569e5f
[root@pc-node-1 zbb]#
[root@pc-node-1 zbb]# k ko vsctl pc-node-1 show | grep 0acba1b569e5
Port "0acba1b569e5_h"
Interface "0acba1b569e5_h"
[root@pc-node-1 zbb]#
[root@pc-node-1 zbb]# crictl ps -a
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID