mirror of
https://github.com/morten-olsen/homelab-apps.git
synced 2026-02-08 01:36:28 +01:00
@@ -1,136 +0,0 @@
|
|||||||
# Agent Documentation
|
|
||||||
|
|
||||||
This document describes how to create a new application chart for the homelab operator.
|
|
||||||
|
|
||||||
## Chart Structure
|
|
||||||
|
|
||||||
Each application has its own chart located in a directory under `charts/apps`. The chart should contain the following files:
|
|
||||||
|
|
||||||
- `Chart.yaml`: The chart metadata.
|
|
||||||
- `values.yaml`: The default values for the chart.
|
|
||||||
- `templates/`: A directory containing the Kubernetes resource templates.
|
|
||||||
|
|
||||||
## Custom Resources
|
|
||||||
|
|
||||||
The homelab operator uses several custom resources to manage applications. These resources are defined in the `templates` directory of the chart.
|
|
||||||
|
|
||||||
### `PostgresDatabase`
|
|
||||||
|
|
||||||
If the application requires a PostgreSQL database, you can create a `PostgresDatabase` resource. The operator will automatically create a database and a secret containing the connection details. The secret will have the same name as the release with a `-pg-connection` postfix.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# templates/database.yaml
|
|
||||||
apiVersion: homelab.mortenolsen.pro/v1
|
|
||||||
kind: PostgresDatabase
|
|
||||||
metadata:
|
|
||||||
name: "{{ .Release.Name }}"
|
|
||||||
spec:
|
|
||||||
environment: "{{ .Values.globals.environment }}"
|
|
||||||
```
|
|
||||||
|
|
||||||
The secret has the following values:
|
|
||||||
|
|
||||||
- `database`: name of the created database
|
|
||||||
- `host`: the hostname of the postgres server
|
|
||||||
- `port`: the port of the postgres server
|
|
||||||
- `url`: combined url in the format `postgresql://{user}:{password}@{host}:{port}/{database}`
|
|
||||||
|
|
||||||
### `OidcClient`
|
|
||||||
|
|
||||||
If the application requires OIDC authentication, you can create an `OidcClient` resource. The operator will automatically create an OIDC client and a secret containing the client ID and secret. The secret will have the same name as the release with a `-client` postfix.
|
|
||||||
|
|
||||||
You need to specify the redirect URIs for the OIDC client. The subdomain is taken from the `values.yaml` file.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# templates/client.yaml
|
|
||||||
apiVersion: homelab.mortenolsen.pro/v1
|
|
||||||
kind: OidcClient
|
|
||||||
metadata:
|
|
||||||
name: "{{ .Release.Name }}"
|
|
||||||
spec:
|
|
||||||
environment: "{{ .Values.globals.environment }}"
|
|
||||||
redirectUris:
|
|
||||||
- path: /user/oauth2/Authentik/callback
|
|
||||||
subdomain: "{{ .Values.subdomain }}"
|
|
||||||
matchingMode: strict
|
|
||||||
```
|
|
||||||
|
|
||||||
The secret has the following value:
|
|
||||||
|
|
||||||
- `authorization`: Authorization endpoint
|
|
||||||
- `clientId`
|
|
||||||
- `clientSecret`
|
|
||||||
- `configuration`: autodiscovery endpoint
|
|
||||||
- `configurationIssuer`: issuer url
|
|
||||||
- `endSession`: end session endpoint
|
|
||||||
- `jwks`: jwks endpoint
|
|
||||||
- `token`: token endpoint
|
|
||||||
- `userinfo`: user info endpoint
|
|
||||||
|
|
||||||
### `HttpService` and `ExternalHttpService`
|
|
||||||
|
|
||||||
To expose the application, you can use either an `HttpService` or an `ExternalHttpService` resource.
|
|
||||||
|
|
||||||
- `HttpService`: This will expose the application through the Istio gateway. This is for internal access only.
|
|
||||||
- `ExternalHttpService`: This will expose the application through a CloudFlare tunnel. This is for external access.
|
|
||||||
|
|
||||||
Both resources take a `subdomain` and a `destination` as parameters. The `destination` is the Kubernetes service to route traffic to.
|
|
||||||
|
|
||||||
Example of `HttpService`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# templates/http-service.yaml
|
|
||||||
apiVersion: homelab.mortenolsen.pro/v1
|
|
||||||
kind: HttpService
|
|
||||||
metadata:
|
|
||||||
name: "{{ .Release.Name }}"
|
|
||||||
spec:
|
|
||||||
environment: "{{ .Values.globals.environment }}"
|
|
||||||
subdomain: "{{ .Values.subdomain }}"
|
|
||||||
destination:
|
|
||||||
host: "{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local"
|
|
||||||
port:
|
|
||||||
number: 80
|
|
||||||
```
|
|
||||||
|
|
||||||
Example of `ExternalHttpService`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# templates/external-http-service.yaml
|
|
||||||
apiVersion: homelab.mortenolsen.pro/v1
|
|
||||||
kind: ExternalHttpService
|
|
||||||
metadata:
|
|
||||||
name: "{{ .Release.Name }}"
|
|
||||||
spec:
|
|
||||||
environment: "{{ .Values.globals.environment }}"
|
|
||||||
subdomain: "{{ .Values.subdomain }}"
|
|
||||||
destination:
|
|
||||||
host: "{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local"
|
|
||||||
port:
|
|
||||||
number: 80
|
|
||||||
```
|
|
||||||
|
|
||||||
## `values.yaml`
|
|
||||||
|
|
||||||
The `values.yaml` file should contain the following values:
|
|
||||||
|
|
||||||
- `globals.environment`: The environment the application is running in (e.g., `prod`, `dev`).
|
|
||||||
- `image.repository`: The Docker image repository.
|
|
||||||
- `image.tag`: The Docker image tag.
|
|
||||||
- `subdomain`: The subdomain for the application.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# values.yaml
|
|
||||||
globals:
|
|
||||||
environment: prod
|
|
||||||
image:
|
|
||||||
repository: docker.gitea.com/gitea
|
|
||||||
tag: latest
|
|
||||||
subdomain: gitea
|
|
||||||
```
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
set -euo pipefail
|
|
||||||
|
|
||||||
find . -name "values.yaml" -type f -print0 | while IFS= read -r -d '' values_file; do
|
|
||||||
location=$(dirname "$values_file")
|
|
||||||
name=$(basename "$location")
|
|
||||||
name=$(echo "$name" | tr '[:upper:]' '[:lower:]' | tr -s '[:punct:][:space:]' '-' | sed -e 's/^-*//' -e 's/-*$//')
|
|
||||||
|
|
||||||
echo "✅ Chart found in: $location"
|
|
||||||
echo " - Generated release name: $name"
|
|
||||||
HELM_COMMAND="helm install --namespace prod \"$name\" \"$location\""
|
|
||||||
helm upgrade -i --namespace prod "$name" "$location"
|
|
||||||
done
|
|
||||||
6
charts/argocd-apps/Chart.yaml
Normal file
6
charts/argocd-apps/Chart.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: argocd-apps
|
||||||
|
description: A Helm chart for ArgoCD ApplicationSet to deploy homelab apps
|
||||||
|
type: application
|
||||||
|
version: 0.1.0
|
||||||
|
appVersion: "1.0.0"
|
||||||
60
charts/argocd-apps/README.md
Normal file
60
charts/argocd-apps/README.md
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# ArgoCD Apps
|
||||||
|
|
||||||
|
This Helm chart deploys an ArgoCD ApplicationSet and AppProject to manage homelab applications.
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
It sets up:
|
||||||
|
- **AppProject**: A project named `apps` (configurable) to group the applications.
|
||||||
|
- **ApplicationSet**: Automatically discovers and deploys Helm charts from `charts/apps/*` in the repository.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Kubernetes cluster
|
||||||
|
- ArgoCD installed in the `argocd` namespace
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
### Option 1: Helm Install
|
||||||
|
|
||||||
|
Run the following command to install the chart directly:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
helm upgrade --install argocd-apps ./charts/argocd-apps \
|
||||||
|
--namespace argocd
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: ArgoCD App of Apps
|
||||||
|
|
||||||
|
You can also deploy this chart using ArgoCD itself by creating an Application that points to this chart.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: argocd-apps
|
||||||
|
namespace: argocd
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
repoURL: https://github.com/morten-olsen/homelab-apps
|
||||||
|
targetRevision: main
|
||||||
|
path: charts/argocd-apps
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: argocd
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
| Parameter | Description | Default |
|
||||||
|
|-----------|-------------|---------|
|
||||||
|
| `repoURL` | URL of the git repository | `https://github.com/morten-olsen/homelab-apps` |
|
||||||
|
| `targetRevision` | Git revision to use | `main` |
|
||||||
|
| `path` | Path to the apps directory | `charts/apps` |
|
||||||
|
| `exclude` | Pattern to exclude directories | `*.disabled` |
|
||||||
|
| `project` | ArgoCD project name | `apps` |
|
||||||
40
charts/argocd-apps/templates/applicationset.yaml
Normal file
40
charts/argocd-apps/templates/applicationset.yaml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: ApplicationSet
|
||||||
|
metadata:
|
||||||
|
name: homelab-apps
|
||||||
|
namespace: argocd
|
||||||
|
spec:
|
||||||
|
generators:
|
||||||
|
- git:
|
||||||
|
repoURL: {{ .Values.repoURL }}
|
||||||
|
revision: {{ .Values.targetRevision }}
|
||||||
|
directories:
|
||||||
|
- path: {{ .Values.path }}/*
|
||||||
|
- path: {{ .Values.path }}/*{{ .Values.exclude }}
|
||||||
|
exclude: true
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
name: '{{`{{path.basename}}`}}'
|
||||||
|
spec:
|
||||||
|
project: {{ .Values.project }}
|
||||||
|
source:
|
||||||
|
repoURL: {{ .Values.repoURL }}
|
||||||
|
targetRevision: {{ .Values.targetRevision }}
|
||||||
|
path: '{{`{{path}}`}}'
|
||||||
|
helm:
|
||||||
|
valueFiles:
|
||||||
|
- values.yaml
|
||||||
|
values: |
|
||||||
|
globals:
|
||||||
|
environment: {{ .Values.globals.environment }}
|
||||||
|
domain: {{ .Values.globals.domain }}
|
||||||
|
timezone: {{ .Values.globals.timezone }}
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: prod
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
15
charts/argocd-apps/templates/project.yaml
Normal file
15
charts/argocd-apps/templates/project.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: AppProject
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.project }}
|
||||||
|
namespace: argocd
|
||||||
|
spec:
|
||||||
|
description: "Project for homelab apps"
|
||||||
|
sourceRepos:
|
||||||
|
- '*'
|
||||||
|
destinations:
|
||||||
|
- namespace: prod
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
clusterResourceWhitelist:
|
||||||
|
- group: '*'
|
||||||
|
kind: '*'
|
||||||
9
charts/argocd-apps/values.yaml
Normal file
9
charts/argocd-apps/values.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
repoURL: "https://github.com/morten-olsen/homelab-apps"
|
||||||
|
targetRevision: "argo"
|
||||||
|
path: "charts/apps"
|
||||||
|
exclude: "*.disabled"
|
||||||
|
project: "apps"
|
||||||
|
globals:
|
||||||
|
environment: prod
|
||||||
|
domain: olsen.cloud
|
||||||
|
timezone: Europe/Amsterdam
|
||||||
Reference in New Issue
Block a user