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

ipam-node: copy nv-ipam cni to cni bin dir #6

Merged
merged 1 commit into from
May 4, 2023
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
21 changes: 21 additions & 0 deletions cmd/ipam-node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import (

// Options stores command line options
type Options struct {
CNIBinDir string
NvIpamCNIBinFile string
SkipNvIpamCNIBinaryCopy bool
NvIpamCNIDataDir string
NvIpamCNIDataDirHost string
CNIConfDir string
Expand All @@ -51,6 +54,10 @@ func (o *Options) addFlags() {
// suppress error message for help
pflag.ErrHelp = nil //nolint:golint,reassign
fs := pflag.CommandLine
fs.StringVar(&o.CNIBinDir,
"cni-bin-dir", "/host/opt/cni/bin", "CNI binary directory")
fs.StringVar(&o.NvIpamCNIBinFile,
"nv-ipam-bin-file", "/nv-ipam", "nv-ipam binary file path")
fs.StringVar(&o.NvIpamCNIDataDir,
"nv-ipam-cni-data-dir", "/host/var/lib/cni/nv-ipam", "nv-ipam CNI data directory")
fs.StringVar(&o.NvIpamCNIDataDirHost,
Expand All @@ -73,6 +80,11 @@ func (o *Options) addFlags() {
}

func (o *Options) verifyFileExists() error {
// CNIBinDir
if _, err := os.Stat(o.CNIBinDir); err != nil {
return fmt.Errorf("cni-bin-dir is not found: %v", err)
}

// CNIConfDir
if _, err := os.Stat(o.CNIConfDir); err != nil {
return fmt.Errorf("cni-conf-dir is not found: %v", err)
Expand Down Expand Up @@ -285,6 +297,15 @@ func main() {
return
}

// copy nv-ipam binary
if !opt.SkipNvIpamCNIBinaryCopy {
// Copy
if err = cmdutils.CopyFileAtomic(opt.NvIpamCNIBinFile, opt.CNIBinDir, "_nv-ipam", "nv-ipam"); err != nil {
log.Printf("failed at nv-ipam copy: %v\n", err)
return
}
}

// copy host-local binary
if !opt.SkipHostLocalBinaryCopy {
// Copy
Expand Down
6 changes: 6 additions & 0 deletions deploy/nv-ipam-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ spec:
securityContext:
privileged: true
volumeMounts:
- name: cnibin
mountPath: /host/opt/cni/bin
- name: cni
mountPath: /host/etc/cni/net.d
- name: hostlocalcnibin
Expand All @@ -87,6 +89,10 @@ spec:
mountPath: /host/var/lib/cni/nv-ipam/state/host-local
terminationGracePeriodSeconds: 10
volumes:
- name: cnibin
hostPath:
path: /opt/cni/bin
type: DirectoryOrCreate
- name: cni
hostPath:
path: /etc/cni/net.d
Expand Down