fluxcd / helm-operator

Successor: https://github.com/fluxcd/helm-controller — The Flux Helm Operator, once upon a time a solution for declarative Helming.

Home Page:https://docs.fluxcd.io/projects/helm-operator/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object 'Kind' is missing in metadata.

joshiomkarj opened this issue · comments

Describe the bug

Helm operator was installed through inside a reconciliation loop of another object using helm3. It was registered and helm-operator deployment was up. However, when I created helm release object through the same reconciliation loop, I got an error saying kind is missing.

If I change my go code to add,

TypeMeta: metav1.TypeMeta{
			Kind:       "HelmRelease",
			APIVersion: "helm.fluxcd.io/v1",
		},

in the helm release object, I receive different error in the controller logs

E1103 14:23:39.719530    6133 reflector.go:446] sigs.k8s.io/controller-runtime/pkg/cache/internal/informers_map.go:224: expected type *v1.HelmRelease, but watch event object had type *unstructured.Unstructured

however, the helm releases do succeed. I suspect the 2nd problem to be due to dependencies, however, I'm not certain if a certain version of kubernetes libraries is required to be used.

To Reproduce

Steps to reproduce the behavior:

  1. Install using go code. helm3 library
  2. See the usage below
  3. Post the HelmRelease status, => errored before helmrelease object was created.
func newHelmReleaseObject(p ReleaseConfig, ns string) *fluxv1.HelmRelease {
	return &fluxv1.HelmRelease{
		ObjectMeta: metav1.ObjectMeta{
			Name:      p.ReleaseName,
			Namespace: ns,
			Labels:    map[string]string{},
		},
		Spec: fluxv1.HelmReleaseSpec{
			HelmVersion: "v3",
			ChartSource: fluxv1.ChartSource{
				RepoChartSource: &fluxv1.RepoChartSource{
					RepoURL:         p.StableRepo,
					Name:            p.ChartName, 
					Version:         p.Version,
					ChartPullSecret: nil,
				},
			},
			ReleaseName:     p.ReleaseName,
			TargetNamespace: p.Namespace,
			Values:          fluxv1.HelmValues{Data: map[string]interface{}{}},
		},
	}
}

When the operator was stopped and started again, the reconciliation(in my operator) succeeded with no errors. Helm releases were installed properly as well.

Expected behavior

Expectation is for helm release object is to get recognized without having to start reconciliation again.

Logs

kubectl logs deploy/helm-operator -n test-system output is as follows:

ts=2020-11-03T20:05:29.789686025Z caller=operator.go:86 component=operator info="setting up event handlers"
ts=2020-11-03T20:05:29.789838835Z caller=operator.go:107 component=operator info="event handlers set up"
ts=2020-11-03T20:05:29.789873997Z caller=main.go:300 component=helm-operator info="waiting for informer caches to sync"
ts=2020-11-03T20:05:29.890151787Z caller=main.go:305 component=helm-operator info="informer caches synced"
ts=2020-11-03T20:05:29.892151589Z caller=server.go:42 component=daemonhttp info="starting HTTP server on :3030"
ts=2020-11-03T20:05:29.890906366Z caller=git.go:104 component=gitchartsync info="starting sync of git chart sources"
ts=2020-11-03T20:05:29.89698011Z caller=operator.go:119 component=operator info="starting operator"
ts=2020-11-03T20:05:29.897028518Z caller=operator.go:121 component=operator info="starting workers"
ts=2020-11-03T20:05:30.330853888Z caller=checkpoint.go:24 component=checkpoint msg="up to date" latest=0.10.1

Logs from my controller:

2020-11-03T13:35:46.288-0500    ERROR   controller-runtime.controller   Reconciler error        {"controller": "test", "request": "test-system/test-test", "error": "TestType in version \"v1alpha1\" cannot be handled as a TestType: unmarshalerDecoder: Object 'Kind' is missing in '{\"metadata\":{\"name\":\"test-test\",\"namespace\":\"test-system\",\"creationTimestamp\":null},\"spec\":{\"version\":\"1.7.0\"},\"status\":{\"releaseStatus\":\"\",\"installed\":false,\"failed\":false}}', error found in #10 byte of ...|d\":false}}\n|..., bigger context ...|leaseStatus\":\"\",\"installed\":false,\"failed\":false}}\n|..."}

Additional context

  • Helm Operator version: v1.2.0
  • Kubernetes version: 1.16.3

My go mod file for context

require (
	github.com/fluxcd/helm-operator v1.2.0
	github.com/go-logr/logr v0.1.0
	github.com/onsi/ginkgo v1.12.0
	github.com/onsi/gomega v1.9.0
	github.com/operator-framework/operator-sdk v0.19.0
	helm.sh/helm/v3 v3.3.0
	k8s.io/api v0.18.8
	k8s.io/apimachinery v0.18.8
	k8s.io/cli-runtime v0.18.4
	k8s.io/client-go v12.0.0+incompatible
	sigs.k8s.io/controller-runtime v0.6.0
)

replace k8s.io/client-go => k8s.io/client-go v0.18.8

replace (
	github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d
	github.com/docker/docker => github.com/moby/moby v1.4.2-0.20200203170920-46ec8731fbce
	github.com/fluxcd/flux => github.com/fluxcd/flux v1.19.0
	github.com/fluxcd/flux/pkg/install => github.com/fluxcd/flux/pkg/install v0.0.0-20200402061723-01a239a69319
	github.com/fluxcd/helm-operator/pkg/install => github.com/fluxcd/helm-operator/pkg/install v0.0.0-20200407140510-8d71b0072a3e
)

Sorry if your issue remains unresolved. The Helm Operator is in maintenance mode, we recommend everybody upgrades to Flux v2 and Helm Controller.

A new release of Helm Operator is out this week, 1.4.4.

We will continue to support Helm Operator in maintenance mode for an indefinite period of time, and eventually archive this repository.

Please be aware that Flux v2 has a vibrant and active developer community who are actively working through minor releases and delivering new features on the way to General Availability for Flux v2.

In the mean time, this repo will still be monitored, but support is basically limited to migration issues only. I will have to close many issues today without reading them all in detail because of time constraints. If your issue is very important, you are welcome to reopen it, but due to staleness of all issues at this point a new report is more likely to be in order. Please open another issue if you have unresolved problems that prevent your migration in the appropriate Flux v2 repo.

Helm Operator releases will continue as possible for a limited time, as a courtesy for those who still cannot migrate yet, but these are strongly not recommended for ongoing production use as our strict adherence to semver backward compatibility guarantees limit many dependencies and we can only upgrade them so far without breaking compatibility. So there are likely known CVEs that cannot be resolved.

We recommend upgrading to Flux v2 which is actively maintained ASAP.

I am going to go ahead and close every issue at once today,
Thanks for participating in Helm Operator and Flux! 💚 💙