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

Improve how we name the girepository and custompackage resources #470

Open
cmoulliard opened this issue Jan 3, 2025 · 2 comments
Open

Comments

@cmoulliard
Copy link
Contributor

cmoulliard commented Jan 3, 2025

Enhancement

When a new cluster is created and a package added, then the gitRepository and custompackage resources like the gitea url name includes twice the same name if by example the name of the YAML file and the name of the Argocd resource uses both the same name.

Example:

If we install the following package -p /Users/cmoullia/code/ch007m/my-konflux/fork-konflux-ci/idp/foundations/ which contains several Argocd files as showed hereafter

foundation/
  cert-manager/
  cluster-issuer/
  test-pvc/
  trust-manager/

  cert-manager.yaml
  cluster-issuer.yaml
  test-pvc.yaml
  trust-manager.yaml

then the file name cluster-issuer.yaml and its Argocd Application name which is cluster-issuer will be used to name the customPackage and gitRepository YAML resources

apiVersion: idpbuilder.cnoe.io/v1alpha1
kind: CustomPackage
metadata:
  name: cluster-issuer-cluster-issuer
  namespace: idpbuilder-dummy
...

apiVersion: idpbuilder.cnoe.io/v1alpha1
kind: GitRepository
metadata:
  name: cluster-issuer-cluster-issuer
  namespace: idpbuilder-dummy

and urls will be:

https://gitea.cnoe.localtest.me:9443/giteaAdmin/idpbuilder-dummy-cluster-issuer-cluster-issuer
https://argocd.cnoe.localtest.me:9443/applications/argocd/cluster-issuer

While this is not an issue per se, that could hurt some users as it is hard to figure out that the package -p .../foundations match several components = argocd applications and that the idp custom resources created on the platform don't include the name of the package (= last word of a/b/c/d string) AND why name could appear twice like in my example.

This is why I would like to propose that we adopt a new convention (which is also perhaps not perfect too but a bit better) to name the resources like the git internal repository and which could address the proposition to have a command able to add/remove a customPackage (see #469)

Convention:

  • We extract the last word from the package path.
    -p  foundations => foundations 
    -p  idp/foundations => foundations 
    -p ~/code/ch007m/my-konflux/fork-konflux-ci/idp/foundations => foundations
    
  • We iterate within the list of the Argocd files and for each item, get the Application(Set) name
    apiVersion: argoproj.io/v1alpha1
    kind: Application
    metadata:
      name: cluster-issuer // Name to be used
      namespace: argocd
    
  • We concatenate the package name with the argocd application name and we use the symbol - as separator
    foundations-cluster-issuer
    

If we do that, then the new name will become:

apiVersion: idpbuilder.cnoe.io/v1alpha1
kind: CustomPackage
metadata:
  name: foundations-cluster-issuer
  namespace: idpbuilder-dummy
  labels:
    app.kubernetes.io/name: cluster-issuer
    cnoe.io/package-name: foundations
    cnoe.io/package-type: custom
...

apiVersion: idpbuilder.cnoe.io/v1alpha1
kind: GitRepository
metadata:
  name: foundations-cluster-issuer
  namespace: idpbuilder-dummy
  labels:
    app.kubernetes.io/name: cluster-issuer
...

https://gitea.cnoe.localtest.me:9443/giteaAdmin/idpbuilder-dummy-foundations-cluster-issuer
or
https://gitea.cnoe.localtest.me:9443/giteaAdmin/foundations_cluster-issuer.git

https://argocd.cnoe.localtest.me:9443/applications/argocd/cluster-issuer

Remarks:

  • We add to each idp resource labels abke to identify them as custom package and to which package it belongs
    !! The idp projects includes a function to SetPackageLabels but it uses the name of the object which until now don't include the package name from where it comes from and is not applied to a customPackage created as you can see hereafter:
apiVersion: idpbuilder.cnoe.io/v1alpha1
kind: CustomPackage
metadata:
  annotations:
    cnoe.io/cli-start-time: "2025-01-03T09:43:19.558631+01:00"
    cnoe.io/last-observed-cli-start-time: "2025-01-03T09:43:19.558631+01:00"
    // cnoe.io/package-name is missing here !!!!!!!!!!!!!!!!
  creationTimestamp: "2025-01-03T08:44:57Z"
  generation: 1
  name: cluster-issuer-cluster-issuer
  namespace: idpbuilder-dummy
  ownerReferences:
  - apiVersion: idpbuilder.cnoe.io/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: Localbuild
    name: dummy
    uid: ce268492-16e5-4d4d-92da-17a9a80c4254
  resourceVersion: "1422"
  uid: 19fc09ed-4205-4f38-a7ab-746774f42cd1
  • We should use the underscore within the git url to make a clear separation between the package name and the component/repository
  • I don't think that it makes a lot of sense to also prefix a git repository with the namespace name idpbuilder-<cluster-name> as there is a relation one-to-one between the internal gitea repository and the cluster running it at the moment

FYI: @nabuskey

@nabuskey
Copy link
Collaborator

nabuskey commented Jan 3, 2025

I am all for having a more user friendly names. The proposed changes look good to me.

@cmoulliard
Copy link
Contributor Author

Note: We should add a new column to the command list packages to tell to the user to which package the customPackage belongs and perhaps also review the convention to name the customPackage using ONLY the name of the Argocd application (if the name is unique of course) !!

Before

NAMESPACE          NAME                            AGE
idpbuilder-dummy   app-guestbook                   14m
idpbuilder-dummy   app2-guestbook2                 14m
idpbuilder-dummy   cert-manager-trust-manager      14m
idpbuilder-dummy   cluster-issuer-cluster-issuer   14m
idpbuilder-dummy   test-pvc-test-pvc               14m
idpbuilder-dummy   trust-manager-cert-manager      14m

After

NAMESPACE    PACKAGE         NAME             AGE
idpbuilder   package2        guestbook        14m
idpbuilder   package2        guestbook2       14m
idpbuilder   foundations     trust-manager    14m
idpbuilder   foundations     cluster-issuer   14m
idpbuilder   foundations     test-pvc         14m
idpbuilder   foundations     cert-manager     14m

@nabuskey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants