fluxcd

How can I change fluxcd automatic sync time?


As we know, fluxcd can check the git reposiroty and docker image repository periodly, and apply the newest changes in the repository. But how can I control how long it will take to check the change ? The default time may be ~5 minutes, if I want to change to 1 minutes, how can I change it ?


Solution

  • FluxCD v1

    For FluxCD v1, the interval times are controlled by flags on the flux deployment.

    There are 2 flags that Control how often Flux syncs the cluster with git.

    --git-poll-interval controls how often flux looks at Git for new commits. This value is git.pollInterval in the flux helm chart.

    --sync-interval controls how often flux will apply what’s in git to the cluster, regardless of new commits. This is how, for example, a resource deleted using other means will be re-created. In the flux helm chart, this value is sync.interval, and defaults to the git.pollInterval time.


    FluxCD V2

    For FluxCD v2, the GitOps Toolkit, the "git poll interval" is controlled by the GitRepository resource for each Git repo defined.

    apiVersion: source.toolkit.fluxcd.io/v1beta1
    kind: GitRepository
    metadata:
      name: my-app-repo
      namespace: flux-system
    spec:
      interval: 1m # Interval
      url: https://github.com/my-org/my-repo.git
      ref:
        branch: master
    

    In Flux v2, the "sync interval" equivalent is referred to in the Kustomization reconciliation. This is the interval at which you want to undo manual changes.

    apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
    kind: Kustomization
    metadata:
      name: my-app
      namespace: default
    spec:
      interval: 15m
      path: "./deploy/prod"
      prune: true
      sourceRef:
        kind: GitRepository
        name: my-app-repo