Create a Git Secret for PAC
When you integrate a repository with PAC over a Webhook (not the GitHub App), the Repository resource references a Kubernetes Secret that holds two pieces of credentials:
- A Git access token PAC uses to call the Git provider's API (read repository metadata, post commit/status checks, manage the webhook).
- A webhook secret the Git provider includes when delivering an event so PAC can verify the request originated from the expected source.
This guide creates that Secret for GitHub Webhook mode and GitLab Webhook mode. GitHub App mode does not need a per-repository Secret because the controller uses the cluster-wide App credentials.
TOC
How PAC reads the SecretPrerequisitesStep 1: Create the Git Access TokenStep 2: Choose a Webhook SecretStep 3: Create the Kubernetes SecretStep 4: Reference the Secret from the RepositoryVerificationUpdating credentialsNext stepsHow PAC reads the Secret
PAC looks up the Secret through the Repository.spec.git_provider fields:
- If
keyis omitted onsecret, PAC readsprovider.token. - If
keyis omitted onwebhook_secret, PAC readswebhook.secret. secret.nameandwebhook_secret.namecan point to the sameSecretor to two different ones.
The Secret must live in the same namespace as the Repository resource.
Prerequisites
- A Git provider account with permission to create a Personal Access Token (PAT) on the repository.
- A target namespace for the Repository resource.
kubectlaccess to that namespace.
Step 1: Create the Git Access Token
Create a PAT on your Git provider:
Copy the token immediately. Most providers display it only once.
Step 2: Choose a Webhook Secret
The webhook secret is a shared string between PAC and the Git provider. PAC verifies incoming events against this value.
You can use any sufficiently random string, such as a generated password from your password manager. The same value must be stored in the Kubernetes Secret and configured in the Git provider webhook.
If you want to generate one from the command line, openssl is one option:
Example output:
The webhook secret is optional but strongly recommended. Without it, anyone who learns the webhook URL can forge events.
Step 3: Create the Kubernetes Secret
Create one Secret that stores both values under the default keys. Replace:
-
<git-access-token>with the Git provider token from Step 1. -
<webhook-secret>with the shared webhook secret string from Step 2.
Example output:
Alternatively, create it from a manifest:
Step 4: Reference the Secret from the Repository
In the Repository resource, point both git_provider.secret and git_provider.webhook_secret at the Secret you just created. Because the default keys are used, the key field can be omitted:
If you stored the credentials under non-default keys, set key explicitly on both fields.
Verification
Confirm the Secret exists and carries both keys:
Example output:
After the Repository resource is created, PAC logs a successful lookup. Tail the controller logs in the PAC namespace:
An authentication failure ("401 Unauthorized", "invalid token") in the controller logs indicates a wrong or insufficiently-scoped token; see Common Issues for the full troubleshooting checklist.
Updating credentials
Rotate the token by updating the Secret in place:
PAC reads the Secret on every incoming event, so no controller restart is needed.