init
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
{{#if isPostgres}}
|
||||
# --- PostgreSQL Deployment ---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: "{{appName}}-db"
|
||||
namespace: "{{namespace}}"
|
||||
labels:
|
||||
app: "{{appName}}-db"
|
||||
managed-by: cloudhost
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: "{{appName}}-db"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: "{{appName}}-db"
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:16-alpine
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_DB
|
||||
value: "{{dbName}}"
|
||||
- name: POSTGRES_USER
|
||||
value: "appuser"
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: "{{appName}}-db-secret"
|
||||
key: password
|
||||
volumeMounts:
|
||||
- name: db-storage
|
||||
mountPath: /var/lib/postgresql/data
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
memory: "256Mi"
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: "512Mi"
|
||||
volumes:
|
||||
- name: db-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: "{{appName}}-db"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: "{{appName}}-db"
|
||||
namespace: "{{namespace}}"
|
||||
spec:
|
||||
selector:
|
||||
app: "{{appName}}-db"
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
type: ClusterIP
|
||||
{{/if}}
|
||||
|
||||
{{#if isMysql}}
|
||||
# --- MySQL Deployment ---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: "{{appName}}-db"
|
||||
namespace: "{{namespace}}"
|
||||
labels:
|
||||
app: "{{appName}}-db"
|
||||
managed-by: cloudhost
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: "{{appName}}-db"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: "{{appName}}-db"
|
||||
spec:
|
||||
containers:
|
||||
- name: mysql
|
||||
image: mysql:8.0
|
||||
ports:
|
||||
- containerPort: 3306
|
||||
env:
|
||||
- name: MYSQL_DATABASE
|
||||
value: "{{dbName}}"
|
||||
- name: MYSQL_USER
|
||||
value: "appuser"
|
||||
- name: MYSQL_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: "{{appName}}-db-secret"
|
||||
key: password
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: "{{appName}}-db-secret"
|
||||
key: password
|
||||
volumeMounts:
|
||||
- name: db-storage
|
||||
mountPath: /var/lib/mysql
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
memory: "256Mi"
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: "512Mi"
|
||||
volumes:
|
||||
- name: db-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: "{{appName}}-db"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: "{{appName}}-db"
|
||||
namespace: "{{namespace}}"
|
||||
spec:
|
||||
selector:
|
||||
app: "{{appName}}-db"
|
||||
ports:
|
||||
- port: 3306
|
||||
targetPort: 3306
|
||||
type: ClusterIP
|
||||
{{/if}}
|
||||
@@ -0,0 +1,65 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: "{{appName}}"
|
||||
namespace: "{{namespace}}"
|
||||
labels:
|
||||
app: "{{appName}}"
|
||||
runtime: "{{runtime}}"
|
||||
managed-by: cloudhost
|
||||
spec:
|
||||
replicas: {{replicas}}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: "{{appName}}"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: "{{appName}}"
|
||||
runtime: "{{runtime}}"
|
||||
spec:
|
||||
containers:
|
||||
- name: "{{appName}}"
|
||||
image: "{{image}}"
|
||||
ports:
|
||||
- containerPort: {{port}}
|
||||
{{#if hasEnvVars}}
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: "{{appName}}-env"
|
||||
{{/if}}
|
||||
{{#if hasDatabase}}
|
||||
env:
|
||||
- name: DB_HOST
|
||||
value: "{{appName}}-db"
|
||||
- name: DB_PORT
|
||||
value: "{{dbPort}}"
|
||||
- name: DB_NAME
|
||||
value: "{{dbName}}"
|
||||
- name: DB_USER
|
||||
value: "appuser"
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: "{{appName}}-db-secret"
|
||||
key: password
|
||||
{{/if}}
|
||||
resources:
|
||||
requests:
|
||||
cpu: "{{cpuRequest}}"
|
||||
memory: "{{memoryRequest}}"
|
||||
limits:
|
||||
cpu: "{{cpuLimit}}"
|
||||
memory: "{{memoryLimit}}"
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: {{port}}
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: {{port}}
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
@@ -0,0 +1,28 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: "{{appName}}"
|
||||
namespace: "{{namespace}}"
|
||||
labels:
|
||||
app: "{{appName}}"
|
||||
managed-by: cloudhost
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: nginx
|
||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: "50m"
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
- "{{subdomain}}.{{domain}}"
|
||||
secretName: "{{appName}}-tls"
|
||||
rules:
|
||||
- host: "{{subdomain}}.{{domain}}"
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: "{{appName}}"
|
||||
port:
|
||||
number: 80
|
||||
@@ -0,0 +1,7 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: "{{namespace}}"
|
||||
labels:
|
||||
managed-by: cloudhost
|
||||
user: "{{userId}}"
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: "{{name}}"
|
||||
namespace: "{{namespace}}"
|
||||
labels:
|
||||
managed-by: cloudhost
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: "{{size}}"
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: "{{name}}"
|
||||
namespace: "{{namespace}}"
|
||||
labels:
|
||||
managed-by: cloudhost
|
||||
type: Opaque
|
||||
data:
|
||||
{{#each data}}
|
||||
{{@key}}: "{{this}}"
|
||||
{{/each}}
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: "{{appName}}"
|
||||
namespace: "{{namespace}}"
|
||||
labels:
|
||||
app: "{{appName}}"
|
||||
managed-by: cloudhost
|
||||
spec:
|
||||
selector:
|
||||
app: "{{appName}}"
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: {{port}}
|
||||
protocol: TCP
|
||||
type: ClusterIP
|
||||
Reference in New Issue
Block a user