Skip to content

Commit

Permalink
Merge branch 'release/0.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoralespou committed May 3, 2024
2 parents f1ebba8 + 3c1fe49 commit 92c0179
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 53 deletions.
56 changes: 15 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,48 +94,21 @@ for each training portal

### Deploy workshop configuration as gitops in an Educates Cluster

**NOTE** THIS NEEDS TO BE REWRITEN AS WE DON'T USE SCRIPTS TO INSTALL/UNINSTALL IN CLUSTER

If manually deploying to an educates cluster,
do following steps:

1. Ensure you have an educates cluster, and KUBECONFIG set to point to its config

1. Configure the following environment variables in shell or runner:

```
export KUBECONFIG=<path to KUBECONFIG>
export WORKSHOP_CONFIG_REPO_URL="https://github.com/<org/repo>" # destination repository with workshop training portal configuration overlays
export WORKSHOP_CONFIG_REPO_REF="origin/main" # branch/tag reference at workshop config repository that will be reconciled to cluster - defaults to origin/main
export WORKSHOP_OVERLAYS_PKG_URL="vmware-tanzu-learning/educates-workshop-gitops-configurer" # url of overlays package - defaults to vmware-tanzu-learning for prod releases, you may want to override for local development.
export ENVIRONMENT="<environment name>" # directory at workshop configuration reposistory from where workshop bundle configuration will be sourced
export GITHUB_USER="<>" # github user whose GITHUB_TOKEN has OCI package read permissions to the workshop config repo
export GITHUB_TOKEN="<>" # GITHUB_USER's token that OCI package read permissions to the workshop config repo
export EDUCATES_VERSION="latest" # defaults to "latest", although you should use the appropriate semver when implemented.
```
example for spring academy tenant staging environment with defaults
```
export WORKSHOP_CONFIG_REPO_URL="https://github.com/vmware-tanzu-learning/spring-academy-educates-workshops-config>"
export ENVIRONMENT="staging"
export GITHUB_USER="<redacted>"
export GITHUB_TOKEN="<redacted>"
export KUBECONFIG="<redacted>"
```
2. Create your version of [the configuration files](./config/sample-environment/) in your GitHub gitops repo.

1. Run the install script:
3. Create the required [RBAC](./resources/rbac.yaml) and [Gitops App definition](./resources/rbac.yaml) and deploy it into your cluster.

```bash
install/install.sh
```
1. Verify the application and workshop configuration has reconciled:
4. Verify the application and workshop configuration has reconciled:

- via `kapp`:

```bash
kapp list -n package-installs
kapp list -n <package-installs>
```

you should see similar to follows:
Expand Down Expand Up @@ -174,11 +147,7 @@ do following steps:

### Remove workshop gitops configuration

Run the following script:
```bash
scripts/uninstall.sh
```
Remove the gitops app and RBAC from the cluster.

It will remove the carvel application and dependent config and security config.

Expand All @@ -192,14 +161,16 @@ This will produce a list of Carvel Apps with the required k8s credentials and co
ytt -v environment=test \
-v mode=app_per_bundle \
--data-values-file test/gitops-app/versions.yaml \
-f overlays/gitops-app/src/bundle/config
-f overlays/gitops-app/src/bundle/config/ytt \
-f overlays/gitops-app/src/bundle/config/kapp
```
```
ytt -v environment=test \
-v mode=one_app \
--data-values-file test/gitops-app/versions.yaml \
-f overlays/gitops-app/src/bundle/config
-f overlays/gitops-app/src/bundle/config/ytt \
-f overlays/gitops-app/src/bundle/config/kapp
```
### Local development/testing of workshop configuration overlays
Expand All @@ -211,21 +182,24 @@ ytt -v name=workshop-bundle-colours \
-v mode=app_per_bundle \
--data-values-file test/portal-app/config \
-f test/portal-app/workshops/workshop-bundle-colours \
-f overlays/portal-app/src/bundle/config
-f overlays/portal-app/src/bundle/config/ytt \
-f overlays/portal-app/src/bundle/config/kapp

ytt -v name=workshop-bundle-animals \
-v mode=app_per_bundle \
--data-values-file test/portal-app/config \
-f test/portal-app/workshops/workshop-bundle-animals \
-f overlays/portal-app/src/bundle/config
-f overlays/portal-app/src/bundle/config/ytt \
-f overlays/portal-app/src/bundle/config/kapp
```
```
ytt -v name=global \
-v mode=one_app \
--data-values-file test/portal-app/config \
-f test/portal-app/workshops/workshop-bundle-animals \
-f overlays/portal-app/src/bundle/config
-f overlays/portal-app/src/bundle/config/ytt \
-f overlays/portal-app/src/bundle/config/kapp
```
## TODO
Expand Down
21 changes: 21 additions & 0 deletions overlays/gitops-app/src/bundle/config/kapp/kapp-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: kapp.k14s.io/v1alpha1
kind: Config
rebaseRules:
- paths:
- [spec, rules, { allIndexes: true }, reclaimPolicy]
type: copy
sources: [existing, new]
resourceMatchers:
- apiVersionKindMatcher: { apiVersion: secrets.educates.dev/v1beta1, kind: SecretCopier }
- paths:
- [metadata, annotations, "kopf.zalando.org/last-handled-configuration"]
type: copy
sources: [existing]
resourceMatchers:
- apiVersionKindMatcher: { apiVersion: secrets.educates.dev/v1beta1, kind: SecretCopier }
- paths:
- [spec, syncPeriod]
type: copy
sources: [existing, new]
resourceMatchers:
- apiVersionKindMatcher: { apiVersion: kappctrl.k14s.io/v1alpha1, kind: App }
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:

deploy:
- kapp:
rawOptions: ["--app-changes-max-to-keep=5", "--wait-timeout=5m"]
rawOptions: ["--app-changes-max-to-keep=5", "--wait-timeout=5m", "--diff-changes=true"]
#@ end

#@ if data.values.mode == "app_per_bundle":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
- path: values
deploy:
- kapp:
rawOptions: ["--app-changes-max-to-keep=5", "--wait-timeout=5m"]
rawOptions: ["--app-changes-max-to-keep=5", "--wait-timeout=5m", "--diff-changes=true"]
#@ end

#@ if data.values.mode == "one_app":
Expand Down
12 changes: 4 additions & 8 deletions overlays/portal-app/src/bundle/config/kapp/kapp-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
apiVersion: kapp.k14s.io/v1alpha1
kind: Config
rebaseRules:
- path: [metadata, annotations, "kopf.zalando.org/last-handled-configuration"]
- paths:
- [metadata, annotations, "kopf.zalando.org/last-handled-configuration"]
type: copy
sources: [new, existing]
sources: [existing]
resourceMatchers:
- apiVersionKindMatcher: { apiVersion: training.educates.dev/v1beta1, kind: TrainingPortal }
diffAgainstExistingFieldExclusionRules:
- path: [status]
type: copy
sources: [new, existing]
resourceMatchers:
- apiVersionKindMatcher: { apiVersion: training.educates.dev/v1beta1, kind: TrainingPortal }
diffAgainstLastAppliedFieldExclusionRules:
- path: [metadata, annotations, "kopf.zalando.org/last-handled-configuration"]
resourceMatchers:
- apiVersionKindMatcher: { apiVersion: training.educates.dev/v1beta1, kind: TrainingPortal }
5 changes: 3 additions & 2 deletions resources/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ spec:
- ytt:
ignoreUnknownComments: true
paths:
- config
- config/ytt
- config/kapp
valuesFrom:
- path: environments/versions.yaml
- downwardAPI:
Expand All @@ -32,4 +33,4 @@ spec:
fieldPath: metadata.annotations['educates_gitops_environment']
deploy:
- kapp:
rawOptions: ["--app-changes-max-to-keep=5", "--wait-timeout=5m"]
rawOptions: ["--app-changes-max-to-keep=5", "--wait-timeout=5m", "--diff-changes=true"]
5 changes: 5 additions & 0 deletions resources/rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
kind: Namespace
apiVersion: v1
metadata:
name: package-installs
---
kind: ServiceAccount
apiVersion: v1
metadata:
Expand Down

0 comments on commit 92c0179

Please sign in to comment.