kapp-controller icon indicating copy to clipboard operation
kapp-controller copied to clipboard

improve error discovery for missing data values

Open cppforlife opened this issue 4 years ago • 2 comments

Error message:

    Stderr:      kapp: Error: Validation errors:
- Expected 'kind' on resource '/ () cluster' to be non-empty (stdin doc 10)
- Expected 'apiVersion' on resource '/ () cluster' to be non-empty (stdin doc 10)
- Expected 'metadata.name' on resource '/ () cluster' to be non-empty (stdin doc 10)

Okay, this took a long time and was pretty much trial and error, would love to find some way to possibly make that easier. My secret that I was using for inline.pathsFrom with the ytt section didn't have #@data/values at the top.

how do we improve finding this kind of error? will schemas help with this?

cppforlife avatar May 15 '20 00:05 cppforlife

App CR looked like this:

---
apiVersion: kappctrl.k14s.io/v1alpha1
kind: App
metadata:
  name: deploy
  namespace: kapp-controller
spec:
  fetch:
  - git:
      url: https://github.com/voor/cluster-api-gitops
      ref: origin/master
      subPath: workload/deploy
  template:
  - ytt:
      ignoreUnknownComments: true
      inline:
        pathsFrom:
        - secretRef:
            name: initial-values
  deploy:
  - kapp: {}

The secret with the error initially looked like this:

---
apiVersion: v1
kind: Secret
metadata:
  name: initial-values
  namespace: kapp-controller
stringData:
  values2.yml: |
    acme_email: [email protected]
    github_client_id: REMOVED
    github_client_secret: REMOVED
    grafana_client_id: REMOVED
    grafana_client_secret: REMOVED
    sonarqube_client_id: 
    sonarqube_client_secret:

Which is incorrect syntax, it should look like this:

---
apiVersion: v1
kind: Secret
metadata:
  name: initial-values
  namespace: kapp-controller
stringData:
  values2.yml: |
+    #@data/values
+    ---
    acme_email: [email protected]
    github_client_id: REMOVED
    github_client_secret: REMOVED
    grafana_client_id: REMOVED
    grafana_client_secret: REMOVED
    sonarqube_client_id: 
    sonarqube_client_secret:

voor avatar May 15 '20 00:05 voor

Tagged the whole repo to find a reference back to what was deployed, too: https://github.com/voor/cluster-api-gitops/tree/v0.0.2

voor avatar May 15 '20 00:05 voor