Skip to content

Commit

Permalink
Update local stack to work with kubernetes-sigs/kind (#206)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
clintonium-119 authored Aug 9, 2022
1 parent 8f715a8 commit e1b7957
Show file tree
Hide file tree
Showing 10 changed files with 301 additions and 239 deletions.
17 changes: 17 additions & 0 deletions Kindconfig.yaml
Original file line number Diff line number Diff line change
@@ -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
218 changes: 123 additions & 95 deletions README.md

Large diffs are not rendered by default.

51 changes: 42 additions & 9 deletions Tiltconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ global:

### Gateway Config Start ###
gateway-proxy:
portForwards: ['3000', '8081']
portForwards: ['3000']

gateway:
validation:
enabled: false

glooingress:
enabled: true
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
24 changes: 3 additions & 21 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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 &')
Expand Down Expand Up @@ -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
)
Expand Down
24 changes: 14 additions & 10 deletions Tiltfile.gateway
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
37 changes: 0 additions & 37 deletions Tiltfile.mongodb

This file was deleted.

Loading

0 comments on commit e1b7957

Please sign in to comment.