Skip to content

Commit a83bcf7

Browse files
authored
Changes to the run-e2e-kind.sh locally (#290)
* Changes to the run-e2e-kind.sh to * Changed out echo server image, small edits * Backed out change in the clean up code. * Updated the makefile to build the executable * Address code review comments. * * Small changes to the e2e script * Build documentation updates. * Documentation updates per code review Fixed errors in the e2e script to load ubuntu:latest image correctly. * Cleaned up false errors Rectified use of undefined variable.
1 parent c03d7c6 commit a83bcf7

File tree

7 files changed

+297
-175
lines changed

7 files changed

+297
-175
lines changed

Makefile

Lines changed: 11 additions & 3 deletions
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,9 +24,10 @@ 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)
28-
CGO_ENABLED=0 GOARCH=amd64 go build -o ${BIN_DIR}/mcad-controller ./cmd/kar-controllers/
30+
CGO_ENABLED=0 GOOS="linux" go build -o ${BIN_DIR}/mcad-controller ./cmd/kar-controllers/
2931

3032
print-global-variables:
3133
$(info "---")
@@ -54,15 +56,15 @@ generate-code:
5456
$(info Generating deepcopy...)
5557
${BIN_DIR}/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
5658

57-
images: verify-tag-name
59+
images: verify-tag-name mcad-controller
5860
$(info List executable directory)
5961
$(info repo id: ${git_repository_id})
6062
$(info branch: ${GIT_BRANCH})
6163
ls -l ${CURRENT_DIR}/_output/bin
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: 135 additions & 57 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,167 @@ $
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, you may build only the executable, or you can build the image directly.
52+
53+
To to build the executable, execute:
4054
41-
$ ./build.sh
55+
```bash
56+
#build for linux OS and for use inside docker image
57+
multi-cluster-app-dispatcher $ make mcad-controller
4258
...
43-
+ cd ..
44-
+ make generate-code
45-
Compiling deepcopy-gen
46-
Generating deepcopy
59+
Compiling deepcopy-gen...
60+
Generating deepcopy...
4761
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
62+
_output/bin/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
63+
Compiling controller
64+
CGO_ENABLED=0 GOOS="linux" go build -o _output/bin/mcad-controller ./cmd/kar-controllers/
65+
66+
#build for local testing purposes, by default enable the race conditions detector
67+
multi-cluster-app-dispatcher $ make mcad-controller-local
68+
...
5069
mkdir -p _output/bin
51-
CGO_ENABLED=0 GOARCH=amd64 go build -o _output/bin/kar-controllers ./cmd/kar-controllers/
52-
$
70+
Compiling deepcopy-gen...
71+
Generating deepcopy...
72+
go build -o _output/bin/deepcopy-gen ./cmd/deepcopy-gen/
73+
_output/bin/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
74+
Compiling controller
75+
go build -race -o _output/bin/mcad-controller-local ./cmd/kar-controllers/
5376
```
5477
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-
$
78+
Ensure the executables: `deepcopy-gen` and `mcad-controllers` are created in the target output directory:
79+
80+
```bash
81+
multi-cluster-app-dispatcher $ ls _output/bin
82+
deepcopy-gen mcad-controller
6083
```
6184
6285
### Build the Multi-Cluster-App-Dispatcher Image
6386
64-
Run the image build script `image.sh`:
87+
If you want to run the end to end tests locally, you will need to have the docker daemon running on your workstation, and build the image using docker. Images can also be build using podman for deployment of the MCAD controller on remote clusters.
6588
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-
```
89+
From the root directory of the repository:
8990
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.
91+
```bash
92+
# With docker daemon running
93+
multi-cluster-app-dispatcher % make images
9194

95+
....
96+
97+
# output from a local branch, MacOS build, local file names replaced with XXXXXXXXXX
98+
"---"
99+
"MAKE GLOBAL VARIABLES:"
100+
" "BIN_DIR="_output/bin"
101+
" "GIT_BRANCH="local_e2e_test"
102+
" "RELEASE_VER="v1.29.55"
103+
" "TAG="local_e2e_test-v1.29.55"
104+
"---"
105+
# Check for invalid tag name
106+
t=local_e2e_test-v1.29.55 && [ ${#t} -le 128 ] || { echo "Target name $t has 128 or more chars"; false; }
107+
mkdir -p _output/bin
108+
Compiling deepcopy-gen...
109+
Generating deepcopy...
110+
go build -o _output/bin/deepcopy-gen ./cmd/deepcopy-gen/
111+
_output/bin/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
112+
Compiling controller
113+
CGO_ENABLED=0 GOOS="linux" go build -o _output/bin/mcad-controller ./cmd/kar-controllers/
114+
List executable directory
115+
repo id:
116+
branch: local_e2e_test
117+
Build the docker image
118+
ls -l XXXXXXXXXXXX/multi-cluster-app-dispatcher/_output/bin
119+
total 268768
120+
-rwxr-xr-x 1 XXXXX staff 8238498 Apr 4 12:46 deepcopy-gen
121+
-rwxr-xr-x 1 XXXXX staff 57584808 Apr 4 12:47 mcad-controller
122+
docker build --quiet --no-cache --tag mcad-controller:local_e2e_test-v1.29.55 -f XXXXXXXX/multi-cluster-app-dispatcher/deployment/Dockerfile.both XXXXXX/multi-cluster-app-dispatcher/_output/bin
123+
sha256:3b4f314b06674f6b52d6a5d77ad1d3d9cebf8fa94a9f80026b02813689c3289d
124+
125+
#Using podman
126+
make images-podman
127+
128+
....
129+
130+
# output from a local branch, MacOS build, local file names replaced with XXXXXXXXXX
131+
"---"
132+
"MAKE GLOBAL VARIABLES:"
133+
" "BIN_DIR="_output/bin"
134+
" "GIT_BRANCH="local_e2e_test"
135+
" "RELEASE_VER="v1.29.55"
136+
" "TAG="local_e2e_test-v1.29.55"
137+
"---"
138+
# Check for invalid tag name
139+
t=local_e2e_test-v1.29.55 && [ ${#t} -le 128 ] || { echo "Target name $t has 128 or more chars"; false; }
140+
mkdir -p _output/bin
141+
Compiling deepcopy-gen...
142+
Generating deepcopy...
143+
go build -o _output/bin/deepcopy-gen ./cmd/deepcopy-gen/
144+
_output/bin/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
145+
Compiling controller
146+
CGO_ENABLED=0 GOOS="linux" go build -o _output/bin/mcad-controller ./cmd/kar-controllers/
147+
List executable directory
148+
repo id:
149+
branch: local_e2e_test
150+
Build the docker image
151+
ls -l XXXXXXXXXX/multi-cluster-app-dispatcher/_output/bin
152+
total 128568
153+
-rwxr-xr-x 1 XXXXXXXX staff 8238498 Apr 4 12:53 deepcopy-gen
154+
-rwxr-xr-x 1 XXXXXXXX staff 57584808 Apr 4 12:53 mcad-controller
155+
podman build --quiet --no-cache --tag mcad-controller:local_e2e_test-v1.29.55 -f XXXXXXXXXX/multi-cluster-app-dispatcher/deployment/Dockerfile.both XXXXXXXXXX/multi-cluster-app-dispatcher/_output/bin
156+
7553c702e5238920f44cba7303d1ff111aca1722e7e3ed4d49afbafa165fc3e3
92157
```
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-
```
158+
98159
### 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
160+
161+
The following example assumes an available `<repository>/mcad-controller` on [Docker Hub](https://hub.docker.com) and using image version `v1.14`
162+
163+
```bash
164+
docker login
165+
docker push <respository>/mcad-controller:v1.14
103166
```
104167
105168
The same can be done with [Quay](quay.io)
106-
```
107-
$ docker login quay.io
108-
$ docker push <quay_respository>/mcad-controller:v1.14
169+
170+
```bash
171+
docker login quay.io
172+
docker push <quay_respository>/mcad-controller:v1.14
109173
```
110174
111175
Refer to [deployment](../deploy/deployment.md) on how to deploy the `multi-cluster-app-dispatcher` as a controller in Kubernetes.
176+
177+
## 3. Running e2e tests locally
178+
179+
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:
180+
181+
* CPU: 2
182+
* Memory: 8 GB
183+
184+
From the root directory of the repository:
185+
186+
```bash
187+
# With docker daemon running
188+
multi-cluster-app-dispatcher % make run-e2e:
189+
```

hack/e2e-kind-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# this config file contains all config fields with comments
22
kind: Cluster
33
apiVersion: kind.x-k8s.io/v1alpha4
4-
# 1 control plane node and 3 workers
4+
# 1 control plane node and 1 workers
55
nodes:
66
# the control plane node config
77
- role: control-plane
88
# kubernetes version 1.20.7 from kind v0.11.0
99
image: kindest/node:v1.20.7@sha256:e645428988191fc824529fd0bb5c94244c12401cf5f5ea3bd875eb0a787f0fe9
10-
# the three workers
10+
# the worker
1111
- role: worker
1212
# kubernetes version 1.20.7 from kind v0.11.0
1313
image: kindest/node:v1.20.7@sha256:e645428988191fc824529fd0bb5c94244c12401cf5f5ea3bd875eb0a787f0fe9

0 commit comments

Comments
 (0)