Add namespace, secret for image registry, and prod configs
This commit is contained in:
@@ -2,6 +2,7 @@ apiVersion: apps/v1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-backend
|
name: todo-backend
|
||||||
|
namespace: todo-test
|
||||||
labels:
|
labels:
|
||||||
app: todo-backend
|
app: todo-backend
|
||||||
spec:
|
spec:
|
||||||
@@ -14,10 +15,12 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: todo-backend
|
app: todo-backend
|
||||||
spec:
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: todo-registry-secret
|
||||||
containers:
|
containers:
|
||||||
- name: todo-backend
|
- name: todo-backend
|
||||||
image: todo-backend:latest
|
image: ccr.ccs.tencentyun.com/todo-test/todo-backend:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
env:
|
env:
|
||||||
@@ -34,7 +37,7 @@ spec:
|
|||||||
- name: SPRING_DATASOURCE_PASSWORD
|
- name: SPRING_DATASOURCE_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: todo-secret
|
name: todo-db-secret
|
||||||
key: DATABASE_PASSWORD
|
key: DATABASE_PASSWORD
|
||||||
- name: SPRING_REDIS_HOST
|
- name: SPRING_REDIS_HOST
|
||||||
valueFrom:
|
valueFrom:
|
||||||
@@ -70,6 +73,7 @@ apiVersion: apps/v1
|
|||||||
kind: StatefulSet
|
kind: StatefulSet
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-postgres
|
name: todo-postgres
|
||||||
|
namespace: todo-test
|
||||||
labels:
|
labels:
|
||||||
app: todo-postgres
|
app: todo-postgres
|
||||||
spec:
|
spec:
|
||||||
@@ -99,7 +103,7 @@ spec:
|
|||||||
- name: POSTGRES_PASSWORD
|
- name: POSTGRES_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: todo-secret
|
name: todo-db-secret
|
||||||
key: DATABASE_PASSWORD
|
key: DATABASE_PASSWORD
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: postgres-data
|
- name: postgres-data
|
||||||
@@ -124,6 +128,7 @@ apiVersion: apps/v1
|
|||||||
kind: StatefulSet
|
kind: StatefulSet
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-redis
|
name: todo-redis
|
||||||
|
namespace: todo-test
|
||||||
labels:
|
labels:
|
||||||
app: todo-redis
|
app: todo-redis
|
||||||
spec:
|
spec:
|
||||||
@@ -142,7 +147,7 @@ spec:
|
|||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 6379
|
- containerPort: 6379
|
||||||
command: ["redis-server", "--requirepass", ""]
|
command: ["redis-server"]
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
memory: "128Mi"
|
memory: "128Mi"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-backend
|
name: todo-backend
|
||||||
|
namespace: todo-test
|
||||||
spec:
|
spec:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
selector:
|
selector:
|
||||||
@@ -15,6 +16,7 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-postgres
|
name: todo-postgres
|
||||||
|
namespace: todo-test
|
||||||
spec:
|
spec:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
selector:
|
selector:
|
||||||
@@ -28,6 +30,7 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-redis
|
name: todo-redis
|
||||||
|
namespace: todo-test
|
||||||
spec:
|
spec:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
selector:
|
selector:
|
||||||
|
|||||||
@@ -2,6 +2,19 @@ apiVersion: v1
|
|||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-config
|
name: todo-config
|
||||||
|
namespace: todo-test
|
||||||
|
data:
|
||||||
|
DATABASE_URL: "jdbc:postgresql://todo-postgres:5432/building_materials"
|
||||||
|
DATABASE_USERNAME: "postgres"
|
||||||
|
REDIS_HOST: "todo-redis"
|
||||||
|
REDIS_PORT: "6379"
|
||||||
|
API_BASE_URL: "http://todo-backend:8080"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: todo-config
|
||||||
|
namespace: todo-prod
|
||||||
data:
|
data:
|
||||||
DATABASE_URL: "jdbc:postgresql://todo-postgres:5432/building_materials"
|
DATABASE_URL: "jdbc:postgresql://todo-postgres:5432/building_materials"
|
||||||
DATABASE_USERNAME: "postgres"
|
DATABASE_USERNAME: "postgres"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ apiVersion: apps/v1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-frontend
|
name: todo-frontend
|
||||||
|
namespace: todo-test
|
||||||
labels:
|
labels:
|
||||||
app: todo-frontend
|
app: todo-frontend
|
||||||
spec:
|
spec:
|
||||||
@@ -14,10 +15,12 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: todo-frontend
|
app: todo-frontend
|
||||||
spec:
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: todo-registry-secret
|
||||||
containers:
|
containers:
|
||||||
- name: todo-frontend
|
- name: todo-frontend
|
||||||
image: todo-frontend:latest
|
image: ccr.ccs.tencentyun.com/todo-test/todo-frontend:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-frontend
|
name: todo-frontend
|
||||||
|
namespace: todo-test
|
||||||
spec:
|
spec:
|
||||||
type: NodePort
|
type: NodePort
|
||||||
selector:
|
selector:
|
||||||
|
|||||||
13
k8s/namespace.yaml
Normal file
13
k8s/namespace.yaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: todo-test
|
||||||
|
labels:
|
||||||
|
env: test
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: todo-prod
|
||||||
|
labels:
|
||||||
|
env: production
|
||||||
50
k8s/prod/deployment.yaml
Normal file
50
k8s/prod/deployment.yaml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: todo-frontend
|
||||||
|
namespace: todo-prod
|
||||||
|
labels:
|
||||||
|
app: todo-frontend
|
||||||
|
spec:
|
||||||
|
replicas: 2
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: todo-frontend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: todo-frontend
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: todo-registry-secret
|
||||||
|
containers:
|
||||||
|
- name: todo-frontend
|
||||||
|
image: ccr.ccs.tencentyun.com/todo-prod/todo-frontend:v1.0.0
|
||||||
|
imagePullPolicy: Always
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
env:
|
||||||
|
- name: API_BASE_URL
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: todo-config
|
||||||
|
key: API_BASE_URL
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "64Mi"
|
||||||
|
cpu: "50m"
|
||||||
|
limits:
|
||||||
|
memory: "128Mi"
|
||||||
|
cpu: "200m"
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: 80
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 10
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: 80
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
14
k8s/prod/service.yaml
Normal file
14
k8s/prod/service.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: todo-frontend
|
||||||
|
namespace: todo-prod
|
||||||
|
spec:
|
||||||
|
type: NodePort
|
||||||
|
selector:
|
||||||
|
app: todo-frontend
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 80
|
||||||
|
protocol: TCP
|
||||||
|
nodePort: 30080
|
||||||
@@ -1,7 +1,18 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
name: todo-secret
|
name: todo-registry-secret
|
||||||
type: Opaque
|
namespace: todo-test
|
||||||
stringData:
|
type: kubernetes.io/dockerconfigjson
|
||||||
DATABASE_PASSWORD: "postgres"
|
data:
|
||||||
|
# base64 encoded: {"auths":{"ccr.ccs.tencentyun.com":{"username":"100024540033","password":"Mb83201048","email":"","auth":"MTAwMDI0NTQwMDMzOk1iODMyMDE0OA=="}}}
|
||||||
|
.dockerconfigjson: eyJhdXRocyI6eyJjY3IuY2NzLnRlbmNlbnR5dW4uY29tIjp7InVzZXJuYW1lIjoiMTAwMDI0NTQwMzMiLCJwYXNzd29yZCI6Ik1iODMyMDE0OCIsImVtYWlsIjoiIiwiYXV0aCI6Ik1hVjFhM2xFYldFPSJ9fX0=
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: todo-registry-secret
|
||||||
|
namespace: todo-prod
|
||||||
|
type: kubernetes.io/dockerconfigjson
|
||||||
|
data:
|
||||||
|
.dockerconfigjson: eyJhdXRocyI6eyJjY3IuY2NzLnRlbmNlbnR5dW4uY29tIjp7InVzZXJuYW1lIjoiMTAwMDI0NTQwMzMiLCJwYXNzd29yZCI6Ik1iODMyMDE0OCIsImVtYWlsIjoiIiwiYXV0aCI6Ik1hVjFhM2xFYldFPSJ9fX0=
|
||||||
|
|||||||
Reference in New Issue
Block a user