url-shortener: helm chart with cue config file (#89)
* added cue file for url-shortener
* added yaml files for url-shortener
* fixed yaml and cue for url-shortener
* port variable fix
* cue minor fix
* added url-shortener into appstore svg change
* minor fixes
* version fix
* added url-shortener into app.go
diff --git a/charts/url-shortener/.helmignore b/charts/url-shortener/.helmignore
new file mode 100644
index 0000000..0e8a0eb
--- /dev/null
+++ b/charts/url-shortener/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/charts/url-shortener/Chart.yaml b/charts/url-shortener/Chart.yaml
new file mode 100644
index 0000000..bb2151d
--- /dev/null
+++ b/charts/url-shortener/Chart.yaml
@@ -0,0 +1,6 @@
+apiVersion: v2
+name: url-shortener
+description: A Helm chart for URL shortener application
+type: application
+version: 0.0.1
+appVersion: "0.0.1"
diff --git a/charts/url-shortener/templates/install.yaml b/charts/url-shortener/templates/install.yaml
new file mode 100644
index 0000000..53125f5
--- /dev/null
+++ b/charts/url-shortener/templates/install.yaml
@@ -0,0 +1,78 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: url-shortener
+ namespace: {{ .Release.Namespace }}
+spec:
+ type: ClusterIP
+ selector:
+ app: url-shortener
+ ports:
+ - name: http
+ protocol: TCP
+ port: 80
+ targetPort: {{ .Values.port }}
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: ingress
+ namespace: {{ .Release.Namespace }}
+{{- if .Values.certificateIssuer }}
+ annotations:
+ acme.cert-manager.io/http01-edit-in-place: "true"
+ cert-manager.io/cluster-issuer: {{ .Values.certificateIssuer }}
+{{- end }}
+spec:
+ ingressClassName: {{ .Values.ingressClassName }}
+{{- if .Values.certificateIssuer }}
+ tls:
+ - hosts:
+ - {{ .Values.domain }}
+ secretName: cert-url-shortener
+{{- end }}
+ rules:
+ - host: {{ .Values.domain }}
+ http:
+ paths:
+ - path: /
+ pathType: Prefix
+ backend:
+ service:
+ name: url-shortener
+ port:
+ name: http
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: url-shortener
+ namespace: {{ .Release.Namespace }}
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: url-shortener
+ template:
+ metadata:
+ labels:
+ app: url-shortener
+ spec:
+ containers:
+ - name: url-shortener
+ image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
+ ports:
+ - name: http
+ containerPort: {{ .Values.port }}
+ protocol: TCP
+ command:
+ - url-shortener
+ - --port={{ .Values.port }}
+ - --db-path="/data/urls.db"
+ volumeMounts:
+ - name: url-shortener
+ mountPath: /data
+ volumes:
+ - name: url-shortener
+ persistentVolumeClaim:
+ claimName: url-shortener
diff --git a/charts/url-shortener/templates/volume.yaml b/charts/url-shortener/templates/volume.yaml
new file mode 100644
index 0000000..992e601
--- /dev/null
+++ b/charts/url-shortener/templates/volume.yaml
@@ -0,0 +1,11 @@
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+ name: url-shortener
+ namespace: {{ .Release.Namespace }}
+spec:
+ accessModes:
+ - ReadWriteOnce
+ resources:
+ requests:
+ storage: {{ .Values.storage.size }}
diff --git a/charts/url-shortener/values.yaml b/charts/url-shortener/values.yaml
new file mode 100644
index 0000000..a62dc10
--- /dev/null
+++ b/charts/url-shortener/values.yaml
@@ -0,0 +1,11 @@
+image:
+ repository: giolekva/url-shortener
+ name: url-shortener
+ tag: latest
+ pullPolicy: Always
+ingressClassName: ingress-public
+certificateIssuer: example-public
+domain: url-shortener.example.com
+storage:
+ size: 1Gi
+port: 8080
diff --git a/core/installer/app.go b/core/installer/app.go
index 058c31b..fa2e270 100644
--- a/core/installer/app.go
+++ b/core/installer/app.go
@@ -33,6 +33,7 @@
"values-tmpl/rpuppy.cue",
"values-tmpl/soft-serve.cue",
"values-tmpl/vaultwarden.cue",
+ "values-tmpl/url-shortener.cue",
}
var infraAppConfigs = []string{
diff --git a/core/installer/values-tmpl/url-shortener.cue b/core/installer/values-tmpl/url-shortener.cue
new file mode 100644
index 0000000..d2d7e84
--- /dev/null
+++ b/core/installer/values-tmpl/url-shortener.cue
@@ -0,0 +1,52 @@
+input: {
+ network: #Network
+ subdomain: string
+}
+
+_domain: "\(input.subdomain).\(input.network.domain)"
+
+name: "url-shortener"
+namespace: "app-url-shortener"
+readme: "URL shortener application will be installed on \(input.network.name) network and be accessible at https://\(_domain)"
+description: "Provides URL shortening service. Can be configured to be reachable only from private network or publicly."
+icon: "<svg xmlns='http://www.w3.org/2000/svg" width="40.63" height="50" viewBox="0 0 13 16"><circle cx="2" cy="10" r="1" fill="currentColor"/><circle cx="2" cy="6" r="1" fill="currentColor"/><path fill="currentColor" d="M4.5 14c-.06 0-.11 0-.17-.03a.501.501 0 0 1-.3-.64l4-11a.501.501 0 0 1 .94.34l-4 11c-.07.2-.27.33-.47.33m3 0c-.06 0-.11 0-.17-.03a.501.501 0 0 1-.3-.64l4-11a.501.501 0 0 1 .94.34l-4 11c-.07.2-.27.33-.47.33'/></svg>"
+
+images: {
+ urlShortener: {
+ repository: "giolekva"
+ name: "url-shortener"
+ tag: "latest"
+ pullPolicy: "Always"
+ }
+}
+
+charts: {
+ urlShortener: {
+ chart: "charts/url-shortener"
+ sourceRef: {
+ kind: "GitRepository"
+ name: "pcloud"
+ namespace: global.id
+ }
+ }
+}
+
+helm: {
+ "url-shortener": {
+ chart: charts.url-shortener
+ values: {
+ ingressClassName: input.network.ingressClass
+ certificateIssuer: input.network.certificateIssuer
+ domain: _domain
+ storage: {
+ size: "1Gi"
+ }
+ image: {
+ repository: images.urlShortener.fullName
+ tag: images.urlShortener.tag
+ pullPolicy: images.urlShortener.pullPolicy
+ }
+ port: 8080
+ }
+ }
+}