amazon-eksfluxcd

FluxCD on EKS cannot read a private repo on GitHub


After installing FluxCD v2 on my EKS cluster, I defined a GitRepository definition pointing to a repo on GitHub.

---
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
  name: springbootflux-infra
  namespace: flux-system
spec:
  interval: 30s
  ref:
    branch: master
  url: https://github.com/***/privaterepo

As the name says, yhe privaterepo on GitHub is a private. Problem is that FluxCD cannot read the repo. What can I do to allow FluxCD on EKS to be able to read the repo?


Solution

  • For private repositories you need to define a secret which contains the credentials.

    Create a secret:

    apiVersion: v1
    kind: Secret
    metadata:
      name: repository-creds
    type: Opaque
    data:
      username: <BASE64>
      password: <BASE64>
    

    Refer to the secret in your GitRepository object:

      secretRef:
        name: repository-creds
    

    Official documentation: https://fluxcd.io/docs/components/source/gitrepositories/#secret-reference