Skip to content

Commit

Permalink
Improvements to Dev Environment
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh committed Sep 12, 2024
1 parent f796bfa commit 712681e
Show file tree
Hide file tree
Showing 101 changed files with 594 additions and 1,445 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
web/node_modules
web/src
api
dev
docs
kustomize
migrations
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,7 @@ jobs:
- name: run kots admin-console push-images
run: |
set +e
./bin/kots admin-console push-images ./hack/tests/small.airgap ttl.sh/automated-${{ github.run_id }}
./bin/kots admin-console push-images ./e2e/artifacts/small.airgap ttl.sh/automated-${{ github.run_id }}
validate-kots-admin-console-generate-manifests:
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/metrics.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ packages/*

# precommit
.pre-commit-config.yaml

# tmp files
*.tmp

# dev cache
dev/.gocache
dev/.gomodcache
103 changes: 41 additions & 62 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
include Makefile.build.mk
CURRENT_USER := $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))
CURRENT_USER := $(shell id -u -n)
MINIO_TAG ?= 0.20240909.165928-r0
RQLITE_TAG ?= 8.30.2-r0
DEX_TAG ?= 2.41.1-r0
LVP_TAG ?= v0.6.7
PACT_PUBLISH_CONTRACT ?= false

define sendMetrics
@if [ -z "${PROJECT_NAME}" ]; then \
echo "PROJECT_NAME not defined"; \
exit 1; \
fi
@curl -X POST "https://api.datadoghq.com/api/v1/series" \
-H "Content-Type: text/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d "{\"series\": [{\"metric\": \"build.time\",\"points\": [[$$(date +%s), $$(expr $$(date +%s) - $$(cat start-time))]],\"tags\": [\"service:${PROJECT_NAME}\"]}]}"
endef

.PHONY: capture-start-time
capture-start-time:
@echo $$(date +%s) > start-time

.PHONY: report-metric
report-metric:
@$(if ${DD_API_KEY}, $(call sendMetrics))
@rm start-time
OS ?= linux
ARCH ?= $(shell go env GOARCH)

.PHONY: test
test:
Expand All @@ -48,6 +31,10 @@ pact-consumer:
e2e:
${MAKE} -C e2e

.PHONY: cluster
cluster:
./cluster.sh

.PHONY: integration-cli
integration-cli:
go build ${LDFLAGS} -o bin/kots-integration ./integration
Expand All @@ -57,15 +44,21 @@ ci-test:
go test $(TEST_BUILDFLAGS) ./pkg/... ./cmd/... ./integration/... -coverprofile cover.out

.PHONY: kots
kots: PROJECT_NAME = kots
kots: capture-start-time kots-real report-metric

.PHONY: kots-real
kots-real:
kots:
mkdir -p web/dist
touch web/dist/README.md
go build ${LDFLAGS} -o bin/kots $(BUILDFLAGS) github.com/replicatedhq/kots/cmd/kots

.PHONY: build
build:
mkdir -p web/dist
touch web/dist/README.md
go build ${LDFLAGS} ${GCFLAGS} -v -o bin/kotsadm $(BUILDFLAGS) ./cmd/kotsadm

.PHONY: run
run:
./bin/kotsadm api

.PHONY: fmt
fmt:
go fmt ./pkg/... ./cmd/...
Expand All @@ -86,35 +79,29 @@ mock:
mockgen -source=pkg/handlers/interface.go -destination=pkg/handlers/mock/mock.go
mockgen -source=pkg/operator/client/client_interface.go -destination=pkg/operator/client/mock/mock.go

.PHONY: build
build: PROJECT_NAME = kotsadm
build: capture-start-time build-real report-metric
.PHONY: dev
dev:
@dev/scripts/dev.sh

.PHONY: build-real
build-real:
mkdir -p web/dist
touch web/dist/README.md
go build ${LDFLAGS} ${GCFLAGS} -v -o bin/kotsadm $(BUILDFLAGS) ./cmd/kotsadm
.PHONY: %-up
%-up:
@dev/scripts/up.sh $*

.PHONY: tidy
tidy:
go mod tidy
.PHONY: %-down
%-down:
@dev/scripts/down.sh $*

.PHONY: run
run:
./bin/kotsadm api
.PHONY: %-up-ec
%-up-ec:
@dev/scripts/up-ec.sh $*

.PHONY: okteto-dev
okteto-dev:
## We download all go modules, instead of putting them in the container. This will
## use the PVC that everyone has, and will build a cache.
##
## We also run `make build` here because the initial compilation is slow and
## this enabled `okteto up` to do all of the long-running stuff and give the user
## a pretty good env right after
@go mod download -x
@make build
@printf "\n\n To build and run api, run: \n\n # make build run\n\n"
.PHONY: %-down-ec
%-down-ec:
@dev/scripts/down-ec.sh $*

.PHONY: reset
reset:
kubectl delete -R -f dev/manifests --ignore-not-found

# Debugging
.PHONY: debug-build
Expand All @@ -130,26 +117,22 @@ web:
source .image.env && ${MAKE} -C web build-kotsadm

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

.PHONY: all-ttl.sh
all-ttl.sh: export GOOS ?= linux
all-ttl.sh: export GOARCH ?= amd64
all-ttl.sh: build-ttl.sh
source .image.env && \
IMAGE=ttl.sh/${CURRENT_USER}/kotsadm-migrations:24h \
DOCKER_BUILD_ARGS="--platform $(GOOS)/$(GOARCH)" \
DOCKER_BUILD_ARGS="--platform $(OS)/$(ARCH)" \
make -C migrations build_schema

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

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

Expand All @@ -174,10 +157,6 @@ kotsadm-bundle-nominio:

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

.PHONY: cache
cache:
docker build -f hack/dev/skaffoldcache.Dockerfile . -t kotsadm:cache

.PHONY: init-sbom
init-sbom:
mkdir -p sbom/spdx
Expand Down
56 changes: 41 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ kubectl kots install sentry-pro

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.

**NOTE** Currently, the kotsadm pod can **only** be scheduled on nodes with the `linux/amd64` platform.

### Access the Admin Console
Visit http://localhost:8800 to access the Admin Console, enter the password.

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

## Supportability

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

# Community

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

# Development

## Github Codespaces
### Requirements

- MacOS
- Docker Desktop with Kubernetes enabled
- jq

### Running the Development Environment

1. Create your own [codespace](https://github.com/replicatedhq/codespace).
1. Clone the KOTS repo:
```bash
git clone [email protected]:replicatedhq/kots.git
git clone https://github.com/replicatedhq/kots.git
cd kots
```

2. From the root directory, run:
```bash
make dev
```

### Testing Changes to kotsadm web

Changes to the kotsadm web component are reflected in real-time, no manual steps required.

### Testing Changes to kotsadm API

1. Run the following commands:
```bash
make kotsadm-up
make build run
```
1. From the root directory, run:

2. To test additional changes, stop the current process with Ctrl+C, then run the following command:
```bash
make cache
skaffold dev
make build run
```
1. Visit the Admin Console URL. For VS Code:
![Image 2024-02-23 at 2 55 11 PM](https://github.com/replicatedhq/kots/assets/39952863/aa86019f-0111-4d04-a142-3dfc539858a2)

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:
### Testing Changes to kurl-proxy web / API

1. Run the following commands:
```bash
cd web && yarn
```
make kurl-proxy-up
make build run
```

2. To test additional changes, stop the current process with Ctrl+C, then run the following command:
```bash
make build run
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CURRENT_USER := $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))
CURRENT_USER := $(shell id -u -n)
SCHEMAHERO_TAG ?= 0.13.2

.PHONY: test
Expand Down
2 changes: 1 addition & 1 deletion cmd/imagedeps/testdata/schemahero/replacers/input/test.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CURRENT_USER := $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))
CURRENT_USER := $(shell id -u -n)
SCHEMAHERO_TAG ?= 0.13.1

.PHONY: test
Expand Down
2 changes: 1 addition & 1 deletion deploy/kurl/kotsadm/hack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ generate:
DEX_TAG=$(shell source ../../../../.image.env && echo "$$DEX_TAG") \
${MAKE} _generate

_generate: CURRENT_USER = $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n))
_generate: CURRENT_USER = $(shell id -u -n)
_generate: generate-tag
@cd ../template && ./generate.sh $(KOTS_VERSION) ttl.sh $(CURRENT_USER) 24h $(shell realpath ../../../../bin/kots)
@rm -rf kurl/addons/kotsadm/$(KOTS_VERSION)
Expand Down
27 changes: 0 additions & 27 deletions deploy/okteto/.dockerignore

This file was deleted.

Loading

0 comments on commit 712681e

Please sign in to comment.