项目作者: franckverrot

项目描述 :
Trek is a CLI/ncurses explorer for HashiCorp Nomad clusters.
高级语言: Go
项目地址: git://github.com/franckverrot/trek.git
创建时间: 2019-01-07T05:24:38Z
项目社区:https://github.com/franckverrot/trek

开源协议:MIT License

下载


Trek

Trek is a CLI/ncurses explorer for HashiCorp Nomad clusters.

In Action

SETUP

Binary Release

Get to revisions, and download a binary.

From Source

  1. git clone https://github.com/franckverrot/trek.git
  2. cd trek
  3. make trek

USAGE

TL;DR Start ./trek -help to get the usage prompt.

CLI

The CLI can be used without a UI. This allows scripting to access IP, ports,
and other info exposed by Nomad.

Options

Here’s a list of options available:

  • nomad-address: address of the nomad cluster

  • list-jobs: list jobs running on the cluster
  1. λ ./trek -list-jobs
  2. * example
  3. * example34

NOTE : this option also works in conjunction with display-format

  • job: select a specific job
  1. λ trek -job example34
  2. * cache34
  3. * cache56

  • task-group: select a specific task group
  1. λ trek -job example34 -task-group cache56
  2. * example34.cache56[0]

  • allocation: select a specific allocation number
  1. λ trek -job example34 -task-group cache56 -allocation 0
  2. (0) redis5
  3. (1) redis6

  • task-name: select a specific task name
  1. λ trek -job example34 -task-group cache56 -allocation 0 -task-name redis6
  2. * Name: redis6
  3. * Node Name: feynman.local
  4. * Node IP: 127.0.0.1
  5. * Driver: docker
  6. * image: redis:3.2
  7. * port_map: [map[db:6379]]
  8. * Dynamic Ports: 24832 (db)

  • display-format: Use the Go templating language to format output when describing a specific job, task group, allocation or task
    • Context-specific data made available:
      • Job
        • TaskGroups (array of task groups): task groups part of the job definition
      • Task Group
        • Allocations (array of allocations): allocations run by that task group
      • Allocation
        • IP (string): node onto which we’re running the selected allocation
        • Tasks (array of tasks): tasks being run by that allocation
      • Task
        • IP (string): node onto which we’re running the selected task
        • Network: network information (like ports)
        • Environment: environment variables provided to the task
    • Available functions:
      • {{Debug <x>}} : show raw representation of the data <x>
      • {{DebugAll}} : show raw representation of everything provided to the template
    • Examples:
  1. λ trek -job example34 -task-group cache56 -allocation 0 -task-name redis6 -display-format "{{DebugAll}}"
  2. DEBUG ALL: {IP:127.0.0.1 Network:{Ports:map[db:{Value:23109 Reserved:false}]} Environment:map[FOO_BAR:{Value:baz_bat}]}
  3. λ trek -job example34 -task-group cache56 -allocation 0 -task-name redis6 -display-format "{{Debug .Environment}}"
  4. DEBUG: map[FOO_BAR:{Value:baz_bat}]
  5. λ trek -job example34 -task-group cache56 -allocation 0 -task redis6 -display-format "{{range .Network.Ports}}{{$.IP}}:{{.Value}}{{println}}{{end}}"
  6. 127.0.0.1:31478
  7. 127.0.0.1:25142

ncurses UI

  1. ./trek -ui=true

Trek Configuration File

Example

  1. { "Environments" : [ { "Name" : "development" , "Address" : "http://127.0.0.1:4646" }
  2. ]
  3. }

Options

  • Environments: List of environments (given a name and address) Trek can connect to

FAQ

  • How do I ssh into an allocation’s node?

    λ ssh $(trek -job … -task-group … -allocation 0 -display-format “{{.IP}}”)

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don’t break it in a
    future version unintentionally.
  • Commit.
  • Send me a pull request. Bonus points for topic branches.

Copyright (c) 2019 Franck Verrot. MIT LICENSE. See LICENSE for details.