-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Unattended Flux installation for GitHub repos (automatic add of deploy key) #2274
Conversation
a8a330a
to
da56041
Compare
@stefanprodan Hey! Thanks for reviewing. Just added e212ee1 to hopefully address every point. |
pkg/gitops/flux/installer.go
Outdated
logger.Info("Committing and pushing manifests to %s", fi.opts.Repo.URL) | ||
if err = fi.addFilesToRepo(); err != nil { | ||
return "", err | ||
if !fi.opts.ReadOnly { |
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.
Why is this conditioned by readonly?
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.
I thought the intention of the user would be that they won't like eksctl to write to the repo as well if you want Flux to be read-only. Is that a right assumption?
If not, maybe we'd better split this to two configuration fields, the one for eksctl as e.g. git.commitManifestsOnStart
or git.commitOperatorManifestsOnInstall
, and one for flux as e.g.git.operator.readOnly
.
WDYT?
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.
Anyway, I've added an additional commit to implement what I think best now based on your review: 18f7d76
It's now:
git:
# NEW: Commit and push Flux manifests to the Git Repo on install
# The default value is true for backward-compatbiility, so explicitly set to `false `to disable
#commitOperatorManifests: false
repo:
url: "git@github.com:mumoshu/gitops-demo.git"
branch: master
fluxPath: "flux/"
user: "gitops"
email: "gitops@myorg.com"
privateSSHKeyPath: /Users/c-ykuoka/.ssh/id_rsa
operator:
namespace: "flux"
# NEW: Instruct Flux to read-only mode and create the deploy key as read-only
readOnly: true
And commands like eksctl enable repo
has been given respective common flux flags:
--read-only Instruct Flux to read-only mode and create the deploy key as read-only
--commit-operator-manifests Commit and push Flux manifests to the Git Repo on install (default true)
@mumoshu Thank you so much for taking the time to build this. We need to discuss in the team if we want to keep this functionality here or somewhere else. I will mark this PR as "changes requested" so we don't accidentally merge it before we have decided. |
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.
Blocked so we don't accidentally merge it
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.
Hi @mumoshu I took a quick look but didn't have time to look at the tests. I will do that tomorrow.
You don't need to manually add GitHub deploy keys anymore. This feature enables you to install Flux via eksctl in an unattended way, by automatically creating GitHub deply key on cluster creation and on `eksctl enable repo`, and by automatically deleting the deploy key on cluster deletion. All you need to use this feature is providing `GITHUB_TOKEN` that has access to your repository's deploy keys, and a standard cluster.yaml that contains a `git` configuration for installing Flux. Usage: ``` $ eksctl create cluster -f cluster.yaml eksctl automatically creates a deploy key named `eksctl-REGION-NAME` from the public ssh key generated by Flux ``` ``` $ eksctl delete cluster -f cluster.yaml eksctl automatically deletes the deploy key named `eksctl-REGION-NAME` by calling GitHub API ``` ``` $ eksctl enable repo -f cluster.yaml eksctl automatically creates a deploy key named `eksctl-REGION-NAME` from the public ssh key generated by Flux ``` Please also note that this feature has an extra ability to make the deploy key "read-only". With the read-only deploy key, If you prefer that, you can effectively block Flux from ever pushing commits to the repository. This can be enabled by setting `git.readOnly` to `true` or passing `--readonly` to `eksctl enable repo`. Resolves eksctl-io#2273
8b8d55b
to
8e6afca
Compare
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.
Thanks @mumoshu!
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.
LGTM
We need to update the docs but this can come later. Thanks @mumoshu 🏅
You don't need to manually add GitHub deploy keys anymore.
This feature enables you to install Flux via eksctl in an unattended way, by automatically creating GitHub deply key on cluster creation and on
eksctl enable repo
, and by automatically deleting the deploy key on cluster deletion.All you need to use this feature is providing
GITHUB_TOKEN
that has access to your repository's deploy keys, and a standard cluster.yaml that contains agit
configuration for installing Flux.Usage
eksctl create cluster
eksctl automatically creates a deploy key named
eksctl-REGION-NAME
from the public ssh key generated by Fluxeksctl delete cluster
eksctl automatically deletes the deploy key named
eksctl-REGION-NAME
by calling GitHub API.eksctl enable repo
eksctl automatically creates a deploy key named
eksctl-REGION-NAME
from the public ssh key generated by FluxPlease also note that this feature has an option to make the deploy key "read-only". With the read-only deploy key, you can effectively block Flux from ever pushing commits to the repository.
This can be enabled by settinggit.readOnly
totrue
or passing--readonly
toeksctl enable repo
.This can be enabled by setting
git.operator.readOnly
totrue
or passing--read-only
toeksctl enable repo
.git.operator.readOnly
affects Flux only and doesn't prevent eksctl from writing to the git repo for Flux manifests. Usegit.commitOperatorManifests: false
for that.Resolves #2273
Description
Checklist
README.md
, or theuserdocs
directory)area/nodegroup
), target version (e.g.version/0.12.0
) and kind (e.g.kind/improvement
)