Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(local-dev): add node affinity on the patches for local dev with EC #5002

Merged
merged 9 commits into from
Nov 20, 2024
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,24 @@ 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: dev-deps
dev-deps:
@dev/scripts/dev-deps.sh

.PHONY: dev
dev:
dev: dev-deps
@dev/scripts/dev.sh

.PHONY: %-up
%-up:
%-up: dev-deps
@dev/scripts/up.sh $*

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

.PHONY: %-up-ec
%-up-ec:
%-up-ec: dev-deps
@dev/scripts/up-ec.sh $*

.PHONY: %-down-ec
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cosign verify-blob --key sbom/key.pub --signature sbom/kots-sbom.tgz.sig sbom/ko

- MacOS
- Docker Desktop with Kubernetes enabled
- jq
- Homebrew

### Running the Development Environment

Expand Down
13 changes: 12 additions & 1 deletion dev/patches/kotsadm-up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ spec:
volumes:
- name: dev
hostPath:
path: __PROJECT_DIR__
path: {{ .Env.PROJECT_DIR }}
type: Directory
{{- if .Env.EC_NODE }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- {{ .Env.EC_NODE }}
{{- end }}
containers:
- name: kotsadm
image: kotsadm-api-dev
Expand Down
15 changes: 13 additions & 2 deletions dev/patches/kotsadm-web-up.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
spec:
template:
spec:
{{- if .Env.EC_NODE }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- {{ .Env.EC_NODE }}
{{- end }}
volumes:
- name: dev
hostPath:
path: __PROJECT_DIR__/web
path: {{ .Env.PROJECT_DIR }}/web
type: Directory
- name: yarncache
hostPath:
path: __PROJECT_DIR__/dev/.yarncache
path: {{ .Env.PROJECT_DIR }}/dev/.yarncache
type: Directory
containers:
- name: kotsadm-web
Expand Down
15 changes: 13 additions & 2 deletions dev/patches/kurl-proxy-up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ spec:
volumes:
- name: dev
hostPath:
path: __PROJECT_DIR__
path: {{ .Env.PROJECT_DIR }}
type: Directory
- name: assets
hostPath:
path: __PROJECT_DIR__/kurl_proxy/assets
path: {{ .Env.PROJECT_DIR }}/kurl_proxy/assets
type: Directory
{{- if .Env.EC_NODE }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- {{ .Env.EC_NODE }}
{{- end }}
containers:
- name: proxy
image: kurl-proxy-dev
Expand Down
4 changes: 2 additions & 2 deletions dev/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ function restart() {
# the mounted directories from the macOS host filesystem into the Docker Desktop VM.
# This is required for using HostPath volumes in Kubernetes.
function render() {
sed "s|__PROJECT_DIR__|/host_mnt$(pwd)|g" "$1"
PROJECT_DIR="/host_mnt$(pwd)" gomplate --missing-key zero -f "$1"
}

# The embedded-cluster container mounts the KOTS project at /replicatedhq/kots
function ec_render() {
sed "s|__PROJECT_DIR__|/replicatedhq/kots|g" "$1"
EC_NODE=$(ec_node) PROJECT_DIR="/replicatedhq/kots" gomplate --missing-key zero -f "$1"
}

# Get the embedded cluster node name
Expand Down
32 changes: 32 additions & 0 deletions dev/scripts/dev-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

function is_not_in_path() {
if ! command -v "$1" > /dev/null; then
echo "$1 is not installed"
return 0
fi
return 1
}

function check_gomplate() {
if is_not_in_path gomplate; then
echo "gomplate is not installed. Installing it now."
go install github.com/hairyhenderson/gomplate/v4/cmd/gomplate@latest
fi
}

function check_jq() {
if is_not_in_path jq; then
echo "jq is not installed. Attempting to install it using brew."
if is_not_in_path brew; then
echo "brew is not installed. Please install jq manually."
return
fi
brew install jq
fi
}

check_gomplate
check_jq
Loading