Local Development

Build images

Build CNI operator

  1. Set IMAGE_REGISTRY and VERSION environment to target image repository for operator

     export IMAGE_REGISTRY=<registry>
     export VERSION=<version>
    
  2. For private image registry, follow these additional steps to add image-pulling secret

    • Put your secret for pulling operator image (operator-secret.yaml) to the secret folder

      mv operator-secret.yaml config/secret
      
    • Run script to update relevant kustomization files

      export OPERATOR_SECRET_NAME=$(cat config/secret/operator-secret.yaml|yq .metadata.name)
      make operator-secret
      
  3. Build and push operator image

     go mod tidy
     make docker-build docker-push
    
  4. Build and push bundle image (optional)

     make bundle
     make bundle-build bundle-push
    

    To test the bundle, run

     operator-sdk run bundle ${IMAGE_REGISTRY}/multi-nic-cni-bundle:v${VERSION}
    

Build CNI daemon

  1. Set IMAGE_REGISTRY and VERSION environment to target image repository for daemon

     export IMAGE_REGISTRY=<registry>
     export VERSION=<version>
    
  2. For private image registry, follow these additional steps to add image-pulling secret

    • Put your secret for pulling daemon image (daemon-secret.yaml) to the secret folder

      mv daemon-secret.yaml config/secret
      
    • Run script to update relevant kustomization files

      export DAEMON_SECRET_NAME=$(cat config/secret/daemon-secret.yaml|yq .metadata.name)
      make daemon-secret
      
  3. Build and push daemon image

        # build environment: 
        #   Linux systems with netlink library
        cd daemon
        go mod tidy
        make docker-build-push
    

    This will also build the cni binary and copy the built binary to daemon component.

Test

# test golang linter (available after v1.0.4)
make golint
# test controller 
make test
# test daemon (available after v1.0.3)
make test-daemon

Install operator

make deploy

Uninstall operator

make undeploy