Helm v3 unknown object type "nil" in Secret.data.couchbase_password - kubernetes-helm

I am getting this error while using helm 3 only. In helm 2 it's working as expected.Here is the secret object's manifest
secret.yaml
apiVersion: v1
data:
couchbase_password: {{ .Values.secrets.cbPass | quote }}
kind: Secret
metadata:
name: {{ include "persistence.name" .}}-cb-pass
type: Opaque
---
apiVersion: v1
data:
couchbase.crt: {{ .Values.secrets.encodedCouchbaseCrt | quote }}
kind: Secret
metadata:
name: {{ include "persistence.name" .}}-cb-crt
type: Opaque
And here are some contents of the values.yamlfile
configmap:
#support for oxtrust API
gluuOxtrustApiEnabled: false
gluuOxtrustApiTestMode: false
gluuCasaEnabled: true
secrets:
cbPass: UEBzc3cwcmQK # UEBzc3cwcmQK
encodedCouchbaseCrt: LS0tLS1CRUdJTiBDR
When I do helm template test . I get
---
# Source: gluu-server-helm/charts/persistence/templates/secrets.yaml
apiVersion: v1
data:
couchbase.crt: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUROVENDQWgyZ0F3SUJBZ0lKQU93NzNOV2x5cTE3TUEwR0NTcUdTSWIzRFFFQkN3VUFNQll4RkRBU0JnTlYKQkFNTUMyTmlMbWRzZFhVdWIzSm5NQjRYRFRFNU1USXlOakE0TXpBd04xb1hEVEk1TVRJeU16QTRNekF3TjFvdwpGakVVTUJJR0ExVUVBd3dMWTJJdVoyeDFkUzV2Y21jd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3CmdnRUtBb0lCQVFDZjhySjhNcHJYMFFEQTdaamVXWkNjQTExd0FnMFpzSERYV2gwRU5BWE9JYjdObkM5c0diWEYKeG1PVnpNL3pGcWhqNWU4Zi9hZnBPQUlSV1RhMzhTeGFiQ3VPR1pUU2pTZ3dtclQ3bmVPK0pSNDA3REdzYzlrSgp5d1lNc083S3FtcFJTMWpsckZTWXpMNGQ4VW5xa3k3OHFMMEw3R3F2Y0hSTTZKYkM4QXpBdDUwWGJ5eEhwaDFsClNVWDBCSWgzbXl5NHpDcjF1anhHN0x6QVVHaDEyZXVSVGpWc3YrdWN4emdIZjVONXNIcFloaWV4NjJ1UE1MeDUKYjVsOVJtMmVadmM2R0ZpU2NpVEYwUFZFSXhRbkVobmd3R1MyNWNOTGdGRzEzMDV0WkFFNWdtem9lK0V6YmJNZQpXczdyUFZDWmF4dmo4ekRZS1A3ZkxsMitWSUcxcXl6M0FnTUJBQUdqZ1lVd2dZSXdIUVlEVlIwT0JCWUVGTGFFCm9rK1lhV1FHczFJM3ZKOGJiV203dGcxb01FWUdBMVVkSXdRL01EMkFGTGFFb2srWWFXUUdzMUkzdko4YmJXbTcKdGcxb29ScWtHREFXTVJRd0VnWURWUVFEREF0allpNW5iSFYxTG05eVo0SUpBT3c3M05XbHlxMTdNQXdHQTFVZApFd1FGTUFNQkFmOHdDd1lEVlIwUEJBUURBZ0VHTUEwR0NTcUdTSWIzRFFFQkN3VUFBNElCQVFBWlJnQ0I5cHFKClVZamZxWCsvUStRODNJQUJOSkJvMlMyYjRvT3NITGVyOGx6ZjlvZXdyR2dHUlRIeHNnRHE1dXcvS0c2TVJPSWEKR08zY0JwYWdENC9kVHBnRWpZemU0eXg0RzlTb253dmNESVNvV0dPN2Q5OG41SnJBaFZOYmFUT1FTSGRUTkxBTgp4UFVvcFh3RTZzOUp3bUxQUUdpQ2txcSs3NWp5OUFLRWRJTThTb0xNQXU3eHBPaDY0SVluRmhJOHAvZW5vNVpyCkxNbUFVbTltWVVaK2x0eDB6N0xDTXF1N3Z6RU55SzZ4anZiY3VxN0Y3aGsydDFmdVVYMUFpb1ZpN1dRdnQ3emwKODE3b2V6UG04NDJjTWZubkFqSzFkNnd1Z2RpNzlQSnJ1UDc4WmJXUThIWjZuSUtBRmlZRGxQTTNEakxnR0xZZgpZRll0LzJvVzJFQzEKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo="
kind: Secret
metadata:
name: persistence-cb-crt
type: Opaque
---
# Source: gluu-server-helm/charts/persistence/templates/secrets.yaml
apiVersion: v1
data:
couchbase_password: "UEBzc3cwcmQK"
kind: Secret
metadata:
name: persistence-cb-pass
type: Opaque
When I use default data directly without referencing values file, it still doesn't work.
Helm version
version.BuildInfo{Version:"v3.0.2", GitCommit:"19e47ee3283ae98139d98460de796c1be1e3975f", GitTreeState:"clean", GoVersion:"go1.13.5"}
kubectl version
Client Version: v1.16.3
Server Version: v1.17.0

Related

application.properties override in HELM

I have following configMap and I need to override value of quarkus.http.port & quarkus.datasource.TEST.jdbc.url while deploying it UAT env. How to override it using values.yaml ?
apiVersion: v1
kind: ConfigMap
metadata:
name: app-yaml
data:
application.yml: |
quarkus.http.port=8890
quarkus.datasource.TEST.jdbc.url=jdbc:oracle:thin:#//localhost:1521/test
define values in the value.yaml file,
quarkus:
port: 8080
url: jdbc:oracle:thin:#//localhost:1521/test
and the configmap should be consuming these value for port and url
apiVersion: v1
kind: ConfigMap
metadata:
name: app-yaml
data:
application.yml: |
quarkus.http.port={{ .Values.quarkus.port }}
quarkus.datasource.TEST.jdbc.url={{ .Values.quarkus.url }}

Config Map in Helm

I am creating a configMap from CSV file using helm tempate but it is getting create different from OC command.
Heml Template:
apiVersion: v1
kind: ConfigMap
metadata:
name: service-config
namespace: {{ .Values.namespace }}
labels:
app: {{ .Values.appname }}
data:
{{- $path := printf "%s/application-config/*" .Values.env }}
{{ (.Files.Glob $path).AsConfig | indent 2 }}
Generated Configmap
kind: ConfigMap
apiVersion: v1
metadata:
name: service-config
namespace: ''
labels:
app.kubernetes.io/managed-by: Helm
data:
esm-instrument-type-map.csv: |-
M-MKT,COB
CMO,COB
MUNI,COB
WARRNT,EQU
PFD,EQU
OC Command :
oc create configmap test-config --from-file= ./esm-instrument-type-map.csv
Generated ConfigMap
kind: ConfigMap
apiVersion: v1
metadata:
name: test-config
namespace: ''
data:
esm-instrument-type-map.csv: "CORP,COB\r\nEQUITY,EQU\r\nGOVT,TRY\r\nMBS,FNM\r\nST-PRD,COB\r\nM-MKT,COB\r\nCMO,COB\r\nMUNI,COB\r\nWARRNT,EQU\r\nPFD,EQU"
As we see, data from the CSV file is in double quotes, when generated by the OC command. I want the same in helm. How can I achieve this?

How to configure datasource of Grafana using bitnami helm charts?

I am having trouble with configuring grafana datasource with Helm Charts and Kubernetees. This is my release.yaml:
kind: Namespace
apiVersion: v1
metadata:
name: monitoring
annotations:
name: monitoring
labels:
name: monitoring
---
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-datasources
namespace: monitoring
data:
grafana.ini: |-
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: prometheus
namespace: monitoring
spec:
interval: 5m
chart:
spec:
chart: kube-prometheus
version: "8.0.7"
sourceRef:
kind: HelmRepository
name: bitnami
namespace: flux-system
interval: 1m
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: grafana
namespace: monitoring
spec:
interval: 5m
chart:
spec:
chart: grafana
version: "7.9.8"
sourceRef:
kind: HelmRepository
name: bitnami
namespace: flux-system
interval: 1m
values:
config:
useGrafanaIniFile: true
grafanaIniConfigMap: grafana-datasources
---
I see that grafana does have grafana.ini file in /opt/bitnami/grafana/conf/ directory but when checking the datasources in grafana UI there is none. Does anyone know why this is the case, because I do not understand what I am doing wrong.
When deploying with Flux you might benefit from using the configMapGenerator constructor instead of creating the config map manually.
I'm going to assuming you have a folder structure like this
monitoring/
├── kustomize.yaml
├── kustomizeconfig.yaml
├── namepace.yaml
├── release.yaml
└── values.yaml
kustomization.yaml
The namespace attribute tells Flux, that it should install all the resources referenced in the file, in the monitoring namespace. This way you only have to reference a namespace, if you're pulling in objects from other namespaces (eg. sources from the flux-system namespace).
If you call your values file something else (eg. grafana-config.yaml), then you should change the name in the files list to something like values.yaml=grafana-config.yaml. Helm will complain if it does not find a values.yaml entry.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: monitoring
resources:
- release.yaml
- namespace.yaml
configMapGenerator:
- name: grafana-values
files:
- values.yaml
# - values.yaml=grafana-config.yaml
configurations:
- kustomizeconfig.yaml
kustomizeconfig.yaml
This nameReference will monkey patch the value of the valuesFrom with kind ConfigMap in the release release.yaml file, so it matches the ConfigMap.
nameReference:
- kind: ConfigMap
version: v1
fieldSpecs:
- path: spec/valuesFrom/name
kind: HelmRelease
namespace.yaml
kind: Namespace
apiVersion: v1
metadata:
name: monitoring
annotations:
name: monitoring
labels:
name: monitoring
release.yaml
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: prometheus
spec:
interval: 5m
chart:
spec:
chart: kube-prometheus
version: "8.0.7"
sourceRef:
kind: HelmRepository
name: bitnami
namespace: flux-system
interval: 1m
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: grafana
spec:
interval: 5m
chart:
spec:
chart: grafana
version: "7.9.8"
sourceRef:
kind: HelmRepository
name: bitnami
namespace: flux-system
interval: 1m
valuesFrom:
- kind: ConfigMap
name: grafana-values
values.yaml
grafana.ini will be transformed into the grafana config file.
grafana.ini obejct
datasources will be imported as data
sources in grafana. datasources obejct
You can reference all the values, that can go into the values.yaml file here: example values.yaml file
grafana.ini:
paths:
data: /var/lib/grafana/
logs: /var/log/grafana
plugins: /var/lib/grafana/plugins
provisioning: /etc/grafana/provisioning
metrics:
enable: true
diable_total_stats: true
date_formats:
use_browser_locale: true
analytics:
reporting_enabled: false
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus-server.monitoring

how can I provide multipe secrets in one yaml file?

How can I define multiple secrets in one file?
Seems that providing multiple secrets doesn't work.
apiVersion: v1
kind: Secret
metadata:
name: ca-secret
labels:
app.kubernetes.io/managed-by: Helm
type: kubernetes.io/tls
data:
tls.crt: LS0tLDR
tls.key: LS0tLDR
apiVersion: v1
kind: Secret
metadata:
name: envoy-secret
labels:
app.kubernetes.io/managed-by: Helm
type: kubernetes.io/tls
data:
tls.crt: LS0tLS1
tls.key: LS0tLS1
I am not able to use multiple files because I need to generate a single template using helm.
You can have separate manifests in one yaml file by separating them with ---. This will work:
apiVersion: v1
kind: Secret
metadata:
name: ca-secret
labels:
app.kubernetes.io/managed-by: Helm
type: kubernetes.io/tls
data:
tls.crt: LS0tLDR
tls.key: LS0tLDR
---
apiVersion: v1
kind: Secret
metadata:
name: envoy-secret
labels:
app.kubernetes.io/managed-by: Helm
type: kubernetes.io/tls
data:
tls.crt: LS0tLS1
tls.key: LS0tLS1

Helmfile YAML parse error on error converting YAML to JSON: yaml: line 2: mapping values are not allowed in this context

I try to use helmfile to run applications on the k8s node. I get an error with the file:
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: redirectscheme
namespace: {{ .Values.namespace }}
spec:
redirectScheme:
scheme: https
permanent: false
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: stsheaders
namespace: {{ .Values.namespace }}
spec:
headers:
forceSTSHeader: true
stsSeconds: 31536000
stsIncludeSubdomains: true
stsPreload: true
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: stripprefix-frontend
namespace: {{ .Values.namespace }}
Error:
COMBINED OUTPUT:
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/kowal/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /home/kowal/.kube/config
Release "frontend" does not exist. Installing it now.
Error: YAML parse error on frontend-app/templates/middleware.yaml: error converting YAML to JSON: yaml: line 2: mapping values are not allowed in this context
I have no idea what's wrong. Please help.
I think you may have answered your own question? Superfluous spaces on last five lines.
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: redirectscheme
namespace: {{ .Values.namespace }}
spec:
redirectScheme:
scheme: https
permanent: false
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: stsheaders
namespace: {{ .Values.namespace }}
spec:
headers:
forceSTSHeader: true
stsSeconds: 31536000
stsIncludeSubdomains: true
stsPreload: true
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: stripprefix-frontend
namespace: {{ .Values.namespace }}