rancher/rancher-metadata

Name: rancher-metadata

Owner: Rancher

Description: A simple HTTP server that returns EC2-style metadata information that varies depending on the source IP address making the request.

Created: 2015-07-18 07:50:20.0

Updated: 2018-05-15 04:55:06.0

Pushed: 2018-05-11 16:23:22.0

Homepage:

Size: 1236

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

rancher-metadata

Build Status

A simple HTTP server that returns EC2-style metadata information that varies depending on the source IP address making the request. This package contains no Rancher-specific code, but is used in Rancher with an answer file that provide the requesting container information about itself, the service and stack it is a member of, the host it is running on, etc.

Usage

ncher-metadata --answers /path/to/answers.{yaml|json} [--debug] [--listen [host]:port] [--log path] [--pid-file path] [--xff]

Compile

dep go build
CLI Options

Option | Default | Description ————|—————-|———— --answers | ./answers.yaml | Path to a JSON or YAML file with client-specific answers --debug | off | Log more debugging info --listen | 0.0.0.0:80 | IP address and port to listen on --log | none | Output log info to a file path instead of stdout --pid-file| none | Write the server PID to a file path on startup --xff | off | Enable using the X-Forwarded-For header to determine source IP

Answers File

The answers file provides all the structure that the metadata server responds with.

YAML
5-12-19': &latest
0.1.2.2':
key1: value1
arbitrarily:
  nested:
    - YAML
    - of
    - any
    - type
    - 42
    - null
    - false
92.168.0.2':
key1: value2

"default" is a special key that will be checked if no answer is found in a client IP-specific entry
fault:
key1: value3

5-07-25':
Data for older revision

st: *latest
JSON

015-12-19": {
"10.1.2.2": {
  "key1": "value1",
  "arbitrarily": {
    "nested": [
      "JSON", "of", "any", "type", 42, null, false
    ]
  }
},

"192.168.0.2": {
  "key1": "value2"
},

# "default" is a special key that will be checked if no answer is found in a client IP-specific entry
"default": {
  "key1": "value3"
}


015-07-25": {
# Data for older revision


Answering queries

A query is answered by following the pieces of the path to walk the answers for the requested IP one step at a time. If the key in the first section of the path is not found or there is no answers entry for the request IP, the "default" section is checked. Defaults are not checked if there are client-specific answers they match one (or more) levels of the path.

If the request contains an Accept header requesting application/json, the response will be the matching subtree as a JSON document.

If the request contains an Accept header requesting {application|text}/{yaml|x-yaml}, the response will be the matching subtree as a YAML document.

Contact

For bugs, questions, comments, corrections, suggestions, etc., open an issue in rancher/rancher with a title starting with [rancher-metadata].

Or just click here to create a new issue.

License

Copyright (c) 2015-2016 Rancher Labs, Inc.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.