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 all 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
8 changes: 6 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
${{ runner.os }}-go-

- name: Build containerlab
run: go build
run: CGO_ENABLED=0 go build -o containerlab -ldflags="-s -w -X 'github.com/srl-labs/containerlab/cmd.version=0.0.0' -X 'github.com/srl-labs/containerlab/cmd.commit=$(git rev-parse --short HEAD)' -X 'github.com/srl-labs/containerlab/cmd.date=$(date)'" -trimpath -tags "podman exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper exclude_graphdriver_overlay containers_image_openpgp" main.go
# store clab binary as artifact
- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
runtime: ["docker", "containerd"]
runtime: ["docker", "containerd", "podman"]
needs:
- unit-test
- build-containerlab
Expand All @@ -121,6 +121,10 @@ jobs:
name: containerlab
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab

- name: Enable Podman API service
run: sudo systemctl start podman

- uses: actions/setup-python@v2
with:
python-version: "3.8"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ site/
.DS_Store
__rd*
tests/out

**/.*clab.y?ml
3 changes: 3 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ builds:
- id: clab-bin
env:
- CGO_ENABLED=0
flags:
- -trimpath
- -tags="podman exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper exclude_graphdriver_overlay containers_image_openpgp"
ldflags:
- -s -w -X github.com/srl-labs/containerlab/cmd.version={{.Version}} -X github.com/srl-labs/containerlab/cmd.commit={{.ShortCommit}} -X github.com/srl-labs/containerlab/cmd.date={{.Date}}
goos:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ build:
mkdir -p $(BIN_DIR)
go build -o $(BINARY) -ldflags="-s -w -X 'github.com/srl-labs/containerlab/cmd.version=0.0.0' -X 'github.com/srl-labs/containerlab/cmd.commit=$$(git rev-parse --short HEAD)' -X 'github.com/srl-labs/containerlab/cmd.date=$$(date)'" main.go

build-with-podman:
mkdir -p $(BIN_DIR)
CGO_ENABLED=0 go build -o $(BINARY) -ldflags="-s -w -X 'github.com/srl-labs/containerlab/cmd.version=0.0.0' -X 'github.com/srl-labs/containerlab/cmd.commit=$$(git rev-parse --short HEAD)' -X 'github.com/srl-labs/containerlab/cmd.date=$$(date)'" -trimpath -tags "podman exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper exclude_graphdriver_overlay containers_image_openpgp" main.go

test:
go test -race ./... -v

Expand All @@ -28,5 +32,5 @@ site:
.PHONY: htmltest
htmltest:
docker run --rm -v $$(pwd):/docs --entrypoint mkdocs squidfunk/mkdocs-material:$(MKDOCS_VER) build --clean --strict
docker run --rm -v $$(pwd):/test wjdp/htmltest --conf ./site/htmltest.yml
docker run --rm -v $$(pwd):/test wjdp/htmltest --conf ./site/htmltest-w-github.yml
rm -rf ./site
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
}
7 changes: 4 additions & 3 deletions docs/cmd/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ Refer to the [configuration artifacts](../manual/conf-artifacts.md) page to get
With `--max-workers` flag it is possible to limit the amout of concurrent workers that create containers or wire virtual links. By default the number of workers equals the number of nodes/links to create.

#### runtime
Containerlab nodes can be started by different runtimes, with `docker` being the default one. Besides `docker`, containerlab has experimental support for `containerd` and `ignite` runtimes.
Containerlab nodes can be started by different runtimes, with `docker` being the default one. Besides that, containerlab has experimental support for `podman`, `containerd`, and `ignite` runtimes.

A global runtime can be selected with a global `--runtime | -r` flag that will select a runtime to use. The supported value are:
A global runtime can be selected with a global `--runtime | -r` flag that will select a runtime to use. The possible value are:

* `docker` - default
* `containerd`
* `podman` - beta support
* `containerd` - experimental support
* `ignite`

#### timeout
Expand Down
29 changes: 29 additions & 0 deletions docs/htmltest-w-github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# adopted from https://github.com/goreleaser/goreleaser/blob/5adf43295767b5be05fa38a01ffb3ad25bd21797/www/htmltest.yml
# using https://github.com/wjdp/htmltest

# this version does not ignore github links and is meant to be run via makefile on the user's machine
# the CI-friendly htmltest config file is named htmltest.yml and excludes github.com links, as they are often return HTTP 429
DirectoryPath: ./site
IgnoreURLs:
- fonts.gstatic.com
- img.shields.io
- www.reddit.com/r/bashonubuntuonwindows/comments/ldbyxa/what_is_the_current_state_of_kvm_acceleration_on/ # sometimes timeouts for unknown reason
- goreleaser.com # doesn't support `range 0` GETs which htmltest uses
- https://documentation.nokia.com/cgi-bin/dbaccessfilename.cgi/3HE15836AAADTQZZA01_V1_vSIM%20Installation%20and%20Setup%20Guide%2020.10.R1.pdf # fuck this false positives...
- https://documentation.nokia.com/cgi-bin/dbaccessfilename.cgi/3HE16113AAAATQZZA01_V1_SR%20Linux%20R20.6%20Software%20Installation.pdf
- https://github.com/srl-labs/containerlab/releases/ # gh rate limiters for this particular endpoint are too aggressive
- https://github.com/srl-labs/containerlab/pkgs/container/clab
- https://linkedin.com/in
- https://www.linkedin.com/in
IgnoreDirectoryMissingTrailingSlash: true
IgnoreAltMissing: true
IgnoreSSLVerify: true
IgnoreDirs:
- overrides
IgnoreInternalEmptyHash: true
ExternalTimeout: 60
HTTPHeaders:
"Range": "bytes=0-10"
"Accept": "*/*"
CacheExpires: "168h"
HTTPConcurrencyLimit: 1
1 change: 1 addition & 0 deletions docs/htmltest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ IgnoreURLs:
- https://github.com/srl-labs/containerlab/pkgs/container/clab
- https://linkedin.com/in
- https://www.linkedin.com/in
- https://*github.com/
IgnoreDirectoryMissingTrailingSlash: true
IgnoreAltMissing: true
IgnoreSSLVerify: true
Expand Down
3 changes: 2 additions & 1 deletion docs/manual/nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,13 @@ my-node:
The `network-mode` configuration option set to `host` will launch the node in the [host networking mode](https://docs.docker.com/network/host/).

### runtime
By default containerlab nodes will be started by `docker` container runtime. Besides that, containerlab has experimental support for `containerd` and `ignite` runtimes.
By default containerlab nodes will be started by `docker` container runtime. Besides that, containerlab has experimental support for `podman`, `containerd`, and `ignite` runtimes.

It is possible to specify a global runtime with a global `--runtime` flag, or set the runtime on a per-node basis:

Options for the runtime parameter are:
- `docker`
- `podman`
- `containerd`
- `ignite`

Expand Down
Loading