-
Notifications
You must be signed in to change notification settings - Fork 577
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
[WIP] Add generic git task - with alternative auth #309
Closed
Closed
Changes from all commits
Commits
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 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,35 @@ | ||
git-clone ssh | ||
==== | ||
|
||
Prepare secrets for ssh authentication. | ||
|
||
### Prepare known_hosts file | ||
Example using github.com as host | ||
|
||
1. Create file with known_hosts (you may also want to verify this further) | ||
|
||
ssh-keyscan github.com > ssh_known_hosts | ||
|
||
2. Create secret from file | ||
|
||
kubectl create secret generic github-known-hosts --from-file=ssh_known_hosts | ||
|
||
### Generate and distribute SSH key pair | ||
Generate a separate SSH key pair for Tekton | ||
|
||
1. Generate keypair to local file | ||
|
||
ssh-keygen -t rsa -b 4096 -f id_rsa -q -N "" | ||
|
||
2. Create a secret from the private key | ||
|
||
kubectl create secret generic github-private-key --from-file=id_rsa | ||
|
||
3. Upload the public key id_rsa.pub to GitHub | ||
|
||
Start with copying the content of the public key with | ||
|
||
pbcopy < id_rsa.pub | ||
|
||
And follow [Adding a new SSH key to your GitHub account](https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account) | ||
~ |
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,28 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: git-clone-ssh | ||
spec: | ||
workspaces: | ||
- name: output | ||
description: The git repo will be cloned onto the volume backing this workspace | ||
params: | ||
- name: url | ||
type: string | ||
description: git url to clone | ||
steps: | ||
- name: git-clone | ||
image: bitnami/git:2.26.2 | ||
command: ['git', '-c', 'core.sshCommand=ssh -i /etc/ssh/id_rsa', 'clone', '$(params.url)', '$(workspaces.output.path)'] | ||
volumeMounts: | ||
- mountPath: /etc/ssh | ||
name: ssh-auth | ||
volumes: | ||
- name: ssh-auth | ||
projected: | ||
defaultMode: 0400 | ||
sources: | ||
- secret: | ||
name: github-known-hosts | ||
- secret: | ||
name: github-private-key | ||
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.
both secret names should be params in a proper implementation.
and in use
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.
Is this a limitation of Tekton at the moment - params can't be used as variables in volumes?
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.
Yes, it is the Secret Name within a projected volume, were we don't have implemented variable substitution. But as the commit is implemented now, it is working. But for proper support, we should add variable substitution here, so that end-users can name the secrets how they want.