Skip to content

Commit d209d38

Browse files
committed
Add Helm chart for UpdateController with deployment and configuration files
1 parent 6aa03e8 commit d209d38

13 files changed

Lines changed: 625 additions & 0 deletions
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Helm Chart Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
paths:
8+
- "helm/**"
9+
- ".github/workflows/helm-release.yaml"
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
jobs:
17+
release-helm:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Configure Git
26+
run: |
27+
git config user.name "$GITHUB_ACTOR"
28+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
29+
30+
- name: Install Helm
31+
uses: azure/setup-helm@v4
32+
with:
33+
version: "latest"
34+
35+
- name: Log in to GHCR
36+
run: |
37+
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
38+
39+
- name: Extract chart version
40+
id: chart-version
41+
run: |
42+
CHART_VERSION=$(grep '^version:' helm/Chart.yaml | awk '{print $2}')
43+
echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT
44+
echo "Chart version: $CHART_VERSION"
45+
46+
- name: Package Helm chart
47+
run: |
48+
helm package helm/
49+
50+
- name: Push Helm chart to OCI registry
51+
run: |
52+
helm push update-controller-${{ steps.chart-version.outputs.version }}.tgz oci://ghcr.io/udl-tf/charts
53+
54+
- name: Logout from GHCR
55+
if: always()
56+
run: |
57+
helm registry logout ghcr.io

helm/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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/

helm/Chart.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: update-controller
3+
description: A Kubernetes controller for automatically managing TF2 game server updates
4+
type: application
5+
version: 0.1.0
6+
appVersion: "latest"
7+
keywords:
8+
- kubernetes
9+
- controller
10+
- game-servers
11+
- tf2
12+
- steamcmd
13+
home: https://github.com/UDL-TF/UpdateController
14+
sources:
15+
- https://github.com/UDL-TF/UpdateController
16+
maintainers:
17+
- name: UDL-TF
18+
url: https://github.com/UDL-TF

helm/README.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# UpdateController Helm Chart
2+
3+
This Helm chart deploys the UpdateController for managing TF2 game server updates in a Kubernetes cluster.
4+
5+
## Prerequisites
6+
7+
- Kubernetes 1.19+
8+
- Helm 3.0+
9+
- A PersistentVolume provisioner (if using persistence)
10+
11+
## Installation
12+
13+
### Install from OCI Registry
14+
15+
The chart is published to GitHub Container Registry as an OCI artifact:
16+
17+
```bash
18+
helm install update-controller oci://ghcr.io/udl-tf/charts/update-controller --version 0.1.0
19+
```
20+
21+
### Install from local chart
22+
23+
```bash
24+
# From the repository root
25+
helm install update-controller ./helm
26+
27+
# Or from the helm directory
28+
cd helm
29+
helm install update-controller .
30+
```
31+
32+
### Install with custom values
33+
34+
```bash
35+
helm install update-controller ./helm -f custom-values.yaml
36+
```
37+
38+
### Install with specific parameters
39+
40+
```bash
41+
helm install update-controller ./helm \
42+
--set image.tag=v1.0.0 \
43+
--set config.checkInterval=15m \
44+
--set persistence.size=100Gi
45+
```
46+
47+
## Configuration
48+
49+
The following table lists the configurable parameters of the UpdateController chart and their default values.
50+
51+
| Parameter | Description | Default |
52+
| ------------------------------ | ---------------------------------- | ---------------------------------- |
53+
| `replicaCount` | Number of controller replicas | `1` |
54+
| `image.repository` | Container image repository | `ghcr.io/udl-tf/update-controller` |
55+
| `image.pullPolicy` | Image pull policy | `Always` |
56+
| `image.tag` | Image tag (overrides appVersion) | `""` |
57+
| `serviceAccount.create` | Create service account | `true` |
58+
| `serviceAccount.name` | Service account name | `""` (generated) |
59+
| `rbac.create` | Create RBAC resources | `true` |
60+
| `config.checkInterval` | Interval to check for updates | `30m` |
61+
| `config.steamAppId` | Steam app ID | `232250` |
62+
| `config.gameMountPath` | Path where game files are mounted | `/tf` |
63+
| `config.podSelector` | Label selector for pods to restart | `app=tf2-server` |
64+
| `config.maxRetries` | Maximum number of retries | `3` |
65+
| `config.namespace` | Namespace where game servers run | `game-servers` |
66+
| `resources.limits.cpu` | CPU limit | `500m` |
67+
| `resources.limits.memory` | Memory limit | `512Mi` |
68+
| `resources.requests.cpu` | CPU request | `100m` |
69+
| `resources.requests.memory` | Memory request | `128Mi` |
70+
| `persistence.enabled` | Enable persistent storage | `true` |
71+
| `persistence.existingClaim` | Use existing PVC | `""` |
72+
| `persistence.size` | PVC size | `50Gi` |
73+
| `persistence.storageClassName` | Storage class name | `standard` |
74+
| `namespace.create` | Create namespace | `true` |
75+
| `namespace.name` | Namespace name | `game-servers` |
76+
77+
## Examples
78+
79+
### Using an existing PVC
80+
81+
```yaml
82+
# custom-values.yaml
83+
persistence:
84+
enabled: true
85+
existingClaim: my-existing-game-files-pvc
86+
```
87+
88+
```bash
89+
helm install update-controller ./helm -f custom-values.yaml
90+
```
91+
92+
### Deploying to a different namespace
93+
94+
```yaml
95+
# custom-values.yaml
96+
namespace:
97+
create: false
98+
name: my-custom-namespace
99+
```
100+
101+
### Custom update interval and retry settings
102+
103+
```yaml
104+
# custom-values.yaml
105+
config:
106+
checkInterval: '15m'
107+
maxRetries: '5'
108+
retryDelay: '10m'
109+
```
110+
111+
### Using a specific image version
112+
113+
```bash
114+
helm install update-controller ./helm --set image.tag=v1.0.0
115+
```
116+
117+
## Upgrading
118+
119+
### Upgrade from OCI Registry
120+
121+
```bash
122+
helm upgrade update-controller oci://ghcr.io/udl-tf/charts/update-controller --version 0.1.0
123+
```
124+
125+
### Upgrade from local chart
126+
127+
```bash
128+
helm upgrade update-controller ./helm
129+
```
130+
131+
With custom values:
132+
133+
```bash
134+
helm upgrade update-controller ./helm -f custom-values.yaml
135+
```
136+
137+
## Uninstallation
138+
139+
```bash
140+
helm uninstall update-controller
141+
```
142+
143+
**Note:** This will not delete the PVC by default. To delete it:
144+
145+
```bash
146+
kubectl delete pvc -n game-servers update-controller-game-files
147+
```
148+
149+
## Troubleshooting
150+
151+
### Check controller status
152+
153+
```bash
154+
kubectl get pods -n game-servers -l app.kubernetes.io/name=update-controller
155+
```
156+
157+
### View controller logs
158+
159+
```bash
160+
kubectl logs -n game-servers -l app.kubernetes.io/name=update-controller -f
161+
```
162+
163+
### Verify RBAC permissions
164+
165+
```bash
166+
kubectl describe clusterrole update-controller
167+
kubectl describe clusterrolebinding update-controller
168+
```
169+
170+
### Check configuration
171+
172+
```bash
173+
kubectl get configmap -n game-servers update-controller-config -o yaml
174+
```
175+
176+
## License
177+
178+
MIT

helm/templates/_helpers.tpl

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "update-controller.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
*/}}
11+
{{- define "update-controller.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+
Create chart name and version as used by the chart label.
26+
*/}}
27+
{{- define "update-controller.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
31+
{{/*
32+
Common labels
33+
*/}}
34+
{{- define "update-controller.labels" -}}
35+
helm.sh/chart: {{ include "update-controller.chart" . }}
36+
{{ include "update-controller.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 "update-controller.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "update-controller.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
{{- end }}
50+
51+
{{/*
52+
Create the name of the service account to use
53+
*/}}
54+
{{- define "update-controller.serviceAccountName" -}}
55+
{{- if .Values.serviceAccount.create }}
56+
{{- default (include "update-controller.fullname" .) .Values.serviceAccount.name }}
57+
{{- else }}
58+
{{- default "default" .Values.serviceAccount.name }}
59+
{{- end }}
60+
{{- end }}
61+
62+
{{/*
63+
Get the namespace
64+
*/}}
65+
{{- define "update-controller.namespace" -}}
66+
{{- .Values.namespace.name }}
67+
{{- end }}
68+
69+
{{/*
70+
Get the PVC name
71+
*/}}
72+
{{- define "update-controller.pvcName" -}}
73+
{{- if .Values.persistence.existingClaim }}
74+
{{- .Values.persistence.existingClaim }}
75+
{{- else }}
76+
{{- printf "%s-game-files" (include "update-controller.fullname" .) }}
77+
{{- end }}
78+
{{- end }}

helm/templates/clusterrole.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ include "update-controller.fullname" . }}
6+
labels:
7+
{{- include "update-controller.labels" . | nindent 4 }}
8+
rules:
9+
- apiGroups: ['']
10+
resources: ['pods']
11+
verbs: ['get', 'list', 'watch']
12+
- apiGroups: ['apps']
13+
resources: ['deployments', 'statefulsets', 'daemonsets', 'replicasets']
14+
verbs: ['get', 'list', 'patch', 'update']
15+
- apiGroups: ['']
16+
resources: ['persistentvolumeclaims']
17+
verbs: ['get', 'list']
18+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
name: {{ include "update-controller.fullname" . }}
6+
labels:
7+
{{- include "update-controller.labels" . | nindent 4 }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: ClusterRole
11+
name: {{ include "update-controller.fullname" . }}
12+
subjects:
13+
- kind: ServiceAccount
14+
name: {{ include "update-controller.serviceAccountName" . }}
15+
namespace: {{ include "update-controller.namespace" . }}
16+
{{- end }}

0 commit comments

Comments
 (0)