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

Error with defaultFelixConfiguration.enabled: true with Helm #9691

Open
mnival opened this issue Jan 9, 2025 · 9 comments
Open

Error with defaultFelixConfiguration.enabled: true with Helm #9691

mnival opened this issue Jan 9, 2025 · 9 comments
Labels
area/helm good first issue Good for first-time contributors looking to learn about Calico help wanted impact/high kind/bug likelihood/high

Comments

@mnival
Copy link

mnival commented Jan 9, 2025

Expected Behavior

It should be possible to enable:

defaultFelixConfiguration:
  enabled: true

after a first installation done with the default values

Current Behavior

Currently, I receive this error:

$ helm upgrade --reset-values -n tigera-operator platform-nonprod-calico projectcalico/tigera-operator -f configuration/calico-values.yaml --version 3.28.1
Error: UPGRADE FAILED: Unable to continue with update: FelixConfiguration "default" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "platform-nonprod-calico"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "tigera-operator"

configuration/calico-values.yaml:

installation:
  cni:
    type: Calico
defaultFelixConfiguration:
  enabled: true
  wireguardEnabled: true

I executed these command before helm command:

kubectl label FelixConfiguration default app.kubernetes.io/managed-by=Helm
kubectl annotate FelixConfiguration default meta.helm.sh/release-namespace=tigera-operator
kubectl annotate FelixConfiguration default meta.helm.sh/release-name=platform-nonprod-calico

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

  • Calico version
  • Calico dataplane (iptables, windows etc.)
  • Orchestrator version (e.g. kubernetes, mesos, rkt):
  • Operating System and version:
  • Link to your project (optional):
@coutinhop
Copy link
Member

@mnival it doesn't look like you followed these steps when upgrading: https://docs.tigera.io/calico/3.28/operations/upgrading/kubernetes-upgrade#upgrading-an-installation-that-was-installed-using-helm

Could you try them and let us know if it works that way?

@mnival
Copy link
Author

mnival commented Jan 16, 2025

Hello @coutinhop,
I haven't updated calico and all resources are already managed by Helm except FelixConfiguration. The page mentionned don't have any information about FelixConfiguration.

I'm on version 3.28.1, I just added the lines below in my values ​​file:

defaultFelixConfiguration:
  enabled: true

And I got the error mentioned in my first message
Thank you

@MichalFupso
Copy link
Contributor

@mnival I think that after installation when the Calico API server is running, use the v3 apiVersion to update felix configuration https://docs.tigera.io/calico/latest/reference/installation/helm_customization

@caseydavenport
Copy link
Member

Error: UPGRADE FAILED: Unable to continue with update: FelixConfiguration "default" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "platform-nonprod-calico"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "tigera-operator"

@mnival was your FelixConfiguration originally created by Helm? Or might it have been created out of band?

@MichalFupso I wonder if this might be due to Calico's handling of labels on our underlying CRDs - we added this code recently to fix another issue:

// Explicitly nil out the labels on the underlying object so that they are not duplicated.
// We make an exception for projectcalico.org/ labels, which we own and may use on the v1 API.
var v1Labels map[string]string
for k, v := range rom.GetLabels() {
if isOurs(k) {
if v1Labels == nil {
v1Labels = map[string]string{}
}
v1Labels[k] = v
}
}
meta.Labels = v1Labels

We may need to make an exception there for helm labels

@caseydavenport caseydavenport added kind/bug likelihood/high impact/high help wanted good first issue Good for first-time contributors looking to learn about Calico and removed kind/support labels Feb 7, 2025
@mnival
Copy link
Author

mnival commented Feb 7, 2025

Hello @caseydavenport,
It was created automatically by Calico but now I would like to be able to manage it by Helm to add configurations but this is not currently possible with the error that I indicated in my first message

@caseydavenport
Copy link
Member

@mnival got it, ok.

This is a limitation in Helm - it refuses to update objects that it doesn't believe it owns. In this case, because Helm didn't originally create the FelixConfiguration, it's refusing to modify it.

There are some hacky ways to trick helm into assuming ownership of a resource by modifying the helm release ConfigMap, but it's a bit of a backdoor.

The other option would be to delete the FelixConfiguration and let Helm recreate it.

@mnival
Copy link
Author

mnival commented Feb 10, 2025

Hello @caseydavenport,

I added the annotations and labels but despite that helm doesn't want to manage it.

I tried to delete FelixConfiguration but it was recreated immediately. Do I need to stop something first?

I checked the commit here bb0ac52 and it says:

if user wants to set some values, they should set enabled: true first and then add the properties and values.

But it doesn't work

@caseydavenport
Copy link
Member

I tried to delete FelixConfiguration but it was recreated immediately. Do I need to stop something first?

Oh, yeah possible the tigera operator is recreating that.

@mnival
Copy link
Author

mnival commented Feb 23, 2025

Hello @caseydavenport ,

I understood my problem. I changed the label and annotations on FelixConfiguration.projectcalico.org but helm manages the resource FelixConfiguration.crd.projectcalico.org:
https://github.com/projectcalico/calico/blob/master/charts/tigera-operator/templates/crs/configmap-felixconfiguration-templates.yaml#L4

I added the label and annotations and the resource is now manageable by Helm but reading #6412 it seems that we should act on FelixConfiguration.projectcalico.org and not FelixConfiguration.crd.projectcalico.org, is there anything to change or with Helm we can only manage FelixConfiguration.crd.projectcalico.org.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm good first issue Good for first-time contributors looking to learn about Calico help wanted impact/high kind/bug likelihood/high
Projects
None yet
Development

No branches or pull requests

4 participants