Skip to content

Commit

Permalink
feat: updates for local gitops dev
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickleet committed Oct 31, 2022
1 parent be0033d commit 6b5132a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 63 deletions.
39 changes: 1 addition & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NOW := $(shell date +%m_%d_%Y_%H_%M)
SERVICE_NAME := example-todo-model-service
DEBUG ?= example*

onboard: install create-env-file deploy-to-local-cluster
onboard: install create-env-file

create-env-file:
./scripts/create-env-file.sh
Expand All @@ -16,40 +16,3 @@ install:

open:
code .

connect-to-local-dev-cluster:
kubectl ctx $(LOCAL_DEV_CLUSTER)
kubectl port-forward --namespace default svc/sourced-mongodb 27017:27017 &
kubectl port-forward --namespace knative-eventing svc/broker-ingress 8080:80 &

build-new-local-image:
kubectl ctx $(LOCAL_DEV_CLUSTER)
docker build -t $(SERVICE_NAME) .
docker tag $(SERVICE_NAME):latest dev.local/$(SERVICE_NAME):$(NOW)

load-local-image-to-kind:
kubectl ctx $(LOCAL_DEV_CLUSTER)
kind --name local-dev-cluster load docker-image dev.local/$(SERVICE_NAME):$(NOW)

deploy-to-local-cluster:
kubectl ctx $(LOCAL_DEV_CLUSTER)
helm template ./charts/$(SERVICE_NAME)/ \
-f ./charts/$(SERVICE_NAME)/values.yaml \
--set image.repository=dev.local/$(SERVICE_NAME),image.tag=$(NOW),local=true \
| kubectl apply -f -

delete-local-deployment:
kubectl ctx $(LOCAL_DEV_CLUSTER)
helm template ./charts/$(SERVICE_NAME)/ \
-f ./charts/$(SERVICE_NAME)/values.yaml \
--set image.repository=dev.local/$(SERVICE_NAME),image.tag=$(NOW) \
| kubectl delete -f -

refresh-kind-image: build-new-local-image load-local-image-to-kind deploy-to-local-cluster
hard-refresh-kind-image: delete-local-deployment build-new-local-image load-local-image-to-kind deploy-to-local-cluster

localizer:
localizer expose default/$(SERVICE_NAME) --map 80:5002

stop-localizer:
localizer expose default/$(SERVICE_NAME) --stop
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,6 @@ To start the tests in watch mode run, which will rerun as you make code changes:
npm run test:integration:watch
```

#### Local development cluster integration tests

To run these tests locally, first set up a [local-development-cluster](https://github.com/cloudnativeentrepreneur/local-development-cluster), and then run the following to deploy a local copy of your app that local cluster:

```bash
make refresh-kind-image
```

Or


```bash
make hard-refresh-kind-image
```


Make sure `localizer` is running (`make localizer` in the [meta repo](https://github.com/cloudnativeentrepreneur/cne-meta), then, trigger the integration tests using:

```
npm run test:integration
```

## Linting

To format the code automatically and fix any automatically fixable errors, run:
Expand Down
4 changes: 2 additions & 2 deletions scripts/create-env-file.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export PG_PASS=$(kubectl get secret sourced.example-sourced-db-postgresql.credentials.postgresql.acid.zalan.do -o jsonpath={.data.password} | base64 -D)
export SOURCED_POSTGRESQL_URL="postgresql://sourced:${PG_PASS}@example-sourced-db-postgresql.default.svc.cluster.local:5432/sourced"
export PG_PASS=$(kubectl -n example-local-env get secret sourced.example-sourced-db-postgresql.credentials.postgresql.acid.zalan.do -o jsonpath={.data.password} | base64 -D)
export SOURCED_POSTGRESQL_URL="postgresql://sourced:${PG_PASS}@example-sourced-db-postgresql.example-local-env.svc.cluster.local:5432/sourced"

cat .env > .local.env
echo "\nSOURCED_POSTGRESQL_URL=${SOURCED_POSTGRESQL_URL}" >> .local.env
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const config = {
todo: {
events:
process.env.TODO_EVENTS_BROKER_URL ||
"http://broker-ingress.knative-eventing.svc.cluster.local/default/todo-events",
"http://broker-ingress.knative-eventing.svc.cluster.local/example-local-env/todo-events",
},
},
source: "example-todo-model-service",
Expand Down

0 comments on commit 6b5132a

Please sign in to comment.