So I'm using helm/helfile with atmos now and I can...
# atmos
p
So I'm using helm/helfile with atmos now and I can deploy some Charts BUT some other charts have input vars like
environment
,
namespace
etc and since that is how our
name_pattern
we need to use them, so how could I avoid those variables to be pass to helmfile?
a
do you have an example of those?
p
example
Copy code
vars:
  namespace: "mgmt"
  environment: "wus3"

components:
  helmfile:
    ingress-nginx:
      vars:
        controller:
          ingressClassResource:
            default: true
          autoscaling:
            enabled: true
          nodeSelector:
            Apps: SystemApps
          tolerations:
            - key: "CriticalAddonsOnly"
              operator: "Equal"
              value: "true"
              effect: "NoSchedule"

    cert-manager:
      metadata:
        component: "letsencrypt-certbot"
      vars:
        installCRDs: true
        crds:
          enabled: true
        nodeSelector:
          Apps: SystemApps
        tolerations:
          - key: "CriticalAddonsOnly"
            operator: "Equal"
            value: "true"
            effect: "NoSchedule"
Copy code
---
repositories:
  - name: cert-manager
    url: https://charts.jetstack.io/

releases:
  - name: cert-manager
    chart: cert-manager/cert-manager
    version: 1.18.2
    namespace: cert-manager
    createNamespace: true
    force: false
    values:
      - mgmt-wus3-cert-manager.helmfile.vars.yaml
cert managet complains about any inputs that are not defined in the chart
also we need to figureout if we can pass
{.vars.environment}
to the values....
a
hmm..
namespace: cert-manager
is not an Atmos namespace, it's a k8s namespace
not related to Atmos at all
if your helm chart accepts a var (can be anything), you define it in the component (terraform or helmfile), and configure it in the atmos component/stack. For the value of the variable, you can use templates
{{.vars.environment}}
p
wait it does not complain about
namespace: cert-manager
that is not part of the values
it complain about
environment:
a
who complains about
environment
?
p
Copy code
atmos helmfile diff cert-manager -s mgmt-wus3                               ✔  5557  12:07:50 
Adding repo cert-manager https://charts.jetstack.io/
"cert-manager" has been added to your repositories

Comparing release=cert-manager, chart=cert-manager/cert-manager, namespace=cert-manager
in ./helmfile.yaml: command "/opt/homebrew/bin/helm" exited with non-zero status:

PATH:
  /opt/homebrew/bin/helm

ARGS:
  0: helm (4 bytes)
  1: diff (4 bytes)
  2: upgrade (7 bytes)
  3: --allow-unreleased (18 bytes)
  4: cert-manager (12 bytes)
  5: cert-manager/cert-manager (25 bytes)
  6: --version (9 bytes)
  7: 1.18.2 (6 bytes)
  8: --namespace (11 bytes)
  9: cert-manager (12 bytes)
  10: --values (8 bytes)
  11: /var/folders/d4/_zh74d4n04n9yf9f2wqsl3640000gn/T/helmfile416742790/cert-manager-cert-manager-values-c84f5d879 (109 bytes)
  12: --reset-values (14 bytes)
  13: --color (7 bytes)

ERROR:
  exit status 1

EXIT STATUS
  1

STDERR:
  Error: Failed to render chart: exit status 1: Error: values don't meet the specifications of the schema(s) in the following chart(s):
  cert-manager:
  - at '': additional properties 'environment' not allowed
  Error: plugin "diff" exited with error

COMBINED OUTPUT:
  Error: Failed to render chart: exit status 1: Error: values don't meet the specifications of the schema(s) in the following chart(s):
  cert-manager:
  - at '': additional properties 'environment' not allowed
  Error: plugin "diff" exited with error
 Error 

exit status 1
a
you think it complains about
environment: "wus3"
sent in the variables to the chart?
p
yes sir
this is the values file generated by atmos
Copy code
crds:
  enabled: true
environment: wus3
namespace: mgmt
nodeSelector:
  Apps: SystemApps
tolerations:
  - effect: NoSchedule
    key: CriticalAddonsOnly
    operator: Equal
    value: "true"
if we delete
environment
and
namespace
and run helmfile from the component/ folder it works
a
that's strange (never seen a chart complaining about an additional var). Also, we've been deploying this https://github.com/cloudposse-terraform-components/aws-eks-cert-manager with Atmos in diff accounts, environments etc. for a long time - take a look at it
p
this is Azure AKS
I can't use most of the stuff there
a
hmm.. interesting. I can see the issue (if the chart complains about the provided but not defined variables)
p
WHY I FIND THIS STUFF ANDRIY? WHY is always me?
I think I'm technology cursed.....
a
no PePe, you find some missing pieces which allows us to improve Atmos, and you did it many times
let me think about the issue
p
lol
a
here's what the smart AI says:
Copy code
You're hitting Helm's values.schema.json gate: the cert-manager chart sets "additionalProperties": false at the root, so any key it doesn't explicitly allow (like your environment) is rejected.
Copy code
Don't pass environment to that chart (cleanest)

Keep environment for Atmos/Helmfile templating, but strip it out of the values you pass to the chart.

Put your chart values in a templated file (Helmfile supports Go templates for values files).
Example values.cert-manager.yaml.gotmpl:

{{- /* . is the Helmfile template context, not the chart .Values */ -}}
{{- $vals := readFile "values.base.yaml" | fromYaml -}}
{{- /* Drop top-level keys your chart doesn't accept */ -}}
{{- $vals = omit $vals "environment" -}}
{{ $vals | toYaml }}

Then in your Helmfile release:

releases:
  - name: cert-manager
    chart: jetstack/cert-manager
    namespace: mgmt
    values:
      - values.cert-manager.yaml.gotmpl
Copy code
Tell Helm to skip value-schema validation (fastest)

If you must pass extra keys (or you don't want to fuss with templating), you can disable the values schema check:

Helm CLI supports --skip-schema-validation on install, upgrade, and template. 

Helmfile exposes this as skipSchemaValidation: true (globally via helmDefaults or per release). 

helmDefaults:
  skipSchemaValidation: true  # requires Helm >= 3.16

Caveat: you're opting out of a useful safety net. Use when you trust your inputs.
p
mmmm
a
try that
p
interesting
a
for Atmos to support it natively, we'll have to implement something to tell it not to include some vars in the generated varfile
p
yes
@Girish Maddineni
👀 1
👍 1
g
--skip-validation make a move forward for
atmos helmfile apply
command and successfully apply resources go into
kube-system
namespace but, failing for
cert-manger
namespace since it's overriding the Namespace of
cert-manger
with Namespace we use for stack recognition
"mgmt"
in this case.
Copy code
Reference of resource failures

- 
+ # Source: cert-manager/templates/webhook-service.yaml
+ apiVersion: v1
+ kind: Service
+ metadata:
+   name: cert-manager-webhook
+   namespace: mgmt
+   labels:
+     app: webhook
+     app.kubernetes.io/name: webhook
+     app.kubernetes.io/instance: cert-manager
+     app.kubernetes.io/component: "webhook"
+     app.kubernetes.io/version: "v1.18.2"
+     app.kubernetes.io/managed-by: Helm
+     helm.sh/chart: cert-manager-v1.18.2
+ spec:
+   type: ClusterIP
+   ports:
+   - name: https
+     port: 443
+     protocol: TCP
+     targetPort: "https"
+   - name: metrics
+     port: 9402
+     protocol: TCP
+     targetPort: "http-metrics"
+   selector:
+     app.kubernetes.io/name: webhook
+     app.kubernetes.io/instance: cert-manager
+     app.kubernetes.io/component: "webhook"
mgmt, cert-manager-webhook, ServiceAccount (v1) has been added:
- 
+ # Source: cert-manager/templates/webhook-serviceaccount.yaml
+ apiVersion: v1
+ kind: ServiceAccount
+ automountServiceAccountToken: true
+ metadata:
+   name: cert-manager-webhook
+   namespace: mgmt
+   labels:
+     app: webhook
+     app.kubernetes.io/name: webhook
+     app.kubernetes.io/instance: cert-manager
+     app.kubernetes.io/component: "webhook"
+     app.kubernetes.io/version: "v1.18.2"
+     app.kubernetes.io/managed-by: Helm
+     helm.sh/chart: cert-manager-v1.18.2
mgmt, cert-manager-webhook:dynamic-serving, Role (rbac.authorization.k8s.io) has been added:
- 
+ # Source: cert-manager/templates/webhook-rbac.yaml
+ apiVersion: rbac.authorization.k8s.io/v1
+ kind: Role
+ metadata:
+   name: cert-manager-webhook:dynamic-serving
+   namespace: mgmt
+   labels:
+     app: webhook
+     app.kubernetes.io/name: webhook
+     app.kubernetes.io/instance: cert-manager
+     app.kubernetes.io/component: "webhook"
+     app.kubernetes.io/version: "v1.18.2"
+     app.kubernetes.io/managed-by: Helm
+     helm.sh/chart: cert-manager-v1.18.2
+ rules:
+ - apiGroups: [""]
+   resources: ["secrets"]
+   resourceNames:
+   - 'cert-manager-webhook-ca'
+   verbs: ["get", "list", "watch", "update"]
+ # It's not possible to grant CREATE permission on a single resourceName.
+ - apiGroups: [""]
+   resources: ["secrets"]
+   verbs: ["create"]
mgmt, cert-manager-webhook:dynamic-serving, RoleBinding (rbac.authorization.k8s.io) has been added:
- 
+ # Source: cert-manager/templates/webhook-rbac.yaml
+ apiVersion: rbac.authorization.k8s.io/v1
+ kind: RoleBinding
+ metadata:
+   name: cert-manager-webhook:dynamic-serving
+   namespace: mgmt
+   labels:
+     app: webhook
+     app.kubernetes.io/name: webhook
+     app.kubernetes.io/instance: cert-manager
+     app.kubernetes.io/component: "webhook"
+     app.kubernetes.io/version: "v1.18.2"
+     app.kubernetes.io/managed-by: Helm
+     helm.sh/chart: cert-manager-v1.18.2
+ roleRef:
+   apiGroup: rbac.authorization.k8s.io
+   kind: Role
+   name: cert-manager-webhook:dynamic-serving
+ subjects:
+ - kind: ServiceAccount
+   name: cert-manager-webhook
+   namespace: mgmt
Copy code
Upgrading release=cert-manager, chart=cert-manager/cert-manager, namespace=cert-manager
Release "cert-manager" does not exist. Installing it now.


FAILED RELEASES:
NAME           NAMESPACE      CHART                       VERSION   DURATION
cert-manager   cert-manager   cert-manager/cert-manager                   8s

in ./helmfile.yaml: failed processing release cert-manager: command "/opt/homebrew/bin/helm" exited with non-zero status:

PATH:
  /opt/homebrew/bin/helm

ARGS:
  0: helm (4 bytes)
  1: upgrade (7 bytes)
  2: --install (9 bytes)
  3: cert-manager (12 bytes)
  4: cert-manager/cert-manager (25 bytes)
  5: --version (9 bytes)
  6: 1.18.2 (6 bytes)
  7: --create-namespace (18 bytes)
  8: --skip-schema-validation (24 bytes)
  9: --namespace (11 bytes)
  10: cert-manager (12 bytes)
  11: --values (8 bytes)
  12: /var/folders/d4/_zh74d4n04n9yf9f2wqsl3640000gn/T/helmfile4052679194/cert-manager-cert-manager-values-c84f5d879 (110 bytes)
  13: --reset-values (14 bytes)
  14: --history-max (13 bytes)
  15: 10 (2 bytes)

ERROR:
  exit status 1

EXIT STATUS
  1

STDERR:
  Error: failed to create resource: namespaces "mgmt" not found

COMBINED OUTPUT:
  Release "cert-manager" does not exist. Installing it now.
  Error: failed to create resource: namespaces "mgmt" not found
 Error                                                                                              
                                                                                                    
exit status 1