-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow creation of deploy keys #16
Comments
That's an interesting idea! Sounds like it would be required to implement a Terraform provisioner. Looks like the Forgejo API offers a call for this: What do you think, @acch? |
Thanks @zeidlos for bringing up this idea! Makes a ton of sense, and I guess it would provide value to many users... I've briefly checked the forgejo-sdk. Looks like this is the function we would need to use: ... which requires these options (link): type CreateKeyOption struct {
// Title of the key to add
Title string `json:"title"`
// An armored SSH key to add
Key string `json:"key"`
// Describe if the key has only read access or read/write
ReadOnly bool `json:"read_only"`
} Hence, looks totally doable! |
@zeidlos @stdevel I've started working on this. Just to make sure I'm addressing the correct use case: you're looking to deploy something like the following configuration, correct? # Private key
resource "tls_private_key" "ed25519" {
algorithm = "ED25519"
}
# Personal repository
resource "forgejo_repository" "personal" {
name = "personal_test_repo"
}
# Deploy key
resource "forgejo_deploy_key" "this" {
repository_id = forgejo_repository.personal.id
key = trimspace(tls_private_key.ed25519.public_key_openssh)
title = "test_key"
read_only = false
} Let me know if that's correct. I'll need to get some unit tests in order, but should be able to provide something worth testing in the next couple of days... |
This looks great! Please take a look at: https://registry.terraform.io/providers/fluxcd/flux/latest/docs |
For now I'm deploying flux via helm chart using a predefined key that i've uploaded manually to forgejo. This works as well and is not too much overhead, but it would be nicer if the key-handling could be done via terraform. This also would help with key-rotation. |
@zeidlos @stdevel I've uploaded a new release v0.2.0 to the Terraform / OpenTofu registries - you can get it from there. The new version now supports a Two things to keep in mind:
Once you're able successfully deploy a Forgejo configuration for Flux, it would be totally rockstar awsome if you could supply your working example code. I would love to submit a PR to the Flux provider to add the Forgejo example (alongside GitHub, GitLab, and Helm) - what do you think? |
Will test today and give you an example! |
@acch @stdevel it works perfectly! Okay, the premise I am working with is: I already have a flux repository that is in use by multiple clusters (homelab, local testing, dev, stage, prod, etc) and I want to bootstrap another cluster or recreate one of the existing ones. This Terraform file also uses the Hetznercloud Terraform provider to provide a fully working cluster, but I'll omit certain parts for brevity.
Using this, I successfully create a Hetznercloud Kubernetes cluster, create a Forgejo deploy key into my pre-existing repository and initialize fluxcd on that cluster. Takes about 5-10 Minutes until everything is up and all flux resources are reconciled and up and running (obviously depending on the contents of your flux repository). If you want, I can provide you with the full, unredacted file in private. It's still WIP. Also I'll create one to spin up a local kind cluster, I can share in the future if needed. |
@zeidlos Great - thanks a million! I'll prepare a PR to the Flux Provider documentation, and let you review it... Are you good with closing this issue for the time being? |
Yes, of course! Ticket scope has been fulfilled. :) I'm still exploring forgejo, but it looks great so far! |
I am currently trying to bootstrap a new kubernetes cluster, using terraform.
Within this process I also want to install fluxcd onto the cluster.
Fluxcd is allowing for a helm deployment.
What do I need?
In order for flux to reconcile the project, I need to give it ssh-keys, so it can pull from the repository.
I want to be able to create a new ssh-keypair from within terraform and then, using the forgejo-provider, upload the deploy key onto the repository with read/write permissions.
If you want a beta-tester for this, please hit me up.
Sadly I believe to lack the necessary skills to create this feature within this provider myself. :)
The text was updated successfully, but these errors were encountered: