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

Deploy a chart via flux #3640

Merged
merged 2 commits into from
Oct 24, 2021
Merged

Deploy a chart via flux #3640

merged 2 commits into from
Oct 24, 2021

Conversation

absoludity
Copy link
Contributor

Description of the change

Similar to the last PR #3628 , this one updates the deploymentform routes so that the available package's namespace is referenced explicitly, rather than relying on a global or namespaced repo.

With this change, I'm able to deploy bitnami apache (pod only, see below) via Flux! Woohoo! But before you get too excited, it just brings us to the next point of integration excitement. See the additional notes below.

Benefits

One step closer to fluxv2 UX integration.

Possible drawbacks

Applicable issues

Additional information

The UX fails to find the release that it just tried to create in the default namespace:

It appears that although my Apache pod is appearing in the correct namespace (default), the HelmRelease resource is created in the kubeapps namespace, rather than the default namespace:

$ kubectl get po -n default
NAME                                         READY   STATUS    RESTARTS   AGE
default-test-apache-flux-2-897565695-wddtb   1/1     Running   0          2m58s

$ kubectl get helmrelease -A
NAMESPACE   NAME                 READY     STATUS                       AGE
kubeapps    test-apache-flux-2   Unknown   Reconciliation in progress   3m22s

Checking the api server logs shows that it's receiving the request to create the installed package in the default namespace:

I1022 03:22:47.706471       1 packages.go:261] +core CreateInstalledPackage (cluster="default", namesp
ace="default")
I1022 03:22:47.706489       1 server.go:364] +fluxv2 CreateInstalledPackage [available_package_ref:{co
ntext:{namespace:"flux-system"} identifier:"bitnami%2Fapache" plugin:{name:"fluxv2.packages" version:"
v1alpha1"}} target_context:{cluster:"default" namespace:"default"} name:"test-via-flux" pkg_version_re
ference:{version:"8.8.4"} values: ...

I'm assuming this isn't intended, but I'll let @gfichtenholt take a look before I investigate more.

There are other issues in the UX which we'll need to deal with next too. In particular, the UX is immediately trying to request the helm release (via the old kubeops service - this was unexpected), which (a) won't exist immediately and (b) the UX can't assume a helm release is created, we should only be getting installed packages. In my case, the helm release fails as does the flux reconciliation, although the apache pod was created - need to dig more there.

flux-release-not-found

$ helm ls -A
 NAME                           NAMESPACE               REVISION        UPDATED                                       STATUS          CHART                   APP VERSION
default-test-apache-flux-2      default                 1               2021-10-22 03:49:29.736340602 +0000 UTC       failed          apache-8.8.4            2.4.51
...

$ kubectl get helmrelease -A
NAMESPACE   NAME                 READY   STATUS                      AGE
kubeapps    test-apache-flux-2   False   install retries exhausted   16m

@gfichtenholt
Copy link
Contributor

gfichtenholt commented Oct 22, 2021

I'm assuming this isn't intended, but I'll let @gfichtenholt take a look before I investigate more.

yeah, that was kind of intended. For the 'CreateInstalledPackage' operation I have potentially up to 3 different namespaces to work with:

  1. that of the helmrepository (and helmchart) CR
  2. that of the helmrelease CR
  3. target namespace (where the pod will go)
    I arbitrarily chose (2) to be kubeapps namespace for now
    https://github.com/kubeapps/kubeapps/blob/master/cmd/kubeapps-apis/plugins/fluxv2/packages/v1alpha1/release.go#L334
    Open to suggestions for a better way :-)

@absoludity
Copy link
Contributor Author

yeah, that was kind of intended. For the 'CreateInstalledPackage' operation I have potentially up to 3 different namespaces to work with:

1. that of the helmrepository (and helmchart) CR

2. that of the helmrelease CR

3. target namespace (where the pod will go)
   I arbitrarily chose (2) to be kubeapps namespace for now
   https://github.com/kubeapps/kubeapps/blob/master/cmd/kubeapps-apis/plugins/fluxv2/packages/v1alpha1/release.go#L334
   Open to suggestions for a better way :-)

Yeah, OK. So yes, 3 is obvious - the resources should be in the target namespace, but I'd be keen for (2) the helm release CR to also be created in the target namespace (where the helm release itself is currently created, as shown above), if that also makes sense to you?

I mean, the API request is to create an installed package in the default namespace, but what is returned by the API is an installed package in the kubeapps namespace, which is going to be very confusing from a UX point of view (in fact, I don't know that we can even represent that in a sane way... the installed package / HelmRelease CR got created in the kubeapps namespace, the actual helm release is listed as being in the default namespace where the resources are). So yes, if you're OK with that, +1 to change that so the installed package / helm release CR is created in the target namespace indicated in the request?

@gfichtenholt
Copy link
Contributor

So yes, if you're OK with that, +1 to change that so the installed package / helm release CR is created in the target namespace indicated in the request?

I am ok with that. Feel free to make that change if you like or I can make it. Whatever lets you go faster

@absoludity
Copy link
Contributor Author

So yes, if you're OK with that, +1 to change that so the installed package / helm release CR is created in the target namespace indicated in the request?

I am ok with that. Feel free to make that change if you like or I can make it. Whatever lets you go faster

Thanks. If you can do the fluxv2 change, I'll continue with the dashboard - that'd be great.

@gfichtenholt
Copy link
Contributor

gfichtenholt commented Oct 22, 2021

So yes, if you're OK with that, +1 to change that so the installed package / helm release CR is created in the target namespace indicated in the request?

I am ok with that. Feel free to make that change if you like or I can make it. Whatever lets you go faster

Thanks. If you can do the fluxv2 change, I'll continue with the dashboard - that'd be great.

No problem. Follow-up question: if the target namespace does not exist (fairly common use case), should I create it programmatically inside the 'CreateInstalledPackage" call or let it fail? I do currently set the "createNamespace" flag to true in flux HelmRelease CRD (another arbitrary decision by me), but this change is going to make that decision irrelevant - I have to be able to place the CRD into a namespace first, before flux can even do its magic. Or yet a 3rd option would be to leave that decision to the caller. We'd need to add a flag 'create_namespace' to our CreateInstalledPackageRequest, if caller says 'true' I do it, otherwise fail if the namespace doesn't exist

Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the changes here!

} as AvailablePackageReference,
packageVersion,
),
actions.packages.fetchAndSelectAvailablePackageDetail(packageReference, packageVersion),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

@absoludity
Copy link
Contributor Author

No problem. Follow-up question: if the target namespace does not exist (fairly common use case), should I create it programmatically inside the 'CreateInstalledPackage" call or let it fail?

For now, I'd let it fail as a bad request. It doesn't affect our UX since the create request is always in the context of a namespace that is already created. And longer term...

I do currently set the "createNamespace" flag to true in flux HelmRelease CRD (another arbitrary decision by me), but this change is going to make that decision irrelevant - I have to be able to place the CRD into a namespace first, before flux can even do its magic. Or yet a 3rd option would be to leave that decision to the caller. We'd need to add a flag 'create_namespace' to our CreateInstalledPackageRequest, if caller says 'true' I do it, otherwise fail if the namespace doesn't exist

Yes, longer term we can support this if there is a need. But for now, +1 to fail with a bad request.

Thanks Greg.

Base automatically changed from flux-ui-3 to master October 24, 2021 21:14
Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
@gfichtenholt
Copy link
Contributor

gfichtenholt commented Oct 25, 2021

For now, I'd let it fail as a bad request

Sounds good. Will do that. What is gRPC code for 'bad request'? I don't see one
https://pkg.go.dev/google.golang.org/grpc/codes
According to this it should be Internal. Just wanted to verify this is what you'd expect

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

Successfully merging this pull request may close these issues.

None yet

3 participants