-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
288 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
overlays/gitops-app/src/bundle/config/ytt/overlays/overlay-configsecretcopier.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#@ load("@ytt:overlay", "overlay") | ||
#@ load("@ytt:data", "data") | ||
|
||
#@ if data.values.config.type == "local": | ||
|
||
#@ def config_secretcopier(name, ns_from, ns_to): | ||
#@ if ns_from != ns_to: | ||
kind: SecretCopier | ||
apiVersion: secrets.educates.dev/v1beta1 | ||
metadata: | ||
annotations: | ||
kapp.k14s.io/change-group: local-config-secrets | ||
name: #@ "{}-{}".format(name, ns_to) | ||
spec: | ||
rules: | ||
- reclaimPolicy: Delete | ||
sourceSecret: | ||
name: #@ name | ||
namespace: #@ ns_from | ||
targetNamespaces: | ||
nameSelector: | ||
matchNames: | ||
- #@ ns_to | ||
#@ end | ||
#@ end #! config_secretcopier | ||
|
||
#@ if data.values.mode == "app_per_bundle": | ||
|
||
#@ for bundle in data.values.workshop_bundles: | ||
--- #@ config_secretcopier(data.values.config.local.secretRef.common.name, data.values.config.local.secretRef.common.namespace, "workshops-{}".format(bundle.name)) | ||
--- #@ config_secretcopier(data.values.config.local.secretRef.workshops.name, data.values.config.local.secretRef.workshops.namespace, "workshops-{}".format(bundle.name)) | ||
#@ end | ||
|
||
#@ else: | ||
|
||
#@ for bundle in data.values.workshop_bundles: | ||
|
||
--- #@ config_secretcopier(data.values.config.local.secretRef.common.name, data.values.config.local.secretRef.common.namespace, "workshops-{}".format("global")) | ||
--- #@ config_secretcopier(data.values.config.local.secretRef.workshops.name, data.values.config.local.secretRef.workshops.namespace, "workshops-{}".format("global")) | ||
|
||
#@ end #! for | ||
|
||
#@ end #! if/else | ||
|
||
#@ end #! data.values.config.type == "local" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Test locally | ||
|
||
How to test on a local educates kind cluster (with local registry) and kapp-controller: | ||
|
||
``` | ||
educates admin cluster create --config kind-config.yaml | ||
``` | ||
|
||
1. Build the image and push it into your local registry: | ||
|
||
``` | ||
imgpkg --debug push -i localhost:5001/gitops-configurer:devel -f ../overlays | ||
``` | ||
2. Create your version of the configuration files in the [versions](./secret-versions.yaml), [common](./secret-common.yaml) and | ||
[workshops](./secret-workshops.yaml) secrets and deploy them into the cluster: | ||
``` | ||
kubectl apply -f secret-versions.yaml | ||
kubectl apply -f secret-common.yaml | ||
kubectl apply -f secret-workshops.yaml | ||
``` | ||
3. Create the required [RBAC](./rbac.yaml) and [Gitops App definition](./crd-devel.yaml) and deploy it into your cluster. | ||
``` | ||
kubectl apply -f rbac.yaml | ||
kubectl apply -f crd-devel.yaml | ||
``` | ||
4. If you want to test any change in configuration, modify the appropriate secret and apply it into the cluster and wait for a reconciliation. | ||
If you don't want to wait, kick the reconciliation manually of the main gitops app: | ||
``` | ||
kctrl app kick -a workshops-gitops -n package-installs | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
apiVersion: kappctrl.k14s.io/v1alpha1 | ||
kind: App | ||
metadata: | ||
name: workshops-gitops | ||
namespace: package-installs | ||
annotations: | ||
educates_gitops_environment: "sample-environment" | ||
kapp.k14s.io/disable-original: "" | ||
spec: | ||
serviceAccountName: workshops-gitops-package-installs | ||
syncPeriod: "0h2m0s" | ||
fetch: | ||
- inline: | ||
pathsFrom: | ||
- secretRef: | ||
name: versions | ||
path: environments | ||
- image: | ||
url: registry.default.svc.cluster.local/gitops-configurer:devel | ||
subPath: "gitops-app/src/bundle/config" | ||
path: config | ||
template: | ||
- ytt: | ||
ignoreUnknownComments: true | ||
paths: | ||
- config/ytt | ||
- config/kapp | ||
valuesFrom: | ||
- path: environments/versions.yaml | ||
- downwardAPI: | ||
items: | ||
- name: environment | ||
fieldPath: metadata.annotations['educates_gitops_environment'] | ||
deploy: | ||
- kapp: | ||
rawOptions: ["--app-changes-max-to-keep=5", "--wait-timeout=5m", "--diff-changes=true"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
clusterInfrastructure: | ||
provider: kind | ||
clusterPackages: | ||
kapp-controller: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
kind: Namespace | ||
apiVersion: v1 | ||
metadata: | ||
name: package-installs | ||
--- | ||
kind: ServiceAccount | ||
apiVersion: v1 | ||
metadata: | ||
name: workshops-gitops-package-installs | ||
namespace: package-installs | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: workshops-gitops-package-installs | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: workshops-gitops-package-installs | ||
namespace: package-installs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: common | ||
namespace: package-installs | ||
annotations: | ||
kapp.k14s.io/disable-original: "" | ||
stringData: | ||
common.yaml: | | ||
live_updates: True | ||
theme_name: light-theme | ||
ancestors: | ||
- https://workshops-test.live | ||
sessions: | ||
anonymous: 1 | ||
registered: 4 | ||
max: 10 | ||
index: https://workshops-test.live | ||
registration: | ||
enabled: false | ||
type: anonymous | ||
cookies_domain: workshops-test.live | ||
analytics: | ||
webhook_url: "https://metrics.educates.dev/?client=name&token=password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: versions | ||
namespace: package-installs | ||
annotations: | ||
kapp.k14s.io/disable-original: "" | ||
stringData: | ||
versions.yaml: | | ||
mode: "one_app" | ||
overlays: | ||
url: registry.default.svc.cluster.local/gitops-configurer | ||
version: devel | ||
config: | ||
type: "local" | ||
# local: | ||
# secretRef: | ||
# common: | ||
# name: common | ||
# namespace: package-installs | ||
# workshops: | ||
# name: workshops | ||
# namespace: package-installs | ||
subPath: "config" | ||
workshop_bundles: | ||
- name: "workshop-animals" | ||
url: "ghcr.io/educates/educates-workshop-gitops-configurer-workshop-animals-manifests" | ||
#semver: ">=1.0.0" | ||
version: "latest" | ||
- name: "workshop-colours" | ||
url: "ghcr.io/educates/educates-workshop-gitops-configurer-workshop-colours-manifests" | ||
version: "latest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: workshops | ||
namespace: package-installs | ||
annotations: | ||
kapp.k14s.io/disable-original: "" | ||
stringData: | ||
workshops.yaml: | | ||
portals: | ||
- name: "workshop-bundle-animals" | ||
title: "Animals workshops" | ||
sessions: | ||
max: 2 | ||
defaults: | ||
expires: 10m | ||
orphaned: 5m | ||
reserved: 0 | ||
workshops: | ||
- name: workshop-dog | ||
expires: 60m | ||
orphaned: 5m | ||
reserved: 1 | ||
- name: workshop-cat | ||
- name: workshop-bird | ||
- name: workshop-fish | ||
- name: workshop-giraffe | ||
- name: "workshop-bundle-colours" | ||
sessions: | ||
max: 2 | ||
defaults: | ||
expires: 10m | ||
orphaned: 5m | ||
reserved: 24 | ||
credentials: | ||
admin: | ||
username: user | ||
password: password | ||
workshops: | ||
- name: workshop-red | ||
- name: workshop-blue | ||
- name: workshop-green |