Skip to content

feat(repository): use git bundles in runners + refactor credentials #605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9f1cb41
feat(runner): launch runners on specific commits (#529)
corrieriluca May 23, 2025
11dd89d
refactor(provider): create dedicated credentials package and rework r…
AlanLonguet May 23, 2025
7f4f400
feat(repo-controller): add LastRelevantCommit annotation to layers
corrieriluca May 29, 2025
0ab918e
feat(layers): do not run plan/apply without a LastRelevantCommit
corrieriluca May 29, 2025
d227fe8
fix(github): support gh enterprise api
corrieriluca May 30, 2025
5ddae9c
fix: remove old file from rebase merge
corrieriluca May 30, 2025
e6964c1
fix(webhook): remove tests for push event
corrieriluca May 30, 2025
2767ce2
fix(layer-controller): fix tests with needed relevant-commit
corrieriluca May 30, 2025
f942cc0
fix(webhook): remove unused function
corrieriluca May 30, 2025
25928ca
fix(credentials): make github apps work
corrieriluca May 30, 2025
83f4396
test: trigger helm chart build to get new CRD
corrieriluca May 30, 2025
354950e
fix(repo-controller): always add last relevant commit annotation
corrieriluca May 30, 2025
da6e066
fix(server-rbac): give read rights to secrets
corrieriluca May 30, 2025
0c53522
feat(config): enable repository controller by default
corrieriluca May 30, 2025
25b07d3
test(webhook): add test for repository annotation on push event
corrieriluca Jun 13, 2025
46e5dd2
test(webhook): add test for repository annotation on pullrequest event
corrieriluca Jun 13, 2025
3f89500
test(webhook): fix test for push repo annotation
corrieriluca Jun 13, 2025
9fc535a
test(repo-controller): add first test of the repository controller sync
corrieriluca Jun 13, 2025
44787e7
test(all): fix May 8th 2023 from Sun to Mon
corrieriluca Jun 13, 2025
0484dc7
test(repo-controller): remove unused pointer
corrieriluca Jun 13, 2025
d432931
test(repo-controller): add tests for new repo
corrieriluca Jun 20, 2025
3d3183c
test(repo-controller): add tests when repo sync too old
corrieriluca Jun 20, 2025
2bcd8c5
test(repo-controller): add tests when new layer created
corrieriluca Jun 20, 2025
cea0fd8
test(repo-controller): add tests when repo are already synced
corrieriluca Jun 20, 2025
78ab32e
test(repo-controller): add tests when repo has no layer anymore
corrieriluca Jun 20, 2025
cb8eabf
test(repo-controller): add tests when repo has sync-now requests
corrieriluca Jun 20, 2025
0096de4
test(repo-controller): add tests when repo sync fails
corrieriluca Jun 20, 2025
c0c2d20
docs: update for new credentials system
corrieriluca Jun 27, 2025
ddb6f70
docs: remove references to old credential system
corrieriluca Jun 27, 2025
301ca65
docs: add doc on repository controller
corrieriluca Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/v1alpha1/terraformrepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ type TerraformRepositorySpec struct {
SyncWindows []SyncWindow `json:"syncWindows,omitempty"`
}
type TerraformRepositoryRepository struct {
Url string `json:"url,omitempty"`
SecretName string `json:"secretName,omitempty"`
Url string `json:"url,omitempty"`
}

// TerraformRepositoryStatus defines the observed state of TerraformRepository
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/terraformrun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Artifact struct {
type TerraformRunLayer struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Revision string `json:"revision,omitempty"`
}

// TerraformRunStatus defines the observed state of TerraformRun
Expand Down
4 changes: 3 additions & 1 deletion cmd/controllers/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ func buildControllersStartCmd(app *burrito.App) *cobra.Command {
defaultWaitActionTimer, _ := time.ParseDuration("5s")
defaultFailureGracePeriod, _ := time.ParseDuration("15s")
defaultRepositorySyncTimer, _ := time.ParseDuration("5m")
defaultCredentialsTTL, _ := time.ParseDuration("2m")

cmd.Flags().StringSliceVar(&app.Config.Controller.Namespaces, "namespaces", []string{"burrito-system"}, "list of namespaces to watch")
cmd.Flags().StringArrayVar(&app.Config.Controller.Types, "types", []string{"layer", "run", "pullrequest"}, "list of controllers to start")
cmd.Flags().StringArrayVar(&app.Config.Controller.Types, "types", []string{"layer", "repository", "run", "pullrequest"}, "list of controllers to start")
cmd.Flags().DurationVar(&app.Config.Controller.Timers.DriftDetection, "drift-detection-period", defaultDriftDetectionTimer, "period between two plans. Must end with s, m or h.")
cmd.Flags().DurationVar(&app.Config.Controller.Timers.RepositorySync, "repository-sync-period", defaultRepositorySyncTimer, "period between two repository sync. Must end with s, m or h.")
cmd.Flags().DurationVar(&app.Config.Controller.Timers.CredentialsTTL, "credentials-ttl", defaultCredentialsTTL, "default TTL for git providers credentials in controller's memory. Must end with s, m or h.")
cmd.Flags().DurationVar(&app.Config.Controller.Timers.OnError, "on-error-period", defaultOnErrorTimer, "period between two runners launch when an error occurred in the controllers. Must end with s, m or h.")
cmd.Flags().DurationVar(&app.Config.Controller.Timers.WaitAction, "wait-action-period", defaultWaitActionTimer, "period between two runners when a layer is locked. Must end with s, m or h.")
cmd.Flags().DurationVar(&app.Config.Controller.Timers.FailureGracePeriod, "failure-grace-period", defaultFailureGracePeriod, "initial time before retry, goes exponential function of number failure. Must end with s, m or h.")
Expand Down
8 changes: 8 additions & 0 deletions deploy/charts/burrito/templates/rbac-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,11 @@ rules:
- get
- patch
- update
- apiGroups:
- ""
resources:
- secrets
verbs:
- list
- watch
- get
9 changes: 4 additions & 5 deletions deploy/charts/burrito/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ config:
# -- Duration to wait before retrying on locked layer
waitAction: 10s
# -- Duration to wait before retrying on failure (increases exponentially with the amount of failed retries)
failureGracePeriod: 30
failureGracePeriod: 15s
# -- Default sync windows for layer reconciliation
defaultSyncWindows: []
# -- Maximum number of concurrent reconciles for the controller, increse this value if you have a lot of resources to reconcile
Expand All @@ -34,9 +34,8 @@ config:
maxConcurrentRunnerPods: 0
# -- Maximum number of retries for Terraform operations (plan, apply...)
terraformMaxRetries: 3
# TODO: enable repository controller by default
# -- Resource types to watch for reconciliation. Note: by default repository controller is disabled as it is not yet fully usable.
types: ["layer", "run", "pullrequest"]
# -- Resource types to watch for reconciliation.
types: ["layer", "repository", "run", "pullrequest"]
leaderElection:
# -- Enable/Disable leader election
enabled: true
Expand Down Expand Up @@ -86,7 +85,7 @@ config:
repository: ghcr.io/padok-team/burrito
tag: "" # By default use Chart's appVersion
pullPolicy: Always

# -- Command to run in the Burrito runner container
command: ["burrito"]
# -- Arguments to pass to the Burrito runner container
Expand Down
Binary file modified docs/assets/design/architecture-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ Create a Kubernetes `Secret` to reference the necessary credentials to clone you
<!-- markdownlint-enable MD046 -->

```yaml
apiVersion: v1
kind: Secret
metadata:
name: burrito-repo
namespace: <tenant-namespace>
type: Opaque
type: credentials.burrito.tf/repository
stringData:
provider: standard
url: <https-or-ssh-repository-url>
username: <my-username>
password: <my-password | my-access-token>
sshPrivateKey: |
Expand All @@ -88,13 +91,12 @@ metadata:
spec:
repository:
url: <https-or-ssh-repository-url>
secretName: burrito-repo
terraform:
enabled: true
```

!!! info
You can also connect to a public repository by omitting `spec.repository.secretName` in your `TerraformRepository` definition.
You can also connect to a public repository without creating any credentials.

## 3. Synchronize a Terraform layer

Expand Down
16 changes: 9 additions & 7 deletions docs/guides/pr-mr-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ spec:
enabled: true
```

You will also need to setup a [GitHub App](https://docs.github.com/en/apps/creating-github-apps/about-creating-github-apps/about-creating-github-apps) to allow Burrito to comment on your PRs/MRs. Follow the instructions in the [PR/MR workflow](../operator-manual/pr-mr-workflow.md#configuration) section of the operator manual to set up the GitHub app.
You will also need to setup a [GitHub App](https://docs.github.com/en/apps/creating-github-apps/about-creating-github-apps/about-creating-github-apps) to allow Burrito to comment on your PRs/MRs. Follow the instructions in the [GitHub App](../operator-manual/git-authentication/github-app.md) section of the operator manual to set up the GitHub app.
Make sure that you created a secret associated to your repository that include the GitHub app ID, installation ID, and private key.

!!! note
You can also use a personal access token instead of a GitHub app. Your GitHub account will be used to comment on the PRs/MRs.
The secret should include the personal access token in the `githubToken` key.
You can also use a [personal access token](../operator-manual/git-authentication/github-token.md) instead of a GitHub app. Your GitHub account will be used to comment on the PRs/MRs.

Now let's configure the GitHub webhook. Expose the `burrito-server` kubernetes service to the internet using the method of your choice. (for testing purposes on a local cluster, you can use `kubectl port-forward` and [ngrok](https://ngrok.com/) to expose the service to the internet).

Expand All @@ -47,18 +46,21 @@ metadata:
spec:
repository:
url: https://github.com/<your-github-handle>/burrito-examples
secretName: burrito-secret
terraform:
enabled: true
---
apiVersion: v1
kind: Secret
metadata:
name: burrito-webhook-secret
namespace: burrito-project
type: Opaque
type: credentials.burrito.tf/repository
stringData:
githubAppId: "123456"
githubAppInstallationId: "12345678"
provider: github
url: https://github.com/<your-github-handle>/burrito-examples
webhookSecret: "your-webhook-secret"
githubAppID: "123456"
githubAppInstallationID: "12345678"
githubAppPrivateKey: |
-----BEGIN RSA PRIVATE KEY-----
my-private-key
Expand Down
Loading
Loading