Waypoint-entrypoint config for exec plugin

Trying to get waypoint entrypoint to work with exec plugin.

The context setup with

waypoint context create \
    -server-addr=localhost:9701 \
    -server-auth-token=abcd1234 \
    -server-tls \
    -set-default my-server

and even this

waypoint context create \
    -server-addr=localhost:9701 \
    -server-auth-token=abcd1234 \
    -server-tls=false \
    -set-default my-server

The waypoint examples I have edited the waypoint.hcl of the docker/nodejs example

project = "example-nodejs"

app "example-nodejs" {
  labels = {
    "service" = "example-nodejs",
    "env" = "dev"
  }

  build {
    use "pack" {}
  }

  deploy { 
    use "exec" {
      command = ["docker", "run","-d","--network=host","-e", "WAYPOINT_SERVER_ADDR=localhost:9701", "-e","WAYPOINT_TOKEN=abcd1234", "{{.Input.DockerImageFull}}" ,"../waypoint-entrypoint node index.js"]
    }
  }
}

I have tried to add "-e", "WAYPOINT_TLS=true", still getting the same error.

The error log

2020-10-18T13:43:51.429Z [TRACE] starting interrupt listener for context cancellation
2020-10-18T13:43:51.430Z [TRACE] interrupt listener goroutine started
2020-10-18T13:43:51.430Z [INFO]  entrypoint starting: deployment_id= instance_id=01EMXZ7FW6V8H9B7P9PV6SV0JT args=[/cnb/lifecycle/launcher, "../waypoint-entrypoint node index.js"]
2020-10-18T13:43:51.430Z [INFO]  entrypoint version: full_string="Waypoint v0.1.2" version=v0.1.2 prerelease= metadata= revision=
2020-10-18T13:43:51.430Z [INFO]  connecting to server: addr=localhost:9701 tls=false tls_skip_verify=false
2020-10-18T13:43:51.430Z [DEBUG] waiting on server connection state to become ready
2020-10-18T13:43:51.430Z [TRACE] connection state: state=IDLE
2020-10-18T13:43:51.430Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:51.430Z [TRACE] connection state: state=TRANSIENT_FAILURE
2020-10-18T13:43:51.430Z [WARN]  failed to connect to the server, temporary network error
2020-10-18T13:43:51.430Z [WARN]  init: server unavailable, will retry in the background
2020-10-18T13:43:51.430Z [INFO]  starting child process: args=[/cnb/lifecycle/launcher, "../waypoint-entrypoint node index.js"] cmd=/cnb/lifecycle/launcher
2020-10-18T13:43:51.430Z [INFO]  connecting to server: addr=localhost:9701 tls=false tls_skip_verify=false
2020-10-18T13:43:51.431Z [DEBUG] waiting on server connection state to become ready
2020-10-18T13:43:51.431Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:51.431Z [TRACE] connection state: state=TRANSIENT_FAILURE
2020-10-18T13:43:51.446Z [TRACE] starting interrupt listener for context cancellation
2020-10-18T13:43:51.446Z [TRACE] interrupt listener goroutine started
2020-10-18T13:43:51.446Z [INFO]  entrypoint starting: deployment_id= instance_id=01EMXZ7FWPP8C9GVQ1Z1F51R4Y args=[node, index.js]
2020-10-18T13:43:51.446Z [INFO]  entrypoint version: full_string="Waypoint v0.1.2" version=v0.1.2 prerelease= metadata= revision=
2020-10-18T13:43:51.446Z [INFO]  connecting to server: addr=localhost:9701 tls=false tls_skip_verify=false
2020-10-18T13:43:51.446Z [DEBUG] waiting on server connection state to become ready
2020-10-18T13:43:51.446Z [TRACE] connection state: state=IDLE
2020-10-18T13:43:51.446Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:51.447Z [TRACE] connection state: state=TRANSIENT_FAILURE
2020-10-18T13:43:51.447Z [WARN]  failed to connect to the server, temporary network error
2020-10-18T13:43:51.447Z [WARN]  init: server unavailable, will retry in the background
2020-10-18T13:43:51.447Z [INFO]  starting child process: args=[/layers/heroku_nodejs-engine/nodejs/bin/node, index.js] cmd=/layers/heroku_nodejs-engine/nodejs/bin/node
2020-10-18T13:43:51.447Z [INFO]  connecting to server: addr=localhost:9701 tls=false tls_skip_verify=false
2020-10-18T13:43:51.447Z [DEBUG] waiting on server connection state to become ready
2020-10-18T13:43:51.447Z [TRACE] connection state: state=IDLE
2020-10-18T13:43:51.447Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:51.447Z [TRACE] connection state: state=TRANSIENT_FAILURE
Listening on 5000
2020-10-18T13:43:52.431Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:52.432Z [TRACE] connection state: state=TRANSIENT_FAILURE
2020-10-18T13:43:52.447Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:52.448Z [TRACE] connection state: state=TRANSIENT_FAILURE
2020-10-18T13:43:54.065Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:54.066Z [TRACE] connection state: state=TRANSIENT_FAILURE
2020-10-18T13:43:54.330Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:54.331Z [TRACE] connection state: state=TRANSIENT_FAILURE
2020-10-18T13:43:56.436Z [TRACE] connection state: state=CONNECTING
2020-10-18T13:43:56.438Z [TRACE] connection state: state=TRANSIENT_FAILURE

Can someone please tell me what other configs I have to add to get the enrtypoint working?

Hey, check out the .Env template in the docs here, you want to set all those env vars: https://www.waypointproject.io/plugins/exec Once those are set then this should work. Unfortunately I don’t think there is an easy way to set these currently in the command like that… so that’s something we’ll look into.

Hi I copied the kubernetes example into a docker-compose format, but I am getting the same error
The template file

version: '2'

services:
  example:
    container_name: example
    image: {{.Input.DockerImageFull}}
    environment:
        - WAYPOINT_ALT_TOKEN_EXAMPLE="{{index .Env "WAYPOINT_CEB_INVITE_TOKEN"}}"{{range $key, $value := .Env}}
        - {{$key}}="{{$value}}"{{end}}

Have I made any mistakes in the template?

the waypoint.hcl

project = "example-nodejs"

app "example-nodejs" {
  labels = {
    "service" = "example-nodejs",
    "env" = "dev"
  }

  build {
    use "pack" {}
  }

  deploy { 
    use "exec" {
      command = ["docker-compose", "-f", "<TPL>", "up"]
      template {
        path = "./docker-compose-template.yml"
      }
    }
  }
}

The logs

Deploying...
✓ Rendering templates...
⠸ Executing command: docker-compose -f /tmp/waypoint-exec698421697/docker-compose-template.yml up
 │ example    | 2020-10-19T12:15:08.305Z [TRACE] connection state: state=TRANSIENT_
 │ FAILURE
 │ example    | 2020-10-19T12:15:10.055Z [TRACE] connection state: state=CONNECTING
 │ example    | 2020-10-19T12:15:10.056Z [TRACE] connection state: state=TRANSIENT_
 │ FAILURE
 │ example    | 2020-10-19T12:15:12.352Z [TRACE] connection state: state=TRANSIENT_
 │ FAILURE
 │ example    | 2020-10-19T12:15:17.069Z [TRACE] connection state: state=TRANSIENT_
 │ FAILURE

Have I made any mistakes in the template or some other mistake somewhere else?
Thank you for the help in advance.

Please check out this example we have: https://github.com/hashicorp/waypoint-examples/tree/main/kubernetes/exec-kubectl-apply

Hi,
Thank you @mitchellh , this readme helped
so this template worked

version: '2'

services:
  example:
    container_name: example
    image: {{.Input.DockerImageFull}}
    environment:
        - WAYPOINT_CEB_INVITE_TOKEN={{index .Env "WAYPOINT_CEB_INVITE_TOKEN"}}
        - WAYPOINT_DEPLOYMENT_ID={{index .Env "WAYPOINT_DEPLOYMENT_ID"}}
        - WAYPOINT_SERVER_ADDR=localhost:9701
        - WAYPOINT_SERVER_TLS={{index .Env "WAYPOINT_SERVER_TLS"}}
        - WAYPOINT_SERVER_TLS_SKIP_VERIFY={{index .Env "WAYPOINT_SERVER_TLS_SKIP_VERIFY"}}
    network_mode: host

I’m assuming the cause of the error before was the templated value for WAYPOINT_SERVER_ADDR was waypoint-server and since I had not explicitly described a network it ran the container in a network that is different from the one in which the waypoint-server runs and hence could not resolve the DNS name and was failing to connect.

The old config

version: '2'

services:
  example:
    container_name: example
    image: {{.Input.DockerImageFull}}
    environment:
        - WAYPOINT_CEB_INVITE_TOKEN={{index .Env "WAYPOINT_CEB_INVITE_TOKEN"}}
        - WAYPOINT_DEPLOYMENT_ID={{index .Env "WAYPOINT_DEPLOYMENT_ID"}}
        - WAYPOINT_SERVER_ADDR={{index .Env "WAYPOINT_SERVER_ADDR"}}
        - WAYPOINT_SERVER_TLS={{index .Env "WAYPOINT_SERVER_TLS"}}
        - WAYPOINT_SERVER_TLS_SKIP_VERIFY={{index .Env "WAYPOINT_SERVER_TLS_SKIP_VERIFY"}}

The way point config

project = "example-nodejs"

app "example-nodejs" {
  labels = {
    "service" = "example-nodejs",
    "env" = "dev"
  }

  build {
    use "pack" {}
  }

  deploy { 
    use "exec" {
      command = ["docker-compose", "-f", "<TPL>", "up","-d"]
      template {
        path = "./docker-compose-template.yml"
      }
    }
  }
}
1 Like