|
1 | 1 | LOCAL = true |
2 | 2 | TARGET_ARCH ?= $(if $(filter true,$(LOCAL)),$(shell go env GOARCH),amd64) |
3 | | -# renovate: dataSource=github-releases depName=helmfile/helmfile |
4 | | -HELMFILE_VERSION ?= "1.3.2" |
| 3 | +IMAGE ?= cf-kind-deployment:latest |
| 4 | +DOCKER_SOCKET ?= $(shell docker context inspect --format '{{.Endpoints.docker.Host}}' | sed 's|unix://||') |
| 5 | +TTY_FLAG := $(shell [ -t 0 ] && echo "-it" || echo "-i") |
5 | 6 |
|
6 | | -init: temp/certs/ca.key temp/certs/ca.crt temp/certs/ssh_key temp/certs/ssh_key.pub temp/secrets.sh temp/secrets.env |
| 7 | +# Common docker run options |
| 8 | +run_opts = --rm $(TTY_FLAG) \ |
| 9 | + --network host \ |
| 10 | + -v $(DOCKER_SOCKET):/var/run/docker.sock \ |
| 11 | + -v "$$PWD/temp:/workspace/temp" \ |
| 12 | + -e ENABLE_TCP_ROUTING \ |
| 13 | + -e ENABLE_NFS_VOLUME \ |
| 14 | + -e ENABLE_POLICY_SUPPORT \ |
| 15 | + -e ENABLE_LOGGREGATOR \ |
| 16 | + -e DISABLE_CACHE |
7 | 17 |
|
8 | | -temp/certs/ca.key temp/certs/ca.crt temp/certs/ssh_key temp/certs/ssh_key.pub temp/secrets.sh temp/secrets.env: |
9 | | - @ ./scripts/init.sh |
| 18 | +# Container run command |
| 19 | +run = docker run $(run_opts) $(IMAGE) |
10 | 20 |
|
11 | | -install: |
12 | | - kind get kubeconfig --name cfk8s > temp/kubeconfig |
13 | | - docker run --rm --net=host --env-file temp/secrets.env \ |
14 | | - --env ENABLE_TCP_ROUTING \ |
15 | | - --env ENABLE_NFS_VOLUME \ |
16 | | - --env ENABLE_POLICY_SUPPORT \ |
17 | | - --env ENABLE_LOGGREGATOR \ |
18 | | - -v "$$PWD/temp/certs:/certs" -v "$$PWD/temp/kubeconfig:/helm/.kube/config:ro" -v "$$PWD:/wd" --workdir /wd ghcr.io/helmfile/helmfile:v$(HELMFILE_VERSION) helmfile sync |
| 21 | +# Default targets (container-based) |
| 22 | +up: _build-installer-quiet |
| 23 | + $(run) "make _create-kind _init _install" |
| 24 | + |
| 25 | +down: _build-installer-quiet |
| 26 | + $(run) "make _delete-kind" |
| 27 | + rm -rf temp |
19 | 28 |
|
20 | 29 | login: |
21 | | - @ . temp/secrets.sh; \ |
| 30 | + @ . ./temp/secrets.sh; \ |
22 | 31 | cf login -a https://api.127-0-0-1.nip.io -u ccadmin -p "$$CC_ADMIN_PASSWORD" --skip-ssl-validation |
23 | 32 |
|
24 | | -create-kind: |
| 33 | +bootstrap: _build-installer-quiet |
| 34 | + $(run) "make login _bootstrap" |
| 35 | + |
| 36 | +bootstrap-complete: _build-installer-quiet |
| 37 | + $(run) "make login _bootstrap-complete" |
| 38 | + |
| 39 | +shell: _build-installer-quiet |
| 40 | + docker run $(run_opts) -v "$$PWD:/workspace" $(IMAGE) "bash" |
| 41 | + |
| 42 | +# Build the installer container (verbose) |
| 43 | +build-installer: |
| 44 | + docker build -t $(IMAGE) . |
| 45 | + |
| 46 | +# Build the installer container (quiet) |
| 47 | +_build-installer-quiet: |
| 48 | + @docker build -q -t $(IMAGE) . > /dev/null |
| 49 | + |
| 50 | +# Internal targets (run inside container or on host with tools installed) |
| 51 | +_init: temp/certs/ca.key temp/certs/ca.crt temp/certs/ssh_key temp/certs/ssh_key.pub temp/secrets.sh temp/secrets.env |
| 52 | + |
| 53 | +temp/certs/ca.key temp/certs/ca.crt temp/certs/ssh_key temp/certs/ssh_key.pub temp/secrets.sh temp/secrets.env: |
| 54 | + @ ./scripts/init.sh |
| 55 | + |
| 56 | +_install: |
| 57 | + kind get kubeconfig --name cfk8s > temp/kubeconfig |
| 58 | + @ . ./temp/secrets.sh && KUBECONFIG=temp/kubeconfig helmfile sync |
| 59 | + |
| 60 | +_create-kind: |
25 | 61 | @ ./scripts/create-kind.sh |
26 | 62 |
|
27 | | -delete-kind: |
| 63 | +_delete-kind: |
28 | 64 | @ ./scripts/delete-kind.sh |
29 | 65 |
|
30 | | -create-org: |
| 66 | +_create-org: |
31 | 67 | cf create-org test |
32 | 68 | cf create-space -o test test |
33 | 69 | cf target -o test -s test |
34 | 70 | @ ./scripts/set_feature_flags.sh |
35 | 71 |
|
36 | | -bootstrap: create-org |
| 72 | +_bootstrap: _create-org |
37 | 73 | @ ./scripts/upload_buildpacks.sh |
38 | 74 |
|
39 | | -bootstrap-complete: create-org |
| 75 | +_bootstrap-complete: _create-org |
40 | 76 | @ ALL_BUILDPACKS=true ./scripts/upload_buildpacks.sh |
41 | 77 |
|
42 | | -up: create-kind init install |
43 | | - |
44 | | -down: delete-kind |
45 | | - @ rm -rf temp |
46 | | - |
47 | | -PHONY: install login create-kind delete-kind up down create-org bootstrap bootstrap-complete |
| 78 | +.PHONY: up down login bootstrap bootstrap-complete shell build-installer |
| 79 | +.PHONY: _init _install _create-kind _delete-kind _create-org _bootstrap _bootstrap-complete _build-installer-quiet |
0 commit comments