This is the starter repository for using Fleet with a GitOps workflow.
-
Clone the GitHub repository, create your own GitHub repository, and push your clone to your new repo. Note that a workflow will run once and fail because the required variables haven't been added (step 2).
-
Add
FLEET_URLandFLEET_API_TOKENsecrets to your new repository's secrets. Learn how here. SetFLEET_URLto your Fleet instance's URL (ex. https://organization.fleet.com). Create an API-only user with the "GitOps" role and setFLEET_API_TOKENto your user's API token. If you're using Fleet Free, set the API-only user's role to global admin. -
In GitHub, enable the
Apply latest configuration to FleetGitHub Actions workflow, and run workflow manually. Now, when anyone pushes a new commit to the default branch, the action will run and update Fleet. For pull requests, the workflow will do a dry run only.
-
Clone the GitLab repository, create your own GitLab repository, and push your clone to your new repo. Note that a pipeline will run once and fail because the required variables haven't been added (step 2).
-
Add
FLEET_URLandFLEET_API_TOKENas masked CI/CD variables. Learn how here. SetFLEET_URLto your Fleet instance's URL (ex. https://organization.fleet.com). SetFLEET_API_TOKENto an API token for an API-only user in Fleet. Learn how here, then, grant it theGitOpsrole via the Settings > Users page so it can make changes. -
Now, when anyone pushes a new commit to the default branch, the pipeline will run and update Fleet. For merge requests, the pipeline will do a dry run only.
-
To ensure your Fleet configuration stays up to date even when there are no new commits, set up a scheduled pipeline:
- In your GitLab project, go to the left sidebar and navigate to Build > Pipeline schedules. (In some GitLab versions, this may appear as CI/CD > Schedules.)
- Click Create a new pipeline schedule (or Schedule a new pipeline).
- Fill in the form:
- Description: e.g.,
Daily GitOps sync - Cron timezone: e.g.,
[UTC 0] UTC - Interval pattern: e.g., Custom:
0 6 * * *(runs nightly at 6AM UTC) - Target branch or tag: your default branch (e.g.,
main)
- Description: e.g.,
- Click Create pipeline schedule.
For all configuration options, go to the YAML files reference in the Fleet docs.
Once you're set up with GitOps in Fleet, you can optionally put the UI in GitOps mode. This prevents you from making changes in the UI that would be overridden by GitOps workflows.
An admin can enable GitOps mode in Settings > Integrations > Change management.
Note that this is a UI-only setting. API permissions are restricted based on user role.