Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Ignite wrapper #481

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ bin
images/kubeadm/run
images/alpine/alpine.*
docs/_build
ignitew
23 changes: 23 additions & 0 deletions Dockerfile.ignitew
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:bionic

RUN apt-get update && apt-get install -y curl

ENV CNI_VERSION v0.8.2
ENV ARCH amd64

# Install wrap packer
ADD https://github.com/dgiagio/warp/releases/download/v0.3.0/linux-x64.warp-packer /usr/bin/linux-x64.warp-packer
RUN chmod +x /usr/bin/linux-x64.warp-packer

RUN mkdir /bundle
WORKDIR /bundle

COPY bin/amd64/ignite /bundle/ignite

RUN mkdir -p opt/cni/bin
RUN curl -sSL https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz | tar -xz -C opt/cni/bin

# Create wrapper
RUN mkdir /output
WORKDIR /output
RUN linux-x64.warp-packer --arch linux-x64 --input_dir /bundle --exec ignite --output ignitew
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ serve-docs: build-docs
@echo Stating docs website on http://localhost:${DOCS_PORT}/_build/html/index.html
@$(DOCKER) run -i --rm -p ${DOCS_PORT}:8000 -e USER_ID=$$UID ignite-docs

build-ignitew: build-all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can change this to ignite instead of build-all

$(DOCKER) build --no-cache -t ignitew-builder -f Dockerfile.ignitew .
$(DOCKER) create --name=ignitew-builder ignitew-builder
$(DOCKER) cp ignitew-builder:/output/ignitew .
$(DOCKER) rm -f ignitew-builder

e2e: build-all e2e-nobuild

e2e-nobuild:
Expand Down
14 changes: 13 additions & 1 deletion pkg/network/cni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"os"
"path"
"path/filepath"
"strings"
"sync"

Expand Down Expand Up @@ -97,7 +98,18 @@ func GetCNINetworkPlugin(runtime runtime.Interface) (network.Plugin, error) {
}
}

binDirs := []string{CNIBinDir}
var binDirs []string

// Check if we have an embedded CNI along side the ignite binary
exeDir := filepath.Dir(os.Args[0])
embeddedCNIBinDir := path.Join(exeDir, "opt", "cni", "bin")
// If we found the local CNI binary dir, we use it
if _, err := os.Stat(embeddedCNIBinDir); err == nil {
binDirs = append(binDirs, embeddedCNIBinDir)
}

// and we always have the default value from CNIBinDir
binDirs = append(binDirs, CNIBinDir)
cniInstance, err := gocni.New(gocni.WithMinNetworkCount(2),
gocni.WithPluginConfDir(CNIConfDir),
gocni.WithPluginDir(binDirs))
Expand Down
16 changes: 14 additions & 2 deletions pkg/preflight/checkers/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"os"
"os/exec"
"path/filepath"
"strings"

api "github.com/weaveworks/ignite/pkg/apis/ignite"
Expand Down Expand Up @@ -99,9 +100,20 @@ func StartCmdChecks(vm *api.VM, ignoredPreflightErrors sets.String) error {
for _, dependency := range constants.PathDependencies {
checks = append(checks, ExistingFileChecker{filePath: dependency})
}
// This should be warning only, in case users prefer other network plugins
if providers.NetworkPluginName == network.PluginCNI {
for _, dependency := range constants.CNIDependencies {
checks = append(checks, ExistingFileChecker{filePath: dependency})
// In case of using ignitew, we put CNI plugin binaries relatively to the executable
exeDir := filepath.Dir(os.Args[0])
if _, err := os.Stat(exeDir); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this may always be true -- it doesn't indicate that the binary is actually ignitew

Perhaps there's a warp native way to detect that the binaries have been unpacked for us

for _, dependency := range constants.CNIDependencies {
releativeCNIPath := filepath.Join(exeDir, dependency)
checks = append(checks, ExistingFileChecker{filePath: releativeCNIPath})
}
} else {
// Otherwise in the normal case, we check usually path
for _, dependency := range constants.CNIDependencies {
checks = append(checks, ExistingFileChecker{filePath: dependency})
}
}
}
checks = append(checks, providers.Runtime.PreflightChecker())
Expand Down