Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contrib/rootless-cni-infra/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ COPY --from=dnsname /dnsname /opt/cni/bin
COPY rootless-cni-infra /usr/local/bin
ENV CNI_PATH=/opt/cni/bin
CMD ["sleep", "infinity"]

ENV ROOTLESS_CNI_INFRA_VERSION=1
2 changes: 2 additions & 0 deletions contrib/rootless-cni-infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Podman then allocates a CNI netns in the infra container, by executing an equiva
The allocated netns is deallocated when the container is being removed, by executing an equivalent of:
`podman exec rootless-cni-infra rootless-cni-infra dealloc $CONTAINER_ID $NETWORK_NAME`.

The container images live on `quay.io/libpod/rootless-cni-infra`. The tags have the format `$version-$architecture`. Please make sure to increase the version number in the Containerfile (i.e., `ROOTLESS_CNI_INFRA_VERSION`) when applying changes to this directory. After committing the changes, upload the image(s) with the corresponding tag.

## Directory layout

* `/run/rootless-cni-infra/${CONTAINER_ID}/pid`: PID of the `sleep infinity` process that corresponds to the allocated netns
Expand Down
3 changes: 1 addition & 2 deletions contrib/rootless-cni-infra/rootless-cni-infra
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
set -eu

ARG0="$0"
VERSION="0.1.0"
BASE="/run/rootless-cni-infra"

# CLI subcommand: "alloc $CONTAINER_ID $NETWORK_NAME $POD_NAME"
Expand Down Expand Up @@ -126,7 +125,7 @@ cmd_entrypoint_help() {

# CLI subcommand: "version"
cmd_entrypoint_version() {
echo "{\"version\": \"${VERSION}\"}"
echo "{\"version\": \"${ROOTLESS_CNI_INFRA_VERSION}\"}"
}

# parse args
Expand Down
26 changes: 20 additions & 6 deletions libpod/rootless_cni_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/libpod/image"
"github.com/containers/podman/v2/pkg/env"
"github.com/containers/podman/v2/pkg/util"
"github.com/containers/storage/pkg/lockfile"
"github.com/hashicorp/go-multierror"
Expand All @@ -22,10 +23,9 @@ import (
"github.com/sirupsen/logrus"
)

// Built from ../contrib/rootless-cni-infra.
var rootlessCNIInfraImage = map[string]string{
// Built from ../contrib/rootless-cni-infra
// TODO: move to Podman's official quay
"amd64": "ghcr.io/akihirosuda/podman-rootless-cni-infra:gd34868a13-amd64",
"amd64": "quay.io/libpod/rootless-cni-infra@sha256:8aa681c4c08dee3ec5d46ff592fddd0259a35626717006d6b77ee786b1d02967", // 1-amd64
}

const (
Expand Down Expand Up @@ -258,9 +258,23 @@ func startRootlessCNIInfraContainer(ctx context.Context, r *Runtime) (*Container
Options: []string{"ro"},
}
g.AddMount(etcCNINetD)
// FIXME: how to propagate ProcessArgs and Envs from Dockerfile?
g.SetProcessArgs([]string{"sleep", "infinity"})
g.AddProcessEnv("CNI_PATH", "/opt/cni/bin")

inspectData, err := newImage.Inspect(ctx)
if err != nil {
return nil, err
}
imageEnv, err := env.ParseSlice(inspectData.Config.Env)
if err != nil {
return nil, err
}
for k, v := range imageEnv {
g.AddProcessEnv(k, v)
}
if len(inspectData.Config.Cmd) == 0 {
return nil, errors.Errorf("rootless CNI infra image %q has no command specified", imageName)
}
g.SetProcessArgs(inspectData.Config.Cmd)

var options []CtrCreateOption
options = append(options, WithRootFSFromImage(newImage.ID(), imageName, imageName))
options = append(options, WithCtrNamespace(rootlessCNIInfraContainerNamespace))
Expand Down