Skip to content

Commit

Permalink
Merge pull request #94 from tillias/dev-79
Browse files Browse the repository at this point in the history
k8s deployment scripts #88
  • Loading branch information
tillias authored Nov 4, 2020
2 parents c180713 + 5520936 commit 4c50122
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/main/k8s/config-maps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
namespace: microservice-catalog
data:
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_USER: microservice-catalog
POSTGRES_DB: microservice-catalog
42 changes: 42 additions & 0 deletions src/main/k8s/database-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-deployment
namespace: microservice-catalog
labels:
app: microservice-catalog
tier: database
spec:
replicas: 1
selector:
matchLabels:
app: microservice-catalog
tier: database
template:
metadata:
labels:
app: microservice-catalog
tier: database
spec:
containers:
- name: postgres
image: postgres
envFrom:
- configMapRef:
name: postgres-config
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: postgres-secret
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-pv-claim
ports:
- containerPort: 5432
protocol: TCP
volumes:
- name: postgres-pv-claim
persistentVolumeClaim:
claimName: postgres-pv-claim
11 changes: 11 additions & 0 deletions src/main/k8s/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- namespace.yaml
- secrets.yaml
- config-maps.yaml
- storage.yaml
- services.yaml
- database-deployment.yaml
- microservice-catalog-deployment.yaml
50 changes: 50 additions & 0 deletions src/main/k8s/microservice-catalog-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: microservice-catalog
namespace: microservice-catalog
labels:
app: microservice-catalog
tier: business
spec:
replicas: 1
selector:
matchLabels:
app: microservice-catalog
tier: business
template:
metadata:
labels:
app: microservice-catalog
tier: business
spec:
containers:
- name: microservice-catalog
image: tillias/microcatalog
env:
- name: DB_HOST
value: postgres-service
- name: DB_PORT
value: "5432"
- name: DB_NAME
valueFrom:
configMapKeyRef:
key: POSTGRES_DB
name: postgres-config
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: postgres-secret
- name: DB_USER
valueFrom:
configMapKeyRef:
key: POSTGRES_USER
name: postgres-config
- name: CSP_IMAGE_SRC
value: "'*'"
- name: SERVER_PORT
value: "8081"
ports:
- containerPort: 8081
protocol: TCP
4 changes: 4 additions & 0 deletions src/main/k8s/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: microservice-catalog
8 changes: 8 additions & 0 deletions src/main/k8s/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
namespace: microservice-catalog
type: Opaque
data:
POSTGRES_PASSWORD: a0V0I3VSNk0=
37 changes: 37 additions & 0 deletions src/main/k8s/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: v1
kind: Service
metadata:
name: postgres-service
namespace: microservice-catalog
labels:
app: microservice-catalog
tier: service
spec:
ports:
- name: postgres
port: 5432
targetPort: 5432
protocol: TCP
selector:
app: microservice-catalog
tier: database

---
apiVersion: v1
kind: Service
metadata:
name: microservice-catalog-service
namespace: microservice-catalog
labels:
app: microservice-catalog
tier: service
spec:
ports:
- name: microservice-catalog
port: 8081
targetPort: 8081
protocol: TCP
type: LoadBalancer
selector:
app: microservice-catalog
tier: business
13 changes: 13 additions & 0 deletions src/main/k8s/storage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pv-claim
namespace: microservice-catalog
labels:
app: microservice-catalog
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50M
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
import com.github.microcatalog.utils.MicroserviceBuilder;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;

import java.util.Optional;
Expand Down

0 comments on commit 4c50122

Please sign in to comment.