-
Notifications
You must be signed in to change notification settings - Fork 3
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
0 parents
commit 92b40ef
Showing
179 changed files
with
4,536 additions
and
0 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,18 @@ | ||
# Rancher Custom Catalog | ||
|
||
This catalog provides templates created by Mateusz Trojak. | ||
|
||
# License | ||
Copyright (c) 2014-2016 [Rancher Labs, Inc.](http://rancher.com) | ||
|
||
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](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 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,119 @@ | ||
import pytest | ||
import cattle | ||
import subprocess | ||
import sys | ||
import os | ||
import re | ||
# import yaml | ||
|
||
|
||
def _base(): | ||
return os.path.dirname(__file__) | ||
|
||
|
||
def _file(f): | ||
return os.path.join(_base(), '../../{}'.format(f)) | ||
|
||
|
||
class CatalogService(object): | ||
def __init__(self, catalog_bin): | ||
self.catalog_bin = catalog_bin | ||
|
||
def assert_retcode(self, ret_code, *args): | ||
p = self.call(*args) | ||
r_code = p.wait() | ||
assert r_code == ret_code | ||
|
||
def call(self, *args, **kw): | ||
cmd = [self.catalog_bin] | ||
cmd.extend(args) | ||
|
||
kw_args = { | ||
'stdin': subprocess.PIPE, | ||
'stdout': sys.stdout, | ||
'stderr': sys.stderr, | ||
'cwd': _base(), | ||
} | ||
|
||
kw_args.update(kw) | ||
return subprocess.Popen(cmd, **kw_args) | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def catalog_bin(): | ||
c = '/usr/bin/rancher-catalog-service' | ||
assert os.path.exists(c) | ||
return c | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def catalog_service(catalog_bin): | ||
return CatalogService(catalog_bin) | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def client(): | ||
url = 'http://localhost:8088/v1-catalog/schemas' | ||
return cattle.from_env(url=url) | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def templates(client): | ||
templates = client.list_template() | ||
assert len(templates) > 0 | ||
return templates | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def requests(): | ||
return requests.Session() | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def template_details(client, templates): | ||
for template in templates: | ||
template.versionDetails = {} | ||
for version, link in template.versionLinks.iteritems(): | ||
template.versionDetails[version] = client._get(link) | ||
return templates | ||
|
||
|
||
def test_validate_exits_normal(catalog_service): | ||
catalog_service.assert_retcode( | ||
0, '-catalogUrl', | ||
_file('./'), | ||
'-validate', '-port', '18088') | ||
|
||
|
||
def test_stack_name(templates): | ||
hostname_label = re.compile(r'^[a-zA-Z0-9\-]{1,63}$') | ||
for template in templates: | ||
# stack_name must be a valid hostname label | ||
assert hostname_label.match(template.id.split(':')[-1].split('*')[-1]) | ||
|
||
|
||
def test_maintainers(templates): | ||
maintainer = re.compile(r'^([\S]+ ){2,5}<[^@]+@[^@]+\.[^@]+>$') | ||
for template in templates: | ||
# Maintainer will soon be a requirement | ||
# assert template.maintainer | ||
if template.maintainer: | ||
assert maintainer.match(template.maintainer) | ||
|
||
|
||
def test_versions(templates): | ||
for template in templates: | ||
# default version must be defined | ||
assert template.defaultVersion | ||
# template with default version must be defined | ||
assert template.versionLinks[template.defaultVersion] | ||
|
||
|
||
def test_template_questions(template_details): | ||
for template in template_details: | ||
for _, template in template.versionDetails.iteritems(): | ||
# there must exist a rancher-compose.yml file | ||
assert template.files['rancher-compose.yml'] | ||
# rancherConfig = yaml.load(template.files['rancher-compose.yml']) | ||
# there must exist at least one question | ||
# assert len(rancherConfig['.catalog']['questions']) > 0 |
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,5 @@ | ||
cattle==0.5.3 | ||
pyyaml==3.11 | ||
|
||
flake8 | ||
pytest==2.8.7 |
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,10 @@ | ||
from distutils.core import setup | ||
|
||
setup( | ||
name='Rancher Catalog YAML Integration Tests', | ||
version='0.1', | ||
packages=[ | ||
'core', | ||
], | ||
license='ASL 2.0', | ||
) |
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,12 @@ | ||
[tox] | ||
envlist=flake8, py27 | ||
|
||
[testenv] | ||
deps=-rrequirements.txt | ||
changedir=core | ||
commands=py.test --duration=20 {posargs} | ||
|
||
[testenv:flake8] | ||
deps=-rrequirements.txt | ||
changedir={toxinidir} | ||
commands=flake8 core |
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,5 @@ | ||
# MongoDB | ||
|
||
MongoDB is an open-source, document database designed for ease of development and scaling. | ||
|
||
This is a MongoDB replica set deployment on Kubernetes environment, it will create MongoDB replica set with the ability to scale it in the future. |
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,32 @@ | ||
kind: ReplicationController | ||
apiVersion: v1 | ||
metadata: | ||
name: mongo-rc | ||
spec: | ||
replicas: ${sec_no} | ||
selector: | ||
name: mongo-sec | ||
template: | ||
spec: | ||
containers: | ||
- name: mongo-sec | ||
image: husseingalal/mongo-k8s | ||
ports: | ||
- containerPort: 27017 | ||
volumeMounts: | ||
- name: mongo-ephermal-storage | ||
mountPath: /data/db | ||
command: | ||
- /run.sh | ||
- mongod | ||
- "--replSet" | ||
- rs0 | ||
- "--smallfiles" | ||
- "--noprealloc" | ||
volumes: | ||
- name: mongo-ephermal-storage | ||
emptyDir: {} | ||
metadata: | ||
labels: | ||
secondary: "true" | ||
name: mongo-sec |
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,41 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
name: mongo-primary | ||
name: mongo-primary | ||
spec: | ||
ports: | ||
- port: 27017 | ||
targetPort: 27017 | ||
selector: | ||
name: mongo-master | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
name: mongo-master | ||
name: mongo-master | ||
spec: | ||
containers: | ||
- name: mongo-master | ||
image: "husseingalal/mongo-k8s" | ||
env: | ||
- name: PRIMARY | ||
value: "true" | ||
ports: | ||
- containerPort: 27017 | ||
command: | ||
- /run.sh | ||
- mongod | ||
- "--replSet" | ||
- rs0 | ||
- "--smallfiles" | ||
- "--noprealloc" | ||
volumeMounts: | ||
- mountPath: /data/db | ||
name: mongo-primary-ephermal-storage | ||
volumes: | ||
- name: mongo-primary-ephermal-storage | ||
emptyDir: {} |
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,11 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
name: mongo-sec | ||
name: mongo-sec | ||
spec: | ||
ports: | ||
- port: 27017 | ||
selector: | ||
secondary: "true" |
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,11 @@ | ||
.catalog: | ||
name: MongoDB | ||
version: 3.2-rancher1 | ||
description: MongoDB Replica Set | ||
questions: | ||
- variable: "sec_no" | ||
label: "Number of Secondary nodes" | ||
required: true | ||
type: int | ||
default: 2 | ||
description: "should be even number" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
name: MongoDB | ||
description: | | ||
MongoDB Replica Set. | ||
version: 3.2-rancher1 | ||
category: Databases |
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,25 @@ | ||
# Prometheus | ||
|
||
### Info: | ||
|
||
This template deploys a collection of containers based upon the technologies below, once deployed you should have a monitoring platform capable of querying all aspects of your environment with some nice pre-built dashboards. | ||
In this deployment the following technologies are utilised to make this as useful as possible. | ||
* **Prometheus** - Used to scrape and store metrics from our data sources. (https://github.com/prometheus/prometheus) | ||
* **Prometheus Node Exporter** - Gets host level metrics and exposes them to Prometheus. (https://github.com/prometheus/node_exporter) | ||
* **Ranch-Eye** - Pre-configured lightwieght haproxy to expose the cadvsior stats used by Rancher's agent container, to Prometheus. (https://github.com/Rucknar/ranch-eye) | ||
* **Grafana** - Used to visualise the data from Prometheus and InfluxDB. (https://github.com/grafana/grafana/) | ||
* **InfluxDB** - Used as database for storing rancher server metrics that rancher exports via the graphite connector. (https://github.com/influxdata/influxdb) | ||
* **rancher-api-integration** - Allows Prometheus to access the Rancher API and return the status of any stack or service in the rancher environment associated with the API key used.(https://github.com/Limilo/prometheus-rancher-exporter/) | ||
|
||
To get the full compliment of metrics available,you need to configure the Rancher `graphite.host` address. This can be done automatically when you deploy the template by choosing the option below, for more information or how to do this change manually,see the following [guide](https://github.com/Rucknar/Guide_Rancher_Monitoring) | ||
|
||
All components in this stack are open source tools available in the community. All this template does is to bound them together in an easy to use package. | ||
I expect most people who find this useful will make use of this as a starting point and develop it further around their own needs. | ||
|
||
## Deployment: | ||
* Select Prometheus from the community catalog. | ||
* Click deploy. | ||
|
||
## Usage | ||
* Grafana will now be available on, running on port 3000. I've added a number of dashboards to help get you started. Authentication is with the default `admin/admin`. | ||
* Prometheus will now be available, running on port 9090. Have a play around with some of the data. For more information on Prometheus - https://prometheus.io/docs/introduction/overview/ |
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,18 @@ | ||
apiVersion: v1 | ||
kind: ReplicationController | ||
metadata: | ||
name: grafana-rc | ||
namespace: default | ||
spec: | ||
replicas: 1 | ||
selector: | ||
template: | ||
metadata: | ||
labels: | ||
name: grafana | ||
spec: | ||
restartPolicy: Always | ||
containers: | ||
- image: infracloud/grafana | ||
imagePullPolicy: Always | ||
name: grafana |
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,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: grafana | ||
namespace: "default" | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: "grafana" | ||
port: 3000 | ||
protocol: TCP | ||
selector: | ||
name: grafana |
Oops, something went wrong.