hashicorp / faas-nomad

OpenFaaS plugin for Nomad
https://www.openfaas.com
MIT License
254 stars 46 forks source link

Local install doesn't start #75

Closed ghost closed 5 years ago

ghost commented 5 years ago

(Thanks for reporting an issue! Please make sure you click the link above to view the issue guidelines, then fill out the blanks below.)

What are the steps to reproduce this issue?

  1. git clone https://github.com/hashicorp/faas-nomad.git
  2. cd faas-nomad
  3. ./startNomad.sh (after adding a further grep to the script to ensure my RFC1918 interface is chosen) (OK)
  4. vagrant up

What happens?

$ consul version Consul v1.4.4 Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)

$ nomad version Nomad v0.9.0 (18dd59056ee1d7b2df51256fe900a98460d3d6b9)

$ vagrant version Installed Version: 2.2.4 Latest Version: 2.2.4

$ VBoxManage --version 5.2.26r128414

$ uname -a Darwin myMac.my.net 17.7.0 Darwin Kernel Version 17.7.0: Wed Feb 27 00:43:23 PST 2019; root:xnu-4570.71.35~1/RELEASE_X86_64 x86_64

$ vagrant up <errors - see below>

What were you expecting to happen?

Vagrant to deliver 1+ docker hosts with the stack running

Any logs, error output, etc?

All went OK until:

# Enabling the service here to ensure each state is independent.
nomad-service:
  service.running:
    - name: nomad
    # Restart service if config changes
    - restart: True
    - enable: True
[DEBUG   ] Results of YAML rendering:
OrderedDict([(u'nomad-config', OrderedDict([(u'file.serialize', [OrderedDict([(u'name', u'/etc/nomad/nomad.hcl')]), OrderedDict([(u'formatter', u'json')]), OrderedDict([(u'dataset_pillar', u'nomad:config')]), OrderedDict([(u'mode', 640)]), OrderedDict([(u'user', u'root')]), OrderedDict([(u'group', u'root')]), OrderedDict([(u'watch_in', [OrderedDict([(u'service', u'nomad-service')])])])])])), (u'nomad-service', OrderedDict([(u'service.running', [OrderedDict([(u'name', u'nomad')]), OrderedDict([(u'restart', True)]), OrderedDict([(u'enable', True)])])]))])
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/dev/nomad/config.sls' using 'yaml' renderer: 0.00392889976501
[DEBUG   ] LazyLoaded highstate.output
local:
    Data failed to compile:
----------
    Rendering SLS 'dev:nomad.install' failed: Jinja variable 'salt.utils.odict.OrderedDict object' has no attribute 'data_dir'
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Any other comments?

What versions of software are you using?

Operating System: macOS 10.13.6 (17G6030)

OpenFaaS Version: 0.8.4 cli

Nomad Version: 0.9.0

nwong4932 commented 5 years ago

I have same issue on windows 10

alexellis commented 5 years ago

I'll ping the maintainer.

@acornies

Alex

acornies commented 5 years ago

Thanks for the report. Unfortunately Nomad 0.9 isn't officially supported yet, although it's definitely on my priority list.

The defined vagrant up flow in this repo technically doesn't use the startNomad.sh script, but the salt directory in provisioning/saltstack/... which provisions Nomad 0.8.6, Consul and Vault w/ Docker.

acornies commented 5 years ago

I should also mention that vagrant flow is designed to locally develop/debug faas-nomad itself, so it assumes you're running vagrant but also running faas-nomad on your local system. I use these settings in vscode + installed Go in conjunction with the vagrant setup:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "faas-nomad",
      "type": "go",
      "request": "launch",
      "mode": "auto",
      "remotePath": "",
      "host": "0.0.0.0",
      "port": 8081,
      "program": "${workspaceFolder}",
      "env": {},
      "args": [
        "-nomad_region", "global",
        "-nomad_addr", "192.168.50.2:4646",
        "-enable_consul_dns=true",
        "-consul_addr", "http://192.168.50.2:8500",
        "-statsd_addr", "192.168.50.2:9125",
        "-basic_auth_secret_path", "provisioning/secrets",
        "-enable_basic_auth=false",
        "-vault_default_policy", "openfaas",
        "-vault_addr", "http://192.168.50.2:8200",
        "-vault_app_role_id", "...",
        "-vault_app_secret_id", "...",
        "-port=8081"
      ],
      "showLog": true
    }
  ]
}

If you're just interested in running not developing, using the docker image from quay.io/nicholasjackson/faas-nomad:v0.4.1 along with he files in nomad_job_files should be sufficient.

nwong4932 commented 5 years ago

@acornies I run vagrant up on Windows 10 without local Nomad, have same problem, how can I fix the problem? Thanks!

acornies commented 5 years ago

@nwong4932 can you try pulling latest master? I believe the config data needed to be updated for local vagrant flow to work.

ghost commented 5 years ago

@acornies, I read the README, but figured it would install openfaas as well as the local hashicorp stack in VMs which was a mistake. Trouble is, faas docs expect docker to be already installed the system, and cover swarm and k8s as orchestrators - which is exactly what I'm trying to use nomad for in order to avoid, i.e. I don't want to install docker for mac but never used faas so I was relying on the guides over there to get faas working first. How is your setup setup? Do I need to get a man-made docker VM running first (i.e. also using Vagrant as I don't do docker desktop)?

ghost commented 5 years ago

BTW, the link on the README to the aws setup is a 404.

acornies commented 5 years ago

@phosphre Let me know how it goes. This repo is a bit of a mess right now and my full-time work is consuming all my energy atm. The plan is to revamp this provider using Nomad 0.9 deps, increase test coverage and make provider configuration simpler.

acornies commented 5 years ago

I don't want to install docker for mac but never used faas so I was relying on the guides over there to get faas working first. How is your setup setup?

I use the Vagrantfile + supporting files in provisioning/... and simply run vagrant up (both virtualbox and vmware fusion supported) which installs Nomad, Consul and Vault and deploys the OpenFaaS components on Nomad. However, if you want to run this provider in the VM as well, just add this example block to this file: provisioning/saltstack/salt/nomad/files/faas.hcl

task "nomadd" {
      driver = "docker"
      config {
        image = "quay.io/nicholasjackson/faas-nomad:v0.4.1"
        args = [
          "-nomad_region", "${NOMAD_REGION}",
          "-nomad_addr", "${NOMAD_IP_http}:4646",
          "-consul_addr", "http://${NOMAD_IP_http}:8500",
          "-statsd_addr", "${NOMAD_ADDR_statsd_statsd}",
          "-node_addr", "${NOMAD_IP_http}",
          "-basic_auth_secret_path", "/secrets",
          "-enable_basic_auth=false",
          "more..."
        ]
        port_map {
          http = 8080
        }
      }
      resources {
        cpu    = 500 # 500 MHz
        memory = 128 # 128MB
        network {
          port "http" {
            static = 8081
          }
        }
      }
      service {
        port = "http"
        name = "faasd-nomad"
        tags = ["faas"]
      }
    }
}

You can use the same runtime args I posted higher up in this issue. You can use vagrant provision to rerun/provision the VM again.