Skip to content

Commit

Permalink
add kustomization for Kubernetes deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
stv0g committed Mar 21, 2022
1 parent f9ed0aa commit eb87a4f
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ chmod +x gose
mv gose /usr/local/bin
```

### Kubernetes / Kustomize

1. Copy default configuration file: `cp config.yaml kustomize/config.yaml`
1. Adjust config: `nano kustomize/config.yaml`
1. Apply configuration: `kubectl apply -k kustomize`

### Docker

Via environment variables in `.env` file:
Expand Down
47 changes: 47 additions & 0 deletions kustomize/backend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
replicas: 3
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: ghcr.io/stv0g/gose
imagePullPolicy: Always
ports:
- containerPort: 8080
name: http
protocol: TCP
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 8080
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 2
resources:
limits:
memory: 512Mi
cpu: 500m
volumeMounts:
- mountPath: /config.yaml
name: config
subPath: config.yaml
readOnly: true
volumes:
- secret:
secretName: config
optional: false
name: config
13 changes: 13 additions & 0 deletions kustomize/backend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: Service
metadata:
name: backend
spec:
ports:
- name: http
port: 8080
targetPort: 8080
protocol: TCP
selector:
app: backend
43 changes: 43 additions & 0 deletions kustomize/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
spec:
replicas: 3
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
volumes:
- name: static-files-volume
emptyDir: {}
initContainers:
- name: copy-static
image: harbor.0l.de/stv0g/gose
command:
- cp
- -r
- /dist
- /static-files
volumeMounts:
- mountPath: /static-files
name: static-files-volume
containers:
- name: nginx
image: nginx:1.17-alpine
volumeMounts:
- mountPath: /usr/share/nginx/html
name: static-files-volume
subPath: dist
resources:
limits:
memory: 250Mi
cpu: "1"
requests:
memory: 250Mi
cpu: "500m"
13 changes: 13 additions & 0 deletions kustomize/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: Service
metadata:
name: frontend
spec:
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
selector:
app: frontend
26 changes: 26 additions & 0 deletions kustomize/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gose
spec:
ingressClassName: nginx
rules:
- host: gose-test.0l.de
http:
paths:
- path: /api/
pathType: Prefix
backend:
service:
name: backend
port:
number: 8080

- path: /
pathType: Prefix
backend:
service:
name: frontend
port:
number: 80
22 changes: 22 additions & 0 deletions kustomize/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: gose-test

resources:
- namespace.yaml
- obc.yaml
- ingress.yaml
- frontend-service.yaml
- frontend-deployment.yaml
- backend-service.yaml
- backend-deployment.yaml

secretGenerator:
- name: config
files:
- config.yaml

generatorOptions:
disableNameSuffixHash: true
5 changes: 5 additions & 0 deletions kustomize/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: gose
8 changes: 8 additions & 0 deletions kustomize/obc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: objectbucket.io/v1alpha1
kind: ObjectBucketClaim
metadata:
name: uploads
spec:
bucketName: gose-uploads
storageClassName: rook-ceph-bucket

0 comments on commit eb87a4f

Please sign in to comment.