Prepare installer and pods for Rel TWELVE
[osm/devops.git] / installers / charm / prometheus-k8s / README.md
1 <!-- Copyright 2021 Canonical Ltd.
2
3 Licensed under the Apache License, Version 2.0 (the "License"); you may
4 not use this file except in compliance with the License. You may obtain
5 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, WITHOUT
11 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 License for the specific language governing permissions and limitations
13 under the License.
14
15 For those usages not covered by the Apache License, Version 2.0 please
16 contact: legal@canonical.com
17
18 To get in touch with the maintainers, please contact:
19 osm-charmers@lists.launchpad.net -->
20
21 # Overview
22
23 Prometheus for Juju CAAS
24
25 ## Testing
26
27 The tests of this charm are done using tox and Zaza.
28
29
30
31 ### Prepare environment
32
33 The machine in which the tests are run needs access to a juju k8s controller. The easiest way to approach this is by executing the following commands:
34
35 ```
36 sudo apt install tox -y
37 sudo snap install microk8s --classic
38 sudo snap install juju
39
40 microk8s.status --wait-ready
41 microk8s.enable storage dashboard dns
42
43 juju bootstrap microk8s k8s-cloud
44 ```
45
46 If /usr/bin/python does not exist, you should probably need to do this:
47
48 ```
49 sudo ln -s /usr/bin/python3 /usr/bin/python
50 ```
51 ### Build Charm
52
53 **Download dependencies:**
54
55 ```
56 mkdir -p ~/charm/layers ~/charm/build ~/charm/interfaces
57 git clone https://git.launchpad.net/canonical-osm ~/canonical-osm
58
59 cd ~/charm/layers
60 git clone https://git.launchpad.net/charm-k8s-prometheus prometheus-k8s 
61
62 cd ~/charm/interfaces
63 mv ~/canonical-osm/charms/interfaces/* .
64 ```
65
66 **Charm structure:**
67
68 ```
69 ├── config.yaml
70 ├── icon.svg
71 ├── layer.yaml
72 ├── metadata.yaml
73 ├── reactive
74 │   ├── spec_template.yaml
75 │   └── prometheus.py
76 ├── README.md
77 ├── test-requirements.txt
78 ├── tests
79 │   ├── basic_deployment.py
80 │   ├── bundles
81 │   │   ├── prometheus-ha.yaml
82 │   │   └── prometheus.yaml
83 │   └── tests.yaml
84 └── tox.ini
85 ```
86
87 **Setup environment variables:**
88
89 ```
90 export CHARM_LAYERS_DIR=~/charm/layers
91 export CHARM_BUILD_DIR=~/charm/build
92 export CHARM_INTERFACES_DIR=~/charm/interfaces
93 ```
94
95 **Build:**
96
97 ```
98 mkdir ~/charm/layers/prometheus-k8s/tests/build
99 charm build ~/charm/layers/prometheus-k8s
100 mv ~/charm/build/* ~/charm/layers/prometheus-k8s/tests/build/
101 ```
102
103 ### Test charm with Tox
104
105 ```
106 cd ~/charm/layers/prometheus-k8s
107 tox -e func
108 ```