Skip to content

Commit 2b804a7

Browse files
authored
Move Dev Environment to MacOS (#4879)
* Move Dev Environment to MacOS
1 parent 6969f1a commit 2b804a7

File tree

101 files changed

+603
-1444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+603
-1444
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
web/node_modules
22
web/src
33
api
4-
dev
54
docs
65
kustomize
76
migrations

.github/workflows/build-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,7 @@ jobs:
21082108
- name: run kots admin-console push-images
21092109
run: |
21102110
set +e
2111-
./bin/kots admin-console push-images ./hack/tests/small.airgap ttl.sh/automated-${{ github.run_id }}
2111+
./bin/kots admin-console push-images ./e2e/artifacts/small.airgap ttl.sh/automated-${{ github.run_id }}
21122112
21132113
21142114
validate-kots-admin-console-generate-manifests:

.github/workflows/metrics.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,10 @@ packages/*
4545

4646
# precommit
4747
.pre-commit-config.yaml
48+
49+
# tmp files
50+
*.tmp
51+
52+
# dev cache
53+
dev/.gocache
54+
dev/.gomodcache

Makefile

Lines changed: 37 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
include Makefile.build.mk
2-
CURRENT_USER := $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))
2+
CURRENT_USER := $(shell id -u -n)
33
MINIO_TAG ?= 0.20240909.165928-r0
44
RQLITE_TAG ?= 8.30.2-r0
55
DEX_TAG ?= 2.41.1-r0
66
LVP_TAG ?= v0.6.7
77
PACT_PUBLISH_CONTRACT ?= false
88

9-
define sendMetrics
10-
@if [ -z "${PROJECT_NAME}" ]; then \
11-
echo "PROJECT_NAME not defined"; \
12-
exit 1; \
13-
fi
14-
@curl -X POST "https://api.datadoghq.com/api/v1/series" \
15-
-H "Content-Type: text/json" \
16-
-H "DD-API-KEY: ${DD_API_KEY}" \
17-
-d "{\"series\": [{\"metric\": \"build.time\",\"points\": [[$$(date +%s), $$(expr $$(date +%s) - $$(cat start-time))]],\"tags\": [\"service:${PROJECT_NAME}\"]}]}"
18-
endef
19-
20-
.PHONY: capture-start-time
21-
capture-start-time:
22-
@echo $$(date +%s) > start-time
23-
24-
.PHONY: report-metric
25-
report-metric:
26-
@$(if ${DD_API_KEY}, $(call sendMetrics))
27-
@rm start-time
9+
OS ?= linux
10+
ARCH ?= $(shell go env GOARCH)
2811

2912
.PHONY: test
3013
test:
@@ -57,15 +40,21 @@ ci-test:
5740
go test $(TEST_BUILDFLAGS) ./pkg/... ./cmd/... ./integration/... -coverprofile cover.out
5841

5942
.PHONY: kots
60-
kots: PROJECT_NAME = kots
61-
kots: capture-start-time kots-real report-metric
62-
63-
.PHONY: kots-real
64-
kots-real:
43+
kots:
6544
mkdir -p web/dist
6645
touch web/dist/README.md
6746
go build ${LDFLAGS} -o bin/kots $(BUILDFLAGS) github.com/replicatedhq/kots/cmd/kots
6847

48+
.PHONY: build
49+
build:
50+
mkdir -p web/dist
51+
touch web/dist/README.md
52+
go build ${LDFLAGS} ${GCFLAGS} -v -o bin/kotsadm $(BUILDFLAGS) ./cmd/kotsadm
53+
54+
.PHONY: run
55+
run:
56+
./bin/kotsadm api
57+
6958
.PHONY: fmt
7059
fmt:
7160
go fmt ./pkg/... ./cmd/...
@@ -86,35 +75,29 @@ mock:
8675
mockgen -source=pkg/handlers/interface.go -destination=pkg/handlers/mock/mock.go
8776
mockgen -source=pkg/operator/client/client_interface.go -destination=pkg/operator/client/mock/mock.go
8877

89-
.PHONY: build
90-
build: PROJECT_NAME = kotsadm
91-
build: capture-start-time build-real report-metric
78+
.PHONY: dev
79+
dev:
80+
@dev/scripts/dev.sh
9281

93-
.PHONY: build-real
94-
build-real:
95-
mkdir -p web/dist
96-
touch web/dist/README.md
97-
go build ${LDFLAGS} ${GCFLAGS} -v -o bin/kotsadm $(BUILDFLAGS) ./cmd/kotsadm
82+
.PHONY: %-up
83+
%-up:
84+
@dev/scripts/up.sh $*
9885

99-
.PHONY: tidy
100-
tidy:
101-
go mod tidy
86+
.PHONY: %-down
87+
%-down:
88+
@dev/scripts/down.sh $*
10289

103-
.PHONY: run
104-
run:
105-
./bin/kotsadm api
90+
.PHONY: %-up-ec
91+
%-up-ec:
92+
@dev/scripts/up-ec.sh $*
10693

107-
.PHONY: okteto-dev
108-
okteto-dev:
109-
## We download all go modules, instead of putting them in the container. This will
110-
## use the PVC that everyone has, and will build a cache.
111-
##
112-
## We also run `make build` here because the initial compilation is slow and
113-
## this enabled `okteto up` to do all of the long-running stuff and give the user
114-
## a pretty good env right after
115-
@go mod download -x
116-
@make build
117-
@printf "\n\n To build and run api, run: \n\n # make build run\n\n"
94+
.PHONY: %-down-ec
95+
%-down-ec:
96+
@dev/scripts/down-ec.sh $*
97+
98+
.PHONY: reset
99+
reset:
100+
kubectl delete -R -f dev/manifests --ignore-not-found
118101

119102
# Debugging
120103
.PHONY: debug-build
@@ -130,26 +113,22 @@ web:
130113
source .image.env && ${MAKE} -C web build-kotsadm
131114

132115
.PHONY: build-ttl.sh
133-
build-ttl.sh: export GOOS ?= linux
134-
build-ttl.sh: export GOARCH ?= amd64
135116
build-ttl.sh: web kots build
136-
docker build --platform $(GOOS)/$(GOARCH) -f deploy/Dockerfile -t ttl.sh/${CURRENT_USER}/kotsadm:24h .
117+
docker build --platform $(OS)/$(ARCH) -f dev/dockerfiles/kotsadm/Dockerfile.ttlsh -t ttl.sh/${CURRENT_USER}/kotsadm:24h .
137118
docker push ttl.sh/${CURRENT_USER}/kotsadm:24h
138119

139120
.PHONY: all-ttl.sh
140-
all-ttl.sh: export GOOS ?= linux
141-
all-ttl.sh: export GOARCH ?= amd64
142121
all-ttl.sh: build-ttl.sh
143122
source .image.env && \
144123
IMAGE=ttl.sh/${CURRENT_USER}/kotsadm-migrations:24h \
145-
DOCKER_BUILD_ARGS="--platform $(GOOS)/$(GOARCH)" \
124+
DOCKER_BUILD_ARGS="--platform $(OS)/$(ARCH)" \
146125
make -C migrations build_schema
147126

148-
docker pull --platform $(GOOS)/$(GOARCH) kotsadm/minio:${MINIO_TAG}
127+
docker pull --platform $(OS)/$(ARCH) kotsadm/minio:${MINIO_TAG}
149128
docker tag kotsadm/minio:${MINIO_TAG} ttl.sh/${CURRENT_USER}/minio:${MINIO_TAG}
150129
docker push ttl.sh/${CURRENT_USER}/minio:${MINIO_TAG}
151130

152-
docker pull --platform $(GOOS)/$(GOARCH) kotsadm/rqlite:${RQLITE_TAG}
131+
docker pull --platform $(OS)/$(ARCH) kotsadm/rqlite:${RQLITE_TAG}
153132
docker tag kotsadm/rqlite:${RQLITE_TAG} ttl.sh/${CURRENT_USER}/rqlite:${RQLITE_TAG}
154133
docker push ttl.sh/${CURRENT_USER}/rqlite:${RQLITE_TAG}
155134

@@ -174,10 +153,6 @@ kotsadm-bundle-nominio:
174153

175154
go run ./scripts/create-airgap-file.go false
176155

177-
.PHONY: cache
178-
cache:
179-
docker build -f hack/dev/skaffoldcache.Dockerfile . -t kotsadm:cache
180-
181156
.PHONY: init-sbom
182157
init-sbom:
183158
mkdir -p sbom/spdx

README.md

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ kubectl kots install sentry-pro
2626

2727
Set a namespace for the admin console and the application components to be installed, and provide a password for the admin console. After this command completes, the kotsadm Admin Console will be running in your cluster, listening on port :8800 on a ClusterIP service in the namespace you deployed the application to. By default this is exposed to your workstation using kubectl port-forward, but you could set up an ingress/load balancer of your own.
2828

29-
**NOTE** Currently, the kotsadm pod can **only** be scheduled on nodes with the `linux/amd64` platform.
30-
3129
### Access the Admin Console
3230
Visit http://localhost:8800 to access the Admin Console, enter the password.
3331

@@ -40,8 +38,7 @@ kubectl kots admin-console --namespace sentry-pro
4038

4139
## Supportability
4240

43-
Currently, the KOTS CLI supports OSX (including Apple Silicon arm64) and Linux platforms. However, the Kubernetes resources
44-
that it creates can **only** be scheduled on nodes with the `linux/amd64` platform.
41+
Supports OSX (including Apple Silicon arm64) and Linux platforms.
4542

4643
# Community
4744

@@ -61,22 +58,65 @@ cosign verify-blob --key sbom/key.pub --signature sbom/kots-sbom.tgz.sig sbom/ko
6158

6259
# Development
6360

64-
## Github Codespaces
61+
### Requirements
62+
63+
- MacOS
64+
- Docker Desktop with Kubernetes enabled
65+
- jq
66+
67+
### Running the Development Environment
6568

66-
1. Create your own [codespace](https://github.com/replicatedhq/codespace).
6769
1. Clone the KOTS repo:
6870
```bash
69-
git clone [email protected]:replicatedhq/kots.git
71+
git clone https://github.com/replicatedhq/kots.git
72+
cd kots
7073
```
74+
7175
1. From the root directory, run:
7276
```bash
73-
make cache
74-
skaffold dev
77+
make dev
7578
```
76-
1. Visit the Admin Console URL. For VS Code:
77-
![Image 2024-02-23 at 2 55 11 PM](https://github.com/replicatedhq/kots/assets/39952863/aa86019f-0111-4d04-a142-3dfc539858a2)
7879

79-
1. If you'll be working on the webapp or plan on using `make all-ttl.sh` for local testing, be sure to setup yarn:
80+
1. Once the development environment is running, you can access the admin console:
81+
- Directly at http://localhost:30808
82+
- Via kURL proxy at http://localhost:30880
83+
84+
### Developing kotsadm web
85+
86+
Changes to the kotsadm web component are reflected in real-time, no manual steps required.
87+
88+
### Developing kotsadm API
89+
90+
1. To apply your current changes, run the following commands:
91+
```bash
92+
make kotsadm-up
93+
make build run
94+
```
95+
96+
1. To apply additional changes, stop the current process with Ctrl+C, then run the following command:
8097
```bash
81-
cd web && yarn
82-
```
98+
make build run
99+
```
100+
101+
1. When finished developing, run the following command to revert back to the original state:
102+
```bash
103+
make kotsadm-down
104+
```
105+
106+
### Developing kurl-proxy web / API
107+
108+
1. To apply your current changes, run the following commands:
109+
```bash
110+
make kurl-proxy-up
111+
make build run
112+
```
113+
114+
1. To apply additional changes, stop the current process with Ctrl+C, then run the following command:
115+
```bash
116+
make build run
117+
```
118+
119+
1. When finished developing, run the following command to revert back to the original state:
120+
```bash
121+
make kurl-proxy-down
122+
```

cmd/imagedeps/testdata/schemahero/replacers/expected/test.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CURRENT_USER := $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))
1+
CURRENT_USER := $(shell id -u -n)
22
SCHEMAHERO_TAG ?= 0.13.2
33

44
.PHONY: test

cmd/imagedeps/testdata/schemahero/replacers/input/test.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CURRENT_USER := $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))
1+
CURRENT_USER := $(shell id -u -n)
22
SCHEMAHERO_TAG ?= 0.13.1
33

44
.PHONY: test

deploy/kurl/kotsadm/hack/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ generate:
3737
DEX_TAG=$(shell source ../../../../.image.env && echo "$$DEX_TAG") \
3838
${MAKE} _generate
3939

40-
_generate: CURRENT_USER = $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))
40+
_generate: CURRENT_USER = $(shell id -u -n)
4141
_generate: generate-tag
4242
@cd ../template && ./generate.sh $(KOTS_VERSION) ttl.sh $(CURRENT_USER) 24h $(shell realpath ../../../../bin/kots)
4343
@rm -rf kurl/addons/kotsadm/$(KOTS_VERSION)

deploy/okteto/.dockerignore

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)