Browse Source

[feature] restructure-clean-up-project

* updating file-structure
* update docker file
* update develop docs
* update api and cmd
changes/20/570020/1
gardlt 2 years ago
parent
commit
68d95bdcc5

+ 18
- 0
.editorconfig View File

@@ -0,0 +1,18 @@
1
+# EditorConfig http://editorconfig.org
2
+
3
+root = true
4
+
5
+[*]
6
+indent_style = space
7
+indent_size = 4
8
+tab_width = 4
9
+end_of_line = lf
10
+charset = utf-8
11
+trim_trailing_whitespace = false
12
+insert_final_newline = true
13
+max_line_length = 80
14
+curly_bracket_next_line = false
15
+spaces_around_operators = true
16
+spaces_around_brackets = true
17
+indent_brace_style = K&R
18
+

+ 22
- 16
.travis.yml View File

@@ -6,24 +6,30 @@ python:
6 6
   - "2.7"
7 7
 
8 8
 before_install:
9
-  - export LIGGIT2_VERSION=0.24.0
10
-  - export LIBGIT2=$VIRTUAL_ENV
11
-  - wget https://github.com/libgit2/libgit2/archive/v${LIGGIT2_VERSION}.tar.gz
12
-  - tar xzf v${LIGGIT2_VERSION}.tar.gz
13
-  - cd libgit2-${LIGGIT2_VERSION}/
14
-  - cmake . -DCMAKE_INSTALL_PREFIX=$LIBGIT2
15
-  - make
16
-  - make install
17
-  - export LDFLAGS="-Wl,-rpath='$LIBGIT2/lib',--enable-new-dtags $LDFLAGS"
18
-  - cd ..
19
-  - pip install -r test-requirements.txt
20
-  - pip install -r requirements.txt
21
-  - pip install pygit2==0.24.0
9
+    - export LIGGIT2_VERSION=0.24.0
10
+    - export LIBGIT2=$VIRTUAL_ENV
11
+    - wget https://github.com/libgit2/libgit2/archive/v${LIGGIT2_VERSION}.tar.gz
12
+    - tar xzf v${LIGGIT2_VERSION}.tar.gz
13
+    - cd libgit2-${LIGGIT2_VERSION}/
14
+    - cmake . -DCMAKE_INSTALL_PREFIX=$LIBGIT2
15
+    - make
16
+    - make install
17
+    - export LDFLAGS="-Wl,-rpath='$LIBGIT2/lib',--enable-new-dtags $LDFLAGS"
18
+    - cd ..
19
+    - pip install -r test-requirements.txt
20
+    - pip install -r requirements.txt
21
+    - pip install tox
22
+    - pip install pygit2==0.24.0
22 23
 
23 24
 install:
24
-  - pip install .
25
+    - pip install .
25 26
 
26 27
 script:
27
-  - flake8
28
-  - armada -h
28
+    - flake8
29
+    - armada -h
29 30
 #  - armada -c examples/armada.yaml -d
31
+
32
+after_success:
33
+    - cd docs && make html
34
+    - touch .nojekyll
35
+    - git clean -fdx

+ 17
- 12
Dockerfile View File

@@ -1,12 +1,16 @@
1 1
 FROM ubuntu:16.04
2 2
 MAINTAINER Armada Team
3 3
 
4
+ARG VERSION
5
+ARG REPO
6
+
4 7
 ENV USER=armada \
5
-    VERSION=master \
6
-    REPO=https://github.com/att-comdev/armada.git
8
+    VERSION=${VERSION:-master} \
9
+    REPO=${REPO:-https://github.com/att-comdev/armada.git}
10
+
7 11
 
8
-RUN apt-get update && \
9
-    apt-get install -y \
12
+RUN apt-get update -yqq && \
13
+    apt-get install -yqq \
10 14
         build-essential \
11 15
         git \
12 16
         git-review \
@@ -16,18 +20,19 @@ RUN apt-get update && \
16 20
         gcc \
17 21
         libssl-dev \
18 22
         libffi-dev \
19
-        libgit2-dev \
20
-    && git clone -b $VERSION $REPO ${HOME}/armada
23
+        libgit2-dev
24
+
25
+RUN git clone -b $VERSION $REPO ${HOME}/armada
21 26
 
22 27
 WORKDIR /root/armada
23 28
 RUN pip install -r requirements.txt \
24
-    && sh scripts/libgit2.sh \
29
+    && sh tools/libgit2.sh \
25 30
     && pip install --upgrade urllib3 \
26
-    && pip install pygit2 \
27
-    && python setup.py install
28
-
29
-ENTRYPOINT ["armada"]
31
+    && pip install pygit2==0.25.0 \
32
+    && pip install -e .
30 33
 
31 34
 EXPOSE 8000
32 35
 
33
-CMD gunicorn server:api -b :8000
36
+ENTRYPOINT ["./entrypoint.sh"]
37
+
38
+CMD ["server"]

+ 0
- 135
README.md View File

@@ -1,135 +0,0 @@
1
-# Armada
2
-
3
-[![Docker Repository on Quay](https://quay.io/repository/attcomdev/armada/status "Docker Repository on Quay")](https://quay.io/repository/attcomdev/armada)
4
-[![Build Status](https://travis-ci.org/att-comdev/armada.svg?branch=master)](https://travis-ci.org/att-comdev/armada)
5
-
6
-A python orchestrator for a installing, upgrading, and managing a collection of helm charts, dependencies, and values overrides.
7
-
8
-Note that this project is pre-alpha and under active development. It may undergo drastic changes to support the long-term vision but contributions are welcome.
9
-
10
-
11
-## Overview
12
-
13
-The armada python library and command line tool provides a way to synchronize a helm (tiller) target with an operators intended state, consisting of several charts, dependencies, and overrides using a single file or directory with a collection of files. This allows operators to define many charts, potentially with different namespaces for those releases, and their overrides in a central place.  With a single command, deploy and/or upgrade them where applicable.
14
-
15
-Armada also supports fetching helm chart source and then building charts from source from various local and remote locations, such as git/github endpoints.  In the future, it may supprot other mechanisms as well.
16
-
17
-It will also give the operator some indication of what is about to change by assisting with diffs for both values, values overrides, and actual template changes.
18
-
19
-Its functionality may extend beyond helm, assisting in interacting with kubernetes directly to perform basic pre and post steps, such as removing completed or failed jobs, running backup jobs,  blocking on chart readiness, or deleting resources that do not support upgrades. However, primarily, it will be an interface to support orchestrating Helm.
20
-
21
-
22
-## Running Armada
23
-
24
-To use this container, use these simple instructions:
25
-
26
-```
27
-docker build -t armada .
28
-```
29
-
30
-
31
-```
32
-docker run -v ~/.kube/config:/root/.kube/config -v $(pwd)/examples/:/examples -v /tmp:/dev/log quay.io/attcomdev/armada:latest
33
-```
34
-
35
-## Development
36
-
37
-For development please refer to [Getting Started](./docs/development/getting-started.rst) guide
38
-
39
-## Installation
40
-
41
-The installation is fairly straight forward:
42
-
43
-Recomended Enviroment: Ubuntu 16.04
44
-
45
-### Installing Dependecies:
46
-
47
-you can run:
48
-
49
-* `tox testenv:ubuntu` or `sudo sh scripts/libgit2.sh`
50
-* `sudo pip install -r requirements.txt`
51
-
52
-NOTE: If you want to use virtualenv please refer to [pygit2](http://www.pygit2.org/install.html#libgit2-within-a-virtual-environment)
53
-
54
-### Installing armada:
55
-
56
-`sudo pip install -e .`
57
-
58
-`armada -h`
59
-
60
-## Using Armada
61
-
62
-Before using armada we need to check a few things:
63
-
64
-1. you have a properly configure `~/.kube/config`
65
-    * `kubectl config view`
66
-    * If it does not exist, you can create it using [kubectl](https://kubernetes.io/docs/user-guide/kubectl/kubectl_config/)
67
-
68
-1. Check that you have a running Tiller
69
-    * `kubectl get pods -n kube-system`
70
-
71
-To run armada, simply supply it with your YAML based intention for any number of charts:
72
-
73
-```
74
-armada -c examples/armada.yaml
75
-```
76
-
77
-Your output will look something like this:
78
-
79
-```
80
-$ armada -c examples/armada.yaml
81
-2017-02-10 09:42:36,753 armada       INFO     Cloning git://github.com/att-comdev/openstack-helm/keystone for release keystone
82
-2017-02-10 09:42:39,238 armada       INFO     Building dependency chart common for release keystone
83
-2017-02-10 09:42:39,238 armada       INFO     Cloning git://github.com/att-comdev/openstack-helm/common for release None
84
-2017-02-10 09:42:41,459 armada       INFO     Installing release keystone
85
-```
86
-
87
-If you were to run it a second time, modifying the shared values override example in examples/armada.conf:
88
-
89
-```
90
-endpoints: &endpoints
91
-  glance:
92
-    this: is an example
93
-```
94
-
95
-to:
96
-
97
-```
98
-endpoints: &endpoints
99
-  glance:
100
-    this: is an example
101
-    that: is another example
102
-```
103
-
104
-And re-run armada, we will notice it will upgrade the keystone release, instead of install it on this pass, as well as report back the values changes as a unified diff.  A unified diff for any template changes would also be shown had those occurred.
105
-
106
-```
107
-alan@hpdesktop:~/Workbench/att/attcomdev/armada$ armada -c examples/armada.yaml
108
-2017-02-10 09:44:43,396 armada       INFO     Cloning git://github.com/att-comdev/openstack-helm/keystone for release keystone
109
-2017-02-10 09:44:47,640 armada       INFO     Building dependency chart common for release keystone
110
-2017-02-10 09:44:47,640 armada       INFO     Cloning git://github.com/att-comdev/openstack-helm/common for release None
111
-2017-02-10 09:44:49,701 armada       INFO     Upgrading release keystone
112
-2017-02-10 09:44:49,704 armada       INFO     Values Unified Diff (keystone)
113
----
114
-
115
-+++
116
-
117
-@@ -1,3 +1,3 @@
118
-
119
- endpoints:
120
--  glance: {this: is an example}
121
-+  glance: {that: is another example, this: is an example}
122
-
123
-```
124
-
125
-# Helm gRPC
126
-
127
-The helm gRPC libraries are located in the hapi directory.  They were generated with the grpc_tools.protoc utility against Helm 2.1.3.  Should you wish to re-generate them you can easily do so:
128
-
129
-```
130
-    git clone https://github.com/kubernetes/helm ./helm
131
-    python -m grpc_tools.protoc -I helm/_proto --python_out=. --grpc_python_out=. helm/_proto/hapi/chart/*
132
-    python -m grpc_tools.protoc -I helm/_proto --python_out=. --grpc_python_out=. helm/_proto/hapi/services/*
133
-    python -m grpc_tools.protoc -I helm/_proto --python_out=. --grpc_python_out=. helm/_proto/hapi/release/*
134
-    python -m grpc_tools.protoc -I helm/_proto --python_out=. --grpc_python_out=. helm/_proto/hapi/version/*
135
-```

+ 119
- 0
README.rst View File

@@ -0,0 +1,119 @@
1
+Armada
2
+======
3
+
4
+|Docker Repository on Quay| |Build Status| |Doc Status|
5
+
6
+A python orchestrator for a installing, upgrading, and managing a
7
+collection of helm charts, dependencies, and values overrides.
8
+
9
+Note that this project is pre-alpha and under active development. It may
10
+undergo drastic changes to support the long-term vision but
11
+contributions are welcome.
12
+
13
+Overview
14
+--------
15
+
16
+The armada python library and command line tool provides a way to
17
+synchronize a helm (tiller) target with an operators intended state,
18
+consisting of several charts, dependencies, and overrides using a single
19
+file or directory with a collection of files. This allows operators to
20
+define many charts, potentially with different namespaces for those
21
+releases, and their overrides in a central place. With a single command,
22
+deploy and/or upgrade them where applicable.
23
+
24
+Armada also supports fetching helm chart source and then building charts
25
+from source from various local and remote locations, such as git/github
26
+endpoints. In the future, it may supprot other mechanisms as well.
27
+
28
+It will also give the operator some indication of what is about to
29
+change by assisting with diffs for both values, values overrides, and
30
+actual template changes.
31
+
32
+Its functionality may extend beyond helm, assisting in interacting with
33
+kubernetes directly to perform basic pre and post steps, such as
34
+removing completed or failed jobs, running backup jobs, blocking on
35
+chart readiness, or deleting resources that do not support upgrades.
36
+However, primarily, it will be an interface to support orchestrating
37
+Helm.
38
+
39
+Running Armada
40
+--------------
41
+
42
+To use this container, use these simple instructions:
43
+
44
+::
45
+
46
+    docker run -d --name armada -p 8000:8000 -v ~/.kube/config:/root/.kube/config -v $(pwd)/examples/:/examples -v /tmp:/dev/log quay.io/attcomdev/armada:latest
47
+
48
+Manual Install
49
+~~~~~~~~~~~~~~
50
+
51
+If you want to build the docker image, follow these steps:
52
+
53
+::
54
+
55
+    docker build . -t <namespace>/armada
56
+    docker run -d --name armada -p 8000:8000 -v ~/.kube/config:/root/.kube/config -v $(pwd)/examples/:/examples <namespace>/armada
57
+
58
+Installation
59
+------------
60
+
61
+The installation is fairly straight forward:
62
+
63
+Recomended Enviroment: Ubuntu 16.04
64
+
65
+Installing Dependecies:
66
+~~~~~~~~~~~~~~~~~~~~~~~
67
+
68
+you can run:
69
+
70
+-  ``tox testenv:ubuntu`` or ``sudo sh scripts/libgit2.sh``
71
+-  ``sudo pip install -r requirements.txt``
72
+
73
+NOTE: If you want to use virtualenv please refer to `pygit2`_
74
+
75
+Installing armada:
76
+~~~~~~~~~~~~~~~~~~
77
+
78
+``sudo pip install -e .``
79
+
80
+``armada [-h | --help]``
81
+
82
+Using Armada
83
+------------
84
+
85
+Before using armada we need to check a few things:
86
+
87
+1. you have a properly configure ``~/.kube/config``
88
+
89
+   -  ``kubectl config view``
90
+   -  If it does not exist, you can create it using `kubectl`_
91
+
92
+2. Check that you have a running Tiller
93
+
94
+   -  ``kubectl get pods -n kube-system``
95
+
96
+To run armada, simply supply it with your YAML based intention for any
97
+number of charts:
98
+
99
+::
100
+
101
+    $ aramda apply examples/armada.yaml [--debug ]
102
+
103
+Your output will look something like this:
104
+
105
+::
106
+
107
+    $ armada apply examples/armada.yaml 2017-02-10 09:42:36,753
108
+      armada INFO Cloning git:
109
+
110
+.. _pygit2: http://www.pygit2.org/install.html#libgit2-within-a-virtual-environment
111
+.. _kubectl: https://kubernetes.io/docs/user-guide/kubectl/kubectl_config/
112
+
113
+.. |Docker Repository on Quay| image:: https://quay.io/repository/attcomdev/armada/status
114
+   :target: https://quay.io/repository/attcomdev/armada
115
+.. |Build Status| image:: https://travis-ci.org/att-comdev/armada.svg?branch=master
116
+   :target: https://travis-ci.org/att-comdev/armada
117
+.. |Doc Status| image:: https://readthedocs.org/projects/armada-helm/badge/?version=latest
118
+   :target: http://armada-helm.readthedocs.io/
119
+

+ 23
- 0
armada/__init__.py View File

@@ -0,0 +1,23 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+__all__ = ['__version__']
16
+
17
+import pbr.version
18
+
19
+version_info = pbr.version.VersionInfo('armada')
20
+try:
21
+    __version__ = version_info.version_string()
22
+except AttributeError:
23
+    __version__ = None

+ 13
- 0
armada/api/__init__.py View File

@@ -0,0 +1,13 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.

+ 13
- 0
armada/cli/__init__.py View File

@@ -0,0 +1,13 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.

+ 53
- 0
armada/cli/apply.py View File

@@ -0,0 +1,53 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+import logging
16
+
17
+from cliff import command as cmd
18
+
19
+from armada.handlers.armada import Armada
20
+
21
+LOG = logging.getLogger(__name__)
22
+
23
+def applyCharts(args):
24
+
25
+    armada = Armada(open(args.file).read(),
26
+                    args.disable_update_pre,
27
+                    args.disable_update_post,
28
+                    args.enable_chart_cleanup,
29
+                    args.skip_pre_flight,
30
+                    args.dry_run)
31
+    armada.sync()
32
+
33
+class ApplyChartsCommand(cmd.Command):
34
+    def get_parser(self, prog_name):
35
+        parser = super(ApplyChartsCommand, self).get_parser(prog_name)
36
+        parser.add_argument('file', type=str, metavar='FILE',
37
+                            help='Armada yaml file')
38
+        parser.add_argument('--dry-run', action='store_true',
39
+                            default=False, help='Run charts with dry run')
40
+        parser.add_argument('--skip-pre-flight', action='store_true',
41
+                            default=False, help='Skip Pre Flight')
42
+        parser.add_argument('--debug', action='store',
43
+                            default=False, help='Run charts with dry run')
44
+        parser.add_argument('--disable-update-pre', action='store',
45
+                            default=False, help='Disable pre upgrade actions')
46
+        parser.add_argument('--disable-update-post', action='store',
47
+                            default=False, help='Disable post upgrade actions')
48
+        parser.add_argument('--enable-chart-cleanup', action='store',
49
+                            default=False, help='Enable Chart Clean Up')
50
+        return parser
51
+
52
+    def take_action(self, parsed_args):
53
+        applyCharts(parsed_args)

+ 45
- 0
armada/cli/tiller.py View File

@@ -0,0 +1,45 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+import logging
16
+
17
+from cliff import command as cmd
18
+
19
+from armada.handlers.tiller import Tiller
20
+
21
+LOG = logging.getLogger(__name__)
22
+
23
+def tillerServer(args):
24
+
25
+    tiller = Tiller()
26
+
27
+    if args.status:
28
+        LOG.info('Tiller is Active: %s', tiller.tiller_status())
29
+
30
+    if args.releases:
31
+        for release in tiller.list_releases():
32
+            LOG.info("Release: %s ( namespace= %s )", release.name,
33
+                     release.namespace)
34
+
35
+class TillerServerCommand(cmd.Command):
36
+    def get_parser(self, prog_name):
37
+        parser = super(TillerServerCommand, self).get_parser(prog_name)
38
+        parser.add_argument('--status', action='store_true',
39
+                            default=False, help='Check Tiller service')
40
+        parser.add_argument('--releases', action='store_true',
41
+                            default=False, help='List Tiller Releases')
42
+        return parser
43
+
44
+    def take_action(self, parsed_args):
45
+        tillerServer(parsed_args)

+ 13
- 0
armada/handlers/__init__.py View File

@@ -0,0 +1,13 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.

armada/armada.py → armada/handlers/armada.py View File

@@ -1,11 +1,30 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
1 15
 import difflib
2 16
 import yaml
17
+import logging
3 18
 
4 19
 from supermutes.dot import dotify
5 20
 
6 21
 from chartbuilder import ChartBuilder
7 22
 from tiller import Tiller
8
-from logutil import LOG
23
+from ..utils.release import release_prefix
24
+from ..utils import git
25
+from ..utils import lint
26
+
27
+LOG = logging.getLogger(__name__)
9 28
 
10 29
 class Armada(object):
11 30
     '''
@@ -17,6 +36,7 @@ class Armada(object):
17 36
                  disable_update_pre=False,
18 37
                  disable_update_post=False,
19 38
                  enable_chart_cleanup=False,
39
+                 skip_pre_flight=False,
20 40
                  dry_run=False):
21 41
         '''
22 42
         Initialize the Armada Engine and establish
@@ -25,6 +45,7 @@ class Armada(object):
25 45
         self.disable_update_pre = disable_update_pre
26 46
         self.disable_update_post = disable_update_post
27 47
         self.enable_chart_cleanup = enable_chart_cleanup
48
+        self.skip_pre_flight = skip_pre_flight
28 49
         self.dry_run = dry_run
29 50
         self.config = yaml.load(config)
30 51
         self.tiller = Tiller()
@@ -37,15 +58,24 @@ class Armada(object):
37 58
             if chart_name == name:
38 59
                 return chart, values
39 60
 
61
+    def pre_flight_checks(self):
62
+        for ch in self.config['armada']['charts']:
63
+            location = ch.get('chart').get('source').get('location')
64
+            ct_type = ch.get('chart').get('source').get('type')
65
+
66
+            if ct_type == 'git' and not git.check_available_repo(location):
67
+                raise ValueError(str("Invalid Url Path: " + location))
68
+
69
+            if not self.tiller.tiller_status():
70
+                raise Exception("Tiller Services is not Available")
71
+
72
+            if not lint.valid_manifest(self.config):
73
+                raise Exception("Invalid Armada Manifest")
74
+
40 75
     def sync(self):
41 76
         '''
42 77
         Syncronize Helm with the Armada Config(s)
43 78
         '''
44
-        def release_prefix(prefix, chart):
45
-            '''
46
-            how to attach prefix to chart
47
-            '''
48
-            return "{}-{}".format(prefix, chart)
49 79
 
50 80
         # extract known charts on tiller right now
51 81
         known_releases = self.tiller.list_charts()
@@ -55,10 +85,16 @@ class Armada(object):
55 85
             LOG.debug("Release %s, Version %s found on tiller", release[0],
56 86
                       release[1])
57 87
 
88
+        if not self.skip_pre_flight:
89
+            LOG.info("Performing Checking Pre Flight Tasks")
90
+            self.pre_flight_checks()
91
+        else:
92
+            LOG.info("Skipping Pre flight Checks")
93
+
58 94
         for entry in self.config['armada']['charts']:
59 95
 
60 96
             chart = dotify(entry['chart'])
61
-            values = entry['chart']['values']
97
+            values = entry.get('chart').get('values', {})
62 98
             pre_actions = {}
63 99
             post_actions = {}
64 100
 
@@ -86,10 +122,12 @@ class Armada(object):
86 122
                 installed_chart, installed_values = self.find_release_chart(
87 123
                     known_releases, release_prefix(prefix, chart.release_name))
88 124
 
89
-                if not self.disable_update_pre:
125
+                if not self.disable_update_pre and getattr(chart, 'upgrade',
126
+                                                           False):
90 127
                     pre_actions = getattr(chart.upgrade, 'pre', {})
91 128
 
92
-                if not self.disable_update_post:
129
+                if not self.disable_update_post and getattr(chart, 'upgrade',
130
+                                                            False):
93 131
                     post_actions = getattr(chart.upgrade, 'post', {})
94 132
 
95 133
                 # show delta for both the chart templates and the chart values

armada/chartbuilder.py → armada/handlers/chartbuilder.py View File

@@ -1,5 +1,20 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
1 15
 import os
2 16
 import yaml
17
+import logging
3 18
 
4 19
 from hapi.chart.template_pb2 import Template
5 20
 from hapi.chart.chart_pb2 import Chart
@@ -7,9 +22,9 @@ from hapi.chart.metadata_pb2 import Metadata
7 22
 from hapi.chart.config_pb2 import Config
8 23
 from supermutes.dot import dotify
9 24
 
10
-from logutil import LOG
11
-from git import git_clone, source_cleanup
25
+from ..utils.git import git_clone, source_cleanup
12 26
 
27
+LOG = logging.getLogger(__name__)
13 28
 
14 29
 class ChartBuilder(object):
15 30
     '''
@@ -67,6 +82,9 @@ class ChartBuilder(object):
67 82
 
68 83
             return os.path.join(self._source_tmp_dir,
69 84
                                 self.chart.source.subpath)
85
+        if self.chart.source.type == 'local':
86
+            return os.path.join(self.chart.source.location,
87
+                                self.chart.source.subpath)
70 88
 
71 89
         else:
72 90
             LOG.exception("Unknown source type %s for chart %s",
@@ -77,7 +95,8 @@ class ChartBuilder(object):
77 95
         '''
78 96
         Cleanup source
79 97
         '''
80
-        source_cleanup(self._source_tmp_dir)
98
+        if self.chart.source.type == 'git':
99
+            source_cleanup(self._source_tmp_dir)
81 100
 
82 101
     def get_metadata(self):
83 102
         '''

armada/k8s.py → armada/handlers/k8s.py View File

@@ -1,7 +1,22 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
1 15
 from kubernetes import client, config
2 16
 from kubernetes.client.rest import ApiException
17
+import logging
3 18
 
4
-from logutil import LOG
19
+LOG = logging.getLogger(__name__)
5 20
 
6 21
 class K8s(object):
7 22
     '''

armada/tiller.py → armada/handlers/tiller.py View File

@@ -1,16 +1,34 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
1 15
 import grpc
16
+import logging
17
+
2 18
 from hapi.services.tiller_pb2 import ReleaseServiceStub, ListReleasesRequest, \
3 19
     InstallReleaseRequest, UpdateReleaseRequest, UninstallReleaseRequest
4 20
 from hapi.chart.config_pb2 import Config
5 21
 
6 22
 from k8s import K8s
7
-from logutil import LOG
23
+from ..utils.release import release_prefix
8 24
 
9 25
 TILLER_PORT = 44134
10 26
 TILLER_VERSION = b'2.1.3'
11 27
 TILLER_TIMEOUT = 300
12 28
 RELEASE_LIMIT = 64
13 29
 
30
+LOG = logging.getLogger(__name__)
31
+
14 32
 class Tiller(object):
15 33
     '''
16 34
     The Tiller class supports communication and requests to the Tiller Helm
@@ -69,7 +87,7 @@ class Tiller(object):
69 87
         '''
70 88
         return if tiller exist or not
71 89
         '''
72
-        if self._get_tiller_ip:
90
+        if self._get_tiller_ip():
73 91
             return True
74 92
 
75 93
         return False
@@ -218,11 +236,6 @@ class Tiller(object):
218 236
 
219 237
         :result - will remove any chart that is not present in yaml
220 238
         '''
221
-        def release_prefix(prefix, chart):
222
-            '''
223
-            how to attach prefix to chart
224
-            '''
225
-            return "{}-{}".format(prefix, chart["chart"]["release_name"])
226 239
 
227 240
         valid_charts = [release_prefix(prefix, chart) for chart in charts]
228 241
         actual_charts = [x.name for x in self.list_releases()]

+ 84
- 0
armada/log.py View File

@@ -0,0 +1,84 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+import os
16
+import logging
17
+import string
18
+import sys
19
+
20
+if sys.version_info < (2, 7):
21
+    import functools
22
+
23
+    @functools.wraps(logging.Formatter.format)
24
+    def new_format(self, record, string=string,
25
+                   old_format=logging.Formatter.format):
26
+        if string.find is None:
27
+            string.find = str.find
28
+        return old_format(self, record)
29
+    logging.Formatter.format = new_format
30
+
31
+
32
+class ColorFormatter(logging.Formatter):
33
+    LEVEL_COLORS = {
34
+        logging.DEBUG: '\033[00;32m',  # GREEN
35
+        logging.INFO: '\033[00;36m',  # CYAN
36
+        logging.WARN: '\033[01;33m',  # BOLD YELLOW
37
+        logging.ERROR: '\033[01;31m',  # BOLD RED
38
+        logging.CRITICAL: '\033[01;31m',  # BOLD RED
39
+    }
40
+
41
+    def format(self, record, Formatter=logging.Formatter):
42
+        # Hack to get last log line instead of exception on 2.6
43
+        res = Formatter.format(self, record)  # old-style class on 2.6
44
+        return self.LEVEL_COLORS[record.levelno] + res + '\033[m'
45
+
46
+
47
+def set_console_formatter(**formatter_kwargs):
48
+    formatter_kwargs.setdefault(
49
+        'fmt', '%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
50
+    formatter_kwargs.setdefault('datefmt', '%m-%d %H:%M')
51
+
52
+    root_logger = logging.getLogger('')
53
+    cliff_log = logging.getLogger('cliff')
54
+    stevedore_log = logging.getLogger('stevedore')
55
+    iso8601_log = logging.getLogger("iso8601")
56
+
57
+    log_dir = os.path.expanduser('~/.armada')
58
+    if not os.path.exists(log_dir):
59
+        os.makedirs(log_dir)
60
+
61
+    file_logger = logging.FileHandler(filename=str(log_dir + '/armada.log'))
62
+    root_logger.addHandler(file_logger)
63
+
64
+    cliff_log.setLevel(logging.INFO)
65
+    stevedore_log.setLevel(logging.INFO)
66
+    iso8601_log.setLevel(logging.INFO)
67
+
68
+    for handler in root_logger.handlers:
69
+        if handler.__class__ is logging.StreamHandler:  # Skip subclasses
70
+            console_handler = handler
71
+            # Skip if not a tty (default ssh, redirect, ...)
72
+            isatty = getattr(handler.stream, 'isatty', None)
73
+            if isatty is None or not isatty():
74
+                continue
75
+            break
76
+    else:
77
+        return  # Didn't find any suitable StreamHandlers there
78
+    formatter = ColorFormatter(**formatter_kwargs)
79
+    console_handler.setFormatter(formatter)
80
+
81
+
82
+def silence_iso8601():
83
+    iso8601_logger = logging.getLogger('iso8601')
84
+    iso8601_logger.setLevel(logging.INFO)

+ 0
- 20
armada/logutil.py View File

@@ -1,20 +0,0 @@
1
-
2
-import logging
3
-from logging.handlers import SysLogHandler
4
-
5
-LOG = logging.getLogger('armada')
6
-LOG_FORMAT = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
7
-LOG_DATE = '%m-%d %H:%M'
8
-
9
-def setup_logging(debug):
10
-    '''
11
-    :params args - logging information arguments in cli
12
-
13
-    various utilties to support logging
14
-    '''
15
-    level = logging.DEBUG if debug else logging.INFO
16
-    logging.basicConfig(level=level, format=LOG_FORMAT, date_fmt=LOG_DATE)
17
-    handler = SysLogHandler(address='/dev/log')
18
-    syslog_formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s')
19
-    handler.setFormatter(syslog_formatter)
20
-    LOG.addHandler(handler)

+ 45
- 0
armada/shell.py View File

@@ -0,0 +1,45 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+import sys
16
+
17
+from cliff import app
18
+from cliff import commandmanager as cm
19
+
20
+import armada
21
+from armada import log
22
+
23
+class ArmadaApp(app.App):
24
+    def __init__(self, **kwargs):
25
+        super(ArmadaApp, self).__init__(
26
+            description='Armada - Upgrade and deploy your charts',
27
+            version=armada.__version__,
28
+            command_manager=cm.CommandManager('armada'),
29
+            **kwargs)
30
+
31
+    def build_option_parser(self, description, version, argparse_kwargs=None):
32
+        parser = super(ArmadaApp, self).build_option_parser(
33
+            description, version, argparse_kwargs)
34
+        return parser
35
+
36
+    def configure_logging(self):
37
+        super(ArmadaApp, self).configure_logging()
38
+        log.set_console_formatter()
39
+        log.silence_iso8601()
40
+
41
+
42
+def main(argv=None):
43
+    if argv is None:
44
+        argv = sys.argv[1:]
45
+    return ArmadaApp().run(argv)

+ 13
- 0
armada/utils/__init__.py View File

@@ -0,0 +1,13 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.

armada/git.py → armada/utils/git.py View File

@@ -1,6 +1,9 @@
1 1
 import pygit2
2 2
 import tempfile
3 3
 import shutil
4
+import requests
5
+
6
+HTTP_OK = 200
4 7
 
5 8
 def git_clone(repo_url, branch='master'):
6 9
     '''
@@ -16,3 +19,14 @@ def source_cleanup(target_dir):
16 19
     Clean up source
17 20
     '''
18 21
     shutil.rmtree(target_dir)
22
+
23
+
24
+def check_available_repo(repo_url):
25
+    try:
26
+        resp = requests.get(repo_url.replace('git:', 'http:'))
27
+        if resp.status_code == HTTP_OK:
28
+            return True
29
+
30
+        return False
31
+    except Exception:
32
+        return False

+ 23
- 0
armada/utils/lint.py View File

@@ -0,0 +1,23 @@
1
+
2
+ARMADA_DEFINITION = 'armada'
3
+RELEASE_PREFIX = 'release_prefix'
4
+CHARTS_DEFINITION = 'charts'
5
+
6
+
7
+def valid_manifest(config):
8
+    if not (isinstance(config.get(ARMADA_DEFINITION, None), dict)):
9
+        raise Exception("Did not declare armada object")
10
+
11
+    armada_config = config.get('armada')
12
+
13
+    if not isinstance(armada_config.get(RELEASE_PREFIX), basestring):
14
+        raise Exception('Release needs to be a string')
15
+
16
+    if not isinstance(armada_config.get(CHARTS_DEFINITION), list):
17
+        raise Exception('Check yaml invalid chart definition must be array')
18
+
19
+    for chart in armada_config.get('charts', []):
20
+        if not isinstance(chart.get('chart').get('name'), basestring):
21
+            raise Exception('Chart name needs to be a string')
22
+
23
+    return True

+ 19
- 0
armada/utils/release.py View File

@@ -0,0 +1,19 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+def release_prefix(prefix, chart):
16
+    '''
17
+    how to attach prefix to chart
18
+    '''
19
+    return "{}-{}".format(prefix, chart)

+ 23
- 0
armada/version.py View File

@@ -0,0 +1,23 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+__all__ = ['__version__']
16
+
17
+import pbr.version
18
+
19
+version_info = pbr.version.VersionInfo('armada')
20
+try:
21
+    __version__ = version_info.version_string()
22
+except AttributeError:
23
+    __version__ = None

+ 153
- 0
docs/source/conf.py View File

@@ -0,0 +1,153 @@
1
+# -*- coding: utf-8 -*-
2
+#
3
+# Armada documentation build configuration file, created by
4
+# sphinx-quickstart on Wed May  3 10:39:15 2017.
5
+#
6
+# This file is execfile()d with the current directory set to its
7
+# containing dir.
8
+#
9
+# Note that not all possible configuration values are present in this
10
+# autogenerated file.
11
+#
12
+# All configuration values have a default; values that are commented out
13
+# serve to show the default.
14
+
15
+# If extensions (or modules to document with autodoc) are in another directory,
16
+# add these directories to sys.path here. If the directory is relative to the
17
+# documentation root, use os.path.abspath to make it absolute, like shown here.
18
+#
19
+# import os
20
+# import sys
21
+# sys.path.insert(0, os.path.abspath('.'))
22
+
23
+
24
+# -- General configuration ------------------------------------------------
25
+
26
+# If your documentation needs a minimal Sphinx version, state it here.
27
+#
28
+# needs_sphinx = '1.0'
29
+
30
+# Add any Sphinx extension module names here, as strings. They can be
31
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32
+# ones.
33
+extensions = []
34
+
35
+# Add any paths that contain templates here, relative to this directory.
36
+# templates_path = ['_templates']
37
+
38
+# The suffix(es) of source filenames.
39
+# You can specify multiple suffix as a list of string:
40
+#
41
+# source_suffix = ['.rst', '.md']
42
+source_suffix = '.rst'
43
+
44
+# The master toctree document.
45
+master_doc = 'index'
46
+
47
+# General information about the project.
48
+project = u'Armada'
49
+copyright = u'2017, Armada Team'
50
+author = u'Armada Team'
51
+
52
+# The version info for the project you're documenting, acts as replacement for
53
+# |version| and |release|, also used in various other places throughout the
54
+# built documents.
55
+#
56
+# The short X.Y version.
57
+version = u'0.2.0'
58
+# The full version, including alpha/beta/rc tags.
59
+release = u'0.2.0'
60
+
61
+# The language for content autogenerated by Sphinx. Refer to documentation
62
+# for a list of supported languages.
63
+#
64
+# This is also used if you do content translation via gettext catalogs.
65
+# Usually you set "language" from the command line for these cases.
66
+language = None
67
+
68
+# List of patterns, relative to source directory, that match files and
69
+# directories to ignore when looking for source files.
70
+# This patterns also effect to html_static_path and html_extra_path
71
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
72
+
73
+# The name of the Pygments (syntax highlighting) style to use.
74
+pygments_style = 'sphinx'
75
+
76
+# If true, `todo` and `todoList` produce output, else they produce nothing.
77
+todo_include_todos = False
78
+
79
+
80
+# -- Options for HTML output ----------------------------------------------
81
+
82
+# The theme to use for HTML and HTML Help pages.  See the documentation for
83
+# a list of builtin themes.
84
+#
85
+html_theme = 'alabaster'
86
+
87
+# Theme options are theme-specific and customize the look and feel of a theme
88
+# further.  For a list of options available for each theme, see the
89
+# documentation.
90
+#
91
+# html_theme_options = {}
92
+
93
+# Add any paths that contain custom static files (such as style sheets) here,
94
+# relative to this directory. They are copied after the builtin static files,
95
+# so a file named "default.css" will overwrite the builtin "default.css".
96
+# html_static_path = ['_static']
97
+
98
+
99
+# -- Options for HTMLHelp output ------------------------------------------
100
+
101
+# Output file base name for HTML help builder.
102
+htmlhelp_basename = 'Armadadoc'
103
+
104
+
105
+# -- Options for LaTeX output ---------------------------------------------
106
+
107
+latex_elements = {
108
+    # The paper size ('letterpaper' or 'a4paper').
109
+    #
110
+    # 'papersize': 'letterpaper',
111
+
112
+    # The font size ('10pt', '11pt' or '12pt').
113
+    #
114
+    # 'pointsize': '10pt',
115
+
116
+    # Additional stuff for the LaTeX preamble.
117
+    #
118
+    # 'preamble': '',
119
+
120
+    # Latex figure (float) alignment
121
+    #
122
+    # 'figure_align': 'htbp',
123
+}
124
+
125
+# Grouping the document tree into LaTeX files. List of tuples
126
+# (source start file, target name, title,
127
+#  author, documentclass [howto, manual, or own class]).
128
+latex_documents = [
129
+    (master_doc, 'Armada.tex', u'Armada Documentation',
130
+     u'Armada Team', 'manual'),
131
+]
132
+
133
+
134
+# -- Options for manual page output ---------------------------------------
135
+
136
+# One entry per manual page. List of tuples
137
+# (source start file, name, description, authors, manual section).
138
+man_pages = [
139
+    (master_doc, 'armada', u'Armada Documentation',
140
+     [author], 1)
141
+]
142
+
143
+
144
+# -- Options for Texinfo output -------------------------------------------
145
+
146
+# Grouping the document tree into Texinfo files. List of tuples
147
+# (source start file, target name, title, author,
148
+#  dir menu entry, description, category)
149
+texinfo_documents = [
150
+    (master_doc, 'Armada', u'Armada Documentation',
151
+     author, 'Armada', 'One line description of project.',
152
+     'Miscellaneous'),
153
+]

docs/development/getting-started.rst → docs/source/development/getting-started.rst View File

@@ -5,11 +5,22 @@ Development
5 5
 Docker
6 6
 ######
7 7
 
8
-To use this container, use these simple instructions:
8
+To use the docker containter to develop:
9
+
10
+1. Fork the [repo](http://github.com/att-comdev/armada)
11
+2. After making changes push to repo and build from forked repo
9 12
 
10 13
 .. code-block:: bash
11 14
 
12
-   docker run quay.io/attcomdev/armada:latest
15
+    export repo="https://github.com/<forked-repo>/armada.git"
16
+    export branch="<branch>"
17
+    docker build . -p 8000:8000 -v ${HOME}/.kube/config:/root/.kube/config -t quay.io/attcomdev/armada:latest --build-arg REPO=$repo --build-arg VERSION=$branch
18
+
19
+.. note::
20
+
21
+    The first build will take a little while. Afterwards the it will much faster
22
+
23
+3. EZPZ :)
13 24
 
14 25
 Virtualenv
15 26
 ##########

+ 13
- 0
docs/source/development/index.rst View File

@@ -0,0 +1,13 @@
1
+.. Armada documentation master file, created by
2
+   sphinx-quickstart on Wed May  3 10:39:15 2017.
3
+   You can adapt this file completely to your liking, but it should at least
4
+   contain the root `toctree` directive.
5
+
6
+Developers Guide
7
+================
8
+
9
+.. toctree::
10
+   :maxdepth: 2
11
+   :caption: Contents:
12
+
13
+   getting-started.rst

+ 24
- 0
docs/source/index.rst View File

@@ -0,0 +1,24 @@
1
+.. Armada documentation master file, created by
2
+   sphinx-quickstart on Wed May  3 10:39:15 2017.
3
+   You can adapt this file completely to your liking, but it should at least
4
+   contain the root `toctree` directive.
5
+
6
+Welcome to Armada's documentation!
7
+==================================
8
+
9
+.. toctree::
10
+   :maxdepth: 2
11
+   :caption: Contents:
12
+
13
+   readme
14
+   development/index
15
+   operations/index
16
+
17
+
18
+
19
+Indices and tables
20
+==================
21
+
22
+* :ref:`genindex`
23
+* :ref:`modindex`
24
+* :ref:`search`

+ 171
- 0
docs/source/operations/guide-build-armada-yaml.rst View File

@@ -0,0 +1,171 @@
1
+Armada - Making Your First Armada Yaml
2
+======================================
3
+
4
+Keywords
5
+--------
6
+
7
++---------------------+--------+----------------------+
8
+| keyword             | type   | action               |
9
++=====================+========+======================+
10
+| ``armada``          | object | will                 |
11
+|                     |        | define an            |
12
+|                     |        | armada               |
13
+|                     |        | release              |
14
++---------------------+--------+----------------------+
15
+| ``release_prefix``  | string | will tag             |
16
+|                     |        | all                  |
17
+|                     |        | charts               |
18
+|                     |        | released             |
19
+|                     |        | by the               |
20
+|                     |        | yaml in              |
21
+|                     |        | order to             |
22
+|                     |        | manage it            |
23
+|                     |        | the                  |
24
+|                     |        | lifecycle            |
25
+|                     |        | of charts            |
26
++---------------------+--------+----------------------+
27
+| ``charts``          | array  | will                 |
28
+|                     |        | store the            |
29
+|                     |        | definitio            |
30
+|                     |        | ns                   |
31
+|                     |        | of all               |
32
+|                     |        | your                 |
33
+|                     |        | charts               |
34
++---------------------+--------+----------------------+
35
+| ``chart``           | object | will                 |
36
+|                     |        | define               |
37
+|                     |        | what your            |
38
+|                     |        | chart                |
39
+|                     |        |                      |
40
++---------------------+--------+----------------------+
41
+
42
+Defining a chart
43
+~~~~~~~~~~~~~~~~
44
+
45
+To define your charts is not any different than helm. we do provide some
46
+post/pre actions that will help us manage our charts better.
47
+
48
+Behavior
49
+^^^^^^^^
50
+
51
+1. will check if chart exists
52
+
53
+   1. if it does not exist
54
+
55
+      -  we will install the chart
56
+
57
+   2. if exist then
58
+
59
+      -  armada will check if there are any differences in the charts
60
+      -  if the charts are different then it will execute an upgrade
61
+      -  else it will not perform any actions
62
+
63
+Chart Keywords
64
+^^^^^^^^^^^^^^
65
+
66
+Chart
67
+^^^^^
68
+
69
++-----------------+----------+------------------------------------------------------------------------+
70
+| keyword         | type     | action                                                                 |
71
++=================+==========+========================================================================+
72
+| name            | string   | will be the name fo the chart                                          |
73
++-----------------+----------+------------------------------------------------------------------------+
74
+| release\_name   | string   | will be the name of the release                                        |
75
++-----------------+----------+------------------------------------------------------------------------+
76
+| namespace       | string   | will place your chart in define namespace                              |
77
++-----------------+----------+------------------------------------------------------------------------+
78
+| install         | object   | will install the chart into your kubernetes cluster                    |
79
++-----------------+----------+------------------------------------------------------------------------+
80
+| update          | object   | will updated any chart managed by the armada yaml                      |
81
++-----------------+----------+------------------------------------------------------------------------+
82
+| values          | object   | will override any default values in the charts                         |
83
++-----------------+----------+------------------------------------------------------------------------+
84
+| source          | object   | will provide a path to a ``git repo`` or ``local dir`` deploy chart.   |
85
++-----------------+----------+------------------------------------------------------------------------+
86
+| dependencies    | object   | will reference any chart deps before install                           |
87
++-----------------+----------+------------------------------------------------------------------------+
88
+
89
+Source
90
+^^^^^^
91
+
92
++-------------+----------+---------------------------------------------------------------+
93
+| keyword     | type     | action                                                        |
94
++=============+==========+===============================================================+
95
+| type        | string   | will be the source to build the charts ``git`` or ``local``   |
96
++-------------+----------+---------------------------------------------------------------+
97
+| location    | string   | will be the ``url`` or ``path`` to the charts                 |
98
++-------------+----------+---------------------------------------------------------------+
99
+| subpath     | string   | will specify the path to target chart                         |
100
++-------------+----------+---------------------------------------------------------------+
101
+| reference   | string   | will be the branch of the repo                                |
102
++-------------+----------+---------------------------------------------------------------+
103
+
104
+.. note::
105
+
106
+    You can use references in order to build your charts, this will reduce the size of the chart definition will show example in multichart below
107
+
108
+Simple Example
109
+~~~~~~~~~~~~~~
110
+
111
+::
112
+
113
+    armada:
114
+       release_prefix: "my_armada"
115
+       charts:
116
+           - chart: &cockroach
117
+            name: cockroach
118
+            release_name: cockroach
119
+            namespace: db
120
+            install:
121
+              no_hooks: false
122
+            values:
123
+                Replicas: 1
124
+            source:
125
+              type: git
126
+              location: git://github.com/kubernetes/charts/
127
+              subpath: stable/cockroachdb
128
+              reference: master
129
+            dependencies: []
130
+
131
+Multichart Example
132
+~~~~~~~~~~~~~~~~~~
133
+
134
+::
135
+
136
+    armada:
137
+       release_prefix: "my_armada"
138
+       charts:
139
+           - chart: &common
140
+             name: common
141
+             release_name: null
142
+             namespace: null
143
+             values: {}
144
+             source:
145
+                type: git
146
+                location: git://github.com/kubernetes/charts/
147
+                subpath: common
148
+                reference: master
149
+             dependencies: []
150
+
151
+           - chart: &cockroach
152
+            name: cockroach
153
+            release_name: cockroach
154
+            namespace: db
155
+            install:
156
+              no_hooks: false
157
+            values:
158
+                Replicas: 1
159
+            source:
160
+              type: git
161
+              location: git://github.com/kubernetes/charts/
162
+              subpath: stable/cockroachdb
163
+              reference: master
164
+            dependencies:
165
+                - *common
166
+
167
+References
168
+~~~~~~~~~~
169
+
170
+For working examples please check the examples in our repo
171
+`here <https://github.com/att-comdev/armada/tree/master/examples>`__

+ 53
- 0
docs/source/operations/guide-troubleshooting.rst View File

@@ -0,0 +1,53 @@
1
+Armada - Troubleshooting
2
+========================
3
+
4
+Debugging Pods
5
+--------------
6
+
7
+Before starting to work in armada we need to check that the tiller pod is active and running.
8
+
9
+.. code:: bash
10
+
11
+    kubectl get pods -n kube-system | grep tiller
12
+
13
+.. code:: bash
14
+
15
+    armada tiller --status
16
+
17
+Checking Logs
18
+-------------
19
+
20
+In order to check the logs the logs file will be in `~/.armada` directory.
21
+
22
+When running Armada in the container you can execute docker logs to retrieve logs
23
+
24
+.. code:: bash
25
+
26
+    docker logs [container-name | container-id]
27
+
28
+
29
+Working with SSL
30
+----------------
31
+
32
+You might run into SSL error with armada if you are not using the correct
33
+versions of SSL.
34
+
35
+Debugging Checklist:
36
+
37
+1. python -c "import ssl; print ssl.OPENSSL_VERSION"
38
+
39
+   If the version that appers is less than 1.0 then problems will occur, please
40
+   update to current or use our docker container solve this issue
41
+
42
+2. check your urllib3 version, you could run into urllib3 issues. older versions
43
+   of this lib can cause SSL errors run ``pip install --upgrade urllib3`` and it
44
+   should solve this issue
45
+
46
+
47
+
48
+Issue
49
+-----
50
+
51
+If the issue that you are having does not appear here please check the aramda
52
+issues [here](https://github.com/att-comdev/armada/issues). If the issue does
53
+not exist, please create an issue. 

+ 14
- 0
docs/source/operations/index.rst View File

@@ -0,0 +1,14 @@
1
+.. Armada documentation master file, created by
2
+   sphinx-quickstart on Wed May  3 10:39:15 2017.
3
+   You can adapt this file completely to your liking, but it should at least
4
+   contain the root `toctree` directive.
5
+
6
+Operations Guide
7
+================
8
+
9
+.. toctree::
10
+   :maxdepth: 2
11
+   :caption: Contents:
12
+
13
+   guide-troubleshooting.rst
14
+   guide-build-armada-yaml.rst

+ 1
- 0
docs/source/readme.rst View File

@@ -0,0 +1 @@
1
+.. include:: ../../README.rst

+ 16
- 0
entrypoint.sh View File

@@ -0,0 +1,16 @@
1
+#!/bin/bash
2
+
3
+CMD="armada"
4
+PORT="8000"
5
+
6
+set -e
7
+
8
+if [ "$1" = 'server' ]; then
9
+    gunicorn server:api -b :$PORT
10
+fi
11
+
12
+if [ "$1" = 'tiller' ] || [ "$1" = 'apply' ]; then
13
+    exec $CMD "$@"
14
+fi
15
+
16
+exec "$@"

+ 6
- 0
requirements.txt View File

@@ -5,6 +5,12 @@ kubernetes==1.0.0
5 5
 protobuf==3.2.0
6 6
 PyYAML==3.12
7 7
 supermutes==0.2.5
8
+urllib3==1.21.1
8 9
 
10
+# API
9 11
 falcon==1.1.0
10 12
 gunicorn==19.7.1
13
+
14
+# CLI
15
+
16
+cliff==2.7.0

+ 0
- 51
scripts/armada View File

@@ -1,51 +0,0 @@
1
-#!/usr/bin/env python
2
-
3
-import sys
4
-import argparse
5
-from armada.armada import Armada
6
-from armada.logutil import LOG, setup_logging
7
-
8
-DESCRIPTION = "Armada"
9
-
10
-def parse_args():
11
-
12
-    ap = argparse.ArgumentParser(description=DESCRIPTION)
13
-    ap.add_argument('-c', '--config', action='store', required=True,
14
-                    help='Path to YAML File or Directory')
15
-    ap.add_argument('--debug', action='store_true', default=False,
16
-                    required=False, help='Enable debug logging')
17
-    ap.add_argument('--enable-chart-cleanup', action='store_true',
18
-                    default=False, required=False, help='Clean up enviroment')
19
-    ap.add_argument('-d', '--dry-run', action='store_true', default=False,
20
-                    required=False, help='Enable dry-run flag on all Tiller'
21
-                    'Calls')
22
-    ap.add_argument('--disable-update-pre', action='store_true', default=False,
23
-                    required=False, help='Disable pre update actions')
24
-    ap.add_argument('--disable-update-post', action='store_true',
25
-                    default=False, required=False,
26
-                    help='Disable post update actions')
27
-
28
-    return ap.parse_args()
29
-
30
-
31
-def run(args):
32
-
33
-    armada = Armada(open(args.config).read(),
34
-                    args.disable_update_pre,
35
-                    args.disable_update_post,
36
-                    args.enable_chart_cleanup,
37
-                    args.dry_run)
38
-    armada.sync()
39
-
40
-
41
-if __name__ == '__main__':
42
-
43
-    args = parse_args()
44
-    setup_logging(args.debug)
45
-
46
-    try:
47
-        run(args)
48
-        sys.exit(0)
49
-    except Exception as err:
50
-        LOG.exception(err)
51
-        sys.exit(1)

+ 0
- 18
scripts/libgit2_docker.sh View File

@@ -1,18 +0,0 @@
1
-#!/bin/sh
2
-
3
-# Ubuntu 16.04 Install only
4
-
5
-apt install git cmake make -y
6
-apt-get install -y python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev libssh2-1 libgit2-dev python-pip libgit2-24
7
-apt-get install -y pkg-config libssh2-1-dev libhttp-parser-dev libssl-dev libz-dev
8
-
9
-LIBGIT_VERSION='0.25.0'
10
-
11
-wget https://github.com/libgit2/libgit2/archive/v${LIBGIT_VERSION}.tar.gz
12
-tar xzf v${LIBGIT_VERSION}.tar.gz
13
-cd libgit2-${LIBGIT_VERSION}/
14
-cmake .
15
-make
16
-make install
17
-pip install pygit2==${LIBGIT_VERSION}
18
-ldconfig

+ 20
- 7
server.py View File

@@ -1,11 +1,28 @@
1
+# Copyright 2017 The Armada Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+#
1 15
 
16
+
17
+import logging
2 18
 import falcon
3 19
 import json
4 20
 from falcon import HTTP_200
5 21
 
6
-from armada.tiller import Tiller as tillerHandler
7
-from armada.armada import Armada as armadaHandler
8
-from armada.logutil import setup_logging
22
+from armada.handlers.tiller import Tiller as tillerHandler
23
+from armada.handlers.armada import Armada as armadaHandler
24
+
25
+LOG = logging.getLogger(__name__)
9 26
 
10 27
 class Tiller(object):
11 28
     '''
@@ -32,7 +49,6 @@ class Armada(object):
32 49
 
33 50
     def on_post(self, req, resp):
34 51
         armada = armadaHandler(req.stream.read())
35
-        print armada.tiller.k8s.get_namespace_pod()
36 52
         armada.sync()
37 53
 
38 54
         resp.data = json.dumps({'message': 'Success'})
@@ -51,6 +67,3 @@ url_routes = (
51 67
 
52 68
 for route, service in url_routes:
53 69
     api.add_route(route, service)
54
-
55
-
56
-setup_logging(False)

+ 47
- 0
setup.cfg View File

@@ -0,0 +1,47 @@
1
+[metadata]
2
+name = armada
3
+summary = tool for managing multiple chart ocherstartion lifecycle
4
+description-file = README.rst
5
+
6
+author = armada team
7
+home-page = http://armada-helm.readthedocs.io/en/latest/
8
+classifier =
9
+    Intended Audience :: Information Technology
10
+    Intended Audience :: System Administrators
11
+    License :: OSI Approved :: Apache Software License
12
+    Operating System :: POSIX :: Linux
13
+    Programming Language :: Python
14
+    Programming Language :: Python :: 2
15
+    Programming Language :: Python :: 2.7
16
+    Programming Language :: Python :: 3
17
+    Programming Language :: Python :: 3.5
18
+
19
+[files]
20
+packages =
21
+    armada
22
+    armada.cli
23
+    armada.api
24
+    armada.handlers
25
+    hapi
26
+    hapi.chart
27
+    hapi.release
28
+    hapi.services
29
+    hapi.version
30
+
31
+[build_sphinx]
32
+source-dir = docs/source
33
+build-dir = docs/build
34
+all_files = 1
35
+
36
+[entry_points]
37
+console_scripts =
38
+    armada = armada.shell:main
39
+armada =
40
+    apply = armada.cli.apply:ApplyChartsCommand
41
+    tiller = armada.cli.tiller:TillerServerCommand
42
+
43
+[pbr]
44
+warnerrors = True
45
+
46
+[wheel]
47
+universal = 1

+ 9
- 13
setup.py View File

@@ -1,6 +1,6 @@
1
-from setuptools import setup
2 1
 from setuptools.command.test import test as TestCommand
3 2
 import sys
3
+import setuptools
4 4
 
5 5
 class Tox(TestCommand):
6 6
     """Runs Tox comands"""
@@ -17,15 +17,11 @@ class Tox(TestCommand):
17 17
         sys.exit(errcode)
18 18
 
19 19
 
20
-setup(
21
-    name='armada',
22
-    version='0.1.0',
23
-    description='Armada Helm Orchestrator',
24
-    packages=['armada',
25
-              'hapi',
26
-              'hapi.chart',
27
-              'hapi.release',
28
-              'hapi.services',
29
-              'hapi.version'],
30
-    scripts=['scripts/armada']
31
-)
20
+try:
21
+    import multiprocessing  # noqa
22
+except ImportError:
23
+    pass
24
+
25
+setuptools.setup(
26
+    setup_requires=['pbr>=2.0.0'],
27
+    pbr=True)

+ 2
- 1
test-requirements.txt View File

@@ -1,2 +1,3 @@
1 1
 flake8==3.3.0
2
-tox==2.6.0
2
+tox
3
+Sphinx

scripts/libgit2.sh → tools/libgit2.sh View File


+ 4
- 2
tox.ini View File

@@ -7,13 +7,15 @@ deps=
7 7
   -r{toxinidir}/test-requirements.txt
8 8
 setenv=
9 9
     PYTHONWARNINGS=all
10
-commands =
11
-	 sh {toxinidir}/scripts/libgit2.sh
12 10
 
13 11
 [testenv:ubuntu]
14 12
 commands =
15 13
 	 sh {toxinidir}/scripts/libgit2.sh
16 14
 
15
+[testenv:docs]
16
+commands = python setup.py build_sphinx
17
+
18
+
17 19
 [flake8]
18 20
 ignore=E302,H306
19 21
 exclude= libgit2-0.24.0, .git, .idea, .tox, *.egg-info, *.eggs, bin, dist, hapi

Loading…
Cancel
Save