Is it possible to apply many network plugins in Kubernetes and if so, which network plugin would be used when creating a Pod?
In CNI SPEC, it doesn't describe the strategy that selects the corresponding plugin.
I have found a possibly related function that solves my doubt: getDefaultCNINetwork(). From this function, I think it is possible to apply many network plugins in Kubernetes and when creating a Pod, Kubernetes will apply the first network plugin in the alphabet order of network plugin confs. Is it right?
As of Kubernetes version v1.14:
CNI
The CNI plugin is selected by passing Kubelet the --network-plugin=cni command-line option. Kubelet reads a file from --cni-conf-dir (default /etc/cni/net.d) and uses the CNI configuration from that file to set up each pod’s network. The CNI configuration file must match the CNI specification, and any required CNI plugins referenced by the configuration must be present in --cni-bin-dir (default /opt/cni/bin).
If there are multiple CNI configuration files in the directory, the first one in lexicographic order of file name is used.
In addition to the CNI plugin specified by the configuration file, Kubernetes requires the standard CNI lo plugin, at minimum version 0.2.0
Kubernetes first checks the /etc/cni/net.d
directory and the first configuration that is in there alphabetically, it will choose.
More information can be found here: https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/
As far as I know, the kubernetes does not support multiple CNI plugins at the moment. There is some on going work in the area of supporting multiple CNI plugins done by Huawei, please check the following repo: https://github.com/Huawei-PaaS/CNI-Genie .