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 (6)
advanced/
# custom-flux-example # Example repository for customizing a Stackspin cluster
Example boilerplate for a custom f[lux](https://fluxcd.io/) repository which can be added to a [Stackspin](https://stackspin.net) cluster. Example boilerplate for a custom [flux](https://fluxcd.io/) repository
The main use-case is to add additional applications which are not integrated into Stackspin (yet). 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 repo see the [flux2-kustomize-helm-example](https://github.com/fluxcd/flux2-kustomize-helm-example) repo. 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` This repo's directory structure is similar to the `flux2-kustomize-helm-example`
one. one.
> **NOTE**: Make sure to not re-use the names of kustomizations,
> helm releases, or any other Kubernetes manifests
> that are already present in the Stackspin `flux2` directory.
> If you do, Flux will alternate between reconciling your
> and our kustomization, which *will* result in an unstable situation.
## Basic configuration ## Basic configuration
We'll start with a very basic configuration: We'll start with a very basic configuration:
...@@ -24,12 +34,13 @@ basic/install.sh ...@@ -24,12 +34,13 @@ basic/install.sh
List the resource created by this flux repo: List the resource created by this flux repo:
```sh ```sh
kubectl -n flux-system get gitrepositories kubectl -n example-basic get gitrepositories
kubectl -n flux-system get kustomizations kubectl -n example-basic get kustomizations
kubectl -n example get helmreleases kubectl -n example-basic get helmreleases
kubectl -n example-basic get pods
``` ```
Show output of the one and only app applied, [podinfo](https://github.com/stefanprodan/podinfo) Show output of the single app applied, [podinfo](https://github.com/stefanprodan/podinfo)
```sh ```sh
curl --resolve podinfo.local:80:CLUSTER_IPV4_ADDRESS http://podinfo.local curl --resolve podinfo.local:80:CLUSTER_IPV4_ADDRESS http://podinfo.local
...@@ -37,8 +48,24 @@ curl --resolve podinfo.local:80:CLUSTER_IPV4_ADDRESS http://podinfo.local ...@@ -37,8 +48,24 @@ curl --resolve podinfo.local:80:CLUSTER_IPV4_ADDRESS http://podinfo.local
## What's next ? ## What's next ?
* Fork this repo to a private git remote (Github, Gitab, etc.) There are two ways of using a custom flux repo to host your custom config/apps
* Configure flux to use ssh instead of https for cloning on a Stackspin cluster.
* Add private ssh key for git pulling to flux
* Add public ssh key for git pulling to your git remote ### A) Manage secrets manually
* [Encrypt your secrets using sops](https://github.com/fluxcd/flux2-kustomize-helm-example#encrypt-kubernetes-secrets)
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/)
...@@ -13,7 +13,7 @@ spec: ...@@ -13,7 +13,7 @@ spec:
sourceRef: sourceRef:
kind: HelmRepository kind: HelmRepository
name: podinfo name: podinfo
namespace: flux-system namespace: example-basic
interval: 60m interval: 60m
# Default values # Default values
# https://github.com/stefanprodan/podinfo/blob/master/charts/podinfo/values.yaml # https://github.com/stefanprodan/podinfo/blob/master/charts/podinfo/values.yaml
......
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1 apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization kind: Kustomization
metadata: metadata:
name: custom-apps-basic name: examle-apps
namespace: flux-system namespace: example-basic
spec: spec:
interval: 24h interval: 24h
sourceRef: sourceRef:
kind: GitRepository kind: GitRepository
name: custom-flux-example name: stackspin-flux-example
path: ./basic/apps path: ./basic/apps
prune: true prune: true
validation: client validation: client
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1 apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization kind: Kustomization
metadata: metadata:
name: custom-infrastructure-basic name: example-infrastructure
namespace: flux-system namespace: example-basic
spec: spec:
interval: 24h interval: 24h
sourceRef: sourceRef:
kind: GitRepository kind: GitRepository
name: custom-flux-example name: stackspin-flux-example
path: ./basic/infrastructure path: ./basic/infrastructure
prune: true prune: true
validation: client validation: client
...@@ -2,7 +2,7 @@ apiVersion: source.toolkit.fluxcd.io/v1beta1 ...@@ -2,7 +2,7 @@ apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmRepository kind: HelmRepository
metadata: metadata:
name: podinfo name: podinfo
namespace: flux-system namespace: example-basic
spec: spec:
interval: 1h interval: 1h
url: https://stefanprodan.github.io/podinfo url: https://stefanprodan.github.io/podinfo
#!/usr/bin/env bash #!/usr/bin/env bash
echo "Creating / updating gitRepository custom-flux-example-basic in namespace flux-system" echo "Creating / updating gitRepository stackspin-flux-example-basic in namespace example-basic"
flux create source git custom-flux-example-basic \ flux create source git stackspin-flux-example \
--url=https://open.greenhost.net/stackspin/custom-flux-example.git \ --namespace=example-basic \
--url=https://open.greenhost.net/stackspin/stackspin-flux-example.git \
--branch=main \ --branch=main \
--interval=1h --interval=1h
echo "Creating / updating kustomization custom-flux-example-basic in namespace flux-system" echo "Creating / updating kustomization stackspin-flux-example in namespace example-basic"
flux create kustomization custom-flux-example-basic \ flux create kustomization stackspin-flux-example \
--source=GitRepository/custom-flux-example-basic \ --namespace=example-basic \
--source=GitRepository/stackspin-flux-example \
--path="./basic/clusters/production/" \ --path="./basic/clusters/production/" \
--prune=true \ --prune=true \
--interval=1h --interval=1h