TODO: https://github.com/tilt-dev/debugger-examples/blob/master/dotnet/.vscode/launch.json
An opinionated/experimental getting started project leveraging Kubernetes, Tilt, Dapr, and SvelteKit. This is a work in progress!
Skip to the Quick Start!
I always enjoy "developer experience" and this repository is being leveraged to experiment with different technologies and streamlining workflows. I hope to learn valuable lessons and share with others what I am doing.
When you execute tilt up
this project currently creates the following in a Kubernetes cluster:
- Proxy Service - .NET 6 preview 7 Minimal API
- Auth service .NET 6 preview 7
- 'Store' service (experimenting using Dapr actor to sync svelte frontend store)
- Dapr for sidecars, plugin components, and secret management
- PostgreSQL
- pgAdmin
- Database migration with Kubernetes Job
- Local Kubernetes secret store (intended to leverage Dapr secret component for a Key vault in production)
There is a svelteKit frontend that can currently be run separately: Running Svelte
This starter kit leverages Tilt to provide a productive environment for development which includes:
- The ability to start all services and databases with a single command (after initial prereqs installed)
- Automatically reload all services on file changes
- Ability to be deployed to production with minimal changes
- Secrets integration
- Authn/z integration
- Database and pgAdmin tools setup
- Ability to easily integrate your own services and focus on business logic
Get started fast! The tools are preconfigured and kubectl, helm, and other tools can be learned over time.
- Docker Desktop with Kubernetes enabled
- Kubectl is installed with Docker Desktop, confirm by typing
kubectl
in the terminal. If you don't have it, Install it - Helm CLI
- Tilt - This is the link to tilt.exe. If tools are not accessible on command line follow these steps.
- Ensure the Prerequisites are installed
- Clone repository
git clone https://github.com/michaelkacher/k8cher
- cd into directory
cd k8cher
tilt up
. You will see a message in the terminal that you can press space bar to open the Tilt Dashboard. Open it and watch the status of the services starting.
- Note: There is an intermittent first time bug I am chasing down that will only occur with the bitnami helm chart for postgres (has never occured with other helm charts). When browsing the Tilt Dashboard (the one accessed by pressing space bar) if there is an error in the Tiltfile, execute the following in the terminal:
helm repo add bitnami https://charts.bitnami.com/bitnami
and run again.
-
The dashboard shows the health of the services, if it shows 16/16 you are ready to go! This displays real time updates as changes to services are saved and it is rebuilt and deployed.
-
View the Swagger for the auth service by clicking the link in the 'Endpoints' column. The base path and port is that of the proxy, and all paths matching '/auth' are redirected to the auth service. A user can be registered through the swagger:
-
Click on the row that reads
Post /auth/register
-
Click the "Try it out button"
-
Paste in the JSON below
{ "email": "michael.kacher@gmail.com", "password": "Passw0rd_" }
-
Click execute, you should see a 200 response
-
This creates the user but they cannot log in until the e-mail has been confirmed. Navigate to the local mail dev server at http://localhost:1080/
-
Click the confirmation link. If the web app is not running the redirect will not work but the account has still been confirmed.
-
Now a JWT for the user can be retrieved with a POST to /auth/login with the following JSON.
{ "email": "michael.kacher@gmail.com", "password": "Passw0rd_" }
-
-
View Resources can be selected to view the logs of all the services. You should see that creation of the user and login is logged.
-
Select the link for pgAdmin
localhost:5555
. NOTE: These secrets are set in the local Kubernetes secret store. The intention is that if deployed to production the Dapr Secret Management plugin is leveraged to integrate with AWS/Azure/GCP secret store.- At the login screen use the following credentials
- Email Address / Username:
user@domain.com
- Password:
bouncingcow
- Email Address / Username:
- This brings you to the admin page, expand the database in the left hand browser and use
postgres
for the password - In the Browser panel expand
k8cher
database and expand Schema->public->Tables. You can right click and query theAspNetUsers
table and confirm the users is there.
- At the login screen use the following credentials
To cleanup the kubernetes resources do the following:
- in the terminal window running tilt, press
ctrl + c
to stop the service - execute
tilt down
- The proxy is currently setup to localhost:8088. If this conflicts with existing ports, navigate to the helm chart values and change the
port
underservice
from 8088 to desired port.
There is a svelte frontend that can be run separately to access the services.
- Ensure that Node is installed (version > 12)
- cd into web directory:
cd src\k8cher.web
- install the npm dependencies:
npm install
- run the dev env:
npm run dev
- access it at http://localhost:3000
Recreate migrations - delete Migrations folder content $dotnet ef migrations add InitialCreate -- --environment Migration
.