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

Add app.kubernetes.io/instance label for flux logs #5

Closed
wants to merge 1 commit into from

Conversation

kingdonb
Copy link

@kingdonb kingdonb commented Aug 4, 2021

#4 not related, I have mixed myself up, #4 was not meant to be about the logs issue.

(I do not quite know how to test this, but I have a feeling it's not going to work)

Fixes #4

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
@kingdonb
Copy link
Author

kingdonb commented Aug 4, 2021

Running through the build process by hand, I can see the labels aren't missing at the point that kustomize build gets called.

@kingdonb
Copy link
Author

kingdonb commented Aug 4, 2021

Stefan suggested we add the label in the location where we are already patching Flux deployments:

fluxcd/flux2#1673 (comment)

Here's my understanding of how the release process works, (and why that will not work) there are some parts I didn't quite understand trying to pick it apart, but I think I have worked most of it out:

  • release.sh pulls a copy of gotk-components.yaml from the flux CLI
  • passes it off to kustomize build, where the fsGroup is removed via patch (at this point, the expected labels are still present)
  • release.js massages this into the bundle-directory form expected by opm-index.sh – Deployment resources are all gone, replaced by templates/clusterserviceversion.yaml which is templated into the current Flux release as:
const csvFileName = `flux.v${version}.clusterserviceversion.yaml`
  • Not sure what happens exactly next,
  • operator-sdk bundle validate which I assume can abort the release if validation would fail
  • Then make opm_index calls opm-index.sh if everything went well so far, which builds OCI format with Docker and pushes the release out to the OpenShift channel?

What is fairly clear is that the Deployment resources are not part of the bundle directory format, they are in the clusterserviceversion, so any labels we might have passed into release.js are apparently discarded. #5 will not work.

ClusterServiceVersion evidently only supports adding labels for the purpose of indicating if support for multiple architectures are present: https://docs.openshift.com/container-platform/4.4/operators/operator_sdk/osdk-generating-csvs.html#olm-enabling-operator-for-multi-arch_osdk-generating-csvs

Is that why you suggest we use an operator to install Flux, @chanwit ? Because it will give us control over the labels, and whatever else we need, (like target namespace?)

I think that sounds over-complicated, the OLM does add some labels, are any of these labels suitable for use by flux cli? (Could we update flux logs to fall back and look for OLM labels if flux logs is called and no pods are selected? Would there be any way to do this without multiple round-trips?)

  labels:
    olm.deployment-spec-hash: 5c69bb97f5
    olm.owner: flux.v0.16.1
    olm.owner.kind: ClusterServiceVersion
    olm.owner.namespace: flux-system
    operators.coreos.com/flux.flux-system: ""

@kingdonb
Copy link
Author

kingdonb commented Aug 4, 2021

Maybe these annotations in the pod spec are more helpful:

olm.operatorGroup: flux-system
olm.operatorNamespace: flux-system

(I just realized we are probably selecting pods, not deployments)

@stefanprodan
Copy link
Contributor

@chanwit
Copy link
Member

chanwit commented Aug 5, 2021

As @stefanprodan pointed out, I think this patch is good enough. Thank you @kingdonb.

@stefanprodan
Copy link
Contributor

@chanwit for this to work, the namespace where OLM deploys Flux must be flux-system, does this happens or the namespace is randomly chosen?

@chanwit
Copy link
Member

chanwit commented Aug 5, 2021

flux-system is annotated as the recommended namespace (the default value) when users click installing.
However, they still can choose other namespaces if they'd like to.

My solution is to document that user must install it only to the flux-system namespace.

@stefanprodan
Copy link
Contributor

When you run flux install --export the app.kubernetes.io/instance: flux-system is added to all deployments, why is OLM removing that? Or @kingdonb maybe installed flux in a different namespace than flux-system?

@chanwit
Copy link
Member

chanwit commented Aug 5, 2021

@stefanprodan
Copy link
Contributor

FFS... so OLM doesn't allow us to set metadata for our own deployments?

@stefanprodan
Copy link
Contributor

I closed this PR as it does nothing, the label was already there, but it's removed by OLM.

@chanwit
Copy link
Member

chanwit commented Aug 5, 2021

Labels could be specified there on each StrategyDeploymentSpec:
https://pkg.go.dev/github.com/operator-framework/api/pkg/operators/v1alpha1#StrategyDeploymentSpec

I'll tweak the generator to do so.

@stefanprodan
Copy link
Contributor

@chanwit great find, this will definitely solve our issues.

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