forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f726af9
commit 77fce96
Showing
7 changed files
with
341 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
**Rancher versions:** | ||
rancher/server: | ||
rancher/agent: | ||
|
||
**Infrastructure Stack versions:** | ||
healthcheck: | ||
ipsec: | ||
network-services: | ||
scheduler: | ||
kubernetes (if applicable): | ||
|
||
**Docker version: (`docker version`,`docker info` preferred)** | ||
|
||
**Operating system and kernel: (`cat /etc/os-release`, `uname -r` preferred)** | ||
|
||
**Type/provider of hosts: (VirtualBox/Bare-metal/AWS/GCE/DO)** | ||
|
||
**Setup details: (single node rancher vs. HA rancher, internal DB vs. external DB)** | ||
|
||
**Environment Template: (Cattle/Kubernetes/Swarm/Mesos)** | ||
|
||
**Steps to Reproduce:** | ||
|
||
**Results:** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,3 +175,4 @@ | |
of your accepting any such warranty or additional liability. | ||
|
||
END OF TERMS AND CONDITIONS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
### Keybase proof | ||
|
||
I hereby claim: | ||
|
||
* I am rancher on github. | ||
* I am rancher (https://keybase.io/rancher) on keybase. | ||
* I have a public key whose fingerprint is 6ECB 4922 01B6 267E 769E 00B3 1375 50C2 2320 5F53 | ||
|
||
To claim this, I am signing this object: | ||
|
||
```json | ||
{ | ||
"body": { | ||
"key": { | ||
"eldest_kid": "01207d08625ab62748f2699d506da5e32ff4e2147334ff3eaed647c80f4b2840277e0a", | ||
"fingerprint": "6ecb492201b6267e769e00b3137550c223205f53", | ||
"host": "keybase.io", | ||
"key_id": "137550c223205f53", | ||
"kid": "0101780bb862682086970b5944deee85c9a44da737120979bfdf8e4f62352c9baa550a", | ||
"uid": "01b937b34ac988003e7eccf9d986f719", | ||
"username": "rancher" | ||
}, | ||
"service": { | ||
"name": "github", | ||
"username": "rancher" | ||
}, | ||
"type": "web_service_binding", | ||
"version": 1 | ||
}, | ||
"ctime": 1483751337, | ||
"expire_in": 157680000, | ||
"prev": "49a429873da4ae85d3a5ed8da2bc1b877ec660cb23fe07c80f77a5187bfa7672", | ||
"seqno": 8, | ||
"tag": "signature" | ||
} | ||
``` | ||
|
||
with the key [6ECB 4922 01B6 267E 769E 00B3 1375 50C2 2320 5F53](https://keybase.io/rancher), yielding the signature: | ||
|
||
``` | ||
-----BEGIN PGP MESSAGE----- | ||
Version: Keybase OpenPGP v2.0.61 | ||
Comment: https://keybase.io/crypto | ||
yMNaAnicdVJrTBRXGN1FJBFEsFhSCxEYiwWyhTt3ZufObAQsaGyM6YtSISCbedxZ | ||
xsey7ovySolb0hpLGzUUsQKlKo9aSzGxEaoGF2wp2oBKsWKlkIIEY2khFa0V7F2C | ||
/9pf997vnnNyvvN93cFLdIH6MNfr3rXR5gz95YuVLl2WLbWlhJIKlCLKVELtxAsH | ||
3qVgh9O8U1MoEwVoCJACeA4aRYmDiOVVyAmCYgScIhoxA1WVxZBmEcOwqspgESsc | ||
i2QeqKwEeRZAhDAQKQOlalYLttvsmtVJZDksS6wAIaCJKIcw4gQMgMTQDDIagQwh | ||
A4FRNTKEmF/g8DGIOUl04EStgNTIw7xg7z/wT30DGvFAkohz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P18cXuUIey+3+oHxxIGkmcq+yZ6e44l/QtAs7lS | ||
=rBA0 | ||
-----END PGP MESSAGE----- | ||
``` | ||
|
||
And finally, I am proving ownership of the github account by posting this as a gist. | ||
|
||
### My publicly-auditable identity: | ||
|
||
https://keybase.io/rancher | ||
|
||
### From the command line: | ||
|
||
Consider the [keybase command line program](https://keybase.io/download). | ||
|
||
```bash | ||
# look me up | ||
keybase id rancher | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
#!/usr/bin/env python2.7 | ||
|
||
# Requires git, python 2.7 and python modules 'PyYAML' and 'semver' | ||
# | ||
# apt-get install git python-pip | ||
# pip install -r requirements.txt | ||
|
||
import argparse | ||
import os | ||
import re | ||
import semver | ||
import sets | ||
import subprocess | ||
import sys | ||
import uuid | ||
import yaml | ||
|
||
description = """Computes Docker images required to run each infrastructure service for a | ||
specific Rancher version. This is valuable when preparing an air-gapped Rancher | ||
installation for the latest infrastructure services without legacy image bloat. | ||
""" | ||
|
||
parser = argparse.ArgumentParser(description=description) | ||
|
||
parser.add_argument('-u', '--url', | ||
default='https://git.rancher.io/rancher-catalog', | ||
help='Rancher catalog URL accessible in airgap environment') | ||
parser.add_argument('-b', '--branch', | ||
help='Rancher catalog branch accessible in airgap environment') | ||
parser.add_argument('-v', '--version', | ||
required=True, | ||
help='Rancher Server version') | ||
args = parser.parse_args() | ||
|
||
|
||
def get_catalog_branch(version): | ||
if semver.match(version, "<=1.6.0"): | ||
return "master" | ||
elif semver.match(version, ">1.6.0") and semver.match(version, "<2.0.0"): | ||
return "v1.6-release" | ||
elif semver.match(version, ">=2.0.0"): | ||
return "v2.0-release" | ||
else: | ||
print "Unknown version" | ||
sys.exit(1) | ||
|
||
|
||
def print_keys(header, iter): | ||
temp = header | ||
for key in iter.iterkeys(): | ||
temp += " " + key | ||
print temp | ||
|
||
|
||
def optimal_version_dir(rancher_version, service_dir): | ||
# Parse each version dir's rancher-compose.yml | ||
version_dirs = {} | ||
for service_version_dir in os.listdir(service_dir): | ||
version_dir = service_dir + "/" + service_version_dir | ||
if os.path.isdir(version_dir): | ||
rancher_compose_filepath = version_dir + "/rancher-compose.yml" | ||
if os.path.isfile(rancher_compose_filepath): | ||
try: | ||
with file(rancher_compose_filepath, 'r') as f: | ||
rancher_compose = yaml.load(f) | ||
version_dirs[service_version_dir] = rancher_compose | ||
except yaml.YAMLError, exc: | ||
print "Error in rancher-compose.yml file: ", exc | ||
else: | ||
print version_dir + ": missing rancher-compose.yml" | ||
# print_keys("Unfiltered:", version_dirs) | ||
|
||
# Filter version dirs by min/max rancher version | ||
filtered = {} | ||
for key, value in version_dirs.iteritems(): | ||
if '.catalog' in value: | ||
catalog = value['.catalog'] | ||
if 'minimum_rancher_version' in catalog: | ||
min_version = catalog['minimum_rancher_version'].lstrip('v') | ||
if semver.compare(rancher_version, min_version) < 0: | ||
continue | ||
if 'maximum_rancher_version' in catalog: | ||
max_version = catalog['maximum_rancher_version'].lstrip('v') | ||
if semver.compare(rancher_version, max_version) > 0: | ||
continue | ||
filtered[key] = value | ||
# print_keys("Server Version:", filtered) | ||
|
||
# Bail out if only one remains | ||
if len(filtered) == 1: | ||
for key, value in filtered.iteritems(): | ||
return key, value['.catalog']['version'] | ||
return list(filtered)[0] | ||
|
||
# Try to return the template version in config.yml | ||
try: | ||
template_config = yaml.load(file(service_dir + "/config.yml", 'r')) | ||
if 'version' in template_config: | ||
version = template_config['version'] | ||
for key, value in filtered.iteritems(): | ||
if '.catalog' in value: | ||
catalog = value['.catalog'] | ||
if 'version' in catalog and catalog['version'] == version: | ||
return key, value['.catalog']['version'] | ||
except yaml.YAMLError, exc: | ||
print "Error in config.yml file: ", exc | ||
|
||
# Choose the highest ordinal value | ||
maxkey = -1 | ||
for key in filtered.iterkeys(): | ||
try: | ||
keyint = int(key) | ||
if keyint > maxkey: | ||
maxkey = keyint | ||
except: | ||
pass | ||
if maxkey > -1: | ||
return str(maxkey), filtered[str(maxkey)]['.catalog']['version'] | ||
else: | ||
return "", "" | ||
|
||
|
||
def version_images(service_version_dir): | ||
images = sets.Set() | ||
compose_filepath = service_version_dir + "/docker-compose.yml" | ||
compose_tpl_filepath = service_version_dir + "/docker-compose.yml.tpl" | ||
|
||
filedata = '' | ||
if os.path.isfile(compose_tpl_filepath): | ||
with open(compose_tpl_filepath, 'r') as f: | ||
filedata = f.read() | ||
filedata, subs = re.subn('{{[^}]*}}', '', filedata) | ||
elif os.path.isfile(compose_filepath): | ||
with open(compose_filepath, 'r') as f: | ||
filedata = f.read() | ||
else: | ||
print "missing docker-compose.yml[.tpl]" | ||
return images | ||
|
||
try: | ||
docker_compose = yaml.load(filedata) | ||
# handle v1/v2 docker-compose | ||
services = docker_compose | ||
if 'services' in services: | ||
services = docker_compose['services'] | ||
|
||
for serviceName in services: | ||
service = services[serviceName] | ||
if 'image' in service: | ||
images.add(service['image']) | ||
|
||
except yaml.YAMLError, exc: | ||
print "Error in docker-compose.yml file: ", exc | ||
|
||
return images | ||
|
||
|
||
version = args.version.lstrip('v') | ||
if args.branch is None: | ||
args.branch = get_catalog_branch(version) | ||
|
||
print 'Rancher Version: ' + version | ||
print 'Catalog URL: ' + args.url | ||
print 'Catalog Branch: ' + args.branch | ||
|
||
catalog_dir = str(uuid.uuid4()) | ||
try: | ||
subprocess.check_call(["git", "clone", args.url, | ||
"--quiet", "--single-branch", "--branch", args.branch, | ||
catalog_dir]) | ||
except subprocess.CalledProcessError: | ||
sys.exit(1) | ||
|
||
|
||
infra_dir = catalog_dir + "/infra-templates" | ||
for infra_service in os.listdir(infra_dir): | ||
service_dir = infra_dir + "/" + infra_service | ||
if os.path.isdir(service_dir): | ||
version_dir, template_ver = optimal_version_dir(version, service_dir) | ||
if version_dir != "": | ||
print infra_service + ": " + template_ver | ||
for image in version_images(service_dir + "/" + version_dir): | ||
print " - " + image | ||
|
||
subprocess.call(["rm", "-rf", catalog_dir]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
PyYAML==3.11 | ||
semver==2.7.7 | ||
flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$1" ]; then | ||
master="(Rancher tag not specified)" | ||
tag='master' | ||
else | ||
tag=$1 | ||
fi | ||
|
||
CATTLE_VER=$(curl https://raw.githubusercontent.com/rancher/rancher/$tag/server/Dockerfile 2>/dev/null | grep 'ENV CATTLE_CATTLE_VERSION' | awk '{print $3}') | ||
|
||
echo -e "\nPrinting project/service tag information for Rancher tag $tag. $master" | ||
|
||
echo -e "\nCattle Tag: $CATTLE_VER\n" | ||
|
||
echo "Other project tags:" | ||
while read -r l; do | ||
PROP=$(echo "$l" | awk -F= '{print $1}') | ||
URL=$(echo "$l" | awk -F= '{print $2}') | ||
IFS=', ' read -r -a array <<< "$(echo $l | awk -F= '{print $2}')" | ||
for element in "${array[@]}" | ||
do | ||
if [[ $element == http* ]]; then | ||
URL=$element | ||
fi | ||
done | ||
|
||
VER_AND_FILE=$(echo "$l" | grep "releases/download" | sed "s/^.*download\///g") | ||
#echo $VER_AND_FILE | ||
VER=$(echo "$VER_AND_FILE" | awk -F/ '{print $1}') | ||
FILE=$(echo "$VER_AND_FILE" | awk -F/ '{print $2}') | ||
if [[ -n "$VER" ]]; then | ||
printf "%40s %15s %s\n" "$PROP" "$VER" "$URL" | ||
fi | ||
|
||
done < <(curl -s https://raw.githubusercontent.com/rancher/cattle/$CATTLE_VER/resources/content/cattle-global.properties) | ||
|
||
echo -e "\n\nCatalog item versions: (Pulling image may take several minutes)" | ||
docker run --rm -it rancher/server:$tag bash -c 'for i in /var/lib/cattle/cache/global/*; do git -C $i remote -vv; git -C $i rev-parse HEAD; for j in $i/infra-templates/*; do A=$(grep version $j/config.yml 2>/dev/null | cut -d" " -f2); echo $(basename $j): $A; for x in $(grep -Irl --exclude=config.yml $A $j 2>/dev/null); do grep -rh --include="docker-compose.*" -e "^[ \t]*image: " $(dirname $x) 2>/dev/null; done; done; echo -e "\n"; done' 2>/dev/null |