Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman support beta #674

Merged
merged 33 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5a6b55e
Add initial podman support
LimeHat Oct 28, 2021
1c1f457
Add a few debug outputs
LimeHat Oct 28, 2021
500efba
Update go.mod/go.sum
LimeHat Oct 28, 2021
e0710e6
Add build tags for podman
LimeHat Oct 29, 2021
6cfbe58
Remove cgo build tags/depedency
LimeHat Jan 5, 2022
98df40b
Update go.mod after a rebase
LimeHat Jan 5, 2022
509ff34
Fix go.mod version of image-spec dep
LimeHat Jan 6, 2022
fa8c422
Add cpu/mem limits to podman
LimeHat Jan 6, 2022
66cc26b
Add support for a custom gw address (v4) with podman
LimeHat Jan 6, 2022
0e34630
Add support for custom MTU on a podman mgmt net
LimeHat Jan 6, 2022
627e06b
Merge branch 'main' into podman-support
hellt Jan 14, 2022
b9670d4
added info about podman runtime option
hellt Jan 14, 2022
b6f15cf
removed unused runtime consts
hellt Jan 14, 2022
dd5e411
applied gofmt for imports
hellt Jan 14, 2022
4e122cf
added make target
hellt Jan 14, 2022
626b8cd
Bump image-spec version to v1.0.3 to resolve conflicts
LimeHat Jan 14, 2022
f7b43a5
Merge branch 'podman-support' of github.com:LimeHat/containerlab into…
hellt Jan 14, 2022
f2530a5
Remove unused code artifacts
LimeHat Jan 17, 2022
06e1733
Merge branch 'podman-support' of github.com:LimeHat/containerlab into…
hellt Jan 17, 2022
37cbb82
fix typos
hellt Jan 17, 2022
beef04a
enable smoke tests for podman
hellt Jan 17, 2022
9fd8b0e
fix build cmd
hellt Jan 17, 2022
bb17d8c
set binary name
hellt Jan 17, 2022
02b800b
added podman service start
hellt Jan 17, 2022
aba2d1e
check podman bind mounts
hellt Jan 17, 2022
4154728
fix tests for podman
hellt Jan 17, 2022
b235b7f
added sudo
hellt Jan 17, 2022
8372fcb
split htmltest to two configs
hellt Jan 17, 2022
90b2684
added url wildcard
hellt Jan 17, 2022
6148f2b
scope out a single test instead of a suite
hellt Jan 17, 2022
ff1df8c
ignore backup lab files
hellt Jan 24, 2022
a584f34
added podman flags to build config
hellt Jan 24, 2022
d594889
build tags rework
hellt Jan 24, 2022
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
7 changes: 5 additions & 2 deletions clab/clab.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func WithRuntime(name string, rtconfig *runtime.RuntimeConfig) ClabOption {
// define runtime name.
// order of preference: cli flag -> env var -> default value of docker
envN := os.Getenv("CLAB_RUNTIME")
log.Debugf("envN runtime var value is %v", envN)
switch {
case name != "":
case envN != "":
Expand All @@ -69,6 +70,7 @@ func WithRuntime(name string, rtconfig *runtime.RuntimeConfig) ClabOption {

if rInit, ok := runtime.ContainerRuntimes[name]; ok {
r := rInit()
log.Debugf("Running runtime.Init with params %+v and %+v", rtconfig, c.Config.Mgmt)
err := r.Init(
runtime.WithConfig(rtconfig),
runtime.WithMgmtNet(c.Config.Mgmt),
Expand All @@ -78,7 +80,7 @@ func WithRuntime(name string, rtconfig *runtime.RuntimeConfig) ClabOption {
}

c.Runtimes[name] = r

log.Debugf("initialized a runtime with params %+v", r)
return nil
}
return fmt.Errorf("unknown container runtime %q", name)
Expand Down Expand Up @@ -136,14 +138,15 @@ func NewContainerLab(opts ...ClabOption) (*CLab, error) {

// initMgmtNetwork sets management network config
func (c *CLab) initMgmtNetwork() error {
log.Debugf("method initMgmtNetwork was called mgmt params %+v", c.Config.Mgmt)
if c.Config.Mgmt.Network == "" {
c.Config.Mgmt.Network = dockerNetName
}
if c.Config.Mgmt.IPv4Subnet == "" && c.Config.Mgmt.IPv6Subnet == "" {
c.Config.Mgmt.IPv4Subnet = dockerNetIPv4Addr
c.Config.Mgmt.IPv6Subnet = dockerNetIPv6Addr
}

log.Debugf("New mgmt params are %+v", c.Config.Mgmt)
// init docker network mtu
if c.Config.Mgmt.MTU == "" {
m, err := utils.DefaultNetMTU()
Expand Down
12 changes: 9 additions & 3 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ var destroyCmd = &cobra.Command{
topos[cont.Labels["clab-topo-file"]] = struct{}{}
}
}

log.Debugf("We got a topos struct for detroy: %+v", topos)
for topo := range topos {
opts := append(opts,
clab.WithTopoFile(topo, varsFile),
)
log.Debugf("going through extracted topos for destroy, got a topo file %v and generated opts list %+v", topo, opts)
c, err := clab.NewContainerLab(opts...)
if err != nil {
return err
Expand Down Expand Up @@ -167,11 +168,12 @@ func destroyLab(ctx context.Context, c *clab.CLab) (err error) {
log.Info("Removing containerlab host entries from /etc/hosts file")
err = clab.DeleteEntriesFromHostsFile(c.Config.Name)
if err != nil {
return err
return fmt.Errorf("error while trying to clean up the hosts file: %w", err)
}

// delete lab management network
if c.Config.Mgmt.Network != "bridge" && !keepMgmtNet {
log.Debugf("Calling DeleteNet method. *CLab.Config.Mgmt value is: %+v", c.Config.Mgmt)
if err = c.GlobalRuntime().DeleteNet(ctx); err != nil {
// do not log error message if deletion error simply says that such network doesn't exist
if err.Error() != fmt.Sprintf("Error: No such network: %s", c.Config.Mgmt.Network) {
Expand All @@ -180,5 +182,9 @@ func destroyLab(ctx context.Context, c *clab.CLab) (err error) {
}
}
// delete container network namespaces symlinks
return c.DeleteNetnsSymlinks()
err = c.DeleteNetnsSymlinks()
if err != nil {
return fmt.Errorf("error while deleting netns symlinks: %w", err)
}
return nil
}
82 changes: 69 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ require (
github.com/containerd/containerd v1.5.8
github.com/containernetworking/cni v0.8.1
github.com/containernetworking/plugins v0.9.1
github.com/containers/podman/v3 v3.4.4
github.com/digitalocean/go-openvswitch v0.0.0-20201214180534-ce0f183468d8
github.com/docker/docker v20.10.6+incompatible
github.com/docker/docker v20.10.11+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0
github.com/dustin/go-humanize v1.0.0
Expand Down Expand Up @@ -39,11 +40,15 @@ require (
require (
cloud.google.com/go v0.95.0 // indirect
cloud.google.com/go/storage v1.16.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v0.4.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/Microsoft/hcsshim v0.8.23 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7 // indirect
github.com/Shopify/ejson v1.3.0 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/armon/go-metrics v0.3.9 // indirect
github.com/aws/aws-sdk-go v1.40.49 // indirect
Expand All @@ -56,45 +61,67 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.4.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.7.1 // indirect
github.com/aws/smithy-go v1.8.0 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/containerd/cgroups v1.0.1 // indirect
github.com/containerd/console v1.0.2 // indirect
github.com/containerd/continuity v0.1.0 // indirect
github.com/containerd/fifo v1.0.0 // indirect
github.com/containerd/go-cni v1.0.2 // indirect
github.com/containerd/go-runc v1.0.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.9.0 // indirect
github.com/containerd/ttrpc v1.1.0 // indirect
github.com/containerd/typeurl v1.0.2 // indirect
github.com/containers/buildah v1.23.1 // indirect
github.com/containers/common v0.44.4 // indirect
github.com/containers/image v3.0.2+incompatible // indirect
github.com/containers/image/v5 v5.17.0 // indirect
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b // indirect
github.com/containers/ocicrypt v1.1.2 // indirect
github.com/containers/psgo v1.7.1 // indirect
github.com/containers/storage v1.37.0 // indirect
github.com/coreos/go-iptables v0.5.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/creack/pty v1.1.11 // indirect
github.com/cri-o/ocicni v0.2.1-0.20210621164014-d0acc7862283 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/disiqueira/gotree/v3 v3.0.2 // indirect
github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.3 // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/libkv v0.2.2-0.20180912205406-458977154600 // indirect
github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/freddierice/go-losetup v0.0.0-20170407175016-fc9adea44124 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-git/go-git/v5 v5.4.2 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/godbus/dbus/v5 v5.0.6 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/google/go-intervals v0.0.2 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/wire v0.5.0 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/schema v1.2.0 // indirect
github.com/gosimple/slug v1.10.0 // indirect
github.com/gosimple/unidecode v1.0.0 // indirect
github.com/hairyhenderson/toml v0.4.2-0.20210923231440-40456b8e66cf // indirect
Expand All @@ -112,66 +139,95 @@ require (
github.com/hashicorp/serf v0.9.5 // indirect
github.com/hashicorp/vault/api v1.1.1 // indirect
github.com/hashicorp/vault/sdk v0.2.1 // indirect
github.com/hpcloud/tail v1.0.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jinzhu/copier v0.3.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joho/godotenv v1.4.0 // indirect
github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.1.0 // indirect
github.com/klauspost/compress v1.13.5 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.7 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-shellwords v1.0.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mdlayher/netlink v1.4.0 // indirect
github.com/miekg/dns v1.1.29 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/sys/mountinfo v0.4.1 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mtrmac/gpgme v0.1.2 // indirect
github.com/nightlyone/lockfile v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283 // indirect
github.com/opencontainers/runc v1.0.3 // indirect
github.com/opencontainers/selinux v1.8.2 // indirect
github.com/opencontainers/runtime-tools v0.9.0 // indirect
github.com/opencontainers/selinux v1.9.1 // indirect
github.com/ostreedev/ostree-go v0.0.0-20190702140239-759a8c1ac913 // indirect
github.com/otiai10/copy v1.1.1 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/prometheus/client_golang v1.7.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.10.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rs/zerolog v1.25.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/sirikothe/gotextfsm v1.0.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/tchap/go-patricia v2.3.0+incompatible // indirect
github.com/ugorji/go/codec v1.2.6 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
github.com/vbauerster/mpb/v7 v7.1.5 // indirect
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect
github.com/weaveworks/libgitops v0.0.0-20200611103311-2c871bbbbf0c // indirect
github.com/weppos/publicsuffix-go v0.5.0 // indirect
github.com/xanzy/ssh-agent v0.3.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190809123943-df4f5c81cb3b // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/zealic/xignore v0.3.3 // indirect
github.com/zmap/zcrypto v0.0.0-20190729165852-9051775e6a2e // indirect
github.com/zmap/zlint v0.0.0-20190806154020-fd021b4cfbeb // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 // indirect
go.opencensus.io v0.23.0 // indirect
go4.org/intern v0.0.0-20210108033219-3eb7198706b2 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222180813-1025295fd063 // indirect
gocloud.dev v0.24.0 // indirect
golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167 // indirect
golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 // indirect
golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.57.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0 // indirect
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apimachinery v0.22.2 // indirect
Expand Down
Loading