serverless / serverless-kubeless

This plugin enables support for Kubeless within the Serverless Framework.
Apache License 2.0
303 stars 80 forks source link

Provider-wide environment variables are not set #147

Closed jsnowacki closed 6 years ago

jsnowacki commented 6 years ago

The provider-wide setup of environment variables is not passed correctly to the function. Description in the documentation states that it should work: https://serverless.com/framework/docs/providers/kubeless/guide/functions#environment-variables. It was mentioned in issue #88, but I'm reporting a new one as the previous one was linked to documentation.

The below code doesn't set the variable correctly and, thus, it isn't visible in the function.

service: google_analytics

provider:
  name: kubeless
  runtime: go1.10
  environment:
      MY_VAR: "123"

plugins:
  - serverless-kubeless

package:
  exclude: 
    - node_modules/**
    - vendor/**

functions:
  kafka-message:
    handler: handler.KafkaHandler
    events:
      - trigger: 'test_topic'

Moving the environment variable to the function solves the problem, though, in this case the environment variable declaration needs to be copied to the all functions, which is more of a workaround than solution.

service: google_analytics

provider:
  name: kubeless
  runtime: go1.10

plugins:
  - serverless-kubeless

package:
  exclude: 
    - node_modules/**
    - vendor/**

functions:
  kafka-message:
    handler: handler.KafkaHandler
    environment:
      MY_VAR: "123"
    events:
      - trigger: 'test_topic'

I've only tested it for Goland provider.

Kubeless version: v1.0.0-alpha.7 Serverless version: 1.29.2 serverless-kubeless version: 0.4.4

andresmgot commented 6 years ago

thanks for reporting @jsnowacki! it seems indeed a regression. #148 should fix it