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

Kyma Functions: Secrets and Config map references are wrong when editing via Function UI #10303

Closed
lechnerc77 opened this issue Jan 9, 2021 · 1 comment · Fixed by #10373
Closed
Assignees
Labels
area/serverless Issues or PRs related to serverless kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@lechnerc77
Copy link

Description

This issue is occurring in Kyma 1.17 (on SCP Trial)

I create a secret ( secretforfunction) and a config map (configforfunction) for a Kyma function. After that I deploy a basic setup for the function via a deployment file referencing the secrets and config map entries

example:

apiVersion: serverless.kyma-project.io/v1alpha1
kind: Function
metadata:
  name: complaint-prev
spec:
  runtime: nodejs12
  source: |
    module.exports = {
      main: function(event, context) {
        console.log(process.env['CLIENT_ID'])
        console.log(process.env['CLIENT_SECRET'])
        console.log(process.env['DURABLE_FUNC_ENDPOINT'])
        console.log(process.env['TOKEN_ENDPOINT_ABAP'])
        console.log(process.env['BASE_URL_ABAP'])
        console.log(process.env['ABAP_MOCK_SCOPE'])
      }
    }
  deps: |
    {
      "name": "complaint-prev",
      "version": "1.0.0",
      "dependencies": {
        "axios": "^0.21.1",
        "qs": "^6.9.4"
      }
    }  
  env:
    - name: CLIENT_ID
      valueFrom:
        secretKeyRef:
          key: clientid
          name: secretforfunction
    - name: CLIENT_SECRET
      valueFrom:
        secretKeyRef:
          key: clientsecret
          name: secretforfunction
    - name: DURABLE_FUNC_ENDPOINT
      valueFrom:
        secretKeyRef:
          key: durabelfuncendpoint
          name: secretforfunction
    - name: TOKEN_ENDPOINT_ABAP
      valueFrom:
        configMapKeyRef:
          key: tokenendpointabap
          name: configforfunction
    - name: BASE_URL_ABAP
      valueFrom:
        configMapKeyRef:
          key: baseurlabap
          name: configforfunction
    - name: ABAP_MOCK_SCOPE
      valueFrom:
        configMapKeyRef:
          key: abapmockscope
          name: configforfunction

The deployment is successfully executed and the references to the environment variables are set correctly (checked via kubectl -n mynamespace describe functions)

After that I make an adoption of the function code in the UI of Kyma, which triggers a redeployment of the function. However this also has an impact to the environment variables. It seems that the name in the valueFrom section is just copied from the very first entry, so after the re-deployment the environment section looks like this:

  env:
    - name: CLIENT_ID
      valueFrom:
        secretKeyRef:
          key: clientid
          name: secretforfunction
    - name: CLIENT_SECRET
      valueFrom:
        secretKeyRef:
          key: clientid
          name: secretforfunction
    - name: DURABLE_FUNC_ENDPOINT
      valueFrom:
        secretKeyRef:
          key:  clientid
          name: secretforfunction
    - name: TOKEN_ENDPOINT_ABAP
      valueFrom:
        configMapKeyRef:
          key: tokenendpointabap
          name: configforfunction
    - name: BASE_URL_ABAP
      valueFrom:
        configMapKeyRef:
          key: tokenendpointabap
          name: configforfunction
    - name: ABAP_MOCK_SCOPE
      valueFrom:
        configMapKeyRef:
          key: tokenendpointabap
          name: configforfunction

=> The first key value per valueFrom type is now copied for every environment variable

Expected result

Either the editing via Kyma UI is not available if a function gets deployed via CLI or the re-deployment does not influence the original setting of the environment variables

Actual result

The environment variables seem to be copied but the key fields are taken from the very first entry per type of valueFrom

Steps to reproduce

  • Create a function with environment variables referencing a secret and/or a configmap via CLI.
  • Change the code of the function via Kyma UI to trigger a redeployment
  • Check the key of the environment variables

Troubleshooting

Staying within one way of editing the function (either via CLI or via Kyma UI) is a workaround

@a-thaler a-thaler added area/serverless Issues or PRs related to serverless kind/bug Categorizes issue or PR as related to a bug. labels Jan 11, 2021
@kwiatekus kwiatekus added this to the 1.20 milestone Jan 11, 2021
@tgorgol tgorgol self-assigned this Jan 20, 2021
@luizcarlospedrosogomes
Copy link

And how would it look for the configuration of the git repository?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/serverless Issues or PRs related to serverless kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants