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

Add support for string extraObjects #1903

Merged
merged 1 commit into from
Jan 4, 2025

Conversation

PseudoResonance
Copy link
Contributor

Currently, extraObjects only allows YAML inputs, which make it a pain to use templating within them. You can single quote a templated line for most cases, but this doesn't work with multiline things, such as labels.

Example:

labels: {{ include "vm.labels" (dict "helm" . "appKey" "server" "extraLabels" .Values.server.service.labels) | nindent 4 }}

will template as

labels: '
  name: abc
  label2: value'

As shown in this documentation, being able to pass the whole object as a string is great for templating and allows for these multiline strings.

@github-actions github-actions bot added k8s-stack k8s-stack helm chart related issue agent vmagent helm chart related issue alert vmalert helm chart related issue auth vmauth helm chart related issue cluster vmcluster helm chart related issue operator operator helm chart related issue single VictoriaMetrics Single node helm chart related issue logs metrics labels Jan 4, 2025
@PseudoResonance
Copy link
Contributor Author

As a more complete example, I am attempting to add the following to my values.yaml.

extraObjects:
  - |
    {{- $app := .Values.server }}
    {{- $ctx := dict "helm" . "appKey" "server" }}
    apiVersion: v1
    kind: Service
    metadata:
      namespace: {{ include "vm.namespace" . }}
      annotations:
        metallb.universe.tf/address-pool: static-pool
        metallb.universe.tf/loadBalancerIPs: 10.5.0.6,fdde:cdb9:984f:2484:10:5:0:6
      {{- $_ := set $ctx "extraLabels" $app.service.labels }}
      labels: {{ include "vm.labels" $ctx | nindent 4 }}
      {{- $_ := unset $ctx "extraLabels" }}
      name: {{ include "vm.plain.fullname" $ctx }}-syslog
    spec:
      type: LoadBalancer
      externalTrafficPolicy: Local
      ipFamilyPolicy: PreferDualStack
      sessionAffinity: ClientIP
      ports:
        - name: syslog
          port: 514
          targetPort: 514
      selector: {{ include "vm.selectorLabels" $ctx | nindent 4 }}

Along with

server:
  extraArgs:
    syslog.listenAddr.tcp: ":514"
    syslog.listenAddr.udp: ":514"

To allow for ingesting syslogs.

@AndrewChubatiuk AndrewChubatiuk merged commit f479f4d into VictoriaMetrics:master Jan 4, 2025
27 checks passed
@AndrewChubatiuk
Copy link
Collaborator

LGTM! Thanks for contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent vmagent helm chart related issue alert vmalert helm chart related issue auth vmauth helm chart related issue cluster vmcluster helm chart related issue k8s-stack k8s-stack helm chart related issue logs metrics operator operator helm chart related issue single VictoriaMetrics Single node helm chart related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants