From a3a3d367eacb98ab7f39320015724c377b40e359 Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Wed, 24 Apr 2024 21:01:17 +0200 Subject: [PATCH] feat: add kubernetes deployment with kustomize (#258) Signed-off-by: Guilhem Lettron --- deploy/README.md | 75 +++++++++++++++++++++++++++++++++++++++ deploy/deployment.yaml | 29 +++++++++++++++ deploy/ingress.yaml | 20 +++++++++++ deploy/kustomization.yaml | 11 ++++++ deploy/pvc.yaml | 15 ++++++++ deploy/service.yaml | 14 ++++++++ 6 files changed, 164 insertions(+) create mode 100644 deploy/README.md create mode 100644 deploy/deployment.yaml create mode 100644 deploy/ingress.yaml create mode 100644 deploy/kustomization.yaml create mode 100644 deploy/pvc.yaml create mode 100644 deploy/service.yaml diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 0000000..100d254 --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,75 @@ +# kustomize + +## Simple + +`kustomization.yaml`: + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +metadata: + name: opengist + +resources: + - https://github.com/thomiceli/opengist/deploy/ +``` + +## Full example + +`kustomization.yaml`: + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +metadata: + name: opengist + +namespace: opengist + +resources: + - namespace.yaml + - https://github.com/thomiceli/opengist/deploy/?ref:v1.7.1 + +images: + - name: ghcr.io/thomiceli/opengist + newTag: 1.7.1 + +patches: + # Add your ingress + - path: ingress.yaml + - patch: |- + - op: add + path: /spec/rules/0/host + value: opengist.mydomain.com + target: + group: networking.k8s.io + version: v1 + kind: Ingress + name: opengist +``` + +`namespace.yaml`: + +```yaml +apiVersion: v1 +kind: Namespace +metadata: + name: opengist +``` + +`ingress.yaml`: + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: opengist + annotations: + cert-manager.io/cluster-issuer: letsencrypt-production +spec: + ingressClassName: nginx + tls: + - hosts: + - opengist.mydomain.com + secretName: opengist-tls +``` diff --git a/deploy/deployment.yaml b/deploy/deployment.yaml new file mode 100644 index 0000000..d67817f --- /dev/null +++ b/deploy/deployment.yaml @@ -0,0 +1,29 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: opengist +spec: + selector: + matchLabels: + app.kubernetes.io/name: opengist + template: + metadata: + labels: + app.kubernetes.io/name: opengist + spec: + containers: + - name: opengist + image: ghcr.io/thomiceli/opengist + ports: + - name: http + containerPort: 6157 + - name: ssh + containerPort: 2222 + volumeMounts: + - mountPath: /opengist + name: data + volumes: + - name: data + persistentVolumeClaim: + claimName: opengist-data diff --git a/deploy/ingress.yaml b/deploy/ingress.yaml new file mode 100644 index 0000000..be2ad05 --- /dev/null +++ b/deploy/ingress.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: opengist + labels: + app.kubernetes.io/name: opengist + app.kubernetes.io/component: ingress +spec: + rules: + - host: opengist.local + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: opengist + port: + name: http diff --git a/deploy/kustomization.yaml b/deploy/kustomization.yaml new file mode 100644 index 0000000..556d8b7 --- /dev/null +++ b/deploy/kustomization.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +metadata: + name: opengist + +resources: + - deployment.yaml + - pvc.yaml + - ingress.yaml + - service.yaml diff --git a/deploy/pvc.yaml b/deploy/pvc.yaml new file mode 100644 index 0000000..52afe47 --- /dev/null +++ b/deploy/pvc.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: opengist-data + labels: + app.kubernetes.io/name: opengist + app.kubernetes.io/component: data +spec: + resources: + requests: + storage: 1Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce diff --git a/deploy/service.yaml b/deploy/service.yaml new file mode 100644 index 0000000..921a857 --- /dev/null +++ b/deploy/service.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: opengist + labels: + app.kubernetes.io/name: opengist +spec: + selector: + app.kubernetes.io/name: opengist + ports: + - port: 80 + targetPort: http + name: http