Initial commit: add .gitignore and README
This commit is contained in:
39
api-gateway/kong/install.sh
Executable file
39
api-gateway/kong/install.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
# Install Kong API Gateway
|
||||
|
||||
set -e
|
||||
|
||||
NAMESPACE="api-gateway"
|
||||
|
||||
echo "🚪 Installing Kong API Gateway..."
|
||||
|
||||
# Check prerequisites
|
||||
command -v kubectl >/dev/null 2>&1 || { echo "❌ kubectl not found"; exit 1; }
|
||||
|
||||
# Create namespace
|
||||
echo "📦 Creating namespace: $NAMESPACE"
|
||||
kubectl create namespace "$NAMESPACE" --dry-run=client -o yaml | kubectl apply -f -
|
||||
|
||||
# Create ConfigMap from kong.yaml
|
||||
echo "📝 Creating Kong configuration..."
|
||||
kubectl create configmap kong-config \
|
||||
--from-file=kong.yaml=kong.yaml \
|
||||
--namespace="$NAMESPACE" \
|
||||
--dry-run=client -o yaml | kubectl apply -f -
|
||||
|
||||
# Apply deployment
|
||||
echo "🚀 Deploying Kong..."
|
||||
kubectl apply -f k8s-deployment.yaml
|
||||
|
||||
# Wait for deployment
|
||||
echo "⏳ Waiting for Kong to be ready..."
|
||||
kubectl wait --for=condition=available --timeout=300s deployment/kong -n "$NAMESPACE"
|
||||
|
||||
echo "✅ Kong API Gateway installed successfully!"
|
||||
echo ""
|
||||
echo "📝 Access Kong Admin API:"
|
||||
echo " kubectl port-forward -n $NAMESPACE svc/kong-proxy 8001:8001"
|
||||
echo ""
|
||||
echo "📝 Access Kong Proxy:"
|
||||
echo " kubectl port-forward -n $NAMESPACE svc/kong-proxy 8000:80"
|
||||
|
||||
89
api-gateway/kong/k8s-deployment.yaml
Normal file
89
api-gateway/kong/k8s-deployment.yaml
Normal file
@@ -0,0 +1,89 @@
|
||||
# Kong API Gateway Kubernetes Deployment
|
||||
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: api-gateway
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: kong
|
||||
namespace: api-gateway
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: kong
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: kong
|
||||
spec:
|
||||
containers:
|
||||
- name: kong
|
||||
image: kong:3.4
|
||||
env:
|
||||
- name: KONG_DATABASE
|
||||
value: "off"
|
||||
- name: KONG_DECLARATIVE_CONFIG
|
||||
value: "/kong/kong.yaml"
|
||||
- name: KONG_PROXY_ACCESS_LOG
|
||||
value: /dev/stdout
|
||||
- name: KONG_ADMIN_ACCESS_LOG
|
||||
value: /dev/stdout
|
||||
- name: KONG_PROXY_ERROR_LOG
|
||||
value: /dev/stderr
|
||||
- name: KONG_ADMIN_ERROR_LOG
|
||||
value: /dev/stderr
|
||||
- name: KONG_ADMIN_LISTEN
|
||||
value: "0.0.0.0:8001"
|
||||
ports:
|
||||
- name: proxy
|
||||
containerPort: 8000
|
||||
- name: admin
|
||||
containerPort: 8001
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
volumeMounts:
|
||||
- name: kong-config
|
||||
mountPath: /kong/kong.yaml
|
||||
subPath: kong.yaml
|
||||
volumes:
|
||||
- name: kong-config
|
||||
configMap:
|
||||
name: kong-config
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: kong-proxy
|
||||
namespace: api-gateway
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8000
|
||||
protocol: TCP
|
||||
name: http
|
||||
- port: 443
|
||||
targetPort: 8443
|
||||
protocol: TCP
|
||||
name: https
|
||||
selector:
|
||||
app: kong
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: kong-config
|
||||
namespace: api-gateway
|
||||
data:
|
||||
kong.yaml: |
|
||||
# Kong configuration will be loaded from kong.yaml file
|
||||
|
||||
75
api-gateway/kong/kong.yaml
Normal file
75
api-gateway/kong/kong.yaml
Normal file
@@ -0,0 +1,75 @@
|
||||
# Kong API Gateway Configuration
|
||||
|
||||
_format_version: "3.0"
|
||||
|
||||
services:
|
||||
- name: example-service
|
||||
url: http://example-service:8080
|
||||
routes:
|
||||
- name: example-route
|
||||
paths:
|
||||
- /api/example
|
||||
methods:
|
||||
- GET
|
||||
- POST
|
||||
- PUT
|
||||
- DELETE
|
||||
strip_path: false
|
||||
preserve_host: true
|
||||
|
||||
plugins:
|
||||
- name: rate-limiting
|
||||
service: example-service
|
||||
config:
|
||||
minute: 100
|
||||
hour: 1000
|
||||
policy: local
|
||||
fault_tolerant: true
|
||||
hide_client_headers: false
|
||||
|
||||
- name: cors
|
||||
service: example-service
|
||||
config:
|
||||
origins:
|
||||
- "*"
|
||||
methods:
|
||||
- GET
|
||||
- POST
|
||||
- PUT
|
||||
- DELETE
|
||||
- OPTIONS
|
||||
headers:
|
||||
- Accept
|
||||
- Accept-Version
|
||||
- Content-Length
|
||||
- Content-MD5
|
||||
- Content-Type
|
||||
- Date
|
||||
- Authorization
|
||||
exposed_headers:
|
||||
- X-Auth-Token
|
||||
credentials: true
|
||||
max_age: 3600
|
||||
|
||||
- name: jwt
|
||||
service: example-service
|
||||
config:
|
||||
uri_param_names:
|
||||
- token
|
||||
cookie_names:
|
||||
- jwt
|
||||
claims_to_verify:
|
||||
- exp
|
||||
- iat
|
||||
secret_is_base64: false
|
||||
run_on_preflight: true
|
||||
|
||||
consumers:
|
||||
- username: api-consumer
|
||||
custom_id: api-consumer-001
|
||||
|
||||
jwt_secrets:
|
||||
- consumer: api-consumer
|
||||
key: api-key-001
|
||||
secret: your-secret-key-here
|
||||
|
||||
Reference in New Issue
Block a user