A gRPC-Gateway-powered framework with Prisma, Kubernetes, and Go for building scalable microservices.
$ ./install.sh
$ thunder init myproject
Creating new Thunder project: myproject
Setting up project structure...
✓ Project created successfully!
$ cd myproject
$ go mod tidy
$ thunder serve
Starting gRPC server on port 50051
Starting REST gateway on port 8080
✓ Server is running!
Automatically expose RESTful APIs from gRPC services with gRPC-Gateway.
Efficient database management and migrations with Prisma ORM.
Easily deploy and scale your services with Kubernetes.
Secure gRPC communications with TLS for enhanced security.
Built-in zap logging for better insights into your application.
Pre-configured middleware for rate limiting and authentication.
Easily extend Thunder for custom use cases and requirements.
Generate, deploy, and create new projects effortlessly.
# Create a Protobuf file (example.proto)
syntax = "proto3";
package example;
import "google/api/annotations.proto";
service Example {
rpc SayHello(HelloRequest) returns (HelloResponse) {
option (google.api.http) = {
get: "/v1/example/sayhello"
};
};
}
message HelloRequest {
string name = 1;
}
message HelloResponse {
string message = 1;
}
# Define the service in services.json
[
{
"ServiceName": "Example",
"ServiceStruct": "ExampleServiceServer",
"ServiceRegister": "RegisterExampleServer",
"HandlerRegister": "RegisterExampleHandler"
}
]
# Generate the service implementation
thunder generate --proto=example.proto
Follow these steps to deploy Thunder on Kubernetes:
$ # PgBouncer Secret Configuration
$ echo '"postgres" "postgres"' | base64
InBvc3RncmVzIiAicG9zdGdyZXMiCg==
$ # Update the pgbouncer-all.yaml with the new base64 value
$ # Generate TLS Certificates
$ cd cmd
$ mkdir certs
$ openssl req -x509 -newkey rsa:4096 -keyout certs/server.key -out certs/server.crt -days 365 -nodes \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
Generating a RSA private key
...............+++++
...+++++
writing new private key to 'certs/server.key'
-----
$ # Create Kubernetes Secrets
$ kubectl create secret generic app-secret \
--from-literal=DATABASE_URL="postgres://postgres:postgres@pgbouncer-service:6432/thunder?sslmode=disable" \
--from-literal=JWT_SECRET="secret"
secret/app-secret created
$ kubectl create secret generic postgres-secret \
--from-literal=POSTGRES_USER=postgres \
--from-literal=POSTGRES_PASSWORD=postgres \
--from-literal=POSTGRES_DB=thunder
secret/postgres-secret created
$ # Build & Deploy Docker Image
$ thunder build
Building Thunder container image...
✓ Successfully built thunder:latest
$ thunder deploy
Deploying Thunder to Kubernetes...
✓ Deployment successful!
$ # Check pod status
$ kubectl get pods -n default
NAME READY STATUS RESTARTS AGE
thunder-5f7b849d8d-x2jtl 1/1 Running 0 30s
postgres-0 1/1 Running 0 30s
pgbouncer-7c8b6d5b4-rmvp9 1/1 Running 0 30s
$ kubectl describe pod thunder-5f7b849d8d-x2jtl -n default
Name: thunder-5f7b849d8d-x2jtl
Namespace: default
Priority: 0
...