Skip to content

Commit

Permalink
[YUNIKORN-1865] Update build process to follow standard conventions
Browse files Browse the repository at this point in the history
- Moved (source) Dockerfiles to docker/{component}
- Changed output directory from _output/ to build/
- All development binaries write to build/dev/
- All production binaries write to build/bin/
- All Docker images are build using build/docker/{component} as a buildroot
- Rename scheduler binary to yunikorn-scheduler
- Rename plugin binary to yunikorn-scheduler-plugin
- Rename admission controller binary to yunikorn-admission-controller
- Allow setting GO environment variable to the name of an alternative compiler
  (i.e. GO=go1.20.5)
- Allow override of Docker image tags from command-line
- Update Makefile to use proper dependencies so that build steps can be cached
  • Loading branch information
craigcondit committed Jul 17, 2023
1 parent 2ab4fc4 commit f073b6b
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 163 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
run: make test
- name: Code coverage
uses: codecov/codecov-action@v3
with:
files: build/coverage.txt

e2e-tests:
needs: build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ jobs:
run: make test
- name: Code coverage
uses: codecov/codecov-action@v3
with:
files: build/coverage.txt
14 changes: 8 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.idea
_output/
_spark/
tools/
coverage.txt
yunikorn-release
shellcheck
/tools/
/build/
/_output/
/_spark/
/deployments/image
/coverage.txt
/yunikorn-release
/shellcheck
*.csr
*.crt
*.key
Expand Down
313 changes: 195 additions & 118 deletions Makefile

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ The simplest way to get a local binary that can be run on a local Kubernetes env
```
make build
```
This command will build a binary `k8s_yunikorn_scheduler` under `_output/dev` dir. This binary is executable on local environment, as long as `kubectl` is properly configured.
Run `./k8s_yunikorn_scheduler -help` to see all options.
This command will build a binary `yunikorn-scheduler` under `build/dev` dir. This binary is executable on local environment, as long as `kubectl` is properly configured.

**Note**: It may take few minutes to run this command for the first time, because it needs to download all dependencies.
In case you get an error relating to `checksum mismatch`, run `go clean -modcache` and then rerun `make build`.
Expand All @@ -52,7 +51,7 @@ If the local kubernetes environment is up and running you can build and run the
make run
```
This will build the code, and run the scheduler with verbose logging.
It will set the configuration for the scheduler to the provided default configuration `queues.yaml` and uses the current setup for kubernetes.
It will use default configurations for the scheduler and the local Kubernetes configuration.

### Build and run tests
Unit tests for the shim only can be run via:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM --platform=$TARGETPLATFORM scratch
COPY --chown=0:0 scheduler-admission-controller /
COPY --chown=0:0 yunikorn-admission-controller /
USER 4444:4444
ENTRYPOINT [ "/scheduler-admission-controller" ]
ENTRYPOINT [ "/yunikorn-admission-controller" ]
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM --platform=$TARGETPLATFORM scratch
COPY --chown=0:0 k8s_yunikorn_scheduler /
COPY --chown=0:0 simulation-gang-worker /
USER 4444:4444
ENTRYPOINT [ "/k8s_yunikorn_scheduler" ]
ENTRYPOINT ["/simulation-gang-worker"]
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM --platform=$TARGETPLATFORM scratch
COPY --chown=0:0 kube-scheduler scheduler-config.yaml /
COPY --chown=0:0 simulation-gang-coordinator /
USER 4444:4444
ENTRYPOINT [ "/kube-scheduler", "--bind-address=0.0.0.0", "--config=/scheduler-config.yaml" ]
EXPOSE 8863
ENTRYPOINT ["/simulation-gang-coordinator"]
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG ARCH=
FROM ${ARCH}alpine:latest

# Home location for all data and executables
ENV HOME=/opt/yunikorn
EXPOSE 8863

COPY simulation-gang-coordinator $HOME/

WORKDIR $HOME
ENTRYPOINT ["./simulation-gang-coordinator"]
FROM --platform=$TARGETPLATFORM scratch
COPY --chown=0:0 yunikorn-scheduler-plugin scheduler-config.yaml /
USER 4444:4444
ENTRYPOINT [ "/yunikorn-scheduler-plugin", "--bind-address=0.0.0.0", "--config=/scheduler-config.yaml" ]
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG ARCH=
FROM ${ARCH}alpine:latest

# Home location for all data and executables
ENV HOME=/opt/yunikorn

COPY simulation-gang-worker $HOME/

WORKDIR $HOME
ENTRYPOINT ["./simulation-gang-worker"]
FROM --platform=$TARGETPLATFORM scratch
COPY --chown=0:0 yunikorn-scheduler /
USER 4444:4444
ENTRYPOINT [ "/yunikorn-scheduler" ]
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/generate-fsm-graph-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

set -e

WORKDIR=$(pwd)/_output/fsm
WORKDIR=$(pwd)/build/fsm

output_fsm() {
# print digraph header
Expand Down
13 changes: 13 additions & 0 deletions scripts/generate-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ set -o errexit
set -o nounset
set -o pipefail

function check_cmd() {
CMD=$1
if ! command -v "${CMD}" &> /dev/null
then
echo "command ${CMD} could not be found"
exit 1
fi
}

GO="${GO:-go}"
check_cmd "${GO}"
GOPATH="${GOPATH:-$("${GO}" env GOPATH)}"

#Set GOPATH if GOPATH is empty.
if [ "${GOPATH}" == "" ]; then
echo "GOPATH is empty."
Expand Down
16 changes: 10 additions & 6 deletions scripts/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
HELM=tools/helm
KIND=tools/kind
KUBECTL=tools/kubectl
GO="${GO:-go}"
export GO

function check_cmd() {
CMD=$1
Expand Down Expand Up @@ -84,7 +86,8 @@ function install_cluster() {
# use latest helm charts from the release repo to install yunikorn unless path is provided
if [ "${GIT_CLONE}" = "true" ]; then
check_cmd "git"
git clone --depth 1 https://github.com/apache/yunikorn-release.git ./yunikorn-release
rm -rf ./build/yunikorn-release
git clone --depth 1 https://github.com/apache/yunikorn-release.git ./build/yunikorn-release
fi
if [ ! -d "${CHART_PATH}" ]; then
exit_on_error "helm charts not found in path: ${CHART_PATH}"
Expand All @@ -99,8 +102,8 @@ function install_cluster() {
exit_on_error "build test web images failed"

# install ginkgo and gomega for e2e tests.
echo "step 4/7: installing Ginkgo & Gomega at $(go env GOPATH)/bin"
go install github.com/onsi/ginkgo/v2/[email protected]
echo "step 4/7: installing Ginkgo & Gomega at $("${GO}" env GOPATH)/bin"
"${GO}" install github.com/onsi/ginkgo/v2/[email protected]
check_cmd "ginkgo"

# create K8s cluster
Expand Down Expand Up @@ -165,18 +168,19 @@ Examples:
${NAME} -a test -n yk8s -v kindest/node:v1.27.3
Use a local helm chart path:
${NAME} -a test -n yk8s -v kindest/node:v1.27.3 -p ./yunikorn-release/helm-charts/yunikorn
${NAME} -a test -n yk8s -v kindest/node:v1.27.3 -p ../yunikorn-release/helm-charts/yunikorn
EOF
}

# setup architectures and OS type
check_cmd "${GO}"
check_cmd "make"
eval "$(make arch)"
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
check_os

KIND_CONFIG=./scripts/kind.yaml
CHART_PATH="./yunikorn-release/helm-charts/yunikorn"
CHART_PATH="./build/yunikorn-release/helm-charts/yunikorn"
GIT_CLONE=true
SCHEDULER_IMAGE="scheduler-${DOCKER_ARCH}-latest"
ADMISSION_IMAGE="admission-${DOCKER_ARCH}-latest"
Expand Down Expand Up @@ -247,7 +251,7 @@ check_opt "kind-cluster-name" "${CLUSTER_NAME}"
# - delete k8s cluster
if [ "${ACTION}" == "test" ]; then
# make will fail without go installed but we call it before that...
check_cmd "go"
check_cmd "${GO}"
check_opt "kind-node-image-version" "${CLUSTER_VERSION}"
check_opt "chart-path" "${CHART_PATH}"
install_cluster
Expand Down

0 comments on commit f073b6b

Please sign in to comment.