Skip to content

Commit da6e039

Browse files
committed
* Small changes to the e2e script
* Build documentation updates.
1 parent 244c81c commit da6e039

File tree

3 files changed

+82
-60
lines changed

3 files changed

+82
-60
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ VERSION_FILE=./CONTROLLER_VERSION
44
RELEASE_VER=v$(shell $(CAT_CMD) $(VERSION_FILE))
55
CURRENT_DIR=$(shell pwd)
66
GIT_BRANCH:=$(shell git symbolic-ref --short HEAD 2>&1 | grep -v fatal)
7+
LOCAL_BUILD_ARGS ?= -race
78
# Reset branch name if this a Travis CI environment
89
ifneq ($(strip $(TRAVIS_BRANCH)),)
910
GIT_BRANCH:=${TRAVIS_BRANCH}
@@ -23,6 +24,7 @@ TAG:=${TAG}${RELEASE_VER}
2324

2425
.PHONY: print-global-variables
2526

27+
# Build the controler executalbe for use in docker image build
2628
mcad-controller: init generate-code
2729
$(info Compiling controller)
2830
CGO_ENABLED=0 GOOS="linux" go build -o ${BIN_DIR}/mcad-controller ./cmd/kar-controllers/
@@ -62,7 +64,7 @@ images: verify-tag-name mcad-controller
6264
$(info Build the docker image)
6365
docker build --quiet --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/deployment/Dockerfile.both ${CURRENT_DIR}/_output/bin
6466

65-
images-podman: verify-tag-name
67+
images-podman: verify-tag-name mcad-controller
6668
$(info List executable directory)
6769
$(info repo id: ${git_repository_id})
6870
$(info branch: ${GIT_BRANCH})
@@ -106,6 +108,12 @@ mcad-controller-private: init generate-code
106108
$(info Compiling controller)
107109
CGO_ENABLED=0 GOARCH=amd64 GOPRIVATE=github.ibm.com/* go build -tags private -modfile ./private.mod -o ${BIN_DIR}/mcad-controller ./cmd/kar-controllers/
108110

111+
# Build the controller executable for use on the local host and using local build args
112+
# the default for local build args is `-race` to turn race detection
113+
mcad-controller-local: init generate-code
114+
$(info Compiling controller)
115+
go build ${LOCAL_BUILD_ARGS} -o ${BIN_DIR}/mcad-controller-local ./cmd/kar-controllers/
116+
109117
coverage:
110118
# KUBE_COVER=y hack/make-rules/test.sh $(WHAT) $(TESTS)
111119

doc/build/build.md

Lines changed: 72 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ To build `Multi-Cluster-App-Deployer`, a running Docker environment must be avai
1313
Clone this repo in your local environment:
1414

1515
__Option 1__: Clone this github project to your local machine via HTTPS
16-
```
16+
17+
```bash
1718
$ git clone https://github.com/project-codeflare/multi-cluster-app-dispatcher.git
1819
Cloning into 'multi-cluster-app-dispatcher'...
1920
Checking connectivity... done.
@@ -22,90 +23,103 @@ $
2223
```
2324
2425
__Option 2__: Clone this github project to your local machine via SSH
25-
```
26+
27+
```bash
2628
$ git clone git@github.com:project-codeflare/multi-cluster-app-dispatcher.git
2729
Cloning into 'multi-cluster-app-dispatcher'...
2830
Checking connectivity... done.
2931
Checking out files: 100% (####/####), done.
3032
$
31-
3233
```
34+
35+
### Additional software needed
36+
37+
To build the controller and to run the end to end tests locally you will need to have the following software installed:
38+
39+
* `Go` (version 1.16) -- the controller will compile and run with later versions, but currently supported version is 1.16
40+
* `kind` (version 0.11) -- later versions will work fine
41+
* `kubectl`
42+
* `helm` - version 3.0 or later
43+
* `make`
44+
45+
On MacOS you will need to have `readlink` executable installed (`brew install coreutils`)
46+
3347
## 2. Building the Multi-Cluster-App-Deployer Controller
3448
3549
### Build the Executable
3650
37-
Run the build script `build.sh`:
38-
```
39-
$ cd multi-cluster-app-dispatcher/deployment/
51+
From the root directory of the repository:
4052
41-
$ ./build.sh
53+
```bash
54+
#build for linux OS and for use inside docker image
55+
multi-cluster-app-dispatcher $ make mcad-controller
4256
...
43-
+ cd ..
44-
+ make generate-code
45-
Compiling deepcopy-gen
46-
Generating deepcopy
57+
Compiling deepcopy-gen...
58+
Generating deepcopy...
4759
go build -o _output/bin/deepcopy-gen ./cmd/deepcopy-gen/
48-
_output/bin/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
49-
+ make kar-controller
60+
_output/bin/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
61+
Compiling controller
62+
CGO_ENABLED=0 GOOS="linux" go build -o _output/bin/mcad-controller ./cmd/kar-controllers/
63+
64+
#build for local testing purposes, by default enable the race conditions detector
65+
multi-cluster-app-dispatcher $ make mcad-controller-local
66+
...
5067
mkdir -p _output/bin
51-
CGO_ENABLED=0 GOARCH=amd64 go build -o _output/bin/kar-controllers ./cmd/kar-controllers/
52-
$
68+
Compiling deepcopy-gen...
69+
Generating deepcopy...
70+
go build -o _output/bin/deepcopy-gen ./cmd/deepcopy-gen/
71+
_output/bin/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
72+
Compiling controller
73+
go build -race -o _output/bin/mcad-controller-local ./cmd/kar-controllers/
5374
```
5475
55-
Ensure the executables: `deepcopy-gen`, `mcad-controllers` are created in the target output directory:
56-
```
57-
$ ls ../_output/bin/
58-
deepcopy-gen mcad-controller
59-
$
76+
Ensure the executables: `deepcopy-gen`, `mcad-controllers`, and optionally `mca-controller-local` are created in the target output directory:
77+
78+
```bash
79+
multi-cluster-app-dispatcher $ ls _output/bin
80+
deepcopy-gen mcad-controller mcad-controller-local
6081
```
6182
6283
### Build the Multi-Cluster-App-Dispatcher Image
6384
64-
Run the image build script `image.sh`:
65-
66-
```
67-
$ ./image.sh
68-
...
69-
+ make images
70-
Changed to executable directory
71-
Build the docker image
72-
cd ./_output/bin
73-
docker build --no-cache --tag mcad-controller:v1.14 ...
74-
Sending build context to Docker daemon 122.7MB
75-
Step 1/7 : From ubuntu:18.04
76-
---> ea4c82dcd15a
77-
Step 2/7 : ADD mcad-controller /usr/local/bin
78-
---> 674cefbce55a
79-
...
80-
---> 911c7c82b5ee
81-
Step 7/7 : WORKDIR /usr/local/bin
82-
---> Running in f2db4649e7a6
83-
Removing intermediate container f2db4649e7a6
84-
---> 1dbf126976cf
85-
Successfully built 1dbf126976cf
86-
Successfully tagged mcad-controller:v1.14
87-
$
88-
```
85+
From the root directory of the repository:
8986
90-
Note the *image name* and *image tag* from the image build script (`./image.sh`) above. For example the *image name* and *image tag* built after running the example above is `mcad-controller:v1.14`. List the Docker images to ensure the image exists.
87+
```bash
88+
# With docker daemon running
89+
multi-cluster-app-dispatcher % make images
9190

91+
#Using podman
92+
make images-podman
9293
```
93-
$ docker images mcad-controller
94-
REPOSITORY TAG IMAGE ID CREATED SIZE
95-
mcad-controller v.1.14 1dbf126976cf 11 minutes ago 272MB
96-
$
97-
```
94+
9895
### Push the Multi-Cluster-App-Dispatcher Image to an Image Repository
99-
The following example assumes an available `<repository>/mcad-controller` on [Docker Hub](https://hub.docker.com)
100-
```
101-
$ docker login
102-
$ docker push <respository>/mcad-controller:v1.14
96+
97+
The following example assumes an available `<repository>/mcad-controller` on [Docker Hub](https://hub.docker.com) and using image version `v1.14`
98+
99+
```bash
100+
docker login
101+
docker push <respository>/mcad-controller:v1.14
103102
```
104103
105104
The same can be done with [Quay](quay.io)
106-
```
107-
$ docker login quay.io
108-
$ docker push <quay_respository>/mcad-controller:v1.14
105+
106+
```bash
107+
docker login quay.io
108+
docker push <quay_respository>/mcad-controller:v1.14
109109
```
110110
111111
Refer to [deployment](../deploy/deployment.md) on how to deploy the `multi-cluster-app-dispatcher` as a controller in Kubernetes.
112+
113+
## 3. Running e2e tests locally
114+
115+
When running e2e tests, is recommended you restrict the `docker` daemon [cpu and memory resources](https://docs.docker.com/config/containers/resource_constraints/). The recomended settings are:
116+
117+
* CPU: 4
118+
* Memory: 4 GB
119+
120+
From the root directory of the repository:
121+
122+
```bash
123+
# With docker daemon running
124+
multi-cluster-app-dispatcher % make run-e2e:
125+
```

hack/run-e2e-kind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# See the License for the specific language governing permissions and
2828
# limitations under the License.
2929

30-
export ROOT_DIR="$(dirname "$(dirname "$(readlink -fm "$0")")")"
30+
export ROOT_DIR="$(dirname "$(dirname "$(readlink -fn "$0")")")"
3131
export LOG_LEVEL=3
3232
export CLEANUP_CLUSTER=${CLEANUP_CLUSTER:-"true"}
3333
export CLUSTER_CONTEXT="--name test"

0 commit comments

Comments
 (0)