Introduce drone.yml and media-share
This commit is contained in:
parent
7b483115b9
commit
d53f205e52
23
.drone.yml
Normal file
23
.drone.yml
Normal file
@ -0,0 +1,23 @@
|
||||
kind: pipeline
|
||||
name: publish
|
||||
type: docker
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
|
||||
steps:
|
||||
- name: step1
|
||||
image: alpine
|
||||
commands:
|
||||
- ./build-tools/upload-new-versions.sh
|
||||
environment:
|
||||
GITEA_PASSWORD:
|
||||
from_secret: gitea_password
|
||||
|
||||
image_pull_secrets:
|
||||
- dockerconfigjson
|
@ -15,6 +15,11 @@ $ curl --user <username>:<password> -X POST --upload-file ./<package>.tgz https:
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
$ helm repo add --username <username> --password <password> <repo-alias> https://hostname.of.gitea/api/packages/scubbo/helm
|
||||
$ helm repo add --username <username> --password <password> <repo-alias> https://hostname.of.gitea/api/packages/<user>/helm
|
||||
$ helm install <release-name> <repo-alias>/<name>
|
||||
```
|
||||
|
||||
## Other links
|
||||
|
||||
* [General documentation on repositories](https://helm.sh/docs/topics/chart_repository/)
|
||||
* [Gitea's own documentation](https://docs.gitea.com/next/usage/packages/helm)
|
36
build-tools/upload-new-versions.sh
Executable file
36
build-tools/upload-new-versions.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
apk add git curl jq helm;
|
||||
# Intentionally does not handle renames, which would begin with `R`.
|
||||
changed_charts=$(git show --name-status --pretty="format:" | grep '^[MA]' | cut -f 2- | grep '^charts' | cut -d '/' -f 1,2 | sort | uniq);
|
||||
echo "$changed_charts";
|
||||
current_versions=$(curl -s --user scubbo:$GITEA_PASSWORD https://gitea.scubbo.org/api/v1/packages/scubbo | jq -r '.[] | select(.type == "helm") | .name + "___" + .version');
|
||||
echo "$current_versions";
|
||||
|
||||
mkdir bundles;
|
||||
for changed_chart in $changed_charts
|
||||
do
|
||||
echo "Operating on $changed_chart";
|
||||
# e.g. /Users/scubbo/Code/helm-charts/hello-world-0.1.1.tgz
|
||||
output_location=$(helm package $changed_chart | rev | cut -d ' ' -f 1 | rev);
|
||||
# e.g. hello-world-0.1.1
|
||||
file_metadata=$(echo $output_location | rev | cut -d '/' -f 1 | cut -c 5- | rev);
|
||||
chart_name=$(echo $file_metadata | rev | cut -d '-' -f 2- | rev);
|
||||
chart_version=$(echo $file_metadata | rev | cut -d '-' -f 1 | rev);
|
||||
if [[ $(echo $current_versions | grep "$chart_name___$chart_version" | wc -l ) -eq 1 ]]; then
|
||||
# I.e. if the current version in the repo is the same as what we're trying to push
|
||||
# TODO - should we check that we're pushing a _newer_ version?
|
||||
# TODO - does the API only show the current version, or all versions?
|
||||
echo "Version clash ($chart_version) for $chart_name";
|
||||
exit 1;
|
||||
else
|
||||
# Move to a directory so we can upload later. Do this after checking all packages so there's no partial update
|
||||
mv $output_location bundles/;
|
||||
fi
|
||||
done
|
||||
|
||||
# All packages have been checked, no version conflicts - upload them all!
|
||||
find bundles -type f -exec curl -s --user "scubbo:$GITEA_PASSWORD" -X POST --upload-file '{}' https://gitea.scubbo.org/api/packages/scubbo/helm/api/charts \;
|
||||
rm -rf bundles;
|
@ -15,7 +15,7 @@ type: application
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.1.1
|
||||
version: 0.1.3
|
||||
|
||||
# This is the version number of the application being deployed. This version number should be
|
||||
# incremented each time you make changes to the application. Versions are not expected to
|
||||
|
24
charts/media-share/Chart.yaml
Normal file
24
charts/media-share/Chart.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
apiVersion: v2
|
||||
name: media-share
|
||||
description: A Helm chart for Kubernetes
|
||||
|
||||
# A chart can be either an 'application' or a 'library' chart.
|
||||
#
|
||||
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||
# to be deployed.
|
||||
#
|
||||
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||
type: application
|
||||
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.1.0
|
||||
|
||||
# This is the version number of the application being deployed. This version number should be
|
||||
# incremented each time you make changes to the application. Versions are not expected to
|
||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||
# It is recommended to use it with quotes.
|
||||
appVersion: "1.16.0"
|
3
charts/media-share/README.md
Normal file
3
charts/media-share/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
A trivial chart which hosts media from a given directory on a basic web server.
|
||||
|
||||
Useful for temporarily uploading stuff to transfer to friends more easily than via email/etc.
|
1
charts/media-share/templates/NOTES.txt
Normal file
1
charts/media-share/templates/NOTES.txt
Normal file
@ -0,0 +1 @@
|
||||
Don't forget to update Cloudflared! Service url is http://{{ include "media-share.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}
|
62
charts/media-share/templates/_helpers.tpl
Normal file
62
charts/media-share/templates/_helpers.tpl
Normal file
@ -0,0 +1,62 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "media-share.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 "media-share.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 "media-share.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "media-share.labels" -}}
|
||||
helm.sh/chart: {{ include "media-share.chart" . }}
|
||||
{{ include "media-share.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "media-share.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "media-share.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "media-share.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "media-share.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
35
charts/media-share/templates/deployment.yaml
Normal file
35
charts/media-share/templates/deployment.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "media-share.fullname" . }}
|
||||
labels:
|
||||
{{- include "media-share.labels" . | nindent 4 }}
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "media-share.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "media-share.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
image: python:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: [ "python", "-c"]
|
||||
args: [ "import http.server; s=http.server.HTTPServer((\"0.0.0.0\", 8000), http.server.SimpleHTTPRequestHandler); s.serve_forever()" ]
|
||||
workingDir: "/media"
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
protocol: TCP
|
||||
volumeMounts:
|
||||
- mountPath: /media
|
||||
name: {{ include "media-share.fullname" . }}-pv
|
||||
volumes:
|
||||
- name: {{ include "media-share.fullname" . }}-pv
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "media-share.fullname" . }}-pvc
|
||||
|
||||
|
15
charts/media-share/templates/service.yaml
Normal file
15
charts/media-share/templates/service.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "media-share.fullname" . }}
|
||||
labels:
|
||||
{{- include "media-share.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: 8000
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "media-share.selectorLabels" . | nindent 4 }}
|
15
charts/media-share/templates/tests/test-connection.yaml
Normal file
15
charts/media-share/templates/tests/test-connection.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ include "media-share.fullname" . }}-test-connection"
|
||||
labels:
|
||||
{{- include "media-share.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
spec:
|
||||
containers:
|
||||
- name: wget
|
||||
image: busybox
|
||||
command: ['wget']
|
||||
args: ['{{ include "media-share.fullname" . }}:{{ .Values.service.port }}']
|
||||
restartPolicy: Never
|
28
charts/media-share/templates/volumes.yaml
Normal file
28
charts/media-share/templates/volumes.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: {{ include "media-share.fullname" . }}-pv
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
nfs:
|
||||
server: {{ .Values.volume.nfsServer }}
|
||||
path: {{ .Values.volume.nfsPath }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ include "media-share.fullname" . }}-pvc
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
storageClassName: ""
|
||||
volumeName: {{ include "media-share.fullname" . }}-pv
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
33
charts/media-share/values.yaml
Normal file
33
charts/media-share/values.yaml
Normal file
@ -0,0 +1,33 @@
|
||||
# Default values for media-share.
|
||||
# This is a YAML-formatted file.
|
||||
# Declare variables to be passed into your templates.
|
||||
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
podAnnotations: {}
|
||||
|
||||
podSecurityContext: {}
|
||||
# fsGroup: 2000
|
||||
|
||||
securityContext: {}
|
||||
# capabilities:
|
||||
# drop:
|
||||
# - ALL
|
||||
# readOnlyRootFilesystem: true
|
||||
# runAsNonRoot: true
|
||||
# runAsUser: 1000
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
volume:
|
||||
nfsServer: "rassigma.avril"
|
||||
nfsPath: "/mnt/BERTHA/shared-media/media"
|
Loading…
x
Reference in New Issue
Block a user