From 7ce6889321a7f95ac1b42dc4ffd12bee54ae2ec5 Mon Sep 17 00:00:00 2001
From: DutchEllie <personal@quenten.nl>
Date: Sat, 12 Mar 2022 17:47:01 +0100
Subject: [PATCH] First test for drone

---
 .drone.yml                                  | 20 +++++++++++-
 .drone/helm/chart/Chart.yaml                |  0
 .drone/helm/chart/templates/deployment.yaml | 35 +++++++++++++++++++++
 .drone/helm/chart/templates/ingress.yaml    | 29 +++++++++++++++++
 .drone/helm/chart/templates/service.yaml    | 17 ++++++++++
 .drone/helm/chart/values.yaml               | 25 +++++++++++++++
 .drone/helm/values.yaml                     |  0
 7 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 .drone/helm/chart/Chart.yaml
 create mode 100644 .drone/helm/chart/templates/deployment.yaml
 create mode 100644 .drone/helm/chart/templates/ingress.yaml
 create mode 100644 .drone/helm/chart/templates/service.yaml
 create mode 100644 .drone/helm/chart/values.yaml
 create mode 100644 .drone/helm/values.yaml

diff --git a/.drone.yml b/.drone.yml
index 0572658..8bd54ee 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -11,4 +11,22 @@ steps:
     password:
       from_secret: docker_password
     repo: dutchellie/proper-website-2
-    tags: latest
\ No newline at end of file
+    tags: latest
+
+- name: deploy-staging
+  image: pelotech/drone-helm3
+  settings:
+    mode: upgrade
+    chart: .drone/helm/chart
+    namespace: default
+    release: newsite-staging
+    values_files:
+      - .drone/helm/values.yaml
+    values:
+      - ingress.tls.host: newsite.staging.dutchellie.nl
+      - ingress.hosts[0].host: newsite.staging.dutchellie.nl
+    kube_api_server:
+      from_secret: staging_api_server
+    kube_token:
+      from_secret: staging_kube_token
+    dry_run: true
\ No newline at end of file
diff --git a/.drone/helm/chart/Chart.yaml b/.drone/helm/chart/Chart.yaml
new file mode 100644
index 0000000..e69de29
diff --git a/.drone/helm/chart/templates/deployment.yaml b/.drone/helm/chart/templates/deployment.yaml
new file mode 100644
index 0000000..227fed4
--- /dev/null
+++ b/.drone/helm/chart/templates/deployment.yaml
@@ -0,0 +1,35 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ .Values.name }}
+  namespace: {{ .Release.Namespace }}
+  {{- if .Values.annotations }}
+    annotations: {{ toYaml .Values.annotations | nindent 4}}
+  {{- end}}
+spec:
+  selector:
+    matchLabels:
+      app: {{ .Values.name }}
+      release: {{ .Values.release }}
+  replicas: {{ .Values.replicas }}
+  template:
+    metadata:
+    {{- if .Values.podAnnotations }}
+      annotations:
+        {{- range $key, $value := .Values.controller.podAnnotations }}
+          {{ $key }}: {{ $value | quote }}
+        {{- end }}
+    {{- end }}
+      labels: 
+        app: {{ .Values.name }}
+        release: {{ .Values.release }}
+    spec:
+      containers:
+        - name: {{ .Values.containerName }}
+          image: {{ .Values.image }}
+          imagePullPolicy: {{ .Values.imagePullPolicy }}
+          ports:
+            - name: http
+              containerPort: 8000
+
+      
\ No newline at end of file
diff --git a/.drone/helm/chart/templates/ingress.yaml b/.drone/helm/chart/templates/ingress.yaml
new file mode 100644
index 0000000..a7c9ca8
--- /dev/null
+++ b/.drone/helm/chart/templates/ingress.yaml
@@ -0,0 +1,29 @@
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: {{ .Values.ingress.name }}
+  namespace: {{ .Release.Namespace }}
+  {{- if .Values.ingress.annotations }}
+    annotations: {{ toYaml .Values.ingress.annotations | nindent 4 }}
+  {{- end}}
+spec:
+  ingressClassName: {{ .Values.ingress.className }}
+{{- if .Values.ingress.tls }}
+  tls:
+    - hosts:
+        - {{ .Values.ingress.tls.host }}
+      secretName: {{ .Values.ingress.tls.secretName }}
+{{- end }}
+  rules:
+    {{- range .Values.ingress.hosts }}
+    - host: {{ .host | quote }}
+      http:
+        paths:
+          {{- range .paths }}
+          - path: {{ .path }}
+            pathType: {{ .pathType }}
+            backend:
+              service:
+                name: {{ .Values.service.name }}
+                port:
+                  number: 8000
\ No newline at end of file
diff --git a/.drone/helm/chart/templates/service.yaml b/.drone/helm/chart/templates/service.yaml
new file mode 100644
index 0000000..534221f
--- /dev/null
+++ b/.drone/helm/chart/templates/service.yaml
@@ -0,0 +1,17 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ .Values.service.name }}
+  namespace: {{ .Release.Namespace }}
+  {{- if .Values.service.annotations }}
+    annotations: {{ toYaml .Values.service.annotations | nindent 4}}
+  {{- end}}
+spec:
+  selector:
+    app: {{ .Values.name }}
+    release: {{ .Values.release }}
+  ports:
+    - protocol: TCP
+      name: http
+      port: 8000
+      targetPort: 8000
\ No newline at end of file
diff --git a/.drone/helm/chart/values.yaml b/.drone/helm/chart/values.yaml
new file mode 100644
index 0000000..4806436
--- /dev/null
+++ b/.drone/helm/chart/values.yaml
@@ -0,0 +1,25 @@
+name: newsite-deployment
+annotations: {}
+release: latest
+replicas: 1
+podAnnotations: {}
+containerName: newsite
+image: dutchellie/proper-website-2:latest
+imagePullPolicy: Always
+
+service:
+  name: newsite-service
+  annotations: {}
+
+ingress:
+  name: newsite-ingress
+  annotations: {}
+  className: nginx
+  tls: 
+    host: example.com
+    secretName: newsite-tls  
+  hosts:
+    - host: example.com
+      paths:
+        - path: /
+          pathType: Prefix
\ No newline at end of file
diff --git a/.drone/helm/values.yaml b/.drone/helm/values.yaml
new file mode 100644
index 0000000..e69de29