Skip to content
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

GitOps setup #709

Open
packituz-gttz opened this issue Dec 10, 2024 · 5 comments
Open

GitOps setup #709

packituz-gttz opened this issue Dec 10, 2024 · 5 comments
Assignees
Labels
controller Update on controller go Pull requests that update Go code

Comments

@packituz-gttz
Copy link

Is your feature request related to a problem? Please describe.
I've been following this tutorial https://cyclops-ui.com/blog/2024/11/29/gitops-clickops , however when modifying the values in Cyclops UI these values are not saved back into the repo. I understand that is the way Cyclops works, but I would like to know if there are plans for Cyclops to save this values back to the repo, so a single source of truth is accomplished.

Describe the solution you'd like
I would like Cyclops to save this values back to the repo, so a single source of truth is accomplished.

Additional context
https://cyclops-ui.com/blog/2024/11/29/gitops-clickops

Thanks!

@petar-cvit
Copy link
Collaborator

Hey @packituz-gttz, thanks for reaching out!

We did think about Cyclops pushing Module changes to git and then leaving a GitOps tool (ArgoCD) to sync into the cluster where our controller could pick up the changes. You would get the same developer experience with GitOps in the loop.

We can add an option to commit all changes to a git repo. That option would be in the "advanced" section while creating a Module, and you could specify which repo and path to push your Module configuration to. By default, Modules would be applied directly to the cluster.

Screenshot 2024-12-11 at 00 16 22

Would that make sense from your perspective? If yes, we can create a release candidate you can try out. Let us know what you think!

@petar-cvit petar-cvit self-assigned this Dec 10, 2024
@petar-cvit petar-cvit added go Pull requests that update Go code controller Update on controller labels Dec 10, 2024
@packituz-gttz
Copy link
Author

Hi, yes that would be really useful. Thanks!

@petar-cvit
Copy link
Collaborator

Hey @packituz-gttz, we made a new release candidate v0.16.0-rc.2, that can commit your module configuration to a git repository.

You can install it with the following command:

kubectl apply -f https://raw.githubusercontent.com/cyclops-ui/cyclops/v0.16.0-rc.2/install/cyclops-install.yaml && kubectl apply -f https://raw.githubusercontent.com/cyclops-ui/cyclops/v0.16.0-rc.2/install/demo-templates.yaml

Injecting credentials

Before deploying a module, you need to configure credentials for your git repos so changes can be pushed to a remote repo. For GitHub, you will need to create a token (can be fine-grained just for a single repo) that has read and write access to contents.

You can use that token to create a secret in your cluster with the following command:

kubectl create secret generic my-cyclops-secret \
    -n cyclops \
    --from-literal=username=<github-username> \
    --from-literal=password=<github-token>

Once that is created, you can apply the following resource which maps credentials to a specific repo. You can read more about it here

apiVersion: cyclops-ui.com/v1alpha1
kind: TemplateAuthRule
metadata:
  name: private-repo-rule
  namespace: cyclops            # has to be in cyclops namespace
spec:
  repo: <git-repo>           # git repo you want to push configuration to
  password:
    name: my-cyclops-secret     # name of the previously created secret
    key: password
  username:
    name: my-cyclops-secret     # name of the previously created secret
    key: username

The <git-repo> is the repo to which you want Cyclops to push the configuration to. In the example image below it would be https://github.com/petar-cvit/gitops-infra.

Deploying a module via GitOps

When creating a new repository, in the advanced section, you can toggle the Push changes to Git? and you will be able to see fields to specify to which repo you want to commit your Module configuration.

For the configuration in the image below, Cyclops will commit your Module as yaml to the repository https://github.com/petar-cvit/gitops-infra on branch main, and create a file applications/my-module.yaml. The name of the file of your module is constructed as {path}/{module name}.yaml. If you want to create a file in the root of your repo, you can set the path to “.”

Screenshot 2024-12-17 at 17 17 11

From your git repository, you can sync Modules into the cluster with ArgoCD. With such a setup, you still get a custom UI for your apps, but you also get all the benefits of the GitOps approach. Let me know what you think or if you need help with the setup

@packituz-gttz
Copy link
Author

packituz-gttz commented Dec 23, 2024

Hi, I've been testing it and it works great, just one issue I found while testing is that the Module will keep unsynchronized due to iconURL and templateResolvedVersion being empty on the git repository but on Kubernetes they got values, as shown in the image:
Captura de pantalla 2024-12-23 093539

@petar-cvit
Copy link
Collaborator

Thanks for reporting this @packituz-gttz! We made a new release candidate (v0.16.0-rc.5) that you can install with

kubectl apply -f https://raw.githubusercontent.com/cyclops-ui/cyclops/v0.16.0-rc.5/install/cyclops-install.yaml && kubectl apply -f https://raw.githubusercontent.com/cyclops-ui/cyclops/v0.16.0-rc.5/install/demo-templates.yaml

It will push the iconURL and templateResolvedVersion to git to keep things in sync. Other status fields won't be pushed to git, and Argo will stop showing as out of sync. Let me know if you have any other issues with this feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controller Update on controller go Pull requests that update Go code
Projects
None yet
Development

No branches or pull requests

2 participants