Hey all, when defining a FlinkDeployment's config...
# troubleshooting
g
Hey all, when defining a FlinkDeployment's configuration in the Flink Kubernetes Operator, is there a way to refer to values from Kubernetes Secrets? Or what is the recommended way of passing sensitive information to the
flinkConfiguration
block?
s
Define Secret.yaml file. Refer this secret in ur flinkdeployment.yaml. If the secret.yaml is part of ur helm chart. You can ovverrides using values.yaml
g
Do you have somewhere an example / snippet on how to do this?
s
secret.yaml
Copy code
apiVersion: v1
kind: Secret
metadata:
  name: my-secret
  namespace: {{ .Release.Namespace}}
type: Opaque
stringData:
  KEY1: {{ .Values.secret.key1}}
  KEY2: {{ .Values.secret.key2}}
In flinkdeployment.yaml
Copy code
containers:
    env:
    - name: SECRET_KEY1
      valueFrom:
        secretKeyRef:
          key: KEY1
          name: my-secret
    - name: SECRET_KEY2
      valueFrom:
        secretKeyRef:
          key: KEY2
          name: my-secret
values.yaml
Copy code
secret:
  key1: changeme
  key2: changeme
👍 1
g
Thanks for the snippets. I get that I now have the secrets as environment variables available in the Flink Pods. What I'm still not understanding is how I could use them in the
flinkConfiguration
block of the
FlinkDeployment
resource itself? Is there some sort of special syntax to use the value of environment variables? e.g.,
Copy code
apiVersion: flink.apache.org/v1beta1
kind: FlinkDeployment
metadata:
  ...
spec:
  ...
  flinkConfiguration:
    some.property.with.key: ${SECRET_KEY1}
s
Setting this- ${SECRET_KEY1} as env variable in ur containers block is enough to get it worked. You can test it. another simpler approach could be
Copy code
spec:
  ...
  flinkConfiguration:
    some.property.with.key: {{ .Values.secret.key1}}
But with this, when u do kubectl edit flinkdeployment , u can see ur secret without encoded
s
I have same problem like @Gerald, I don’t want to put secrets in values file( we do not check-in secrets). My secrets are in Kubernetes secrets and I tried setting in ENV variable and fetching in flinkConfiguration like ${SECRET_KEY1}, it does get the value from env variable.
s
Yes Its not good to check in secrets. Our secret.yaml is part of helm chart and secret values are passed at runtime using our CI CD tools using some automation.
s
so there is no other option then converting the flinkconfig into secret?
g
I found a Flink Improvement Proposal (https://cwiki.apache.org/confluence/display/FLINK/FLIP-161%3A+Configuration+through+envrionment+variables), but apparently it looks like this feature was discarded unfortunately. 😞
s
that is too bad 😞
I have to try dirty hacks to make this work
s
helm upgrade release-name secretName= key1. So thats how we run our helm upgrade command. So this key1 can be replaced from ur actual value at runtime how ever u want
j
I can't make this to work. @Sucheth S. Are you sure this is how it works? I'm trying to achieve the same result but with DD API KEY:
metrics.reporter.dghttp.apikey: xxx
Has someone went over a similar situation recently?
s
it won’t work, unless you write some code to add apikey during initcontainer during dpeloyment