Skip to content

Commit babf196

Browse files
authored
Merge pull request #99 from zevisert/ops/kubeify
Deploy with k8s and dev with skaffold
2 parents 3c9cdff + 0728378 commit babf196

23 files changed

Lines changed: 923 additions & 79 deletions

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
build/
2+
node_modules/
3+
4+
test/integration/screenshots-current/
5+
_site/
6+
7+
server/uploads
8+
!server/uploads/.gitfolder
9+
10+
*.env

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ server/uploads
88
!server/uploads/.gitfolder
99

1010
*.env
11+
k8s/**/*.secret.yaml

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

k8s/api.service.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app: api
6+
name: api
7+
8+
spec:
9+
type: ClusterIP
10+
selector:
11+
app: server
12+
ports:
13+
- name: api
14+
port: 80
15+
protocol: TCP
16+
targetPort: 80

k8s/ca-issuer.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: ClusterIssuer
3+
metadata:
4+
name: ca-issuer
5+
namespace: cert-manager
6+
spec:
7+
ca:
8+
secretName: ca-key-pair

k8s/dev/ingress.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: zuzi-ingress
5+
6+
spec:
7+
ingressClassName: nginx
8+
rules:
9+
- host: kubernetes.docker.internal
10+
http:
11+
paths:
12+
- path: /api/v1
13+
pathType: Prefix
14+
backend:
15+
service:
16+
name: api
17+
port:
18+
name: api
19+
- path: /uploads
20+
pathType: Prefix
21+
backend:
22+
service:
23+
name: api
24+
port:
25+
name: api
26+
- path: /
27+
pathType: Prefix
28+
backend:
29+
service:
30+
name: http
31+
port:
32+
name: http

k8s/dev/namespace.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: zuzi-dev

k8s/frontend.deployment.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: frontend
6+
name: frontend
7+
8+
spec:
9+
progressDeadlineSeconds: 600
10+
replicas: 1
11+
revisionHistoryLimit: 10
12+
selector:
13+
matchLabels:
14+
app: frontend
15+
strategy:
16+
rollingUpdate:
17+
maxSurge: 25%
18+
maxUnavailable: 25%
19+
type: RollingUpdate
20+
template:
21+
metadata:
22+
labels:
23+
app: frontend
24+
spec:
25+
containers:
26+
- image: zevisert/zuzi-site-frontend
27+
imagePullPolicy: IfNotPresent
28+
name: zuzi-site
29+
ports:
30+
- containerPort: 80
31+
resources:
32+
limits:
33+
cpu: 500m
34+
memory: 500M
35+
requests:
36+
cpu: 100m
37+
memory: 100M
38+
dnsPolicy: ClusterFirst
39+
restartPolicy: Always
40+
terminationGracePeriodSeconds: 5

k8s/http.service.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app: http
6+
name: http
7+
8+
spec:
9+
type: ClusterIP
10+
selector:
11+
app: frontend
12+
ports:
13+
- name: http
14+
port: 80
15+
protocol: TCP
16+
targetPort: 80
17+

k8s/mongodb.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# yaml-language-server: $schema=../schemas/mongodb-kubernetes-operator/master/mongodbcommunity.mongodbcommunity.mongodb.com-v1.json
2+
apiVersion: mongodbcommunity.mongodb.com/v1
3+
kind: MongoDBCommunity
4+
metadata:
5+
name: mongodb
6+
spec:
7+
members: 2
8+
arbiters: 1
9+
type: ReplicaSet
10+
version: "5.0.3"
11+
security:
12+
authentication:
13+
modes:
14+
- SCRAM
15+
users:
16+
- name: koa
17+
db: admin
18+
passwordSecretRef:
19+
name: env
20+
key: MONGO_PW
21+
roles:
22+
- name: clusterAdmin
23+
db: admin
24+
- name: dbAdminAnyDatabase
25+
db: admin
26+
- name: dbOwner
27+
db: admin
28+
- name: readWriteAnyDatabase
29+
db: admin
30+
scramCredentialsSecretName: mongodb-scram
31+
statefulSet:
32+
spec:
33+
template:
34+
metadata:
35+
labels:
36+
environment: production
37+
spec:
38+
affinity:
39+
podAntiAffinity:
40+
# read: A pod should not be scheduled on the node if a pod with
41+
# the label environment=production is already running on it.
42+
preferredDuringSchedulingIgnoredDuringExecution:
43+
- weight: 100
44+
podAffinityTerm:
45+
labelSelector:
46+
matchExpressions:
47+
- key: environment
48+
operator: In
49+
values:
50+
- production
51+
topologyKey: kubernetes.io/hostname
52+
containers:
53+
- name: mongod
54+
resources:
55+
limits:
56+
cpu: 600m
57+
memory: 500M
58+
requests:
59+
cpu: 200m
60+
memory: 200M
61+
- name: mongodb-agent
62+
resources:
63+
limits:
64+
cpu: 500m
65+
memory: 250M
66+
requests:
67+
cpu: 100m
68+
memory: 100M
69+
---
70+
71+
# These resources are from the mongodb-kubernetes-operator repository
72+
apiVersion: v1
73+
kind: ServiceAccount
74+
metadata:
75+
name: mongodb-kubernetes-operator
76+
---
77+
apiVersion: rbac.authorization.k8s.io/v1
78+
kind: Role
79+
metadata:
80+
name: mongodb-kubernetes-operator
81+
rules:
82+
- apiGroups: [""]
83+
verbs: ["create", "delete", "get", "list", "patch", "update", "watch"]
84+
resources: ["pods", "services", "configmaps", "secrets"]
85+
86+
- apiGroups: ["apps"]
87+
verbs: ["create", "delete", "get", "list", "patch", "update", "watch"]
88+
resources: ["statefulsets"]
89+
90+
- apiGroups: ["mongodbcommunity.mongodb.com"]
91+
verbs: ["get", "patch", "list", "update", "watch"]
92+
resources:
93+
- mongodbcommunity
94+
- mongodbcommunity/status
95+
- mongodbcommunity/spec
96+
- mongodbcommunity/finalizers
97+
---
98+
apiVersion: rbac.authorization.k8s.io/v1
99+
kind: RoleBinding
100+
metadata:
101+
name: mongodb-kubernetes-operator
102+
roleRef:
103+
apiGroup: rbac.authorization.k8s.io
104+
kind: Role
105+
name: mongodb-kubernetes-operator
106+
subjects:
107+
- kind: ServiceAccount
108+
name: mongodb-kubernetes-operator

0 commit comments

Comments
 (0)