Skip to content

Commit

Permalink
feat: add minikube, kind and podman support (#206)
Browse files Browse the repository at this point in the history
Signed-off-by: Shay Dratler <[email protected]>
Signed-off-by: Derek Wang <[email protected]>
  • Loading branch information
dratler authored Nov 14, 2022
1 parent d40ecda commit 3206bd1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
42 changes: 28 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ ifndef PYTHON
$(error "Python is not available, please install.")
endif

K3D ?= $(shell [ "`command -v kubectl`" != '' ] && [ "`command -v k3d`" != '' ] && [[ "`kubectl config current-context`" =~ k3d-* ]] && echo true || echo false)
IMAGE_IMPORT_CMD:=$(shell [ "`command -v kubectl`" != '' ] && [ "`command -v k3d`" != '' ] && [[ "`kubectl config current-context`" =~ k3d-* ]] && echo "k3d image import")
ifndef IMAGE_IMPORT_CMD
IMAGE_IMPORT_CMD:=$(shell [ "`command -v kubectl`" != '' ] && [ "`command -v minikube`" != '' ] && [[ "`kubectl config current-context`" =~ minikube* ]] && echo "minikube image load")
endif
ifndef IMAGE_IMPORT_CMD
IMAGE_IMPORT_CMD:=$(shell [ "`command -v kubectl`" != '' ] && [ "`command -v kind`" != '' ] && [[ "`kubectl config current-context`" =~ kind-* ]] && echo "kind load docker-image")
endif

DOCKER:=$(shell command -v docker 2> /dev/null)
ifndef DOCKER
DOCKER:=$(shell command -v podman 2> /dev/null)
endif

.PHONY: build
build: dist/$(BINARY_NAME)-linux-amd64.gz dist/$(BINARY_NAME)-linux-arm64.gz dist/$(BINARY_NAME)-linux-arm.gz dist/$(BINARY_NAME)-linux-ppc64le.gz dist/$(BINARY_NAME)-linux-s390x.gz dist/e2eapi
Expand Down Expand Up @@ -146,22 +157,25 @@ ui-test: ui-build

.PHONY: image
image: clean ui-build dist/$(BINARY_NAME)-linux-amd64
DOCKER_BUILDKIT=1 docker build --build-arg "ARCH=amd64" -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi
ifeq ($(K3D),true)
k3d image import $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)
DOCKER_BUILDKIT=1 $(DOCKER) build --build-arg "ARCH=amd64" -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then $(DOCKER) push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi
ifdef IMAGE_IMPORT_CMD
$(IMAGE_IMPORT_CMD) $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)
endif

image-linux-%: dist/$(BINARY_NAME)-linux-$*
DOCKER_BUILDKIT=1 docker build --build-arg "ARCH=$*" -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$* --platform "linux/$*" --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$*; fi
DOCKER_BUILDKIT=1 $(DOCKER) build --build-arg "ARCH=$*" -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$* --platform "linux/$*" --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then $(DOCKER) push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$*; fi


image-multi: ui-build set-qemu dist/$(BINARY_NAME)-linux-arm64.gz dist/$(BINARY_NAME)-linux-amd64.gz
docker buildx build --tag $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) --platform linux/amd64,linux/arm64 --file ./Dockerfile ${PUSH_OPTION} .
$(DOCKER) buildx build --tag $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) --platform linux/amd64,linux/arm64 --file ./Dockerfile ${PUSH_OPTION} .


set-qemu:
docker pull tonistiigi/binfmt:latest
docker run --rm --privileged tonistiigi/binfmt:latest --install amd64,arm64
$(DOCKER) pull tonistiigi/binfmt:latest
$(DOCKER) run --rm --privileged tonistiigi/binfmt:latest --install amd64,arm64


.PHONY: swagger
swagger:
Expand Down Expand Up @@ -213,10 +227,10 @@ start: image

.PHONY: e2eapi-image
e2eapi-image: clean dist/e2eapi
DOCKER_BUILDKIT=1 docker build . --build-arg "ARCH=amd64" --platform=linux/amd64 --target e2eapi --tag $(IMAGE_NAMESPACE)/e2eapi:$(VERSION) --build-arg VERSION="$(VERSION)"
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/e2eapi:$(VERSION); fi
ifeq ($(K3D),true)
k3d image import $(IMAGE_NAMESPACE)/e2eapi:$(VERSION)
DOCKER_BUILDKIT=1 $(DOCKER) build . --build-arg "ARCH=amd64" --platform=linux/amd64 --target e2eapi --tag $(IMAGE_NAMESPACE)/e2eapi:$(VERSION) --build-arg VERSION="$(VERSION)"
@if [ "$(DOCKER_PUSH)" = "true" ]; then $(DOCKER) push $(IMAGE_NAMESPACE)/e2eapi:$(VERSION); fi
ifdef IMAGE_IMPORT_CMD
$(IMAGE_IMPORT_CMD) $(IMAGE_NAMESPACE)/e2eapi:$(VERSION)
endif

/usr/local/bin/mkdocs:
Expand Down
15 changes: 9 additions & 6 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ This doc explains how to set up a development environment for Numaflow.
1. [`pandoc`](https://pandoc.org/installing.html) 2.17 for generating API markdown
1. [`Node.js®`](https://nodejs.org/en/) for running the UI
1. [`yarn`](https://classic.yarnpkg.com/en/)
1. [`k3d`](https://k3d.io/) for local development, if needed
1. A local Kubernetes cluster - you need one of the following options as your local Kubernetes cluster for development usage:
1. [`k3d`](https://k3d.io/)
2. [`kind`](https://kind.sigs.k8s.io/)
3. [`minikube`](https://minikube.sigs.k8s.io/docs/start/)

### Create a k8s cluster with k3d if needed
### Example: Create a k8s cluster with k3d

```shell
# Create a cluster with default name k3s-default
Expand All @@ -25,6 +28,9 @@ k3d kubeconfig get k3s-default

### Useful Commands

- `make start`
Build the source code, image, and install the Numaflow controller in the `numaflow-system` namespace.

- `make build`
Binaries are placed in `./dist`.

Expand All @@ -35,10 +41,7 @@ k3d kubeconfig get k3s-default
Run unit tests.

- `make image`
Build container image, and import it to `k3d` cluster if corresponding `kubeconfig` is sourced.

- `make start`
Build the source code, image, and install the Numa controller in the `numaflow-system` namespace.
Build container image, and import it to `k3d` or `minikube` cluster if corresponding `kubeconfig` is sourced.

- `make docs`
Convert the docs to Github pages, check if there's any error.
Expand Down

0 comments on commit 3206bd1

Please sign in to comment.