Add k8s for spring web api
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
81506bf605
commit
32c59a69f2
@ -1,2 +1,2 @@
|
||||
server:
|
||||
port: ${APP_PORT:8090}
|
||||
port: ${APP_PORT:8080}
|
@ -3,8 +3,8 @@ APP_MODULE_PATH=api
|
||||
APP_PROFILE=demo
|
||||
|
||||
# Docker Image variables
|
||||
VERSION=latest
|
||||
IMAGE=api-demo
|
||||
VERSION=demo
|
||||
IMAGE=spring-web-api
|
||||
CONTAINER=$IMAGE
|
||||
REGISTRY=registry.kh.cubetiqs.com
|
||||
EXPOSE_PORT=8080
|
||||
|
6
k8s/01-namespace.yaml
Normal file
6
k8s/01-namespace.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-web-dev
|
||||
name: spring-web-dev
|
12
k8s/02-volume.yaml
Normal file
12
k8s/02-volume.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: spring-web-dev-volume
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: nfs-client # nfs-client OR local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
22
k8s/03-secret.yaml
Normal file
22
k8s/03-secret.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: registry-secret
|
||||
stringData:
|
||||
.dockerconfigjson: |
|
||||
{"auths":{"YOUR_PRIVATE_REGISTRY_HERE":{"auth":"YOUR_SECRET_HERE"}}}
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: spring-web-dev-secret
|
||||
stringData:
|
||||
REDIS_PASSWORD: demo
|
||||
POSTGRES_USER: demo
|
||||
POSTGRES_DB: demo
|
||||
POSTGRES_PASSWORD: demo
|
||||
type: Opaque
|
57
k8s/04-postgres.yaml
Normal file
57
k8s/04-postgres.yaml
Normal file
@ -0,0 +1,57 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: postgres-service
|
||||
spec:
|
||||
selector:
|
||||
app: postgres
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: postgres-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:alpine
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_DB
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: spring-web-dev-secret
|
||||
key: POSTGRES_DB
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: spring-web-dev-secret
|
||||
key: POSTGRES_PASSWORD
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
subPath: postgresql-data
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
limits:
|
||||
cpu: 200m
|
||||
memory: 200Mi
|
||||
volumes:
|
||||
- name: postgres-data
|
||||
persistentVolumeClaim:
|
||||
claimName: spring-web-dev-volume
|
56
k8s/05-redis.yaml
Normal file
56
k8s/05-redis.yaml
Normal file
@ -0,0 +1,56 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: redis-service
|
||||
spec:
|
||||
selector:
|
||||
app: redis
|
||||
ports:
|
||||
- port: 6379
|
||||
clusterIP: None
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: redis-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
spec:
|
||||
containers:
|
||||
- name: redis
|
||||
image: redis:alpine
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
args: [ "--requirepass", "$(REDIS_PASSWORD)" ]
|
||||
env:
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: spring-web-dev-secret
|
||||
key: REDIS_PASSWORD
|
||||
volumeMounts:
|
||||
- name: redis-data
|
||||
mountPath: /data
|
||||
subPath: redis-data
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "500m"
|
||||
volumes:
|
||||
- name: redis-data
|
||||
persistentVolumeClaim:
|
||||
claimName: spring-web-dev-volume
|
46
k8s/06-app.yaml
Normal file
46
k8s/06-app.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: spring-web-service
|
||||
spec:
|
||||
selector:
|
||||
app: spring-web-api
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
type: ClusterIP
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
namespace: spring-web-dev
|
||||
name: spring-web-deployment
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: spring-web-api
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: spring-web-api
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: registry-secret
|
||||
containers:
|
||||
- name: spring-web-api
|
||||
image: registry.kh.cubetiqs.com/spring-web-api:demo
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: spring-web-dev-secret
|
||||
imagePullPolicy: Always
|
||||
resources:
|
||||
requests:
|
||||
cpu: 300m
|
||||
memory: 300Mi
|
||||
limits:
|
||||
cpu: 800m
|
||||
memory: 800Mi
|
17
k8s/07-ingress.yaml
Normal file
17
k8s/07-ingress.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: spring-web-ingress
|
||||
namespace: spring-web-dev
|
||||
spec:
|
||||
rules:
|
||||
- host: springwebapi-demo.ctdn.dev
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: spring-web-service
|
||||
port:
|
||||
number: 8080
|
||||
path: /
|
||||
pathType: Prefix
|
Loading…
Reference in New Issue
Block a user