diff --git a/README.md b/README.md index c364907..947faa9 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/kustomize/backend-deployment.yaml b/kustomize/backend-deployment.yaml new file mode 100644 index 0000000..e449e66 --- /dev/null +++ b/kustomize/backend-deployment.yaml @@ -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 diff --git a/kustomize/backend-service.yaml b/kustomize/backend-service.yaml new file mode 100644 index 0000000..2bd74f5 --- /dev/null +++ b/kustomize/backend-service.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: backend +spec: + ports: + - name: http + port: 8080 + targetPort: 8080 + protocol: TCP + selector: + app: backend diff --git a/kustomize/frontend-deployment.yaml b/kustomize/frontend-deployment.yaml new file mode 100644 index 0000000..8d552a9 --- /dev/null +++ b/kustomize/frontend-deployment.yaml @@ -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" diff --git a/kustomize/frontend-service.yaml b/kustomize/frontend-service.yaml new file mode 100644 index 0000000..9e5a4be --- /dev/null +++ b/kustomize/frontend-service.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: frontend +spec: + ports: + - name: http + port: 80 + targetPort: 80 + protocol: TCP + selector: + app: frontend diff --git a/kustomize/ingress.yaml b/kustomize/ingress.yaml new file mode 100644 index 0000000..83fafa6 --- /dev/null +++ b/kustomize/ingress.yaml @@ -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 diff --git a/kustomize/kustomization.yaml b/kustomize/kustomization.yaml new file mode 100644 index 0000000..4ea1e0a --- /dev/null +++ b/kustomize/kustomization.yaml @@ -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 diff --git a/kustomize/namespace.yaml b/kustomize/namespace.yaml new file mode 100644 index 0000000..97c59cc --- /dev/null +++ b/kustomize/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: gose diff --git a/kustomize/obc.yaml b/kustomize/obc.yaml new file mode 100644 index 0000000..9ea0fd5 --- /dev/null +++ b/kustomize/obc.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: objectbucket.io/v1alpha1 +kind: ObjectBucketClaim +metadata: + name: uploads +spec: + bucketName: gose-uploads + storageClassName: rook-ceph-bucket