summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2020-12-03 22:26:29 +0100
committerPaul Holzinger <paul.holzinger@web.de>2021-01-27 20:58:03 +0100
commit1fac43654cf2ec950a2b3221e27425dbcd3bbf4d (patch)
tree7c1408499317b96b145f1ff16b57a6ba5cbd42b8 /libpod
parentc717b3cacad00ec8ea5415a2246994ac3adf7ae0 (diff)
downloadpodman-1fac43654cf2ec950a2b3221e27425dbcd3bbf4d.tar.gz
podman-1fac43654cf2ec950a2b3221e27425dbcd3bbf4d.tar.bz2
podman-1fac43654cf2ec950a2b3221e27425dbcd3bbf4d.zip
Add support for rootless network-aliases
Make sure we pass the network aliases as capability args to the cnitool in the rootless-cni-infra container. Also update the dnsname plugin in the cni-infra container. Fixes #8567 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/rootless_cni_linux.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/libpod/rootless_cni_linux.go b/libpod/rootless_cni_linux.go
index 9cfadc1f1..94ae062aa 100644
--- a/libpod/rootless_cni_linux.go
+++ b/libpod/rootless_cni_linux.go
@@ -25,7 +25,7 @@ import (
// Built from ../contrib/rootless-cni-infra.
var rootlessCNIInfraImage = map[string]string{
- "amd64": "quay.io/luap99/rootless-cni-infra@sha256:4e9f1e223463a46d9f9b019c0fa8c902494ed34872f75104d985b23812f19683", // 4-amd64
+ "amd64": "quay.io/libpod/rootless-cni-infra@sha256:adf352454666f7ce9ca3e1098448b5ee18f89c4516471ec99447ec9ece917f36", // 5-amd64
}
const (
@@ -66,10 +66,25 @@ func AllocRootlessCNI(ctx context.Context, c *Container) (ns.NetNS, []*cnitypes.
if c.config.StaticMAC != nil {
mac = c.config.StaticMAC.String()
}
+ aliases, err := c.runtime.state.GetAllNetworkAliases(c)
+ if err != nil {
+ return nil, nil, err
+ }
+ capArgs := ""
+ // add network aliases json encoded as capabilityArgs for cni
+ if len(aliases) > 0 {
+ capabilityArgs := make(map[string]interface{})
+ capabilityArgs["aliases"] = aliases
+ b, err := json.Marshal(capabilityArgs)
+ if err != nil {
+ return nil, nil, err
+ }
+ capArgs = string(b)
+ }
cniResults := make([]*cnitypes.Result, len(networks))
for i, nw := range networks {
- cniRes, err := rootlessCNIInfraCallAlloc(infra, c.ID(), nw, k8sPodName, ip, mac)
+ cniRes, err := rootlessCNIInfraCallAlloc(infra, c.ID(), nw, k8sPodName, ip, mac, capArgs)
if err != nil {
return nil, nil, err
}
@@ -146,11 +161,11 @@ func getCNIPodName(c *Container) string {
return c.Name()
}
-func rootlessCNIInfraCallAlloc(infra *Container, id, nw, k8sPodName, ip, mac string) (*cnitypes.Result, error) {
- logrus.Debugf("rootless CNI: alloc %q, %q, %q, %q, %q", id, nw, k8sPodName, ip, mac)
+func rootlessCNIInfraCallAlloc(infra *Container, id, nw, k8sPodName, ip, mac, capArgs string) (*cnitypes.Result, error) {
+ logrus.Debugf("rootless CNI: alloc %q, %q, %q, %q, %q, %q", id, nw, k8sPodName, ip, mac, capArgs)
var err error
- _, err = rootlessCNIInfraExec(infra, "alloc", id, nw, k8sPodName, ip, mac)
+ _, err = rootlessCNIInfraExec(infra, "alloc", id, nw, k8sPodName, ip, mac, capArgs)
if err != nil {
return nil, err
}