Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • stackspin/stackspin-flux-example
  • xeruf/stackspout
2 results
Show changes
Commits on Source (93)
Showing
with 420 additions and 76 deletions
# Example repository for customizing a Stackspin cluster
Example boilerplate for a custom [flux](https://fluxcd.io/) repository
which can be added to a [Stackspin](https://stackspin.net) cluster.
The main use-case is to add additional applications
which are not integrated into Stackspin (yet).
For a more advanced example
see the [flux2-kustomize-helm-example](https://github.com/fluxcd/flux2-kustomize-helm-example)
repository.
This repo's directory structure is similar to the `flux2-kustomize-helm-example`
one.
## Basic configuration
We'll start with a very basic configuration:
* It uses a public git repo
* No secrets are included
* No forking/modifications needed, install as it is
# Stackspin Outwards - Stackspout
This repository extends [Stackspin](https://open.greenhost.net/stackspin/stackspin)
with extra applications and overrides
to make it more commercially/professionally interesting.
Once stabilized, the aim is to contribute as much upstream as possible.
Stackspout is used in day-to-day business
with a 2-digit user number,
so all experiments happen carefully.
## Customizations
### Overrides
- Adds many Nextcloud extensions and some configuration
- Add Email Auth back to Zulip
### New Applications
> subdomain: Service (helmrepo, if not provided by the service authors)
#### Stable including Single-Sign-On
- dev: Gitea
- do: Vikunja (k8s-at-home)
#### In Development
- people: SuiteCRM (bitnami repo)
- time: Kimai (robjuz repo)
#### Planned
- meet: Jitsi Meet
- wiki: Wiki (maybe wikijs, but I'd like something that integrated with Nextcloud and Markdown/Orgdown)
#### Ideas
- link: URL Shortener
- Bonfire
### Issues to tackle
#### Structurally
- generate_secrets.py was copied from Stackpin
- all apps except gitea lack pvcs
#### Functionally
- Nextcloud too slow - add Redis
- Preconfigure user settings in Nextcloud, Vikunja and more
## Installation
> Warning: Lots of experiments happening here!
Apply it to your cluster:
......@@ -25,41 +48,13 @@ Apply it to your cluster:
basic/install.sh
```
List the resource created by this flux repo:
List the resource related to this repo:
```sh
kubectl -n example-basic get gitrepositories
kubectl -n example-basic get kustomizations
kubectl -n example-basic get helmreleases
kubectl -n example-basic get pods
kubectl get gitrepositories -A
kubectl get kustomization -A -o=jsonpath='{.items[?(@.spec.sourceRef.name=="stackspout")].metadata.name}'
kubectl -n stackspout get helmreleases
kubectl -n stackspout get pods
```
Show output of the single app applied, [podinfo](https://github.com/stefanprodan/podinfo)
```sh
curl --resolve podinfo.local:80:CLUSTER_IPV4_ADDRESS http://podinfo.local
```
## What's next ?
There are two ways of using a custom flux repo to host your custom config/apps
on a Stackspin cluster.
### A) Manage secrets manually
This approach is easier to start with,
because you don't need to configure your cluster to handle encrypted secrets
and access to a private git repository.
* Fork this repository into a public git repo, cloneable via `https://`
### Everything in version control, including secrets
* Fork this repository into a private git repo, cloneable via `ssh://`
* [Configure flux to use ssh instead of https for cloning](https://fluxcd.io/docs/components/source/gitrepositories/#ssh-authentication)
* You shouln't rely solely on transport encryption for your git repository
but rather end-to-end encrypt your secrets.
Different methods are available for flux:
* [Sops](https://fluxcd.io/docs/guides/mozilla-sops/)
[Sops section in flux2-kustomize-helm-example](https://github.com/fluxcd/flux2-kustomize-helm-example#encrypt-kubernetes-secrets)
* [Sealed Secrets](https://fluxcd.io/docs/guides/sealed-secrets/)
But there are also ConfigMaps, Secrets, StatefulSets, PVCs, Helmrepos and all that stuff...
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitea-data
namespace: stackspout
labels:
stackspin.net/backupSet: "gitea"
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 2Gi
storageClassName: local-path
apiVersion: hydra.ory.sh/v1alpha1
kind: OAuth2Client
metadata:
name: gitea-oauth-client
# Has to live in the same namespace as the stackspin-wordpress-oauth-variables secret
namespace: flux-system
spec:
# TODO copied from wekan: https://github.com/wekan/wekan/wiki/Keycloak
grantTypes:
- authorization_code
- refresh_token
- client_credentials
- implicit
responseTypes:
- id_token
- code
scope: "openid profile email stackspin_roles"
secretName: stackspin-gitea-oauth-variables
redirectUris:
- https://dev.${domain}/user/oauth2/Stackspin/callback
tokenEndpointAuthMethod: client_secret_post
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitea-postgres
namespace: stackspout
labels:
stackspin.net/backupSet: "gitea"
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 2Gi
storageClassName: local-path
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: gitea
namespace: stackspout
spec:
releaseName: gitea
chart:
spec:
chart: gitea
version: 5.0.9
sourceRef:
kind: HelmRepository
name: gitea
namespace: flux-system
interval: 5m
valuesFrom:
- kind: ConfigMap
name: stackspin-gitea-values
optional: false
# Allow overriding values by ConfigMap or Secret
- kind: ConfigMap
name: stackspin-gitea-override
optional: true
- kind: Secret
name: stackspin-gitea-override
optional: true
apiVersion: v1
kind: ConfigMap
metadata:
name: stackspin-gitea-values
namespace: stackspout
data:
values.yaml: |
ingress:
enabled: true
annotations:
kubernetes.io/tls-acme: "true"
hosts:
- host: "dev.${domain}"
paths:
- path: /
pathType: Prefix
tls:
- secretName: gitea-tls
hosts:
- "dev.${domain}"
- "tmpdev.${domain}"
gitea:
oauth:
- name: Stackspin
provider: "openidConnect"
key: "${client_id}"
secret: "${client_secret}"
autoDiscoverUrl: "https://sso.${domain}/.well-known/openid-configuration"
config:
server:
ROOT_URL: "https://dev.${domain}"
persistence:
enabled: true
existingClaim: gitea-data
postgresql:
persistence:
enabled: true
existingClaim: gitea-postgres
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gitea-postgres-pvc.yaml
- gitea-release.yaml
- gitea-oauth-client.yaml
- gitea-values-configmap.yaml
- gitea-data-pvc.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- vikunja-oauth-client.yaml
- vikunja-release.yaml
- vikunja-values-configmap.yaml
- vikunja-postgres-pvc.yaml
apiVersion: hydra.ory.sh/v1alpha1
kind: OAuth2Client
metadata:
name: vikunja-oauth-client
# Has to live in the same namespace as the stackspin-wordpress-oauth-variables secret
namespace: flux-system
spec:
# TODO copied from wekan: https://github.com/wekan/wekan/wiki/Keycloak
grantTypes:
- authorization_code
- refresh_token
- client_credentials
- implicit
responseTypes:
- id_token
- code
scope: "openid profile email stackspin_roles"
secretName: stackspin-vikunja-oauth-variables
redirectUris:
- https://do.${domain}/auth/openid/stackspin
tokenEndpointAuthMethod: client_secret_post
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: vikunja-postgres
namespace: stackspout
labels:
stackspin.net/backupSet: "vikunja"
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 2Gi
storageClassName: local-path
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: vikunja
namespace: stackspout
spec:
releaseName: vikunja
chart:
spec:
chart: vikunja
version: 5.5.3
sourceRef:
kind: HelmRepository
name: k8s-at-home
namespace: flux-system
interval: 5m
valuesFrom:
- kind: ConfigMap
name: stackspin-vikunja-values
optional: false
# Allow overriding values by ConfigMap or Secret
- kind: ConfigMap
name: stackspin-vikunja-override
optional: true
- kind: Secret
name: stackspin-vikunja-override
optional: true
apiVersion: v1
kind: ConfigMap
metadata:
name: stackspin-vikunja-values
namespace: stackspout
data:
# Defaults: https://github.com/k8s-at-home/charts/blob/master/charts/stable/vikunja/values.yaml
# Inherits: https://github.com/k8s-at-home/library-charts/blob/main/charts/stable/common/values.yaml
values.yaml: |
vikunja:
config: |-
auth:
openid:
# https://vikunja.io/docs/config-options/#openid
# Example: https://github.com/go-vikunja/api/blob/main/config.yml.sample#L289-L312
enabled: true
redirecturl: "https://do.${domain}/auth/openid/"
providers:
- name: Stackspin
authurl: "https://sso.${domain}/"
clientid: "${client_id}"
clientsecret: "${client_secret}"
local:
enabled: false
service:
frontendurl: "https://do.${domain}"
motd: "Please allow public profile discovery in settings!"
timezone: "CET"
database:
host: db
type: postgres
password: "${postgres_password}"
ingress:
main:
enabled: true
primary: false
annotations:
kubernetes.io/tls-acme: "true"
hosts:
- host: "do.${domain}"
paths:
- path: /
pathType: Prefix
tls:
- secretName: vikunja-tls
hosts:
- "do.${domain}"
additionalContainers:
api:
image: vikunja/api:0.18.1
frontend:
image: vikunja/frontend:0.18.2
postgresql:
enabled: true
postgresqlUsername: vikunja
postgresqlPassword: "${postgres_password}"
postgresqlDatabase: vikunja
persistence:
enabled: true
existingClaim: vikunja-postgres
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: podinfo
namespace: example-basic
spec:
releaseName: podinfo
chart:
spec:
# https://artifacthub.io/packages/helm/podinfo/podinfo
chart: podinfo
version: 6.1.1
sourceRef:
kind: HelmRepository
name: podinfo
namespace: example-basic
interval: 60m
# Default values
# https://github.com/stefanprodan/podinfo/blob/master/charts/podinfo/values.yaml
values:
ingress:
enabled: true
#!/bin/sh -e
# Generates kubernetes kustomizations
find -mindepth 1 -maxdepth 1 -type d | while read dir;
do echo "$dir"
{ echo 'apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:'
find $dir -type f -not -name "*.bak" -not -name "kustomization.yaml" -printf " - %f\n"; } | tee $dir/kustomization.yaml
done
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- suitecrm-values-configmap.yaml
- suitecrm-release.yaml
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: suitecrm
namespace: stackspout
spec:
releaseName: suitecrm
chart:
spec:
chart: suitecrm
version: 11.1.10
sourceRef:
kind: HelmRepository
name: bitnami
namespace: flux-system
interval: 5m
valuesFrom:
- kind: ConfigMap
name: stackspin-suitecrm-values
optional: false
# Allow overriding values by ConfigMap or Secret
- kind: ConfigMap
name: stackspin-suitecrm-override
optional: true
- kind: Secret
name: stackspin-suitecrm-override
optional: true
apiVersion: v1
kind: ConfigMap
metadata:
name: stackspin-suitecrm-values
namespace: stackspout
data:
values.yaml: |
ingress:
enabled: true
hostname: "people.${domain}"
tls: true
certManager: true
suitecrmUsername: "admin"
suitecrmEmail: "${admin_email}"
suitecrmPassword: "${suitecrm_password}"
mariadb:
auth:
password: "${mariadb_password}"
rootPassword: "${mariadb_root_password}"
# TODO Adjust OIDC SSO to service
# - name: Stackspin
# key: "${client_id}"
# secret: "${client_secret}"
# customAuthUrl: "https://people.${domain}/login/login"
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: kimai
namespace: stackspout
spec:
releaseName: kimai
chart:
spec:
chart: kimai2
version: 1.3.0
sourceRef:
kind: HelmRepository
name: robjuz
namespace: flux-system
interval: 5m
valuesFrom:
- kind: ConfigMap
name: stackspin-kimai-values
optional: false
# Allow overriding values by ConfigMap or Secret
- kind: ConfigMap
name: stackspin-kimai-override
optional: true
- kind: Secret
name: stackspin-kimai-override
optional: true
apiVersion: v1
kind: ConfigMap
metadata:
name: stackspin-kimai-values
namespace: stackspout
data:
values.yaml: |
# https://github.com/robjuz/helm-charts/tree/master/charts/kimai2#parameters
image:
# Maybe apache-latest?
tag: apache-1.20.4-prod
ingress:
enabled: true
certManager: true
tls: true
hostname: "time.${domain}"
# - name: Stackspin
# key: "${client_id}"
# secret: "${client_secret}"
# autoDiscoverUrl: 'https://sso.${domain}/.well-known/openid-configuration'
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- kimai-release.yaml
- kimai-values-configmap.yaml