Skip to main content

Set up pull request delivery

A GitStateStore's delivery mode controls how Kratix writes to the Git repository. By default, Kratix pushes straight to the branch. With pull request delivery, SKE opens a pull request for each change instead, and the change reaches the cluster only after someone merges it. SKE never merges the pull request itself.

Pull request delivery works with GitHub pull requests (github.com and GitHub Enterprise Server), Azure DevOps pull requests, and GitLab merge requests. GitLab calls a pull request a merge request.

What you need​

warning

A Destination with filepath.mode: aggregatedYAML cannot use pull request delivery. Kratix refuses to create or update the Destination or the GitStateStore if the change would put them together.

Turn it on​

Add a delivery block to the GitStateStore:

apiVersion: platform.kratix.io/v1alpha1
kind: GitStateStore
metadata:
name: production
spec:
url: https://github.com/acme/platform-state
branch: main
authMethod: basicAuth
secretRef:
name: git-credentials
namespace: default
delivery:
mode: pullRequest
config:
provider: github

SKE now writes to every Destination that uses this GitStateStore through pull requests. For the optional settings, see the pull request delivery reference.

Check it works​

Request a resource from a Promise scheduled to one of those Destinations. Its STATUS links the pull request:

kubectl get <RESOURCE_KIND> <RESOURCE_NAME> -n <NAMESPACE>
NAME MESSAGE STATUS
redis Redis provisioned Waiting for approval: https://github.com/acme/platform-state/pull/42

Merge the pull request. Within the checkInterval (default: 30 seconds), the request is ready and any later pipelines run.

Review a change​

Each change to a request gets its own pull request, opened from a kratix/<WORKPLACEMENT_NAME> branch into the Destination's branch.

  • Merge it to write the change to the Destination's branch.

  • Close it without merging to reject the change. The request fails, and if the pull request was closed with Close with comment, the comment is quoted in the STATUS of the request:

    NAME MESSAGE STATUS
    redis Redis provisioned Rejected in https://github.com/acme/platform-state/pull/42: "not during the freeze"

SKE does not open a pull request for the same files again. A new one opens when the request or the Promise produces different files, or when you retry.

Don't change SKE's branches by hand

Do not commit to the kratix/<WORKPLACEMENT_NAME> branches or edit SKE's files on the Destination's branch. SKE replaces those commits, or opens a pull request to undo them. Change the Promise or the request instead.

Retry a rejected change​

To force SKE to recreate a pull request, for example when the previous one was closed without being merged, label the request's Work with kratix.io/redeliver=true:

kubectl label works -n <NAMESPACE> \
-l kratix.io/promise-name=<PROMISE_NAME>,kratix.io/resource-name=<RESOURCE_NAME> \
kratix.io/redeliver=true

Delete a request​

Deleting a request also opens a pull request to remove its files from the State Store. The request is only removed when that pull request is merged. The request's status shows the URL of the pull request:

NAME MESSAGE STATUS
redis Redis provisioned Waiting for approval to remove: https://github.com/acme/platform-state/pull/57

If a reviewer closes the removal pull request without merging it, the workloads keep running and the request stays on the platform. To retry by opening a new pull request, use the label above. To let the request finish deleting and keep its files, see Deleting.