In Fleet 4.45, Fleet GitOps was released in beta. The Fleet team is currently dogfooding and documenting the feature. You can track the progress here.
This folder illustrates the best practice for using Fleet with a GitOps workflow.
How to set up a GitOps workflow to manage Fleet:
-
Clone this repository.
-
If you do not have a Premium Fleet license, delete the
teams
folder. -
Make any changes to policies, queries, controls, and more defined in the files.
-
Create your own GitHub repository.
-
Add
FLEET_URL
andFLEET_API_TOKEN
to your GitHub repository secrets. -
Update the
env
section of your .github/workflows/workflow.yml file for all the environment variables that are mentioned in yourdefault.yml
andteams/*.yml
YAML files. For the environment variables that map to secrets, add the required secrets to your GitHub repository secrets. -
Push your cloned and modified code to your repo.
-
In GitHub, enable the
Apply latest configuration to Fleet
GitHub Actions workflow, and run workflow manually. Now, when anyone pushes a new commit, the action will run and update Fleet.
lib/
- folder for policies, queries, configuration profiles, scripts, and agent options. These files can be referenced in top level keys in thedefault.yml
file and the files in theteams/
folder.default.yml
- file that defines the queries, policies, controls, and agent options for all hosts. If you're using Fleet Premium, this file updates queries and policies that run on all hosts ("All teams"). Controls and agent options are defined for hosts on "No team."teams/
- folder for teams in Fleet. These*.yml
files define the controls, queries, policies, and agent options for hosts assigned to the specified team..github/workflows/workflow.yml
- the GitHub workflow file that applies the latest configuration to Fleet..github/gitops-action/action.yml
- the GitHub action that runsgitops.sh
. This action is used in the GitHub workflow file. It can also be used in other workflows.gitops.sh
- the bash script that applies the latest configuration to Fleet by executingfleetctl gitops
. This script is used in the GitHub action file. It can be run standalone during development.