diff --git a/src/main/cljc/dda/c4k_jira/jira.cljc b/src/main/cljc/dda/c4k_jira/jira.cljc index ab342ea..341fd5d 100644 --- a/src/main/cljc/dda/c4k_jira/jira.cljc +++ b/src/main/cljc/dda/c4k_jira/jira.cljc @@ -8,3 +8,21 @@ (s/def ::fqdn cm/fqdn-string?) (s/def ::issuer cm/letsencrypt-issuer?) +(defn generate-certificate [config] + (let [{:keys [fqdn issuer] + :or {issuer :staging}} config + letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer")] + (-> + (yaml/from-string (yaml/load-resource "jira/certificate.yaml")) + (assoc-in [:spec :commonName] fqdn) + (assoc-in [:spec :dnsNames] [fqdn]) + (assoc-in [:spec :issuerRef :name] letsencrypt-issuer)))) + +(defn generate-ingress [config] + (let [{:keys [fqdn issuer] + :or {issuer :staging}} config + letsencrypt-issuer (str "letsencrypt-" (name issuer) "-issuer")] + (-> + (yaml/from-string (yaml/load-resource "jira/ingress.yaml")) + (assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer) + (cm/replace-all-matching-values-by-new-value "fqdn" fqdn)))) diff --git a/src/main/resources/jira/certificate.yaml b/src/main/resources/jira/certificate.yaml new file mode 100644 index 0000000..49a75be --- /dev/null +++ b/src/main/resources/jira/certificate.yaml @@ -0,0 +1,13 @@ +apiVersion: cert-manager.io/v1alpha2 +kind: Certificate +metadata: + name: jira-cert + namespace: default +spec: + secretName: jira-secret + commonName: fqdn + dnsNames: + - fqdn + issuerRef: + name: letsencrypt-staging-issuer + kind: ClusterIssuer \ No newline at end of file diff --git a/src/main/resources/jira/ingress.yaml b/src/main/resources/jira/ingress.yaml new file mode 100644 index 0000000..f0f7c33 --- /dev/null +++ b/src/main/resources/jira/ingress.yaml @@ -0,0 +1,26 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: ingress-jira + annotations: + cert-manager.io/cluster-issuer: letsencrypt-staging-issuer + nginx.ingress.kubernetes.io/proxy-body-size: "256m" + nginx.ingress.kubernetes.io/ssl-redirect: "true" + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/proxy-connect-timeout: "300" + nginx.ingress.kubernetes.io/proxy-send-timeout: "300" + nginx.ingress.kubernetes.io/proxy-read-timeout: "300" + namespace: default +spec: + tls: + - hosts: + - fqdn + secretName: jira-secret + rules: + - host: fqdn + http: + paths: + - path: / + backend: + serviceName: jira-service + servicePort: 8080 diff --git a/src/main/resources/jira/persistent-volume.yml b/src/main/resources/jira/persistent-volume.yml new file mode 100644 index 0000000..b5e9b37 --- /dev/null +++ b/src/main/resources/jira/persistent-volume.yml @@ -0,0 +1,14 @@ +kind: PersistentVolume +apiVersion: v1 +metadata: + name: jira-pv-volume + labels: + type: local +spec: + storageClassName: manual + accessModes: + - ReadWriteOnce + capacity: + storage: 30Gi + hostPath: + path: "/var/jira" diff --git a/src/main/resources/jira/pod.yaml b/src/main/resources/jira/pod.yaml new file mode 100644 index 0000000..5c5afab --- /dev/null +++ b/src/main/resources/jira/pod.yaml @@ -0,0 +1,20 @@ +kind: Pod +apiVersion: v1 +metadata: + name: jira-app + labels: + app: jira +spec: + containers: + - name: jira-app + image: domaindrivenarchitecture/meissa-jira-crate + imagePullPolicy: IfNotPresent + command: ["/app/entrypoint.sh"] + args: ["{{fqdn}}", "{{db-user-name}}", "{{db-user-password}}"] + volumeMounts: + - mountPath: /var/jira + name: jira-data-volume + volumes: + - name: jira-data-volume + persistentVolumeClaim: + claimName: jira-pvc diff --git a/src/main/resources/jira/pvc.yaml b/src/main/resources/jira/pvc.yaml new file mode 100644 index 0000000..c89e620 --- /dev/null +++ b/src/main/resources/jira/pvc.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: jira-pvc + labels: + app: jira +spec: + storageClassName: manual + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 30Gi \ No newline at end of file diff --git a/src/main/resources/jira/service.yaml b/src/main/resources/jira/service.yaml new file mode 100644 index 0000000..f80e456 --- /dev/null +++ b/src/main/resources/jira/service.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Service +metadata: + name: jira-service +spec: + selector: + app: jira + ports: + - port: 8080