Skip to content

Commit

Permalink
Tidy up documentation
Browse files Browse the repository at this point in the history
 * Add template example for matrix
 * Fix up the count of generators
 * Add note about local dev.
 * Fix the broken yaml.
  • Loading branch information
bigkevmcd committed Jan 31, 2023
1 parent a1e8f85 commit bf93bb2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ make undeploy
IMG=<user/repo>:$(git rev-parse --short HEAD) make manifests generate docker-build docker-push release
```

This release file can be easily applied to a cluster:
```sh
kubectl apply -f release.yaml
```

### For development purposes
You will need a bare minimum of Flux installed
```sh
flux install --components source-controller,kustomize-controller
make run
```

## Contributing
// TODO(user): Add detailed information on how you would like others to contribute to this project

Expand Down
1 change: 1 addition & 0 deletions controllers/gitopsset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func (r *GitOpsSetReconciler) removeResourceRefs(ctx context.Context, deletions
return fmt.Errorf("failed to delete %v: %w", u, err)
}
}

return nil
}

Expand Down
53 changes: 51 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ In this case, six different `ConfigMaps` are generated, three for the "dev-team"

## Generators

We currently provide three generators:
We currently provide these generators:

* list
* pullRequests
Expand Down Expand Up @@ -158,7 +158,7 @@ spec:
- path: examples/generation/staging.yaml
templates:
- content:
- kind: Kustomization
kind: Kustomization
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
metadata:
name: "{{ .element.env }}-demo"
Expand Down Expand Up @@ -253,6 +253,13 @@ The fields emitted by the pull-request are as follows:
* `clone_url` this is the HTTPS clone URL for this repository
* `clone_ssh_url` this is the SSH clone URL for this repository

You will need an API key that can query the GitHub API.
```shell
$ kubectl create secret generic github-secret \
--from-literal password=<insert access token here>
```
You can limit the scope of this token to read only access to your repositories.

### Matrix generator

The matrix generator doesn't generate by itself, it combines the results of
Expand Down Expand Up @@ -296,6 +303,48 @@ This will result in three sets of generated parameters, which are a combination
version: 1.0.0
```

These can be referenced in the templates, note that all keys in the merged generators from the Matrix are contained in the `element` scope.

```yaml
apiVersion: templates.weave.works/v1alpha1
kind: GitOpsSet
metadata:
name: matrix-sample
spec:
generators:
- matrix:
generators:
- gitRepository:
repositoryRef: go-demo-repo
files:
- path: examples/generation/dev.yaml
- path: examples/generation/production.yaml
- path: examples/generation/staging.yaml
- list:
elements:
- cluster: dev-cluster
version: 1.0.0
templates:
- content:
kind: Kustomization
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
metadata:
name: "{{ .element.env }}-demo"
labels:
app.kubernetes.io/name: go-demo
app.kubernetes.io/instance: "{{ .element.env }}"
com.example/team: "{{ .element.team }}"
com.example/cluster: "{{ .element.cluster }}"
com.example/version: "{{ .element.version }}"
spec:
interval: 5m
path: "./examples/kustomize/environments/{{ .element.env }}"
prune: true
sourceRef:
kind: GitRepository
name: go-demo-repo
```

## Security

**WARNING** generating resources and applying them directly into your cluster can be dangerous to the health of your cluster.
Expand Down

0 comments on commit bf93bb2

Please sign in to comment.