diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d617e555c2b93e3c22365a35f74309fb9cb17ad2..3b6940b288f17754ee3d6779e5d6e3c7e71d8238 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,7 @@ stages: - lint - release include: + - /amp/pipeline.yml - /fdroid-repo/pipeline.yml - /flood/pipeline.yml - /imghost/pipeline.yml diff --git a/amp/Chart.yaml b/amp/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b8c5438f0244b3b34b6053530b0d530fd4351ee7 --- /dev/null +++ b/amp/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: amp +description: Helm Chart for amp +type: application +version: 0.1.0 +appVersion: "latest" diff --git a/amp/pipeline.yml b/amp/pipeline.yml new file mode 100644 index 0000000000000000000000000000000000000000..691de83ea78cfc33705fc51dded77a25b68340a4 --- /dev/null +++ b/amp/pipeline.yml @@ -0,0 +1,22 @@ +lint-amp: + stage: lint + rules: + - changes: + - amp/**/* + script: + - helm lint amp + +release-amp: + stage: release + needs: + - lint-amp + rules: + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + changes: + - amp/**/* + script: + - apk add --no-cache git + - helm plugin install https://github.com/chartmuseum/helm-push.git + - helm repo add --username gitlab-ci-token --password $CI_JOB_TOKEN repo ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/stable + - helm cm-push amp repo + diff --git a/amp/templates/_helpers.tpl b/amp/templates/_helpers.tpl new file mode 100644 index 0000000000000000000000000000000000000000..b280a16dce8f02afedb9bd5e3489b85a268ad2c0 --- /dev/null +++ b/amp/templates/_helpers.tpl @@ -0,0 +1,56 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "amp-helm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "amp-helm.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "amp-helm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "amp-helm.labels" -}} +helm.sh/chart: {{ include "amp-helm.chart" . }} +{{ include "amp-helm.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "amp-helm.selectorLabels" -}} +app.kubernetes.io/name: {{ include "amp-helm.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + + +{{- define "amp-helm.sslPath" -}} +/certs +{{- end }} diff --git a/amp/templates/deployment.yaml b/amp/templates/deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8cbe3429995b04c57599ff4f128e72c71b4559c5 --- /dev/null +++ b/amp/templates/deployment.yaml @@ -0,0 +1,107 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "amp-helm.fullname" . }} + labels: + {{- include "amp-helm.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "amp-helm.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "amp-helm.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + volumes: + - name: data + {{- .Values.volume | nindent 10 }} + - name: tmp + emptyDir: {} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: "AMP_LICENCE" + valueFrom: + secretKeyRef: + key: "license" + name: {{ include "amp-helm.fullname" . }} + - name: "USERNAME" + valueFrom: + secretKeyRef: + key: "admin-user" + name: {{ include "amp-helm.fullname" . }} + - name: "PASSWORD" + valueFrom: + secretKeyRef: + key: "admin-pass" + name: {{ include "amp-helm.fullname" . }} + ports: + - name: sftp + containerPort: 2224 + protocol: TCP + - name: http + containerPort: 8080 + protocol: TCP + {{- range .Values.gamePorts }} + - name: {{ .name }} + containerPort: {{ .port }} + protocol: {{ .protocol }} + {{- end }} + startupProbe: + httpGet: + path: "/API" + port: http + failureThreshold: 60 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + livenessProbe: + httpGet: + path: "/API" + port: http + initialDelaySeconds: 3 + periodSeconds: 3 + successThreshold: 1 + timeoutSeconds: 1 + readinessProbe: + httpGet: + path: "/API" + port: http + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: "/home/amp/.ampdata" + name: data + - mountPath: "/tmp" + name: tmp + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/amp/templates/ingress.yaml b/amp/templates/ingress.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b0a016b20b8b4687e36990e3b41b65892a863ae4 --- /dev/null +++ b/amp/templates/ingress.yaml @@ -0,0 +1,20 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "amp-helm.fullname" . }} + labels: + {{- include "amp-helm.labels" . | nindent 4 }} + annotations: + {{- .Values.ingress.annotations | toYaml | nindent 4 }} +spec: + rules: + - host: "{{ .Values.ingress.host }}" + http: + paths: + - path: "{{ .Values.ingress.path }}" + backend: + service: + name: {{ include "amp-helm.fullname" . }} + port: + name: http + pathType: Prefix diff --git a/amp/templates/secret.yaml b/amp/templates/secret.yaml new file mode 100644 index 0000000000000000000000000000000000000000..69707473e81614e70274ab916dd85415f7bd077f --- /dev/null +++ b/amp/templates/secret.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "amp-helm.fullname" . }} + labels: + {{- include "amp-helm.labels" . | nindent 4 }} +type: Opaque +stringData: + admin-pass: "{{ .Values.config.admin.pass }}" + admin-user: "{{ .Values.config.admin.user }}" + license: "{{ .Values.config.license }}" diff --git a/amp/templates/service.yaml b/amp/templates/service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..00091087e8bf00c3721d9e64fc3327539f1ef7d8 --- /dev/null +++ b/amp/templates/service.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "amp-helm.fullname" . }} + labels: + {{- include "amp-helm.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - name: sftp + port: 2224 + protocol: TCP + targetPort: sftp + - name: http + port: 8080 + protocol: TCP + targetPort: http + {{- range .Values.gamePorts }} + - name: {{ .name }} + port: {{ .port}} + targetPort: {{ .name }} + protocol: {{ .protocol }} + {{- end }} + selector: + {{- include "amp-helm.selectorLabels" . | nindent 4 }} diff --git a/amp/values.yaml b/amp/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d8cc32be295ae814d3ce4b86940ab876bd7d270a --- /dev/null +++ b/amp/values.yaml @@ -0,0 +1,56 @@ +replicaCount: 1 + +image: + repository: mitchtalmadge/amp-dockerized + pullPolicy: IfNotPresent + tag: "" + +imagePullSecrets: [ ] +nameOverride: "" +fullnameOverride: "" + +config: + admin: + user: "" + pass: "" + license: "" + +service: + type: ClusterIP + +ingress: + host: "example.com" + path: "/" + annotations: {} + +gamePorts: [] + +volume: |- + emptyDir: {} + +podAnnotations: { } + +podSecurityContext: { } + +securityContext: { } +# capabilities: +# drop: +# - ALL +# runAsNonRoot: true +# runAsUser: 1000 + +resources: + limits: + cpu: 4 + ephemeral-storage: 16Gi + memory: 16Gi + requests: + cpu: 2 + ephemeral-storage: 4Gi + memory: 4Gi + +nodeSelector: { } + +tolerations: [ ] + +affinity: { }