Skip to content

error: 401 Must authenticate to access this API when deploying via Kustomize on GKE connected to a self-hosted Github Enterprise Server #5565

@alan707

Description

@alan707

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

When Atlantis v0.33.0 is deployed against a GitHub Enterprise Server (GHES) instance, it repeatedly fails to post comments on pull requests with:

401 Must authenticate to access this API

Despite:

  1. Generating and validating a GitHub App JWT (returns HTTP 200 from /api/v3/app).
  2. Exchanging that JWT for an installation access token (manually via curl).
  3. Confirming the App has Read & Write permissions on Issues and Pull Requests and is installed on the target repo.
  4. Mounting the private key and webhook secret correctly via a Kubernetes Secret.
  5. Setting both ATLANTIS_GH_APP_KEY_FILE and ATLANTIS_GH_WEBHOOK_SECRET in the pod environment.

Restarting the StatefulSet after every configuration change.

What does work

I’ve verified that posting an atlantis help comment on a PR in the allowed repository successfully appears in the pod’s logs.

Reproduction Steps

  1. Deploy Atlantis via kubectl apply
  2. Bootstraped the GitHub App via Atlantis gtihub-app/setup URL
  3. Store credentials in Kubernetes secrets encoding them via base64 (including app-key file contents)
  4. Confirmed Github Enterprise server can ping atlantis
  5. Create a PR in the allowed repo and create a comment atlantis help

Logs

Environment details

  • Atlantis version: v0.33.0
  • Deployment method: Kustomization via GKE
  • Atlantis flags: None
  • Env Vars:
        - name: ATLANTIS_DATA_DIR
          value: /atlantis
        - name: ATLANTIS_PORT
          value: "4141" 
        - name: ATLANTIS_GH_USER
          value: fake # recommended by Atlantis docs: https://www.runatlantis.io/docs/access-credentials.html#github-app
        - name: ATLANTIS_GH_TOKEN
          value: fake # recommended by Atlantis docs: https://www.runatlantis.io/docs/access-credentials.html#github-app
        - name: ATLANTIS_GH_ORG
          value: readacted_org
        - name: ATLANTIS_ATLANTIS_URL
          value: https://<ATLANTIS_URL>
        - name: ATLANTIS_LOG_LEVEL
          value: debug
        - name: ATLANTIS_REPO_ALLOWLIST
          value: URL/REPO
        - name: ATLANTIS_GH_HOSTNAME
          value: "HOSTNAME"
        - name: ATLANTIS_GH_APP_ID
          value: "redacted"
        - name: ATLANTIS_GH_APP_KEY_FILE
          value: /etc/atlantis/gh-app-key.pem
        - name: ATLANTIS_GH_WEBHOOK_SECRET
          valueFrom:
            secretKeyRef:
              name: atlantis-vcs
              key: webhook-secret # must generate this with base64 encode

Additional Context

Decided to use an ATLANTIS_GH_APP_KEY_FILE but I also tried just passing the value for ATLANTIS_GH_APP_KEY directly from the Kubernetes secret. That failed to authenticate as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions