Adding local development environment via Tilt
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
1f7c5a77e6
commit
545ae30df9
@ -0,0 +1,23 @@
|
|||||||
|
PYTHON ?= python3.11
|
||||||
|
KIND_KUBECONFIG ?= $(HOME)/.kube/config-kind.yaml
|
||||||
|
|
||||||
|
# Checks system dependencies needed to run the local dev environment
|
||||||
|
check-system-deps:
|
||||||
|
@echo "Checking system dependencies..."
|
||||||
|
@command -v $(PYTHON) > /dev/null || (echo "Python 3.11 is not installed."; exit 1)
|
||||||
|
@command -v kubectl > /dev/null || (echo "kubectl is not installed."; exit 1)
|
||||||
|
@command -v docker > /dev/null || (echo "Docker is not installed."; exit 1)
|
||||||
|
@command -v kind > /dev/null || (echo "Kind is not installed."; exit 1)
|
||||||
|
@command -v ctlptl version > /dev/null || (echo "ctlptl is not installed."; exit 1)
|
||||||
|
@command -v tilt > /dev/null || (echo "Tilt is not installed."; exit 1)
|
||||||
|
@command -v helm > /dev/null || (echo "Helm is not installed."; exit 1)
|
||||||
|
@echo "All required dependencies are installed."
|
||||||
|
|
||||||
|
start-local:
|
||||||
|
export KUBECONFIG=$(KIND_KUBECONFIG) ;\
|
||||||
|
ctlptl apply -f kind.yaml ;\
|
||||||
|
tilt up --context kind-kind-local
|
||||||
|
|
||||||
|
stop-local:
|
||||||
|
export KUBECONFIG=$(KIND_KUBECONFIG) ;\
|
||||||
|
tilt down --context kind-kind-local
|
@ -0,0 +1,89 @@
|
|||||||
|
print("""
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
✨ Speech Collect Tiltfile! ✨
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
""".strip())
|
||||||
|
|
||||||
|
# User must manually trigger update for dirty(changed) resources in the UI.
|
||||||
|
trigger_mode(TRIGGER_MODE_MANUAL)
|
||||||
|
|
||||||
|
# ------------- Variables -----------
|
||||||
|
kube_namespace = 'speech-collect-local'
|
||||||
|
|
||||||
|
db_name = "tilt-local-db"
|
||||||
|
db_user = "postgres"
|
||||||
|
db_pass = "passwd"
|
||||||
|
db_service = "pg-sql-service"
|
||||||
|
db_tag = "15"
|
||||||
|
secret_name = 'speech-collect-secret'
|
||||||
|
db_secret_key = 'PGSQL_PASSWORD'
|
||||||
|
|
||||||
|
# ------------- Docker Image Build -----------
|
||||||
|
|
||||||
|
docker_build(
|
||||||
|
'registry.runcible.io/speech-collect',
|
||||||
|
'./',
|
||||||
|
build_args={"REPO_NAME": "registry.runcible.io/speech-collect", "COMMIT_SHA": "local"}
|
||||||
|
)
|
||||||
|
|
||||||
|
# ------------- Prepare Namespace -----------
|
||||||
|
|
||||||
|
# load executes another Tiltfile, and imports the named variables into current scope
|
||||||
|
load('ext://namespace', 'namespace_create', 'namespace_inject')
|
||||||
|
namespace_create(kube_namespace)
|
||||||
|
k8s_resource(objects=[kube_namespace], new_name=kube_namespace+"-ns", labels='speech-collect')
|
||||||
|
|
||||||
|
load('ext://helm_remote', 'helm_remote')
|
||||||
|
load('ext://cert_manager', 'deploy_cert_manager')
|
||||||
|
deploy_cert_manager()
|
||||||
|
|
||||||
|
|
||||||
|
# ------------- Secrets -----------
|
||||||
|
print('Creating secrets')
|
||||||
|
load('ext://secret', 'secret_from_dict')
|
||||||
|
k8s_yaml(secret_from_dict(secret_name,
|
||||||
|
inputs={db_secret_key : db_pass},
|
||||||
|
namespace=kube_namespace,
|
||||||
|
))
|
||||||
|
#
|
||||||
|
k8s_resource(objects=[secret_name], new_name=secret_name, labels="speech-collect")
|
||||||
|
|
||||||
|
|
||||||
|
# ------------- Postgres -----------
|
||||||
|
|
||||||
|
print('Installing Postgres')
|
||||||
|
helm_remote(
|
||||||
|
'postgresql',
|
||||||
|
namespace=kube_namespace,
|
||||||
|
repo_url='https://charts.bitnami.com/bitnami',
|
||||||
|
set=[
|
||||||
|
"global.postgresql.auth.postgresPassword=",
|
||||||
|
"global.postgresql.auth.database=" + db_name,
|
||||||
|
"global.postgresql.auth.username=" + db_user,
|
||||||
|
"global.postgresql.auth.password=" + db_pass,
|
||||||
|
"image.tag=" + db_tag,
|
||||||
|
"fullnameOverride=" + db_service,
|
||||||
|
"nameOverride=" + db_service,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
# Modifies the resource (our postgres in this case) by portforwarding to 5432 and applying a label
|
||||||
|
k8s_resource(workload=db_service, port_forwards=["5432"], labels="local-external-platform")
|
||||||
|
# Renames the secret created by the above helm chart to pg-secret in the Tilt UI
|
||||||
|
k8s_resource(objects=[db_service+":secret"], new_name="pg-secret", labels="local-external-platform")
|
||||||
|
|
||||||
|
# HERE IS YOUR LOCAL SERVICE
|
||||||
|
load('ext://helm_remote', 'helm_remote')
|
||||||
|
|
||||||
|
# ------------ Local Chart ------------
|
||||||
|
k8s_yaml(
|
||||||
|
helm(
|
||||||
|
'./charts/speech-collect',
|
||||||
|
namespace=kube_namespace,
|
||||||
|
set=[
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
k8s_resource('speech-collect-api', resource_deps=[], labels="speech-collect")
|
||||||
|
k8s_resource(objects=['speech-collect-sa:serviceaccount'], new_name="speech-collect-sa", labels='speech-collect')
|
||||||
|
k8s_resource(objects=['speech-collect-configmap:configmap'], new_name="speech-collect-configmap", labels='speech-collect')
|
Loading…
Reference in New Issue