Repository navigation
Improve the Helm chart #894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simonchrz
wants to merge
5
commits into
git-pkgs:main
Choose a base branch
from
simonchrz:chart/improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6ef5139
Improve the Helm chart
simonchrz 3322ff8
Harden the chart's rendering of names, ports and the test pod
simonchrz cf4e63a
Leave the name label off the chart's test pod
simonchrz 8e21162
Add a NetworkPolicy and keep secrets out of the chart's ConfigMap
simonchrz 503bfe5
Refuse database passwords in query strings and keyword DSNs
simonchrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # git-pkgs proxy | ||
|
|
||
| A caching proxy for package registries. This chart runs it as a Deployment | ||
| with a Service, and optionally an Ingress or HTTPRoute, a ServiceMonitor, a | ||
| ServiceAccount, a PodDisruptionBudget and a NetworkPolicy. | ||
|
|
||
| ```bash | ||
| helm install proxy oci://ghcr.io/git-pkgs/charts/proxy \ | ||
| --set config.data.base_url=https://proxy.example.com | ||
| ``` | ||
|
|
||
| The defaults give one replica with a 10 GiB volume at `/data`, holding a | ||
| SQLite database and the cached artifacts. [`values.yaml`](values.yaml) | ||
| describes every value; `values.schema.json` rejects a value the chart doesn't | ||
| know, so a misspelled key fails the install instead of being ignored. | ||
|
|
||
| ## Configuration | ||
|
|
||
| `config.data` is the proxy's configuration file, passed through as it is; the | ||
| [configuration reference](https://github.com/git-pkgs/proxy/blob/main/docs/configuration.md) | ||
| lists the keys. Environment variables override it, and are the place for | ||
| secrets: | ||
|
|
||
| ```yaml | ||
| config: | ||
| data: | ||
| base_url: https://proxy.example.com | ||
| database: | ||
| driver: postgres | ||
|
|
||
| extraEnv: | ||
| - name: PROXY_DATABASE_URL | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: proxy-database | ||
| key: url | ||
| ``` | ||
|
|
||
| Secrets in `config.data` would be stored in the ConfigMap in plain text, so | ||
| the chart refuses to render a `token`, `password`, `header_value` or | ||
| `signing_key` that isn't a `${VAR}` reference, or a `database.url` with a | ||
| password, whether as `user:password@`, as `?password=` or as a `password=` | ||
| keyword (set such a URL through `PROXY_DATABASE_URL` instead). The proxy | ||
| expands `${VAR}` in the other keys, so the value can come from a Secret: | ||
|
|
||
| ```yaml | ||
| config: | ||
| data: | ||
| upstream: | ||
| auth: | ||
| "https://npm.pkg.github.com": | ||
| type: bearer | ||
| token: "${GITHUB_TOKEN}" | ||
|
|
||
| extraEnv: | ||
| - name: GITHUB_TOKEN | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: proxy-upstream | ||
| key: github-token | ||
| ``` | ||
|
|
||
| `config.allowSecretsInConfigMap: true` turns the check off. Other keys that | ||
| can hold credentials, such as scanner `headers`, aren't checked. | ||
|
|
||
| Set `config.existingConfigMap` to use a ConfigMap of your own instead. | ||
|
|
||
| The container port follows `config.data.listen`. Set `service.containerPort` | ||
| when the listen address comes from an existing ConfigMap or `PROXY_LISTEN`. | ||
|
|
||
| ## More than one replica | ||
|
|
||
| Replicas can't share a SQLite file, so they need: | ||
|
|
||
| - `config.data.database.driver: postgres`, with the URL in `PROXY_DATABASE_URL` | ||
| - `deploymentStrategy.type: RollingUpdate` | ||
| - artifact storage all replicas reach: object storage with | ||
| `persistence.enabled: false`, or a `file://` URL on a `ReadWriteMany` volume | ||
|
|
||
| The chart refuses to render more than one replica when the generated | ||
| configuration uses SQLite and nothing else can set the database. | ||
| `podDisruptionBudget.enabled` adds a budget once there is more than one. | ||
|
|
||
| ## Cloud credentials | ||
|
|
||
| The `ecr` upstream auth type and S3 storage take AWS credentials from the | ||
| SDK's default chain. To bind them to the pod, give it a ServiceAccount: | ||
|
|
||
| ```yaml | ||
| serviceAccount: | ||
| create: true | ||
| annotations: | ||
| eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/proxy | ||
| ``` | ||
|
|
||
| ## Exposing the proxy | ||
|
|
||
| Use `ingress` or `httpRoute` (Gateway API), not both. Artifacts and hosted | ||
| uploads can be large, and most controllers cap the request body and time out | ||
| long responses by default; `values.yaml` shows the annotations for | ||
| ingress-nginx, and `httpRoute.timeouts` sets the route's. | ||
|
|
||
| ## Limiting who reaches the proxy | ||
|
|
||
| `/ui`, `/api/cache`, `/api/mirror` and `/_internal/scan-fetch` have no | ||
| authentication of their own. `networkPolicy.enabled` adds a NetworkPolicy that | ||
| admits only the peers in `networkPolicy.from` to the proxy's port, and the pod | ||
| of `helm test`: | ||
|
|
||
| ```yaml | ||
| networkPolicy: | ||
| enabled: true | ||
| from: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: ingress-nginx | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: ci | ||
| ``` | ||
|
|
||
| List the ingress controller or gateway, the clients that pull packages, and | ||
| Prometheus if it scrapes `/metrics`. `networkPolicy.egress` restricts outgoing | ||
| traffic as well; once set, everything it doesn't list is denied, DNS included. | ||
|
|
||
| The chart's policy doesn't replace other NetworkPolicies that select the proxy | ||
| pods: Kubernetes adds their allow rules together, so a policy that admits all | ||
| traffic keeps `/ui`, `/api/cache`, `/api/mirror` and `/_internal/scan-fetch` | ||
| open to everyone it admits. Look for such policies in the namespace and | ||
| restrict them, for ingress and egress. | ||
|
|
||
| A NetworkPolicy sees addresses and ports, not paths, and the cluster's network | ||
| plugin has to enforce it. To keep `/ui` or the APIs from clients that may pull | ||
| packages, restrict those paths at the ingress or gateway too. | ||
|
|
||
| ## Checking an install | ||
|
|
||
| ```bash | ||
| helm test proxy | ||
| ``` | ||
|
|
||
| runs a pod that asks the proxy for `/health` through its Service. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.