github.com/openebs/node-disk-manager@v1.9.1-0.20230225014141-4531f06ffa1e/BUILD.md (about)

     1  # Development Workflow
     2  
     3  ## Prerequisites
     4  
     5  * You have Go 1.19 or above installed on your local host/development machine.
     6  * You have Docker installed on your local host/development machine. Docker is required for building NDM container images and to push them into a Kubernetes cluster for testing. 
     7  * You have `kubectl` installed. For running integration tests, you will require an existing single node cluster. Don't worry if you don't have access to the Kubernetes cluster, raising a PR with the NDM repository will run integration tests for your changes against a Minikube cluster.
     8  
     9  
    10  ## Install the build dependencies.
    11    * By default node-disk-manager enables fetching disk attributes using udev. This requires udev develop files. For Ubuntu, `libudev-dev` package should be installed.
    12    * Run `make bootstrap` to install the required Go tools
    13    * node-disk-manager uses OpenSeaChest to fetch certain details of the disk like temperature and rotation rate. This requires cloning the `openSeaChest` repo **outside the node-disk-manager repo**
    14      ```sh
    15      git clone --recursive --branch Release-19.06.02 https://github.com/openebs/openSeaChest.git
    16      cd openSeaChest/Make/gcc
    17      make release
    18      ```
    19    * Copy the generated static library files to `/usr/lib`
    20      ```sh
    21      cd ../../
    22      sudo cp opensea-common/Make/gcc/lib/libopensea-common.a /usr/lib
    23      sudo cp opensea-operations/Make/gcc/lib/libopensea-operations.a /usr/lib
    24      sudo cp opensea-transport/Make/gcc/lib/libopensea-transport.a /usr/lib
    25      ```
    26  
    27  ## Building and Testing your changes
    28  
    29  * run `make` in the node-disk-manager directory. It will:
    30    * Build the binary.
    31    * Build the docker image with the binary.
    32  
    33  * To build multi-arch images, you need to have `buildx` installed. Follow these [instructions](https://github.com/docker/buildx#installing) to install buildx.
    34  
    35    Supported architectures are: amd64, arm64, armv7, ppc64le. 
    36  
    37    * NDM multi-arch images are built using QEMU mode(**NOTE**: This can take a lot of time since it runs in an emulated environment). If you're on linux, run :
    38  
    39      ``` docker run --rm --privileged linuxkit/binfmt:v0.8 ```
    40  
    41    * Set the value of environment variable of `IMAGE_ORG` based on your user name at Dockerhub or any other registry which supports storing multi-arch images (This is required because multi-arch images cannot be stored locally, so `buildx` pushes to the registry after building):  
    42  
    43      ``` export IMAGE_ORG=name ```
    44    * Depending on what you're working on, run:
    45      * For node-disk-manager:
    46  
    47        ``` make docker.buildx.ndm ```
    48      * For node-disk-operator:
    49  
    50        ``` make docker.buildx.ndo ```
    51      * For node-disk-exporter:
    52  
    53        ``` make docker.buildx.exporter ```
    54  
    55  * Test your changes
    56    * `sudo -E env "PATH=$PATH" make test` execute the unit tests
    57    * Integration tests are written in ginkgo and run against a minikube cluster. Minikube cluster should be running so as to execute the tests. To install minikube follow the doc [here](https://kubernetes.io/docs/tasks/tools/install-minikube/). 
    58    `make integration-test` will run the integration tests on the minikube cluster.
    59  
    60  #### Push Image
    61  By default, Github Action pushes the docker image to `openebs/node-disk-manager`, with *ci* tags.
    62  You can push to your custom registry and modify the ndm-operator.yaml file for your testing.