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')