hashicorp / waypoint

A tool to build, deploy, and release any application on any platform.
https://waypointproject.io
Other
4.76k stars 327 forks source link

Kubernetes containers should support environment variables from app config #4589

Open ivanvanderbyl opened 1 year ago

ivanvanderbyl commented 1 year ago

Is your feature request related to a problem? Please describe.

I'm really excited about the potential of Waypoint, and decided to give it another try yesterday. One thing that has blocked me is when deploying to Kubernetes the container spec does not receive any environment variables from App config, as seen here https://github.com/hashicorp/waypoint/blob/c0f0e03b1805dc8a80f185a98a6e2a99d670d040/builtin/k8s/platform.go#L638-L650

Describe the solution you'd like

Environment variables defined in App/Project config should be applied to the K8s ContainerSpec.

Describe alternatives you've considered

Explain any additional use-cases If there are any use-cases that would help us understand the use/need/value please share them as they can help us decide on acceptance and prioritization.

Additional context

To replicate this as a bug, deploy a container to Kubernetes using something like this:

app "my-app" {
  config {
    env = {
      "THIS_SHOULD_BE_SET_ON_CONTAINER" = "true"
    }
  }

  deploy {
    use "kubernetes" {}
  }
}

Inspect the Deployment in k8s and notice that the environment does not contain THIS_SHOULD_BE_SET_ON_CONTAINER:

    Environment:
      WAYPOINT_DEPLOYMENT_ID:           01GWAQ7HVC7YG9NHRN54CT24Y8
      WAYPOINT_SERVER_ADDR:             XXXXXX.us-west-2.elb.amazonaws.com:9701
      WAYPOINT_SERVER_TLS:              1
      WAYPOINT_SERVER_TLS_SKIP_VERIFY:  1
      WAYPOINT_CEB_INVITE_TOKEN:        XXXXXX
      PORT:                             3000
ivanvanderbyl commented 1 year ago

I must be misunderstanding how tasks are executed because it doesn't look like app.config is available to any of the builtin deploy plugins. I was hoping to find a simple example of how to patch this from one of the other runners.

xiaolin-ninja commented 1 year ago

Hi @ivanvanderbyl, have you ran waypoint config sync to sync the configs? https://developer.hashicorp.com/waypoint/commands/config-sync

ivanvanderbyl commented 1 year ago

Hi @xiaolin-ninja I didn't see that documented anywhere and have just given it a try, however, it doesn't change anything. The environment specified in the deployment is still the same as mentioned above.

I spent some time digging through the source code and I can't see any way this could work, which makes me wonder if it ever did work for k8s? Do you have an example that I can deploy that demonstrates this working?

cicoyle commented 1 year ago

@ivanvanderbyl, In looking at our examples repo, here is an example waypoint.hcl with app config set. Are you saying static and dynamic env vars are not working, or are you saying it's just the dynamic env vars that are not working for you?

ivanvanderbyl commented 1 year ago

It's only dynamic vars. Static env works fine, as expected since the code actually implements reading it. But I can't see any way dynamic config is ever passed into the k8s platform.

teresamychu commented 1 year ago

@ivanvanderbyl Variables that come via config either static/dynamic are injected via Entrypoint binary. Are you using the entrypoint binary?