-
Notifications
You must be signed in to change notification settings - Fork 62
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
Implement git repository controller #82
Conversation
cd01ed4
to
6538ae2
Compare
|
||
const ( | ||
DefaultBranchName = "main" | ||
// DefaultGiteaUsername and DefaultGiteaPassword taken from gitea helm chart. https://gitea.com/gitea/helm-chart#gitea |
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.
We need a way to get these values dynamically. If the gitea object can expose that information, we can do so. Otherwise we will have to rely on a secret naming convention. e.g. we will always look for a secret named abc
in namespace abc
.
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.
Looks neat, thanks. left a few comments.
Also, looks like the bit that actually hooks things up and runs this in RunControllers
is not here in this commit. intentional?
also looks like you've got some conflicts to resolve |
dd48340
to
cb6156f
Compare
This PR's become a bit too large for my liking but it implements the entire workflow with Gitea. All emebdded manifests are pushed to gitea server under the admin user organization. We may want to make this configurable in the future. Once they are pushed, argo applications are created. They reference the repos created above. From here, ArgoCD takes care of the rest. The Git repository contents are reconciled only once for embedded applications. If users wants to reconfigure things, they can do so in the Gitea UI. Once this PR merges, I just need to rebase and build should pass. |
push manifests to gitea Signed-off-by: Manabu Mccloskey <[email protected]>
cb6156f
to
d27a5ae
Compare
Signed-off-by: Manabu Mccloskey <[email protected]>
d27a5ae
to
6dd8cda
Compare
Signed-off-by: Manabu Mccloskey <[email protected]>
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.
few minor updates. otherwise looks good.
One higher level question, for the backstage embeded app, shall we use the helm chart with its image set to our CNOE backstage image and let Argo CD handle it, rather than having the raw resources?
log := log.FromContext(ctx) | ||
logger := log.FromContext(ctx) |
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 think we have called the variable log
in other places. would be good to make this consistent across the board and btw i like logger
better.
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.
Problem with using log
is that it collides with package import like this
"sigs.k8s.io/controller-runtime/pkg/log" |
I agree that we should use logger instead of log across the project. I'll file an issue.
giteaAdminSecret = "gitea-admin-secret" | ||
// this is the URL accessible outside cluster. resolves to localhost | ||
giteaIngressURL = "http://gitea.cnoe.localtest.me:8880" |
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.
8443
or 8880
for the port number?
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.
Should be 8880. We should consider using TLS in the future, but it's all http for gitea as of now.
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.
Should be 8880. We should consider using TLS in the future, but it's all http for gitea as of now.
I don t think that we should append additional ports to the URL as we do now:
https://argocd.<host_IP>.<DOMAIN>:8443
,https://gitea.<host_IP>.<DOMAIN>:8880
,https://backstage.<host_IP>.<DOMAIN>:8443
,- etc
Why: ?
- Adding more and more new ports will make the work of the users not really cool and easy as they will have to remember the ports to be used for each component
- Only default HTTP(S) ports are needed and will be recognized by the browser: 80, 443 automatically.
- As the ingress controller which is acting as a reverse proxy using nginx is able to forward from URL:
https://backend>.<host_ip>.<domain>
the packets to the target backends: argocd, backstage, vault, gitea, etc then adding new ports make the job to configure ingress + kind part of the idpbuilder hardder instead of having Ingress YAML files
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 agree from the user friendliness standpoint. The reason we are not using default http and https ports is that allocation of lower number port (< 1024) requires higher privileges that some organizations do not allow end users to have. I would like to use default ports but I would rather have the assurance that port allocation will work for all users. Maybe we can make it configurable in the future.
// Type is the source type. | ||
// +kubebuilder:validation:Enum:=local;embedded | ||
// +kubebuilder:default:=embedded | ||
Type string `json:"type"` |
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.
Can you describe what is the purpose of the type and what will happen if we select one the values: local
, embedded
, etc ?
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.
Local indicates the gitea repository contents will come from a local directory. E.g. /home/ubuntu/myrepo
Embedded indicates the repository contents will come from what is embedded in the go binary.
} | ||
|
||
type GitRepositorySource struct { | ||
// +kubebuilder:validation:Enum:=argocd;backstage;crossplane;gitea;nginx |
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.
crossplane should be removed from the enum and we should keep what currently we support or point to a link = doc page enumerating them
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.
We will probably have to keep it since the reference implementation uses it. For now, I am keeping it because the purpose of this PR is to move the git functionality over from embedded git server to gitea.
api/v1alpha1/gitrepository_types.go
Outdated
ExternalGitRepositoryUrl string `json:"externalGitRepositoryUrl"` | ||
// GitRepositoryUrl is the url for the in-cluster repository accessible within the cluster. | ||
// +kubebuilder:validation:Optional | ||
GitRepositoryUrl string `json:"gitRepositoryUrl"` |
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 don't you name it InternalGitRepositoryUrl as it is used for internal purposes ? If we use gitea which is accessible by the users, does that makes sense that we keep ext vs internal repos ?
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.
Good idea I will rename the field.
We need to distinct the internal and external git repo URLs (gitea.cnoe.localtest.me
) because the domain name will always resolve to 127.0.0.1. Therefore this URL is not usable by ArgoCD to fetch manifests from the gitea server.
Signed-off-by: Manabu Mccloskey <[email protected]>
d7ae0fe
to
9d00824
Compare
This implements the git repository types and controller.
Syncs the contents of a local directory to an in-cluster gitea repository for ArgoCD to pick up.
We need #39 merged first.
closes #59, closes #60