FluxCD on EKS cannot read a private repo on GitHub

451 views Asked by At

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?

1

There are 1 answers

0
Paulo Gomes On BEST ANSWER

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