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

Helm installation fails when using Flux #751

Closed
nliakm opened this issue Feb 18, 2023 · 2 comments · Fixed by #820
Closed

Helm installation fails when using Flux #751

nliakm opened this issue Feb 18, 2023 · 2 comments · Fixed by #820
Assignees

Comments

@nliakm
Copy link

nliakm commented Feb 18, 2023

When trying to install the mondoo-operator via Helm and Flux, the installation fails due to following error:

Helm install failed: error while running post render on files: map[string]interface {}(nil): yaml: unmarshal errors: line 18: mapping key "app.kubernetes.io/name" already defined at line 17

The reason for this behaviour is described here:

Unlike Helm, the Kustomize yaml parser (kyaml) does not accept duplicate keys, while Helm drops the duplicates, Kustomize errors out. This impacts helm-controller as it uses kustomize/kyaml to label objects reconciled by a HelmRelease.

The duplicated keys are inside the rendered Deployment and Service manifests.

---
# Source: mondoo-operator/templates/metrics-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: mondoo-operator-controller-manager-metrics-service
  labels:
    helm.sh/chart: mondoo-operator-1.11.1
    app.kubernetes.io/name: mondoo-operator
    app.kubernetes.io/instance: mondoo-operator
    app.kubernetes.io/version: "1.11.1"
    app.kubernetes.io/managed-by: Helm
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: mondoo-operator # << duplicate keys
    app.kubernetes.io/name: mondoo-operator # << duplicate keys
    app.kubernetes.io/instance: mondoo-operator
  ports:
  - name: metrics
    port: 8080
    protocol: TCP
    targetPort: metrics
---
# Source: mondoo-operator/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mondoo-operator-controller-manager
  labels:
    helm.sh/chart: mondoo-operator-1.11.1
    app.kubernetes.io/name: mondoo-operator
    app.kubernetes.io/instance: mondoo-operator
    app.kubernetes.io/version: "1.11.1"
    app.kubernetes.io/managed-by: Helm
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: mondoo-operator # << duplicate keys
      app.kubernetes.io/name: mondoo-operator # << duplicate keys
      app.kubernetes.io/instance: mondoo-operator
  template:
    metadata:
      labels:
        app.kubernetes.io/name: mondoo-operator # << duplicate keys
        app.kubernetes.io/name: mondoo-operator # << duplicate keys
        app.kubernetes.io/instance: mondoo-operator
      annotations:
...

The solution to fix it, would be probably to just delete the hardcoded app.kubernetes.io/name: mondoo-operator inside the deployment.yaml and metrics-service.yaml, because they will get templated anyway when rendering the manifest files.

@czunker czunker self-assigned this Jun 8, 2023
@czunker
Copy link
Contributor

czunker commented Jun 8, 2023

Sorry, I missed this issue. I'll have a look at it.

czunker added a commit that referenced this issue Jun 9, 2023
Fixes #751

Signed-off-by: Christian Zunker <[email protected]>
czunker added a commit that referenced this issue Jun 12, 2023
@czunker
Copy link
Contributor

czunker commented Jun 20, 2023

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 a pull request may close this issue.

2 participants