From e1b795733f4f6de78eb3201452f949850892c322 Mon Sep 17 00:00:00 2001 From: Clint Beacock Date: Tue, 9 Aug 2022 10:28:45 -0400 Subject: [PATCH] Update local stack to work with kubernetes-sigs/kind (#206) * Update gloo version to latest stable * Add kafka topic prefix to clinic-worker and update gateway validation settings to enable local deployment to work * Update 'tidepool start' command to work with latest Tilt version * Update Tiltfile to work with latest tilt version * Update 'tidepool verify-account-email' to use local mongo * Set CORS on internal http virtualservice to allow connecting from local blip on another port * Push tilt builds to local registry * remove tidepool 'server-x' commands * Small Tiltconfig updates * Update the server-start and server-stop tidepool commands * Add Kindconfig.yaml * Updated Kindconfig * Re-add tidepool server-destroy command * Update versions in tidepool doctor check * Add missing 'connect=direct' mongodb connection param to tilt config * Re-implement tidepool server-init command * Update tidepool command list to include up and down global commands * Tweak tidepool up and start commands * Specify port 5000 for Kindconfig registry * Add utility commands to tidepool script to allow restarting gloo or kafka services * Update Kindconfig to use 1pv4 networking * Add DEMO_CLINIC_USER_ID to clinic deployment env * Remove mongodb in-cluster provisioning * Tiltconfig: Enable clinics integration on shoreline and hydrophone, use development buildTarget for clinic * use MONGO_SHELL env variable to run mongo commands in tidepool script * Update documentation * Bump chart version to 0.13.15 * Remove extraPortMappings in Kindconfig * Set user's mongosh as default if MONGODB_SHELL not set * Update local mongo docs --- Kindconfig.yaml | 17 ++ README.md | 218 ++++++++++-------- Tiltconfig.yaml | 51 +++- Tiltfile | 24 +- Tiltfile.gateway | 24 +- Tiltfile.mongodb | 37 --- bin/tidepool | 153 ++++++------ charts/tidepool/Chart.yaml | 2 +- .../charts/clinic/templates/1-deployment.yaml | 6 + .../templates/4-http-virtual-service.yaml | 8 + 10 files changed, 301 insertions(+), 239 deletions(-) create mode 100644 Kindconfig.yaml delete mode 100644 Tiltfile.mongodb diff --git a/Kindconfig.yaml b/Kindconfig.yaml new file mode 100644 index 000000000..4690ba2e6 --- /dev/null +++ b/Kindconfig.yaml @@ -0,0 +1,17 @@ +apiVersion: ctlptl.dev/v1alpha1 +kind: Cluster +kubernetesVersion: v1.21.12 +registry: ctlptl-registry +product: kind +kindV1Alpha4Cluster: + name: tidepool-kind + networking: + ipFamily: ipv4 + apiServerAddress: 127.0.0.1 + nodes: + - role: control-plane +--- +apiVersion: ctlptl.dev/v1alpha1 +kind: Registry +name: ctlptl-registry +port: 5000 diff --git a/README.md b/README.md index cc7de4589..9466d5c47 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,12 @@ Of course, if you haven't already done so, you should check out [Tidepool](https - [Initial Setup](#initial-setup) - [Install Docker](#install-docker) - - [Install Docker Compose](#install-docker-compose) - [Install Kubernetes Client](#install-kubernetes-client) - [Install Helm](#install-helm) - [Install Tilt](#install-tilt) + - [Install Tilt "cattle patrol" (ctlptl)](#install-ctlptl) - [Install Netcat](#install-netcat) + - [Install and Configure MongoDB](#install-and-configure-mongodb) - [Clone This Repository](#clone-this-repository) - [Add Tidepool Helper Script (recommended)](#add-tidepool-helper-script-recommended) - [Environment Setup (recommended)](#environment-setup-recommended) @@ -68,12 +69,6 @@ Follow the appropriate link for your platform (Mac OSx or Linux recommended) at **IMPORTANT:** This stack is VERY resource intensive. You will need a fairly robust computer to run it efficiently, and will need to provide Docker with at least 60 GB of disk space and 4 GB of RAM. The default 2 GB RAM for Docker on MacOS won't cut it, and will need to be increased via the preferences panel. We recommend 8 GB or higher if you have 12 GB or more available. -## Install Docker Compose - -We use [Docker Compose](https://docs.docker.com/compose/) to run a local Kubernetes cluster within Docker. There are a number of _Kubernetes-in-Docker_ solutions available, but the one we've settled on as offering the best all-around fit for local development is [bsycorp/kind](https://github.com/bsycorp/kind/). - -If you installed Docker Desktop, the `docker-compose` tool will have been automatically installed with it. If you installed Docker on Linux, you'll need to download the binary by following the [Docker Compose Installation Instructions](https://docs.docker.com/compose/install/#install-compose) - ## Install Kubernetes Client The Kubernetes command-line tool, [kubectl](https://kubernetes.io/docs/user-guide/kubectl/), allows you to run commands against Kubernetes clusters. @@ -134,6 +129,18 @@ curl -fsSL https://github.com/windmilleng/tilt/releases/download/v0.16.1/tilt.0. After installing Tilt, you can verify the correct version by typing `tilt version` in your terminal. +## Install ctlptl + +We provision the kubernetes backend using a Tilt-provided tool called ctlptl. This sets up a Kubernetes-in-Docker (kind) server that integrates well with Tilt. Please follow the [ctlptl Installation Instructions](https://github.com/tilt-dev/ctlptl). + +Once installed, you can provision the kubernetes stack with `ctlptl`, using the `Kindconfig.yaml` configuration provided at the root of this repo. + +``` +ctlptl apply -f Kindconfig.yaml +``` + +This config will provision and start up the Kubernetes server, and a private docker registry that Tilt will deploy development builds to as you work locally on the Tidepool services. + ## Install Netcat Netcat should be installed by default on an recent versions of MacOS. If it is not, you can install it via homebrew. @@ -153,6 +160,86 @@ sudo apt-get install Netcat After installing Netcat, you can verify it's working by typing `nc -h` in your terminal. +## Install and configure MongoDB + +In order to run the local Tidepool services, you will need to provide a running MongoDB replica set. + +We recommend installing a local instance of MongoDB Community Edition with a single member for this purpose, though you should be fine with providing an already-running remote instance as well if you have one available by providing the appropriate address and auth details in the `Tiltconfig.yaml` referenced below. + +For local installation of MongoDB, please follow [these installation instructions](https://www.mongodb.com/docs/manual/administration/install-community/) for your platform. + +The stack has been tested with version `6.x`, which is the latest version available at the time of writing. The minimum supported version is `5.0`. + +After installing MongoDB locally, you will need to set up your `mongo.conf` to allow local connections, and configure it as a replica set (it will be a standalone instance by default). + +If, for instance, you installed via homebrew on Mac, the default file location will be `/usr/local/etc/mongod.conf`. This is the configuration we recommend for local use. Note, however, that this is very permissive, and allows all incoming connections, so you may want to + +```bash +systemLog: + destination: file + path: /usr/local/var/log/mongodb/mongo.log # Update this path as desired + logAppend: true +storage: + dbPath: /usr/local/var/mongodb # Update this path as desired + journal: + enabled: true +net: + bindIp: ::,0.0.0.0 # Restrict as required if your machine is publicly accessible +replication: + replSetName: rs0 +``` + +After setting up the config, you may need to restart your MongoDB service in order for the changes to take effect. + +At this point, you'll now need to initiate the replica set (`rs0`) that you defined in the `mongod.conf`. To do so, enter your mongo shell, and run: + +```js +// Initiate the replica set +rs.initiate() + +// Confirm that it's set up +rs.conf() + +// Should output something like: +/* +{ + _id: 'rs0', + version: 1, + term: 3, + protocolVersion: Long("1"), + writeConcernMajorityJournalDefault: true, + members: [ + { + _id: 0, + priority: 1, + votes: 1 + ... + } + ], + settings: { + ... + } +} +*/ + +// Exit the shell +quit() +``` + +At this point, your MongoDB service is ready. + +**Note for Linux users:** If you are running this stack on a Linux machine, then you will likely need to use the Docker host IP of `172.17.0.1` to point to the MongoDB. For example, in `local/Tiltconfig.yaml`: + +```yaml +mongo: + secret: + data_: + Addresses: "172.17.0.1" + # ... +``` + +For more information about setting up overrides to the Tilt config, see [Tilt Config Overrides](#tilt-config-overrides) + ## Clone This Repository At a minimum you'll need to clone this very GitHub repository to your computer. Execute the following command in a terminal window, but be sure to replace the `` with the destination directory where you want the respository to be copied. @@ -230,12 +317,12 @@ It's recommended that you export them in a persistent way, such as within your l export KUBECONFIG="$HOME/.kube/config" ``` -`TIDEPOOL_DOCKER_MONGO_VOLUME` - This is the path used to persist your local MongoDB data. You don't need to set this, but if you don't, you'll be restarting from a blank slate each time you start up your dev environment. +`MONGODB_SHELL` - This is the path used run the MongoDB shell on your local machine. By default, if unset, the `tidepool` script will use the path resolved by running `which mongosh`. -For example, if you want to store the Mongo data in the `~/MyMongoData` directory, then just set the value of the environment variable like so: +If you would like to override this, for instance, if the command you run to open the MongoDB shell is `/usr/local/bin/mongo`, then just set the value of the environment variable like so: ```bash -export TIDEPOOL_DOCKER_MONGO_VOLUME="~/MyMongoData" +export MONGODB_SHELL="/usr/local/bin/mongo" ``` [[back to top]](#welcome) @@ -288,43 +375,26 @@ tidepool server-stop **NOTE:** All commands must be run from the root of this repo. -### Start the kubernetes server - -```bash -docker-compose -f 'docker-compose.k8s.yml' up -d -``` - -### Retrieve and store the Kubernetes server config - -```bash -docker-compose -f 'docker-compose.k8s.yml' logs -f server -``` - -We can move on once we see the following message: +### Initial provisioning of the kubernetes server and registry ```bash -INFO exited: start (exit status 0; expected) +ctlptl apply -f 'Kindconfig.yaml' ``` +This will save the Kubernetes server config to the path defined in your `$KUBECONFIG` environment variable. This is only required for the initial server provisioning. -Now that the server has started, we need to retrieve the Kubernetes config and store it to the path we exported our `KUBECONFIG` variable to. +For subsequent server starts, run: ```bash -# Replace ~/.kube/config as needed if you -# chose a different path for KUBECONFIG -curl http://127.0.0.1:10080/config > ~/.kube/config +docker start tidepool-kind-control-plane +docker start ctlptl-registry ``` - ### Start the tidepool services ```bash -# First, set the DOCKER_HOST variable to allow using the docker process -# inside the server container for retrieving and building images -export DOCKER_HOST=tcp://127.0.0.1:2375 - # Start the tidepool services with Tilt, # with trap to shut down properly upon exit -trap 'SHUTTING_DOWN=1 tilt down' EXIT; tilt up --port=0 +trap 'SHUTTING_DOWN=1 tilt down' EXIT; tilt up -dv --port=0 --legacy ``` ### Stop the tidepool services @@ -335,10 +405,11 @@ You can stop the Tidepool services either by exiting the Tilt UI with `ctrl-c`, export SHUTTING_DOWN=1; tilt down ``` -### Stop the kubernetes server +### Stop the kubernetes server and registry ```bash -docker-compose -f 'docker-compose.k8s.yml' stop +docker stop tidepool-kind-control-plane +docker stop ctlptl-registry ``` ## Monitor Kubernetes State With K9s (Optional) @@ -397,7 +468,7 @@ NOTE: If you wish to upload to our official, production Tidepool later, you'll h ## Data Retention -Remember, this is all running on your computer only. This means that all accounts you create and all data you upload to your local Tidepool are _ONLY_ stored in a Mongo database located in the local directory on your computer that you defined with the `TIDEPOOL_DOCKER_MONGO_VOLUME` environment variable (See [Environment Setup (recommended)](#environment-setup-recommended)). If you delete that directory, then all of the data you uploaded locally is gone, **permanently**. If you are going to run Tidepool locally as a permanent solution, then we very **strongly** suggest regular backups of the `mongo` directory. +Remember, this is all running on your computer only. This means that all accounts you create and all data you upload to your local Tidepool are _ONLY_ stored in a Mongo database located in the local directory on your computer. Fortunately, at [Tidepool Web](https://app.tidepool.org), we worry about that for you and make sure all of your data is secure and backed up regularly. @@ -424,42 +495,6 @@ In addition to the helm chart overrides, there are some extra configuration para See [Building Local Images](#building-local-images) for more details -## Alternate MongoDB Host - -If you wish to use an alternate Mongo host running outside of Docker, then you'll need to do a few things. - -Set the `mongodb.useExternal` flag to `true` in your `local/Tiltconfig.yaml` file as required, and update `mongo.secret.data_` section as needed. For example: - -```yaml -mongodb: - useExternal: true - # ... - -mongo: - secret: - data_: - Scheme: "mongodb" - Addresses: "http://host:port" # comma-separated list of MongoDB host[:port] addresses - Username: "" # the MongoDB port to connect to - Password: "" # a username in the Mongo instance - Tls: "false" # whether to use SSL to communicate with Mongo - OptParams: "" # optional parameters to pass on the Mongo connection string - Database: "admin" # database to connect to - # ... -``` - -If you are running Mongo natively on your local Mac (not in Docker, but via another installation, such as [Homebrew](https://brew.sh/)), then you can use the Docker-specific, container-accessible-only address `host.docker.internal` to point to the alternate Mongo host. For example, - -```yaml -mongo: - secret: - data_: - Addresses: "host.docker.internal" - # ... -``` - -If the alternate Mongo host requires a TLS/SSL connection, be sure to set the `global.mongo.ssl` flag to `true`. - ## Dexcom API integration The Dexcom API integration will not work out of the box as it requires a private developer id and secret known only to Dexcom and Tidepool. If you wish to enable this functionality, please see https://developer.dexcom.com/. @@ -821,21 +856,18 @@ exit This is overkill when just doing a simple command (streamlined alternative outlined below), but it's very hand when you need to perform multiple operations or simply poke around the container's file system. -| Command | Description | -|-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `up [service]` | start and/or (re)build the entire tidepool stack or the specified service | -| `down` | shut down and remove the entire tidepool stack | -| `stop` | shut down the entire tidepool stack or the specified service | -| `rm [service]` | stops and removes containers and volumes for the entire tidepool stack or the specified service | -| `restart [service]` | restart the entire tidepool stack or the specified service | -| `pull [service]` | pull the latest images for the entire tidepool stack or the specified service | -| `logs [service]` | tail logs for the entire tidepool stack or the specified service | -| `rebuild [service]` | rebuild and run image for all services in the tidepool stack or the specified service | -| `exec service [...cmds]` | run arbitrary shell commands in the currently running service container | -| `link node_service package` | yarn link a mounted package and restart the Node.js service (package must be mounted into a root directory that matches it's name) | -| `unlink node_service package` | yarn unlink a mounted package, reinstall the remote package, and restart the Node.js service (package must be mounted into a root directory that matches it's name) | -| `yarn node_service [...cmds]` | shortcut to run yarn commands against the specified Node.js service | -| `help` | show more detailed usage text than what's listed here | +| Command | Description | +|-------------------------------|--------------------------------------------------------------------------| +| `up [service]` | Start the Kubernetes server and Tidepool services, in that order | +| `down` | Stop the Tidepool services and Kubernetes server, in that order | +| `destroy` | Shut down and completely remove the local Kubernetes server and services | +| `start` | Provision and start the Tidepool services via Tilt | +| `stop` | Stop and remove the Tidepool services via Tilt | +| `restart [service]` | Restart the specified service | +| `logs [service]` | tail logs for the entire tidepool stack or the specified service | +| `exec service [...cmds]` | run arbitrary shell commands in the currently running service container | +| `yarn node_service [...cmds]` | shortcut to run yarn commands against the specified Node.js service | +| `help` | show more detailed usage text than what's listed here | ```bash # Examples (from your local terminal) @@ -865,7 +897,7 @@ This will allow your changes to be tracked properly in version control, and Tilt | Service | Standard Port(s) | | ----------------------------------------------------------------- | ---------------------- | -| [blip](https://github.com/tidepool-org/blip) | N/A (see below) | +| [blip](https://github.com/tidepool-org/blip) | 3000 | | [export](https://github.com/tidepool-org/export) | 9300 | | [gatekeeper](https://github.com/tidepool-org/gatekeeper) | 9123 | | [hakken](https://github.com/tidepool-org/hakken) | 8000 | @@ -906,7 +938,6 @@ Stay Tuned :) | kubectl errors when provisioning services | Make sure you've set the `KUBECONFIG` environment variable. See [Environment Setup (recommended)](#environment-setup-recommended) and [Retrieve and store the Kubernetes server config](#retrieve-and-store-the-kubernetes-server-config) | | kubectl errors when starting k9s | Make sure you've set the `KUBECONFIG` environment variable. See [Environment Setup (recommended)](#environment-setup-recommended) and [Retrieve and store the Kubernetes server config](#retrieve-and-store-the-kubernetes-server-config) | | Tidepool Web ('blip') not loading | Check the service logs, either in the Tilt UI or with `tidepool logs blip` to make sure it's finished compiling successfully. If it has compiled, see [Tidepool Web becomes inaccessible](#tidepool-web-becomes-inaccessible) | -| `tidepool start` hangs at "Preparing mongodb service..." | NOTE: It's normal for this to take a few minutes the first time you run this. Otherwise, check to see if mongodb pods are still provisioning in [k9s](#monitor-kubernetes-state-with-k9s-optional), and if so, wait, else cancel the `tidepool start` process and re-run it | | `tidepool start` hangs at "Preparing gateway services..." | NOTE: It's normal for this to take a few minutes the first time you run this. Otherwise, check to see if gloo gateway pods are still provisioning in [k9s](#monitor-kubernetes-state-with-k9s-optional), and if so, wait, else cancel the `tidepool start` process and re-run it | | `tidepool start` has numerous "Bad Address: shoreline" errors | NOTE: It's normal for this to happen while services wait for shoreline to be provisioned. This can go on for a quite a while during the first time running the stack, due to the extra time it takes to download all the service images. Give it a few minutes, and as long as shoreline comes up eventually, it should resolve itself | | Services are crashed and k9s shows them in an **evicted** state | The docker environment running the k8s server node has run out of disk space, likely due to old image build layers. Run `tidepool server-prune`. Afterwards, within a few minutes, services should begin re-deploying again automatically | @@ -937,13 +968,10 @@ Currently, there is a known issue where at times the gateway proxy service that This will present itself usually with the web app getting stuck in a loading state in the browser, or possibly resolving with an error message like: `‘No healthy upstream on blip (http://localhost:3000)` -The solution first solution to try is to restart the `gateway-proxy` service, which should restore access in a few moments: +The solution first solution to try is to restart the gloo `gateway` services, which should restore access in a few moments: ```bash -tidepool restart gateway-proxy - -# or use the built-in shortcut -tidepool restart-proxy +tidepool restart-gateway ``` If this doesn't work, simply stop the running `tidepool start` process, and re-run it. This will terminate and re-provision the entire stack, and should fix the issue. This second approach is often needed after the initial provisioning of the stack, likely due to some timeouts stemming from the extra time it takes for all the images to be downloaded the first time. diff --git a/Tiltconfig.yaml b/Tiltconfig.yaml index 61218f9ec..ab44d16c7 100644 --- a/Tiltconfig.yaml +++ b/Tiltconfig.yaml @@ -33,7 +33,11 @@ global: ### Gateway Config Start ### gateway-proxy: - portForwards: ['3000', '8081'] + portForwards: ['3000'] + +gateway: + validation: + enabled: false glooingress: enabled: true @@ -43,6 +47,30 @@ glooingress: http: name: "internal" dnsNames: ["*"] + serveAllDomains: true + options: + cors: + allowCredentials: true + allowHeaders: + - authorization + - content-type + - x-tidepool-session-token + - x-tidepool-trace-request + - x-tidepool-trace-session + allowMethods: + - GET + - POST + - PUT + - PATCH + - DELETE + - OPTIONS + allowOriginRegex: + - .* + exposeHeaders: + - x-tidepool-session-token + - x-tidepool-trace-request + - x-tidepool-trace-session + maxAge: 600s port: "3000" apiServer: @@ -54,22 +82,19 @@ keycloak: ### MongoDB Config Start ### mongodb: - persistent: true enabled: false # False to disable the helm-chart-defined mongo, as we deploy our own directly within the Tiltfile - useExternal: false # Set to true and update the global mongo config below if using an external mongo db - hostPath: '/data/db' # Note: this path is relative to the k8s server container defined in `docker-compose.k8s.yml`. Local machine path is volume-mounted using the TIDEPOOL_DOCKER_MONGO_VOLUME environment variable. - portForwards: ['27017'] + useExternal: true # Set to true and update the global mongo config below if using an external mongo db mongo: secret: data_: Scheme: "mongodb" - Addresses: "mongodb" + Addresses: "192.168.65.2" # Default docker host IP for Mac and Windows. Change to 172.17.0.1 for Linux hosts Username: "" Password: "" Database: "admin" Tls: "false" - OptParams: "" + OptParams: "connect=direct" ### MongoDB Config End ### ### Carelink API Config Start ###carelink: @@ -242,7 +267,7 @@ clinic: # hostPath: ~/go/src/github.com/tidepool-org/clinic # Uncomment to build and run local image containerPath: '/go/src/github.com/tidepool-org/clinic' dockerFile: 'Dockerfile' - rebuildCommand: 'SERVICE=make build' + buildTarget: development clinic-worker: deployment: @@ -251,7 +276,11 @@ clinic-worker: # hostPath: ~/go/src/github.com/tidepool-org/clinic-worker # Uncomment to build and run local image containerPath: '/go/src/github.com/tidepool-org/clinic-worker' dockerFile: 'Dockerfile' - rebuildCommand: 'SERVICE=make build' + rebuildCommand: 'make build' + configmap: + enabled: true + data: + KafkaTopicPrefix: "default." blob: deployment: @@ -298,6 +327,8 @@ highwater: hydrophone: deployment: + env: + clinicServiceEnabled: true # image: tidepool-k8s-hydrophone # Uncomment to build and run local image or a specific remote image # hostPath: ~/go/src/github.com/tidepool-org/hydrophone # Uncomment to build and run local image containerPath: '/go/src/github.com/tidepool-org/hydrophone' @@ -340,6 +371,8 @@ seagull: shoreline: deployment: + env: + clinicServiceEnabled: true # image: tidepool-k8s-shoreline # Uncomment to build and run local image or a specific remote image # hostPath: ../shoreline # Uncomment to build and run local image containerPath: '/go/src/github.com/tidepool-org/shoreline' diff --git a/Tiltfile b/Tiltfile index 1df384e48..24e58be03 100644 --- a/Tiltfile +++ b/Tiltfile @@ -21,9 +21,6 @@ def main(): # Set up tidepool helm template command tidepool_helm_template_cmd = 'helm template --namespace default ' - mongodb_port_forwards = getNested(config,'mongodb.portForwards', ['27017']) - mongodb_port_forward_host_port = mongodb_port_forwards[0].split(':')[0] - if not is_shutdown: updateHelmDependancies() provisionClusterRoleBindings() @@ -33,24 +30,12 @@ def main(): # Ensure kafka service is deployed kafka_service = local('kubectl get service kafka-kafka-bootstrap --ignore-not-found') if not kafka_service: - local('tilt up --file=Tiltfile.kafka --hud=0 --port=0 >/dev/null 2>&1 &') - - # Ensure mongodb service is deployed - if not getNested(config, 'mongodb.useExternal'): - mongodb_service = local('kubectl get service mongodb --ignore-not-found') - if not mongodb_service: - local('tilt up --file=Tiltfile.mongodb --hud=0 --port=0 >/dev/null 2>&1 &') + local('tilt up --file=Tiltfile.kafka --legacy=0 --port=0 >/dev/null 2>&1 &') # Ensure proxy services are deployed gateway_proxy_service = local('kubectl get service gateway-proxy --ignore-not-found') if not gateway_proxy_service: - local('tilt up --file=Tiltfile.gateway --hud=0 --port=0 >/dev/null 2>&1 &') - - # Wait until mongodb and gateway proxy services are forwarding before provisioning rest of stack - if not getNested(config, 'mongodb.useExternal'): - print("Preparing mongodb service...") - local('while ! nc -z localhost {}; do sleep 1; done'.format(mongodb_port_forward_host_port)) - print("Mongodb ready.") + local('tilt up --file=Tiltfile.gateway --legacy=0 --port=0 >/dev/null 2>&1 &') # Wait until kafka is ready and kafka secrets are created if not kafka_service: @@ -59,9 +44,6 @@ def main(): print("Kafka ready.") else: - # Shut down the mongodb, kafka, and gateway services - if not getNested(config, 'mongodb.useExternal'): - local('SHUTTING_DOWN=1 tilt down --file=Tiltfile.mongodb &>/dev/null &') local('SHUTTING_DOWN=1 tilt down --file=Tiltfile.gateway &>/dev/null &') local('SHUTTING_DOWN=1 tilt down --file=Tiltfile.kafka &>/dev/null &') @@ -335,7 +317,7 @@ def applyServiceOverrides(tidepool_helm_template_cmd): entrypoint=entrypoint, command='{} {} {}'.format(preBuildCommand, buildCommand, postBuildCommand), deps=build_deps, - disable_push=True, + disable_push=False, tag='tilt', live_update=live_update_commands ) diff --git a/Tiltfile.gateway b/Tiltfile.gateway index 5dd72ca48..83d13aa5a 100644 --- a/Tiltfile.gateway +++ b/Tiltfile.gateway @@ -17,7 +17,7 @@ local_downloads_dir = getAbsoluteDir('./local/downloads') is_shutdown = isShutdown() -gloo_version = '1.4.4' +gloo_version = '1.11.23' gloo_archive_name = 'gloo-{}.tgz'.format(gloo_version) gloo_helm_url = 'https://storage.googleapis.com/solo-public-helm/charts/{}'.format(gloo_archive_name) @@ -57,19 +57,23 @@ def extractGlooGatewayCharts(): ### Custom Resource Definitions Start ### def provisionCRDs(): crds_filename_map = { - 'authconfig': 'auth_config', - 'gateway': 'gateway', - 'proxy': 'proxy', - 'routetable': 'route_table', - 'settings': 'settings', - 'upstreamgroup': 'upstream_group', - 'upstream': 'upstream', - 'virtualservice': 'virtual_service', + 'authconfig': 'v1_AuthConfig', + 'gateway': 'v1_Gateway', + 'httpgateway': 'v1_MatchableHttpGateway', + 'routeoptions': 'v1_RouteOption', + 'routetable': 'v1_RouteTable', + 'virtualhostoptions': 'v1_VirtualHostOption', + 'virtualservice': 'v1_VirtualService', + 'proxy': 'v1_Proxy', + 'settings': 'v1_Settings', + 'upstream': 'v1_Upstream', + 'upstreamgroup': 'v1_UpstreamGroup', + 'graphqlapi': 'v1beta1_GraphQLApi.yaml', + 'ratelimitconfig': 'ratelimit_config', } gloo_crds = listdir('{}/gloo/crds'.format(absolute_gloo_chart_dir)) - print(gloo_crds); for crd in crds_filename_map.keys(): createdCRD = local('kubectl get crd {crd} --ignore-not-found'.format( crd = crd diff --git a/Tiltfile.mongodb b/Tiltfile.mongodb deleted file mode 100644 index 591f5f778..000000000 --- a/Tiltfile.mongodb +++ /dev/null @@ -1,37 +0,0 @@ -load('./Tiltfile.global', 'getAbsoluteDir', 'getNested', 'getConfig') - -allow_k8s_contexts('kind-admin@mk') - -### Config Start ### -config = getConfig() -mongo_helm_chart_dir = getAbsoluteDir('./local/tilt/charts/mongo') -### Config End ### - -### Main Start ### -def main(): - # Provision mongo db - provisionMongoDB() - - # Back out of actual provisioning for debugging purposes by uncommenting below - # fail('NOT YET ;)') -### Main End ### - -### MongoDB Start ### -def provisionMongoDB (): - mongodb_data_dir = getNested(config, 'mongodb.hostPath') - mongo_helm_template_cmd = 'helm template --namespace default ' - - if mongodb_data_dir: - mongo_helm_template_cmd += '--set "mongodb.hostPath={}" '.format(mongodb_data_dir) - - k8s_yaml(local(mongo_helm_template_cmd + mongo_helm_chart_dir)) - - # Expose mongodb on a host port - mongodb_port_forwards = getNested(config,'mongodb.portForwards', ['27017']) - k8s_resource('mongodb', port_forwards=mongodb_port_forwards) - - watch_file(mongo_helm_chart_dir) -### MongoDB End ### - -# Unleash the beast -main() diff --git a/bin/tidepool b/bin/tidepool index a404fed69..cf9c529ef 100755 --- a/bin/tidepool +++ b/bin/tidepool @@ -2,37 +2,36 @@ shopt -s extglob DIR=$(cd $(dirname $(dirname ${0})); pwd) +MONGODB_SHELL=${MONGODB_SHELL:-`which mongosh`} usage() { cat <