-
Notifications
You must be signed in to change notification settings - Fork 30
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
Adding Porch private authenticated registries functionality documentation #178
Merged
Merged
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6c14729
added documentation for setting up function runner to use private aut…
Catalin-Stratulat-Ericsson 3c10cdb
modification to language, hyperlinks and improved consistency
Catalin-Stratulat-Ericsson 240014b
small patch for secret name variable
Catalin-Stratulat-Ericsson a8562b4
added small statement regarding potential access permission issues
Catalin-Stratulat-Ericsson cb9cd33
added example for mount path permissions
Catalin-Stratulat-Ericsson 119236b
fix typo in first point
Catalin-Stratulat-Ericsson b79522b
added namespace clarification
Catalin-Stratulat-Ericsson 9907d33
changed symbol type for file names as per suggestion
Catalin-Stratulat-Ericsson eb97c98
changed e.g. usage to for example as per suggestions
Catalin-Stratulat-Ericsson 13f9793
added note synax to notes as per recommendation
Catalin-Stratulat-Ericsson b9672d0
changed the Hugo Warnings to Notes
Catalin-Stratulat-Ericsson c681720
made ammendments to language and structure as per comment suggestions
Catalin-Stratulat-Ericsson 34b062f
renamed file name to match the title change in previous commit
Catalin-Stratulat-Ericsson f8dc2d3
changed small formating issue
Catalin-Stratulat-Ericsson 99d13cb
ammended requested changes which were missed
Catalin-Stratulat-Ericsson 672afec
added docker config.json template explination for clarity
Catalin-Stratulat-Ericsson 3e15fe1
fixed repeated here in link
Catalin-Stratulat-Ericsson 3b272ee
fixed incorrect style use as per styling guide
Catalin-Stratulat-Ericsson 777d91f
adding documentation to match new arguments
Catalin-Stratulat-Ericsson bed0059
added clarification of secret duplication to porch-fn-system namespace
Catalin-Stratulat-Ericsson aa7129e
fixed few grammatical errors as suggested by comments
Catalin-Stratulat-Ericsson 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
88 changes: 88 additions & 0 deletions
88
content/en/docs/porch/using-porch/using-authenticated-private-registries.md
This file contains 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,88 @@ | ||
--- | ||
title: "Using authenticated private registries" | ||
type: docs | ||
weight: 4 | ||
description: "" | ||
--- | ||
|
||
To enable the Porch function runner to pull kpt function images from authenticated private registries, the system requires: | ||
|
||
1. Creating a kubernetes secret using a JSON file according to the Docker config schema, containing valid credentials for each authenticated registry. | ||
2. Mounting this new secret as a volume on the function runner. | ||
3. Providing the path of the mounted secret to the function runner using the argument `--registry-auth-secret-path` | ||
|
||
An example template of what a docker *config.json* file looks like is as follows below. The base64 encoded value *bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ=* of the *auth* key decodes to *my_username:my_password*, which is the format used by the config when authenticating. | ||
|
||
```json | ||
{ | ||
"auths": { | ||
"https://index.docker.io/v1/": { | ||
"auth": "bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ=" | ||
}, | ||
"ghcr.io": { | ||
"auth": "bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ=" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
A quick way to generate this secret for your use using your docker *config.json* would be to run the following command: | ||
|
||
```bash | ||
kubectl create secret generic <SECRET_NAME> --from-file=.dockerconfigjson=/path/to/your/config.json --type=kubernetes.io/dockerconfigjson --dry-run=client -o yaml -n porch-system | ||
``` | ||
|
||
{{% alert title="Note" color="primary" %}} | ||
The secret must be in the same namespace as the function runner deployment. By default, this is the *porch-system* namespace. | ||
{{% /alert %}} | ||
|
||
This should generate a secret template, similar to the one below, which you can add to the *2-function-runner.yaml* file in the Porch catalog package found [here](https://github.com/nephio-project/catalog/tree/main/nephio/core/porch) | ||
|
||
```yaml | ||
apiVersion: v1 | ||
data: | ||
.dockerconfigjson: <base64-encoded-data> | ||
kind: Secret | ||
metadata: | ||
creationTimestamp: null | ||
name: <SECRET_NAME> | ||
namespace: porch-system | ||
type: kubernetes.io/dockerconfigjson | ||
``` | ||
|
||
Next you must mount the secret as a volume on the function runner deployment. Add the following snippet to the Deployment object in the *2-function-runner.yaml* file: | ||
|
||
```yaml | ||
volumeMounts: | ||
- mountPath: /pod-cache-config | ||
name: pod-cache-config-volume | ||
- mountPath: /var/tmp/auth-secret | ||
name: docker-config | ||
readOnly: true | ||
volumes: | ||
- name: pod-cache-config-volume | ||
configMap: | ||
name: pod-cache-config | ||
- name: docker-config | ||
secret: | ||
secretName: <SECRET_NAME> | ||
``` | ||
|
||
You may specify your desired `mountPath:` so long as the function runner can access it. | ||
|
||
{{% alert title="Note" color="primary" %}} | ||
The chosen `mountPath:` should use its own, dedicated sub-directory, so that it does not overwrite access permissions of the existing directory. For example, if you wish to mount on `/var/tmp` you should use `mountPath: /var/tmp/<SUB_DIRECTORY>` etc. | ||
{{% /alert %}} | ||
|
||
Lastly you must add the `--registry-auth-secret-path` to the arguments of the function-runner Deployment object in the *2-function-runner.yaml* file, giving the path of the secret file mount: | ||
|
||
```yaml | ||
command: | ||
- /server | ||
- --config=/config.yaml | ||
- --registry-auth-secret-path=/var/tmp/auth-secret/.dockerconfigjson | ||
- --functions=/functions | ||
- --pod-namespace=porch-fn-system | ||
``` | ||
|
||
With this last step, if your Porch package uses a custom kpt function image stored in an authenticated private registry (for example `- image: ghcr.io/private-registry/set-namespace:customv2`), the function runner will now use the secret info as an `imagePullSecret` for the function pods as documented [here](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/). |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Catalin-Stratulat-Ericsson Secret generated like this
kubectl create secret docker-registry XXXX --docker-server=https://index.docker.io/v1/ --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
Should also work I suppose? That creates a
.dockerconfigjson
inside secrets.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I agree with the second point but we can always remove it from the history using
history -d <line-number>