Skip to content

Commit

Permalink
Merge pull request #6 from Mellanox/cp-nv-ipam
Browse files Browse the repository at this point in the history
ipam-node: copy nv-ipam cni to cni bin dir
  • Loading branch information
adrianchiris committed May 4, 2023
2 parents e65d305 + 4ec68ec commit d4203c3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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

0 comments on commit d4203c3

Please sign in to comment.