Skip to content

Commit ffd1b5a

Browse files
initial commit
0 parents  commit ffd1b5a

17 files changed

Lines changed: 470 additions & 0 deletions

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.claude
2+
.direnv

.helmignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
24+
# Nix
25+
.direnv/
26+
.envrc
27+
flake.nix
28+
flake.lock
29+

Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: static-webhost
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
description = "webhost-template dev shell";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{
11+
nixpkgs,
12+
flake-utils,
13+
...
14+
}:
15+
flake-utils.lib.eachDefaultSystem (
16+
system:
17+
let
18+
pkgs = import nixpkgs {
19+
inherit system;
20+
config.allowUnfree = true;
21+
};
22+
in
23+
{
24+
devShells.default = pkgs.mkShell {
25+
buildInputs = with pkgs; [
26+
kubernetes-helm
27+
jetbrains.goland
28+
];
29+
};
30+
}
31+
);
32+
}

templates/_helpers.tpl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "static-webhost.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Fully qualified app name.
10+
*/}}
11+
{{- define "static-webhost.fullname" -}}
12+
{{- if .Values.fullnameOverride }}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- else }}
15+
{{- $name := default .Chart.Name .Values.nameOverride }}
16+
{{- if contains $name .Release.Name }}
17+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
23+
24+
{{/*
25+
Chart label.
26+
*/}}
27+
{{- define "static-webhost.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
31+
{{/*
32+
Common labels
33+
*/}}
34+
{{- define "static-webhost.labels" -}}
35+
helm.sh/chart: {{ include "static-webhost.chart" . }}
36+
{{ include "static-webhost.selectorLabels" . }}
37+
{{- if .Chart.AppVersion }}
38+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
39+
{{- end }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
{{- end }}
42+
43+
{{/*
44+
Selector labels
45+
*/}}
46+
{{- define "static-webhost.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "static-webhost.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
{{- end }}
50+
51+
{{/*
52+
Component-scoped selector labels (used by per-component Deployments/Services).
53+
Call with: (dict "Context" . "Component" "code-server")
54+
*/}}
55+
{{- define "static-webhost.componentSelectorLabels" -}}
56+
{{ include "static-webhost.selectorLabels" .Context }}
57+
app.kubernetes.io/component: {{ .Component }}
58+
{{- end }}

templates/caddy-configmap.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "static-webhost.fullname" . }}-caddy
5+
labels:
6+
{{- include "static-webhost.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: caddy
8+
data:
9+
Caddyfile: |
10+
:8080 {
11+
root * /srv
12+
file_server browse
13+
}

templates/caddy-deployment.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "static-webhost.fullname" . }}-caddy
5+
labels:
6+
{{- include "static-webhost.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: caddy
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
{{- include "static-webhost.componentSelectorLabels" (dict "Context" . "Component" "caddy") | nindent 6 }}
13+
template:
14+
metadata:
15+
labels:
16+
{{- include "static-webhost.componentSelectorLabels" (dict "Context" . "Component" "caddy") | nindent 8 }}
17+
spec:
18+
containers:
19+
- name: caddy
20+
image: "{{ .Values.caddy.image.repository }}:{{ .Values.caddy.image.tag }}"
21+
imagePullPolicy: {{ .Values.caddy.image.pullPolicy }}
22+
ports:
23+
- name: http
24+
containerPort: 8080
25+
protocol: TCP
26+
volumeMounts:
27+
- name: data
28+
mountPath: /srv
29+
readOnly: true
30+
- name: caddyfile
31+
mountPath: /etc/caddy/Caddyfile
32+
subPath: Caddyfile
33+
{{- with .Values.caddy.resources }}
34+
resources:
35+
{{- toYaml . | nindent 12 }}
36+
{{- end }}
37+
volumes:
38+
- name: data
39+
persistentVolumeClaim:
40+
claimName: {{ include "static-webhost.fullname" . }}-data
41+
- name: caddyfile
42+
configMap:
43+
name: {{ include "static-webhost.fullname" . }}-caddy

templates/caddy-service.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "static-webhost.fullname" . }}-caddy
5+
labels:
6+
{{- include "static-webhost.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: caddy
8+
spec:
9+
type: ClusterIP
10+
ports:
11+
- port: 80
12+
targetPort: http
13+
protocol: TCP
14+
name: http
15+
selector:
16+
{{- include "static-webhost.componentSelectorLabels" (dict "Context" . "Component" "caddy") | nindent 4 }}

0 commit comments

Comments
 (0)