vectordotdev / helm-charts

Helm charts for Vector.
https://vector.dev
Mozilla Public License 2.0
106 stars 91 forks source link

Provide helpful error messages when ports aren't defined #188

Open spencergilbert opened 2 years ago

spencergilbert commented 2 years ago

If you've provided existingConfigMap/s but no ports for the service we don't force an error and the user only gets the Kubernetes rejection, we can create a similar experience as we have for the data dir and direct the user to correct the error.

arve0 commented 1 year ago

Also relevant when using customConfig with api.enabled: false and no sources.vector.adress.

For example this values.yaml:

role: Agent

customConfig:
  data_dir: /vector-data-dir
  api:
    enabled: false
    address: 127.0.0.1:8686
    playground: false
  sources:
    in:
      type: stdin
  sinks:
    stdout:
      type: console
      inputs: [vector]
      encoding:
        codec: json

Gives an invalid Service.spec.ports (empty):

$ helm template -f v.yaml . | yq 'select(.kind == "Service").spec'
clusterIP: None
ports:
selector:
  app.kubernetes.io/name: vector
  app.kubernetes.io/instance: release-name
  app.kubernetes.io/component: Agent
type: ClusterIP
---
ports:
selector:
  app.kubernetes.io/name: vector
  app.kubernetes.io/instance: release-name
  app.kubernetes.io/component: Agent
type: ClusterIP

Kind of documented in if used all options need to be specified, but took me some time to figure out.

spencergilbert commented 1 year ago

Yeah, technically documented but clearly not clear. I've done some work on a related chart and working in some additional fail usage to help catch this at "compile time" vs apply time, that I can port back over. Still a place I'd like to improve the UX and documentation.

ogarcia commented 9 months ago

I think I have fallen into the same error. If I put this configuration file:

role: "Agent"

service:
  enabled: false

serviceHeadless:
  enabled: false

customConfig:
  data_dir: /vector-data-dir
  api:
    enabled: false
    address: 127.0.0.1:8686
    playground: false
  sources:
    kubernetes_logs:
      type: kubernetes_logs
  sinks:
    type: console
    inputs: [kubernetes_logs]
    encoding:
      codec: json

I get an error and it won't install: Error: INSTALLATION FAILED: template: vector/templates/daemonset.yaml:42:10: executing "vector/templates/daemonset.yaml" at <include "vector.pod" .>: error calling include: template: vector/templates/_pod.tpl:90:8: executing "vector.pod" at <include "vector.containerPorts" .>: error calling include: template: vector/templates/_helpers.tpl:150:62: executing "vector.containerPorts" at <include "_helper.componentIter">: error calling include: template: vector/templates/_helpers.tpl:119:19: executing "_helper.componentIter" at <$options>: wrong type for value; expected map[string]interface {}; got []interface {}

The most interesting thing is that if I set api.enabled to true with the same configuration, it also gives the same error.

UPDATE: My mistake, I missed the stdout: in the sinks:. Sorry for the noise.