3

I am trying to concatenate variable in helmchart to develop connection strings.

connection string:

ConnectionStrings:TheSourceContext="Server=10.xx.xx.xx,1433;Database=Test;User Id=Test; Password=pass123;"

I am passing user id &password as secret but it is not working. it is not building up the requried strings.

      - name: DBUSERD
        valueFrom:
          secretKeyRef:
            key: dbuser
            name: api-catalogue
      - name: DBPASSD
        valueFrom:
          secretKeyRef:
            key: dbpass
            name: api-catalogue
      - name: ConnectionStrings__TheSourceContext
        value: {{ .Values.const.DBSVR }}{{ .Values.app.connectionStringsServer }},{{.Values.app.connectionStringsPort }}{{ .Values.const.DB }}{{ .Values.app.connectionStringsDB }}{{ .Values.const.DBUSR }}$(DBUSERD){{ .Values.const.DBPASS }}($DBPASSD)*

How to correct above variable so that it will work?

edbighead
  • 5,607
  • 5
  • 29
  • 35
rahul131286
  • 31
  • 1
  • 2
  • 1
    https://stackoverflow.com/questions/58447111/how-to-reference-kubernetes-secrets-in-helm-chart , see if this helps. – Tarun Khosla Jul 31 '20 at 08:03
  • What doesn't work? What output are you getting? (`helm template` can show you the generated YAML without submitting it to Kubernetes.) The sample string you show has some constant text and punctuation that your YAML doesn't obviously seem to (`Server=` for example). – David Maze Jul 31 '20 at 10:55
  • Below Logic is working value: {{ .Values.const.DBSVR }}{{ .Values.app.connectionStringsServer }},{{.Values.app.connectionStringsPort }}{{ .Values.const.DB }}{{ .Values.app.connectionStringsDB }}{{ .Values.const.DBUSR }}{{ printf $ }}{{ .Values.const.DBPASS }}{{ .Values.app.connectionStringsPassword }} Below entry in values.yaml const: DBSVR: "Server=" DB: ";Database=" DBUSR: ";User ID=" DBPASS: "; Password=" --------------------------- Issue is when I use secrets as variable & try to use those variable it is throwing error As shared in first post – rahul131286 Jul 31 '20 at 12:27
  • With value: {{ .Values.const.DBSVR }} {{ .Values.app.connectionStringsServer }},{{ .Values.app.connectionStringsPort }}{{ .Values.const.DB }}{{ .Values.app.connectionStringsDB }} {{ .Values.const.DBUSR }} {{ printf "%s:$DBUSERD" }}{{ .Values.const.DBPASS }}{{ printf "%s:$DBPASSD" }} Output: ConnectionStrings__TheSourceContext = "Server= 10.241.64.28,1433;Database=TheSource_new ;User ID= %!s(MISSING):$DBUSERD; Password=%!s(MISSING):$DBPASSD"Password=%!s(MISSING):$DBPASSD – rahul131286 Jul 31 '20 at 14:12
  • Can you update this into the question? Please avoid placing code or commands in the comments. – acid_fuji Aug 04 '20 at 08:49
  • @rahul131286, any progress with this issue ? Did you manage to solve it ? – mario Apr 26 '21 at 09:20

0 Answers0