mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
Add the option of Rootless CNI networking by default
When the containers.conf field "NetNS" is set to "Bridge" and the "RootlessNetworking" field is set to "cni", Podman will now handle rootless in the same way it does root - all containers will be joined to a default CNI network, instead of exclusively using slirp4netns. If no CNI default network config is present for the user, one will be auto-generated (this also works for root, but it won't be nearly as common there since the package should already ship a config). I eventually hope to remove the "NetNS=Bridge" bit from containers.conf, but let's get something in for Brent to work with. Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
@ -253,7 +253,7 @@ func ParseUserNamespace(ns string) (Namespace, error) {
|
||||
// ParseNetworkNamespace parses a network namespace specification in string
|
||||
// form.
|
||||
// Returns a namespace and (optionally) a list of CNI networks to join.
|
||||
func ParseNetworkNamespace(ns string) (Namespace, []string, error) {
|
||||
func ParseNetworkNamespace(ns string, rootlessDefaultCNI bool) (Namespace, []string, error) {
|
||||
toReturn := Namespace{}
|
||||
var cniNetworks []string
|
||||
// Net defaults to Slirp on rootless
|
||||
@ -264,7 +264,11 @@ func ParseNetworkNamespace(ns string) (Namespace, []string, error) {
|
||||
toReturn.NSMode = FromPod
|
||||
case ns == "" || ns == string(Default) || ns == string(Private):
|
||||
if rootless.IsRootless() {
|
||||
toReturn.NSMode = Slirp
|
||||
if rootlessDefaultCNI {
|
||||
toReturn.NSMode = Bridge
|
||||
} else {
|
||||
toReturn.NSMode = Slirp
|
||||
}
|
||||
} else {
|
||||
toReturn.NSMode = Bridge
|
||||
}
|
||||
|
Reference in New Issue
Block a user