From 47f8a9e1d4831437c8575d78a86ee03dbd0fe479 Mon Sep 17 00:00:00 2001 From: beierlm Date: Wed, 22 Jun 2022 10:12:29 -0400 Subject: [PATCH] Removing deprecated files Removing old charm files that are no longer in use Change-Id: I4aaf35a3708f47bd04beffcba8e2fbd850e1f433 Signed-off-by: beierlm --- installers/charm/grafana-k8s/.gitignore | 24 -- installers/charm/grafana-k8s/.yamllint.yaml | 34 -- installers/charm/grafana-k8s/README.md | 23 - installers/charm/grafana-k8s/config.yaml | 34 -- installers/charm/grafana-k8s/icon.svg | 85 ---- installers/charm/grafana-k8s/layer.yaml | 29 -- installers/charm/grafana-k8s/metadata.yaml | 34 -- .../charm/grafana-k8s/reactive/grafana.py | 104 ----- .../grafana-k8s/reactive/spec_template.yaml | 71 ---- .../charm/grafana-k8s/test-requirements.txt | 22 - .../grafana-k8s/tests/basic_deployment.py | 60 --- .../grafana-k8s/tests/bundles/grafana-ha.yaml | 38 -- .../grafana-k8s/tests/bundles/grafana.yaml | 38 -- installers/charm/grafana-k8s/tests/tests.yaml | 28 -- installers/charm/grafana-k8s/tox.ini | 82 ---- installers/charm/kafka-k8s/.gitignore | 24 -- installers/charm/kafka-k8s/.yamllint.yaml | 34 -- installers/charm/kafka-k8s/README.md | 107 ----- installers/charm/kafka-k8s/config.yaml | 50 --- installers/charm/kafka-k8s/icon.svg | 21 - installers/charm/kafka-k8s/layer.yaml | 30 -- installers/charm/kafka-k8s/metadata.yaml | 44 -- installers/charm/kafka-k8s/reactive/kafka.py | 139 ------ .../kafka-k8s/reactive/spec_template.yaml | 140 ------- .../charm/kafka-k8s/test-requirements.txt | 22 - .../charm/kafka-k8s/tests/basic_deployment.py | 30 -- .../kafka-k8s/tests/bundles/kafka-ha.yaml | 44 -- .../charm/kafka-k8s/tests/bundles/kafka.yaml | 44 -- installers/charm/kafka-k8s/tests/tests.yaml | 28 -- installers/charm/kafka-k8s/tox.ini | 85 ---- installers/charm/kafka/.gitignore | 28 -- installers/charm/kafka/.jujuignore | 32 -- installers/charm/kafka/.yamllint.yaml | 32 -- installers/charm/kafka/README.md | 22 - installers/charm/kafka/charmcraft.yaml | 37 -- installers/charm/kafka/config.yaml | 36 -- installers/charm/kafka/icon.svg | 21 - installers/charm/kafka/metadata.yaml | 53 --- installers/charm/kafka/requirements-test.txt | 21 - installers/charm/kafka/requirements.txt | 22 - installers/charm/kafka/src/charm.py | 245 ----------- installers/charm/kafka/tests/__init__.py | 40 -- installers/charm/kafka/tests/test_charm.py | 75 ---- installers/charm/kafka/tox.ini | 126 ------ installers/charm/lcm-k8s/.yamllint.yaml | 25 -- installers/charm/lcm-k8s/README.md | 100 ----- installers/charm/lcm-k8s/config.yaml | 76 ---- installers/charm/lcm-k8s/icon.svg | 118 ------ installers/charm/lcm-k8s/layer.yaml | 23 - installers/charm/lcm-k8s/metadata.yaml | 37 -- installers/charm/lcm-k8s/reactive/lcm.py | 152 ------- .../charm/lcm-k8s/reactive/spec_template.yaml | 52 --- installers/charm/lcm-k8s/tox.ini | 64 --- installers/charm/mon-k8s/.yamllint.yaml | 24 -- installers/charm/mon-k8s/README.md | 95 ----- installers/charm/mon-k8s/config.yaml | 90 ---- installers/charm/mon-k8s/icon.svg | 118 ------ installers/charm/mon-k8s/layer.yaml | 22 - installers/charm/mon-k8s/metadata.yaml | 37 -- installers/charm/mon-k8s/reactive/mon_k8s.py | 123 ------ .../charm/mon-k8s/reactive/spec_template.yaml | 62 --- installers/charm/mon-k8s/tox.ini | 60 --- installers/charm/mongodb-k8s/.gitignore | 24 -- installers/charm/mongodb-k8s/.yamllint.yaml | 34 -- installers/charm/mongodb-k8s/README.md | 175 -------- installers/charm/mongodb-k8s/actions.yaml | 48 --- installers/charm/mongodb-k8s/actions/backup | 46 -- .../charm/mongodb-k8s/actions/is-primary | 25 -- .../charm/mongodb-k8s/actions/remove-backup | 25 -- installers/charm/mongodb-k8s/actions/restore | 25 -- installers/charm/mongodb-k8s/config.yaml | 58 --- installers/charm/mongodb-k8s/icon.svg | 395 ------------------ installers/charm/mongodb-k8s/layer.yaml | 29 -- installers/charm/mongodb-k8s/metadata.yaml | 41 -- .../charm/mongodb-k8s/reactive/mongo.py | 128 ------ .../mongodb-k8s/reactive/spec_template.yaml | 49 --- .../reactive/spec_template_ha.yaml | 63 --- .../charm/mongodb-k8s/test-requirements.txt | 23 - .../mongodb-k8s/tests/basic_deployment.py | 122 ------ .../mongodb-k8s/tests/bundles/mongodb-ha.yaml | 32 -- .../mongodb-k8s/tests/bundles/mongodb.yaml | 29 -- installers/charm/mongodb-k8s/tests/tests.yaml | 27 -- installers/charm/mongodb-k8s/tox.ini | 91 ---- installers/charm/nbi-k8s/.yamllint.yaml | 24 -- installers/charm/nbi-k8s/README.md | 95 ----- installers/charm/nbi-k8s/config.yaml | 46 -- installers/charm/nbi-k8s/icon.svg | 118 ------ installers/charm/nbi-k8s/layer.yaml | 25 -- installers/charm/nbi-k8s/metadata.yaml | 42 -- installers/charm/nbi-k8s/reactive/nbi.py | 246 ----------- .../charm/nbi-k8s/reactive/spec_template.yaml | 44 -- installers/charm/nbi-k8s/tox.ini | 60 --- installers/charm/nbi-k8s/wheelhouse.txt | 14 - installers/charm/pol-k8s/.yamllint.yaml | 24 -- installers/charm/pol-k8s/README.md | 95 ----- installers/charm/pol-k8s/config.yaml | 34 -- installers/charm/pol-k8s/icon.svg | 118 ------ installers/charm/pol-k8s/layer.yaml | 21 - installers/charm/pol-k8s/metadata.yaml | 35 -- installers/charm/pol-k8s/reactive/pol_k8s.py | 108 ----- .../charm/pol-k8s/reactive/spec_template.yaml | 51 --- installers/charm/pol-k8s/tox.ini | 60 --- installers/charm/prometheus-k8s/.gitignore | 24 -- .../charm/prometheus-k8s/.yamllint.yaml | 34 -- installers/charm/prometheus-k8s/README.md | 108 ----- installers/charm/prometheus-k8s/config.yaml | 46 -- installers/charm/prometheus-k8s/icon.svg | 12 - installers/charm/prometheus-k8s/layer.yaml | 28 -- installers/charm/prometheus-k8s/metadata.yaml | 41 -- .../prometheus-k8s/reactive/prometheus.py | 107 ----- .../reactive/spec_template.yaml | 68 --- .../prometheus-k8s/test-requirements.txt | 22 - .../prometheus-k8s/tests/basic_deployment.py | 61 --- .../tests/bundles/prometheus-ha.yaml | 31 -- .../tests/bundles/prometheus.yaml | 31 -- .../charm/prometheus-k8s/tests/tests.yaml | 28 -- installers/charm/prometheus-k8s/tox.ini | 82 ---- installers/charm/ro-k8s/.yamllint.yaml | 24 -- installers/charm/ro-k8s/README.md | 91 ---- installers/charm/ro-k8s/config.yaml | 46 -- installers/charm/ro-k8s/icon.svg | 118 ------ installers/charm/ro-k8s/layer.yaml | 24 -- installers/charm/ro-k8s/metadata.yaml | 40 -- installers/charm/ro-k8s/reactive/ro.py | 219 ---------- .../charm/ro-k8s/reactive/spec_template.yaml | 37 -- installers/charm/ro-k8s/tox.ini | 65 --- installers/charm/zookeeper/.gitignore | 28 -- installers/charm/zookeeper/.jujuignore | 32 -- installers/charm/zookeeper/.yamllint.yaml | 32 -- installers/charm/zookeeper/README.md | 22 - installers/charm/zookeeper/charmcraft.yaml | 37 -- installers/charm/zookeeper/config.yaml | 93 ----- installers/charm/zookeeper/icon.svg | 38 -- installers/charm/zookeeper/metadata.yaml | 51 --- .../charm/zookeeper/requirements-test.txt | 21 - installers/charm/zookeeper/requirements.txt | 22 - installers/charm/zookeeper/src/charm.py | 187 --------- installers/charm/zookeeper/tests/__init__.py | 40 -- .../charm/zookeeper/tests/test_charm.py | 94 ----- installers/charm/zookeeper/tox.ini | 126 ------ 140 files changed, 8575 deletions(-) delete mode 100644 installers/charm/grafana-k8s/.gitignore delete mode 100644 installers/charm/grafana-k8s/.yamllint.yaml delete mode 100644 installers/charm/grafana-k8s/README.md delete mode 100644 installers/charm/grafana-k8s/config.yaml delete mode 100644 installers/charm/grafana-k8s/icon.svg delete mode 100644 installers/charm/grafana-k8s/layer.yaml delete mode 100644 installers/charm/grafana-k8s/metadata.yaml delete mode 100644 installers/charm/grafana-k8s/reactive/grafana.py delete mode 100644 installers/charm/grafana-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/grafana-k8s/test-requirements.txt delete mode 100644 installers/charm/grafana-k8s/tests/basic_deployment.py delete mode 100644 installers/charm/grafana-k8s/tests/bundles/grafana-ha.yaml delete mode 100644 installers/charm/grafana-k8s/tests/bundles/grafana.yaml delete mode 100644 installers/charm/grafana-k8s/tests/tests.yaml delete mode 100644 installers/charm/grafana-k8s/tox.ini delete mode 100644 installers/charm/kafka-k8s/.gitignore delete mode 100644 installers/charm/kafka-k8s/.yamllint.yaml delete mode 100755 installers/charm/kafka-k8s/README.md delete mode 100755 installers/charm/kafka-k8s/config.yaml delete mode 100644 installers/charm/kafka-k8s/icon.svg delete mode 100644 installers/charm/kafka-k8s/layer.yaml delete mode 100755 installers/charm/kafka-k8s/metadata.yaml delete mode 100644 installers/charm/kafka-k8s/reactive/kafka.py delete mode 100644 installers/charm/kafka-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/kafka-k8s/test-requirements.txt delete mode 100644 installers/charm/kafka-k8s/tests/basic_deployment.py delete mode 100644 installers/charm/kafka-k8s/tests/bundles/kafka-ha.yaml delete mode 100644 installers/charm/kafka-k8s/tests/bundles/kafka.yaml delete mode 100644 installers/charm/kafka-k8s/tests/tests.yaml delete mode 100644 installers/charm/kafka-k8s/tox.ini delete mode 100644 installers/charm/kafka/.gitignore delete mode 100644 installers/charm/kafka/.jujuignore delete mode 100644 installers/charm/kafka/.yamllint.yaml delete mode 100644 installers/charm/kafka/README.md delete mode 100644 installers/charm/kafka/charmcraft.yaml delete mode 100644 installers/charm/kafka/config.yaml delete mode 100644 installers/charm/kafka/icon.svg delete mode 100644 installers/charm/kafka/metadata.yaml delete mode 100644 installers/charm/kafka/requirements-test.txt delete mode 100644 installers/charm/kafka/requirements.txt delete mode 100755 installers/charm/kafka/src/charm.py delete mode 100644 installers/charm/kafka/tests/__init__.py delete mode 100644 installers/charm/kafka/tests/test_charm.py delete mode 100644 installers/charm/kafka/tox.ini delete mode 100644 installers/charm/lcm-k8s/.yamllint.yaml delete mode 100644 installers/charm/lcm-k8s/README.md delete mode 100644 installers/charm/lcm-k8s/config.yaml delete mode 100644 installers/charm/lcm-k8s/icon.svg delete mode 100644 installers/charm/lcm-k8s/layer.yaml delete mode 100644 installers/charm/lcm-k8s/metadata.yaml delete mode 100644 installers/charm/lcm-k8s/reactive/lcm.py delete mode 100644 installers/charm/lcm-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/lcm-k8s/tox.ini delete mode 100644 installers/charm/mon-k8s/.yamllint.yaml delete mode 100644 installers/charm/mon-k8s/README.md delete mode 100644 installers/charm/mon-k8s/config.yaml delete mode 100644 installers/charm/mon-k8s/icon.svg delete mode 100644 installers/charm/mon-k8s/layer.yaml delete mode 100644 installers/charm/mon-k8s/metadata.yaml delete mode 100644 installers/charm/mon-k8s/reactive/mon_k8s.py delete mode 100644 installers/charm/mon-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/mon-k8s/tox.ini delete mode 100644 installers/charm/mongodb-k8s/.gitignore delete mode 100644 installers/charm/mongodb-k8s/.yamllint.yaml delete mode 100755 installers/charm/mongodb-k8s/README.md delete mode 100644 installers/charm/mongodb-k8s/actions.yaml delete mode 100755 installers/charm/mongodb-k8s/actions/backup delete mode 100755 installers/charm/mongodb-k8s/actions/is-primary delete mode 100755 installers/charm/mongodb-k8s/actions/remove-backup delete mode 100755 installers/charm/mongodb-k8s/actions/restore delete mode 100755 installers/charm/mongodb-k8s/config.yaml delete mode 100644 installers/charm/mongodb-k8s/icon.svg delete mode 100644 installers/charm/mongodb-k8s/layer.yaml delete mode 100755 installers/charm/mongodb-k8s/metadata.yaml delete mode 100644 installers/charm/mongodb-k8s/reactive/mongo.py delete mode 100644 installers/charm/mongodb-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/mongodb-k8s/reactive/spec_template_ha.yaml delete mode 100644 installers/charm/mongodb-k8s/test-requirements.txt delete mode 100644 installers/charm/mongodb-k8s/tests/basic_deployment.py delete mode 100644 installers/charm/mongodb-k8s/tests/bundles/mongodb-ha.yaml delete mode 100644 installers/charm/mongodb-k8s/tests/bundles/mongodb.yaml delete mode 100644 installers/charm/mongodb-k8s/tests/tests.yaml delete mode 100644 installers/charm/mongodb-k8s/tox.ini delete mode 100644 installers/charm/nbi-k8s/.yamllint.yaml delete mode 100755 installers/charm/nbi-k8s/README.md delete mode 100755 installers/charm/nbi-k8s/config.yaml delete mode 100644 installers/charm/nbi-k8s/icon.svg delete mode 100644 installers/charm/nbi-k8s/layer.yaml delete mode 100755 installers/charm/nbi-k8s/metadata.yaml delete mode 100644 installers/charm/nbi-k8s/reactive/nbi.py delete mode 100644 installers/charm/nbi-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/nbi-k8s/tox.ini delete mode 100644 installers/charm/nbi-k8s/wheelhouse.txt delete mode 100644 installers/charm/pol-k8s/.yamllint.yaml delete mode 100644 installers/charm/pol-k8s/README.md delete mode 100644 installers/charm/pol-k8s/config.yaml delete mode 100644 installers/charm/pol-k8s/icon.svg delete mode 100644 installers/charm/pol-k8s/layer.yaml delete mode 100644 installers/charm/pol-k8s/metadata.yaml delete mode 100644 installers/charm/pol-k8s/reactive/pol_k8s.py delete mode 100644 installers/charm/pol-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/pol-k8s/tox.ini delete mode 100644 installers/charm/prometheus-k8s/.gitignore delete mode 100644 installers/charm/prometheus-k8s/.yamllint.yaml delete mode 100755 installers/charm/prometheus-k8s/README.md delete mode 100755 installers/charm/prometheus-k8s/config.yaml delete mode 100644 installers/charm/prometheus-k8s/icon.svg delete mode 100644 installers/charm/prometheus-k8s/layer.yaml delete mode 100755 installers/charm/prometheus-k8s/metadata.yaml delete mode 100644 installers/charm/prometheus-k8s/reactive/prometheus.py delete mode 100644 installers/charm/prometheus-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/prometheus-k8s/test-requirements.txt delete mode 100644 installers/charm/prometheus-k8s/tests/basic_deployment.py delete mode 100644 installers/charm/prometheus-k8s/tests/bundles/prometheus-ha.yaml delete mode 100644 installers/charm/prometheus-k8s/tests/bundles/prometheus.yaml delete mode 100644 installers/charm/prometheus-k8s/tests/tests.yaml delete mode 100644 installers/charm/prometheus-k8s/tox.ini delete mode 100644 installers/charm/ro-k8s/.yamllint.yaml delete mode 100755 installers/charm/ro-k8s/README.md delete mode 100755 installers/charm/ro-k8s/config.yaml delete mode 100644 installers/charm/ro-k8s/icon.svg delete mode 100644 installers/charm/ro-k8s/layer.yaml delete mode 100755 installers/charm/ro-k8s/metadata.yaml delete mode 100644 installers/charm/ro-k8s/reactive/ro.py delete mode 100644 installers/charm/ro-k8s/reactive/spec_template.yaml delete mode 100644 installers/charm/ro-k8s/tox.ini delete mode 100644 installers/charm/zookeeper/.gitignore delete mode 100644 installers/charm/zookeeper/.jujuignore delete mode 100644 installers/charm/zookeeper/.yamllint.yaml delete mode 100644 installers/charm/zookeeper/README.md delete mode 100644 installers/charm/zookeeper/charmcraft.yaml delete mode 100644 installers/charm/zookeeper/config.yaml delete mode 100644 installers/charm/zookeeper/icon.svg delete mode 100644 installers/charm/zookeeper/metadata.yaml delete mode 100644 installers/charm/zookeeper/requirements-test.txt delete mode 100644 installers/charm/zookeeper/requirements.txt delete mode 100755 installers/charm/zookeeper/src/charm.py delete mode 100644 installers/charm/zookeeper/tests/__init__.py delete mode 100644 installers/charm/zookeeper/tests/test_charm.py delete mode 100644 installers/charm/zookeeper/tox.ini diff --git a/installers/charm/grafana-k8s/.gitignore b/installers/charm/grafana-k8s/.gitignore deleted file mode 100644 index 712eb963..00000000 --- a/installers/charm/grafana-k8s/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -release/ -__pycache__ -.tox diff --git a/installers/charm/grafana-k8s/.yamllint.yaml b/installers/charm/grafana-k8s/.yamllint.yaml deleted file mode 100644 index 21b95b5b..00000000 --- a/installers/charm/grafana-k8s/.yamllint.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - ---- - -extends: default -rules: - line-length: disable -yaml-files: - - '*.yaml' - - '*.yml' - - '.yamllint' -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/grafana-k8s/README.md b/installers/charm/grafana-k8s/README.md deleted file mode 100644 index ad66a557..00000000 --- a/installers/charm/grafana-k8s/README.md +++ /dev/null @@ -1,23 +0,0 @@ - - -# Overview - -Grafana for Juju CAAS diff --git a/installers/charm/grafana-k8s/config.yaml b/installers/charm/grafana-k8s/config.yaml deleted file mode 100644 index 2f606c10..00000000 --- a/installers/charm/grafana-k8s/config.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -options: - advertised-hostname: - description: Grafana Hostname - type: string - default: "grafana-k8s" - advertised-port: - description: Grafana Port - type: int - default: 3000 - image: - type: string - description: OCI image - default: rocks.canonical.com:443/grafana/grafana:latest diff --git a/installers/charm/grafana-k8s/icon.svg b/installers/charm/grafana-k8s/icon.svg deleted file mode 100644 index 093de146..00000000 --- a/installers/charm/grafana-k8s/icon.svg +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/installers/charm/grafana-k8s/layer.yaml b/installers/charm/grafana-k8s/layer.yaml deleted file mode 100644 index 0c9220d7..00000000 --- a/installers/charm/grafana-k8s/layer.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -includes: - - "layer:caas-base" - - 'layer:status' - - 'layer:leadership' - - "layer:osm-common" - - "interface:prometheus" - -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/grafana-k8s/metadata.yaml b/installers/charm/grafana-k8s/metadata.yaml deleted file mode 100644 index 1f5dbe77..00000000 --- a/installers/charm/grafana-k8s/metadata.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -name: "grafana-k8s" -summary: "Grafana charm for Kubernetes" -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy grafana -tags: - - "application" -series: - - "kubernetes" -requires: - prometheus: - interface: prometheus diff --git a/installers/charm/grafana-k8s/reactive/grafana.py b/installers/charm/grafana-k8s/reactive/grafana.py deleted file mode 100644 index 923aca6d..00000000 --- a/installers/charm/grafana-k8s/reactive/grafana.py +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -from charms.layer.caas_base import pod_spec_set -from charms.reactive import endpoint_from_flag -from charms.reactive import when, when_not, hook -from charms.reactive.flags import set_flag, clear_flag -from charmhelpers.core.hookenv import ( - log, - metadata, - config, -) -from charms import layer -from charmhelpers.core import hookenv -import traceback - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("grafana-k8s.configured") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("grafana-k8s.configured") - - -@when_not("endpoint.prometheus.available") -@when("leadership.is_leader") -def waiting_for_prometheus_interface(): - layer.status.waiting("Waiting for prometheus interface") - - -@when("endpoint.prometheus.available") -@when_not("grafana-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring grafana container") - try: - prometheus = endpoint_from_flag("endpoint.prometheus.available") - prometheus_url = prometheus.targets()[0]["targets"][0] - - if prometheus_url: - spec = make_pod_spec(prometheus_url) - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - set_flag("grafana-k8s.configured") - layer.status.active("ready") - - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - log(traceback.format_exc(), level=hookenv.ERROR) - - -@when("grafana-k8s.configured") -def set_grafana_active(): - layer.status.active("ready") - - -@when("endpoint.prometheus.available") -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -def make_pod_spec(prometheus_url): - """Make pod specification for Kubernetes - - Returns: - pod_spec: Pod specification for Kubernetes - """ - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - md = metadata() - cfg = config() - - data = { - "name": md.get("name"), - "docker_image": cfg.get("image"), - "prometheus_url": prometheus_url, - } - data.update(cfg) - return pod_spec_template % data diff --git a/installers/charm/grafana-k8s/reactive/spec_template.yaml b/installers/charm/grafana-k8s/reactive/spec_template.yaml deleted file mode 100644 index 10165848..00000000 --- a/installers/charm/grafana-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -version: 2 -containers: - - name: %(name)s - image: %(docker_image)s - ports: - - containerPort: %(advertised-port)s - protocol: TCP - files: - - name: dashboards - mountPath: /etc/grafana/provisioning/dashboards/ - files: - dashboards-osm.yml: | - apiVersion: 1 - providers: - - name: 'osm' - orgId: 1 - folder: '' - type: file - options: - path: /etc/grafana/provisioning/dashboards/ - - name: datasources - mountPath: /etc/grafana/provisioning/datasources/ - files: - datasource-prometheus.yml: | - datasources: - - access: proxy - editable: true - is_default: true - name: osm_prometheus - org_id: 1 - type: prometheus - url: http://%(prometheus_url)s - version: 1 - kubernetes: - readinessProbe: - httpGet: - path: /api/health - port: %(advertised-port)s - initialDelaySeconds: 10 - periodSeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 3 - livenessProbe: - httpGet: - path: /api/health - port: %(advertised-port)s - initialDelaySeconds: 60 - timeoutSeconds: 30 - failureThreshold: 10 \ No newline at end of file diff --git a/installers/charm/grafana-k8s/test-requirements.txt b/installers/charm/grafana-k8s/test-requirements.txt deleted file mode 100644 index b302c2e7..00000000 --- a/installers/charm/grafana-k8s/test-requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -git+https://github.com/davigar15/zaza.git#egg=zaza diff --git a/installers/charm/grafana-k8s/tests/basic_deployment.py b/installers/charm/grafana-k8s/tests/basic_deployment.py deleted file mode 100644 index 4cb760ab..00000000 --- a/installers/charm/grafana-k8s/tests/basic_deployment.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python3 -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -import unittest -import zaza.model as model -import requests as http -import time - - -def get_grafana_uri(): - ip = model.get_status().applications["grafana-k8s"]["public-address"] - port = 3000 - return "http://{}:{}".format(ip, port) - - -class BasicDeployment(unittest.TestCase): - def setUp(self): - ready = False - num_retries = 0 - while not ready and num_retries < 5: - if ( - model.get_status().applications["grafana-k8s"]["status"]["status"] - == "active" - ): - ready = True - else: - num_retries += 1 - time.sleep(5) - - def test_get_grafana_uri(self): - get_grafana_uri() - - def test_grafana_get_home(self): - grafana_uri = get_grafana_uri() - body = http.get("{}/api/dashboards/home".format(grafana_uri)) - self.assertEqual(body.status_code, 401) # TODO: Get API Token - - def test_grafana_get_tags(self): - grafana_uri = get_grafana_uri() - body = http.get("{}/api/dashboards/tags".format(grafana_uri)) - self.assertEqual(body.status_code, 401) # TODO: Get API Token diff --git a/installers/charm/grafana-k8s/tests/bundles/grafana-ha.yaml b/installers/charm/grafana-k8s/tests/bundles/grafana-ha.yaml deleted file mode 100644 index bce8ad62..00000000 --- a/installers/charm/grafana-k8s/tests/bundles/grafana-ha.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -bundle: kubernetes -applications: - prometheus-k8s: - charm: 'cs:~charmed-osm/prometheus-k8s' - channel: 'edge' - scale: 2 - options: - default-target: "mon-k8s:8000" - series: kubernetes - storage: - database: 50M - grafana-k8s: - charm: '../../release' - scale: 2 -relations: - - - 'grafana-k8s:prometheus' - - 'prometheus-k8s:prometheus' diff --git a/installers/charm/grafana-k8s/tests/bundles/grafana.yaml b/installers/charm/grafana-k8s/tests/bundles/grafana.yaml deleted file mode 100644 index d144d149..00000000 --- a/installers/charm/grafana-k8s/tests/bundles/grafana.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -bundle: kubernetes -applications: - prometheus-k8s: - charm: 'cs:~charmed-osm/prometheus-k8s' - channel: 'edge' - scale: 1 - options: - default-target: "mon-k8s:8000" - series: kubernetes - storage: - database: 50M - grafana-k8s: - charm: '../../release' - scale: 1 -relations: - - - 'grafana-k8s:prometheus' - - 'prometheus-k8s:prometheus' diff --git a/installers/charm/grafana-k8s/tests/tests.yaml b/installers/charm/grafana-k8s/tests/tests.yaml deleted file mode 100644 index 281044a1..00000000 --- a/installers/charm/grafana-k8s/tests/tests.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -gate_bundles: - - grafana - - grafana-ha -smoke_bundles: - - grafana -tests: - - tests.basic_deployment.BasicDeployment diff --git a/installers/charm/grafana-k8s/tox.ini b/installers/charm/grafana-k8s/tox.ini deleted file mode 100644 index 63875b34..00000000 --- a/installers/charm/grafana-k8s/tox.ini +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju -passenv = HOME TERM CS_API_* OS_* AMULET_* -deps = -r{toxinidir}/test-requirements.txt -install_command = - pip install {opts} {packages} - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = /tmp -whitelist_externals = git - charm - rm - mv -commands = - rm -rf /tmp/canonical-osm /tmp/osm-common - rm -rf release/ - git clone https://git.launchpad.net/charm-osm-common /tmp/osm-common - charm build . --build-dir /tmp - mv /tmp/grafana-k8s/ release/ - -[testenv:black] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . - yamllint . - flake8 reactive/ --max-line-length=88 - flake8 tests/ --max-line-length=88 - -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:func-noop] -basepython = python3 -commands = - true - -[testenv:func] -basepython = python3 -commands = functest-run-suite - - -[testenv:func-smoke] -basepython = python3 -commands = functest-run-suite --keep-model --smoke - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/kafka-k8s/.gitignore b/installers/charm/kafka-k8s/.gitignore deleted file mode 100644 index 712eb963..00000000 --- a/installers/charm/kafka-k8s/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -release/ -__pycache__ -.tox diff --git a/installers/charm/kafka-k8s/.yamllint.yaml b/installers/charm/kafka-k8s/.yamllint.yaml deleted file mode 100644 index 21b95b5b..00000000 --- a/installers/charm/kafka-k8s/.yamllint.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - ---- - -extends: default -rules: - line-length: disable -yaml-files: - - '*.yaml' - - '*.yml' - - '.yamllint' -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/kafka-k8s/README.md b/installers/charm/kafka-k8s/README.md deleted file mode 100755 index b5283a9d..00000000 --- a/installers/charm/kafka-k8s/README.md +++ /dev/null @@ -1,107 +0,0 @@ - - -# Overview - -Kafka for Juju CAAS - - -## Testing - -The tests of this charm are done using tox and Zaza. - - - -### Prepare environment - -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: - -``` -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dashboard dns - -juju bootstrap microk8s k8s-cloud -``` - -If /usr/bin/python does not exist, you should probably need to do this: - -``` -sudo ln -s /usr/bin/python3 /usr/bin/python -``` - -### Build Charm - -**Download dependencies:** - -``` -mkdir -p ~/charm/layers ~/charm/build -cd ~/charm/layers -git clone https://git.launchpad.net/charm-k8s-kafka kafka-k8s -git clone https://git.launchpad.net/charm-k8s-zookeeper zookeeper-k8s -git clone https://git.launchpad.net/charm-osm-common osm-common -``` - -**Charm structure:** - -``` -├── config.yaml -├── icon.svg -├── layer.yaml -├── metadata.yaml -├── reactive -│ ├── spec_template.yaml -│ └── kafka.py -├── README.md -├── test-requirements.txt -├── tests -│ ├── basic_deployment.py -│ ├── bundles -│ │ ├── kafka-ha.yaml -│ │ └── kafka.yaml -│ └── tests.yaml -└── tox.ini -``` - -**Setup environment variables:** - -``` -export CHARM_LAYERS_DIR=~/charm/layers -export CHARM_BUILD_DIR=~/charm/build -``` - -**Build:** - -``` -mkdir ~/charm/layers/kafka-k8s/tests/build -charm build ~/charm/layers/kafka-k8s -charm build ~/charm/layers/zookeeper-k8s -mv ~/charm/build/* ~/charm/layers/kafka-k8s/tests/build/ -``` - -### Test charm with Tox - -``` -cd ~/charm/layers/kafka-k8s -tox -e func -``` \ No newline at end of file diff --git a/installers/charm/kafka-k8s/config.yaml b/installers/charm/kafka-k8s/config.yaml deleted file mode 100755 index 3f925ceb..00000000 --- a/installers/charm/kafka-k8s/config.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -options: - advertised-hostname: - description: Kafka Hostname - type: string - default: "kafka-k8s" - advertised-port: - description: Kafka port - type: int - default: 9092 - kafka-units: - description: Kafka kafka-units - type: int - default: 1 - zookeeper-units: - description: Zookeeper kafka-units - type: int - default: 1 - zookeeper-service-name: - description: Zookeeper Service name - type: string - default: zookeeper-k8s-endpoints - image: - type: string - description: OCI image - default: rocks.canonical.com:443/wurstmeister/kafka:2.12-2.2.1 - num-partitions: - description: Kafka number of partitions per topic - type: int - default: 1 diff --git a/installers/charm/kafka-k8s/icon.svg b/installers/charm/kafka-k8s/icon.svg deleted file mode 100644 index de5ab1be..00000000 --- a/installers/charm/kafka-k8s/icon.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - kafka - Created with Sketch. - - - - - - - - - - - - - - - - - diff --git a/installers/charm/kafka-k8s/layer.yaml b/installers/charm/kafka-k8s/layer.yaml deleted file mode 100644 index d7277267..00000000 --- a/installers/charm/kafka-k8s/layer.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -includes: - - "layer:caas-base" - - 'layer:status' - - 'layer:leadership' - - "layer:osm-common" - - 'interface:kafka' - - 'interface:zookeeper' - -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/kafka-k8s/metadata.yaml b/installers/charm/kafka-k8s/metadata.yaml deleted file mode 100755 index 7c22ce22..00000000 --- a/installers/charm/kafka-k8s/metadata.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -name: "kafka-k8s" -summary: "Kafka charm for Kubernetes." -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy kafka. -tags: - - "application" -series: - - "kubernetes" -provides: - kafka: - interface: kafka -requires: - zookeeper: - interface: zookeeper -storage: - database: - type: filesystem - location: /var/lib/kafka -deployment: - type: stateful - service: cluster diff --git a/installers/charm/kafka-k8s/reactive/kafka.py b/installers/charm/kafka-k8s/reactive/kafka.py deleted file mode 100644 index 72ff5bcf..00000000 --- a/installers/charm/kafka-k8s/reactive/kafka.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -from charms.layer.caas_base import pod_spec_set -from charms.reactive import when, when_not, hook -from charms.reactive import endpoint_from_flag -from charms.reactive.flags import set_flag, clear_flag -from charmhelpers.core.hookenv import log, metadata, config -from charms import layer -from charms.osm.k8s import get_service_ip - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("kafka-k8s.configured") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("kafka-k8s.configured") - - -@when_not("zookeeper.ready") -@when("leadership.is_leader") -def waiting_for_zookeeper(): - layer.status.waiting("Waiting for Zookeeper to be ready") - - -@when("zookeeper.ready") -@when_not("kafka-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring kafka container") - try: - zookeeper = endpoint_from_flag("zookeeper.ready") - zk_units = zookeeper.zookeepers() - zk_unit = zk_units[0] - if zk_unit["port"]: - cfg = config() - zookeeper_uri = "" - zk_pod_base_name = "zookeeper-k8s" - zk_service_name = cfg.get("zookeeper-service-name") - zk_num = cfg.get("zookeeper-units") - if zk_num == 1: - zookeeper_uri = "{}:{}".format(zk_unit["host"], zk_unit["port"]) - else: - for i in range(0, zk_num): - if i: - zookeeper_uri += "," - zookeeper_uri += "{}-{}.{}:{}".format( - zk_pod_base_name, i, zk_service_name, zk_unit["port"] - ) - spec = make_pod_spec(zookeeper_uri) - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - set_flag("kafka-k8s.configured") - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - - -@when("kafka-k8s.configured") -def set_kafka_active(): - layer.status.active("ready") - - -@when("zookeeper.ready") -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -@when("kafka-k8s.configured") -@when("kafka.joined", "zookeeper.ready") -def serve_client(): - layer.status.maintenance("Sending kafka configuration") - try: - kafka = endpoint_from_flag("kafka.joined") - zookeeper = endpoint_from_flag("zookeeper.ready") - if zookeeper and kafka: - service_ip = get_service_ip("kafka") - if service_ip: - kafka.send_connection( - get_kafka_port(), service_ip, - ) - kafka.send_zookeepers(zookeeper.zookeepers()) - clear_flag("kafka.joined") - except Exception as e: - log("Fail sending kafka configuration: {}".format(e)) - - -def make_pod_spec(zookeeper_uri): - """Make pod specification for Kubernetes - - Args: - zookeeper_uri (str): Zookeeper hosts appended by comma. - Returns: - pod_spec: Pod specification for Kubernetes - """ - - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - md = metadata() - cfg = config() - - data = { - "name": md.get("name"), - "docker_image": cfg.get("image"), - "port": get_kafka_port(), - "zookeeper_uri": zookeeper_uri, - } - data.update(cfg) - return pod_spec_template % data - - -def get_kafka_port(): - """Returns Kafka port""" - cfg = config() - return cfg.get("advertised-port") diff --git a/installers/charm/kafka-k8s/reactive/spec_template.yaml b/installers/charm/kafka-k8s/reactive/spec_template.yaml deleted file mode 100644 index f083084e..00000000 --- a/installers/charm/kafka-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -version: 2 -containers: - - name: %(name)s - image: %(docker_image)s - ports: - - containerPort: %(advertised-port)s - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - ENABLE_AUTO_EXTEND: "true" - KAFKA_ADVERTISED_HOST_NAME: %(advertised-hostname)s - KAFKA_ADVERTISED_PORT: %(advertised-port)s - KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true" - KAFKA_RESERVED_BROKER_MAX_ID: "999999999" - command: - - sh - - -c - - "exec kafka-server-start.sh /opt/kafka/config/server.properties --override broker.id=${HOSTNAME##*-} \ - --override listeners=PLAINTEXT://:%(advertised-port)s \ - --override zookeeper.connect=%(zookeeper_uri)s \ - --override log.dir=/var/lib/kafka \ - --override auto.create.topics.enable=true \ - --override auto.leader.rebalance.enable=true \ - --override background.threads=10 \ - --override compression.type=producer \ - --override delete.topic.enable=false \ - --override leader.imbalance.check.interval.seconds=300 \ - --override leader.imbalance.per.broker.percentage=10 \ - --override log.flush.interval.messages=9223372036854775807 \ - --override log.flush.offset.checkpoint.interval.ms=60000 \ - --override log.flush.scheduler.interval.ms=9223372036854775807 \ - --override log.retention.bytes=-1 \ - --override log.retention.hours=168 \ - --override log.roll.hours=168 \ - --override log.roll.jitter.hours=0 \ - --override log.segment.bytes=1073741824 \ - --override log.segment.delete.delay.ms=60000 \ - --override message.max.bytes=1000012 \ - --override min.insync.replicas=1 \ - --override num.io.threads=8 \ - --override num.network.threads=%(kafka-units)s \ - --override num.recovery.threads.per.data.dir=1 \ - --override num.replica.fetchers=1 \ - --override offset.metadata.max.bytes=4096 \ - --override offsets.commit.required.acks=-1 \ - --override offsets.commit.timeout.ms=5000 \ - --override offsets.load.buffer.size=5242880 \ - --override offsets.retention.check.interval.ms=600000 \ - --override offsets.retention.minutes=1440 \ - --override offsets.topic.compression.codec=0 \ - --override offsets.topic.num.partitions=50 \ - --override offsets.topic.replication.factor=%(kafka-units)s \ - --override offsets.topic.segment.bytes=104857600 \ - --override queued.max.requests=500 \ - --override quota.consumer.default=9223372036854775807 \ - --override quota.producer.default=9223372036854775807 \ - --override replica.fetch.min.bytes=1 \ - --override replica.fetch.wait.max.ms=500 \ - --override replica.high.watermark.checkpoint.interval.ms=5000 \ - --override replica.lag.time.max.ms=10000 \ - --override replica.socket.receive.buffer.bytes=65536 \ - --override replica.socket.timeout.ms=30000 \ - --override request.timeout.ms=30000 \ - --override socket.receive.buffer.bytes=102400 \ - --override socket.request.max.bytes=104857600 \ - --override socket.send.buffer.bytes=102400 \ - --override unclean.leader.election.enable=true \ - --override zookeeper.session.timeout.ms=6000 \ - --override zookeeper.set.acl=false \ - --override broker.id.generation.enable=true \ - --override connections.max.idle.ms=600000 \ - --override controlled.shutdown.enable=true \ - --override controlled.shutdown.max.retries=3 \ - --override controlled.shutdown.retry.backoff.ms=5000 \ - --override controller.socket.timeout.ms=30000 \ - --override default.replication.factor=1 \ - --override fetch.purgatory.purge.interval.requests=1000 \ - --override group.max.session.timeout.ms=300000 \ - --override group.min.session.timeout.ms=6000 \ - --override log.cleaner.backoff.ms=15000 \ - --override log.cleaner.dedupe.buffer.size=134217728 \ - --override log.cleaner.delete.retention.ms=86400000 \ - --override log.cleaner.enable=true \ - --override log.cleaner.io.buffer.load.factor=0.9 \ - --override log.cleaner.io.buffer.size=524288 \ - --override log.cleaner.io.max.bytes.per.second=1.7976931348623157E308 \ - --override log.cleaner.min.cleanable.ratio=0.5 \ - --override log.cleaner.min.compaction.lag.ms=0 \ - --override log.cleaner.threads=1 \ - --override log.cleanup.policy=delete \ - --override log.index.interval.bytes=4096 \ - --override log.index.size.max.bytes=10485760 \ - --override log.message.timestamp.difference.max.ms=9223372036854775807 \ - --override log.message.timestamp.type=CreateTime \ - --override log.preallocate=false \ - --override log.retention.check.interval.ms=300000 \ - --override max.connections.per.ip=2147483647 \ - --override num.partitions=%(num-partitions)s \ - --override producer.purgatory.purge.interval.requests=1000 \ - --override replica.fetch.backoff.ms=1000 \ - --override replica.fetch.max.bytes=1048576 \ - --override replica.fetch.response.max.bytes=10485760 \ - --override reserved.broker.max.id=1000 " - kubernetes: - readinessProbe: - tcpSocket: - port: %(advertised-port)s - timeoutSeconds: 5 - periodSeconds: 5 - initialDelaySeconds: 10 - livenessProbe: - exec: - command: - - sh - - -c - - "/opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server=localhost:%(advertised-port)s" - initialDelaySeconds: 60 - timeoutSeconds: 10 - periodSeconds: 5 diff --git a/installers/charm/kafka-k8s/test-requirements.txt b/installers/charm/kafka-k8s/test-requirements.txt deleted file mode 100644 index b302c2e7..00000000 --- a/installers/charm/kafka-k8s/test-requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -git+https://github.com/davigar15/zaza.git#egg=zaza diff --git a/installers/charm/kafka-k8s/tests/basic_deployment.py b/installers/charm/kafka-k8s/tests/basic_deployment.py deleted file mode 100644 index 363089d9..00000000 --- a/installers/charm/kafka-k8s/tests/basic_deployment.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python3 -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -import unittest - -# import zaza.model as model - - -class BasicDeployment(unittest.TestCase): - def test_kafka(self): - pass diff --git a/installers/charm/kafka-k8s/tests/bundles/kafka-ha.yaml b/installers/charm/kafka-k8s/tests/bundles/kafka-ha.yaml deleted file mode 100644 index 7c70e41a..00000000 --- a/installers/charm/kafka-k8s/tests/bundles/kafka-ha.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -bundle: kubernetes -applications: - kafka-k8s: - charm: '../../release/' - scale: 2 - options: - zookeeper-units: 2 - kafka-units: 2 - series: kubernetes - storage: - database: 50M - zookeeper-k8s: - charm: 'cs:~charmed-osm/zookeeper-k8s' - channel: edge - scale: 2 - options: - zookeeper-units: 2 - series: kubernetes - storage: - database: 50M -relations: - - - 'kafka-k8s:zookeeper' - - 'zookeeper-k8s:zookeeper' diff --git a/installers/charm/kafka-k8s/tests/bundles/kafka.yaml b/installers/charm/kafka-k8s/tests/bundles/kafka.yaml deleted file mode 100644 index 99fd49bf..00000000 --- a/installers/charm/kafka-k8s/tests/bundles/kafka.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -bundle: kubernetes -applications: - kafka-k8s: - charm: '../../release/' - scale: 1 - options: - zookeeper-units: 1 - kafka-units: 1 - series: kubernetes - storage: - database: 50M - zookeeper-k8s: - charm: 'cs:~charmed-osm/zookeeper-k8s' - channel: edge - scale: 1 - options: - zookeeper-units: 1 - series: kubernetes - storage: - database: 50M -relations: - - - 'kafka-k8s:zookeeper' - - 'zookeeper-k8s:zookeeper' diff --git a/installers/charm/kafka-k8s/tests/tests.yaml b/installers/charm/kafka-k8s/tests/tests.yaml deleted file mode 100644 index c90cd258..00000000 --- a/installers/charm/kafka-k8s/tests/tests.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -gate_bundles: - - kafka - - kafka-ha -smoke_bundles: - - kafka -tests: - - tests.basic_deployment.BasicDeployment diff --git a/installers/charm/kafka-k8s/tox.ini b/installers/charm/kafka-k8s/tox.ini deleted file mode 100644 index a621d6a6..00000000 --- a/installers/charm/kafka-k8s/tox.ini +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju -passenv = HOME TERM CS_API_* OS_* AMULET_* -deps = -r{toxinidir}/test-requirements.txt -install_command = - pip install {opts} {packages} - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = /tmp - CHARM_INTERFACES_DIR = /tmp/canonical-osm/charms/interfaces/ -whitelist_externals = git - charm - mkdir - rm - mv - cp -commands = - rm -rf /tmp/canonical-osm /tmp/osm-common - rm -rf release/ - git clone https://git.launchpad.net/canonical-osm /tmp/canonical-osm - git clone https://git.launchpad.net/charm-osm-common /tmp/osm-common - charm build . --build-dir /tmp - mv /tmp/kafka-k8s/ release/ - -[testenv:black] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . - yamllint . - flake8 reactive/ --max-line-length=88 - flake8 tests/ --max-line-length=88 -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:func-noop] -basepython = python3 -commands = - true - -[testenv:func] -basepython = python3 -commands = functest-run-suite - - -[testenv:func-smoke] -basepython = python3 -commands = functest-run-suite --keep-model --smoke - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/kafka/.gitignore b/installers/charm/kafka/.gitignore deleted file mode 100644 index a85ce6d9..00000000 --- a/installers/charm/kafka/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -venv -.vscode -*.charm -.coverage -coverage.xml -.stestr -cover \ No newline at end of file diff --git a/installers/charm/kafka/.jujuignore b/installers/charm/kafka/.jujuignore deleted file mode 100644 index 3738c1c2..00000000 --- a/installers/charm/kafka/.jujuignore +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -venv -.vscode -*.charm -.coverage -coverage.xml -.gitignore -.stestr -cover -tests/ -requirements* -tox.ini diff --git a/installers/charm/kafka/.yamllint.yaml b/installers/charm/kafka/.yamllint.yaml deleted file mode 100644 index 5244c94f..00000000 --- a/installers/charm/kafka/.yamllint.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - ---- -extends: default - -yaml-files: - - "*.yaml" - - "*.yml" - - ".yamllint" -ignore: | - .tox - cover/ - venv diff --git a/installers/charm/kafka/README.md b/installers/charm/kafka/README.md deleted file mode 100644 index 851adae9..00000000 --- a/installers/charm/kafka/README.md +++ /dev/null @@ -1,22 +0,0 @@ - - -# Kafka operator Charm for Kubernetes - diff --git a/installers/charm/kafka/charmcraft.yaml b/installers/charm/kafka/charmcraft.yaml deleted file mode 100644 index 0a285a9d..00000000 --- a/installers/charm/kafka/charmcraft.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -type: charm -bases: - - build-on: - - name: ubuntu - channel: "20.04" - architectures: ["amd64"] - run-on: - - name: ubuntu - channel: "20.04" - architectures: - - amd64 - - aarch64 - - arm64 -parts: - charm: - build-packages: [git] diff --git a/installers/charm/kafka/config.yaml b/installers/charm/kafka/config.yaml deleted file mode 100644 index 4049d93f..00000000 --- a/installers/charm/kafka/config.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -options: - image_pull_policy: - description: | - ImagePullPolicy configuration for the pod. - Possible values: always, ifnotpresent, never - type: string - default: always - num_partitions: - description: Kafka number of partitions per topic - type: int - default: 1 - security_context: - description: Enables the security context of the pods - type: boolean - default: false diff --git a/installers/charm/kafka/icon.svg b/installers/charm/kafka/icon.svg deleted file mode 100644 index de5ab1be..00000000 --- a/installers/charm/kafka/icon.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - kafka - Created with Sketch. - - - - - - - - - - - - - - - - - diff --git a/installers/charm/kafka/metadata.yaml b/installers/charm/kafka/metadata.yaml deleted file mode 100644 index 78bbee69..00000000 --- a/installers/charm/kafka/metadata.yaml +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -name: osm-kafka -summary: "Kafka charm for Kubernetes." -description: | - A CAAS charm to deploy kafka. -series: - - kubernetes -tags: - - kubernetes - - osm - - kafka -min-juju-version: 2.8.0 -resources: - image: - type: oci-image - description: OSM docker image for kafka - upstream-source: "rocks.canonical.com:443/wurstmeister/kafka:2.12-2.2.1" -provides: - kafka: - interface: kafka -requires: - zookeeper: - interface: zookeeper -peers: - cluster: - interface: kafka-cluster -storage: - database: - type: filesystem - location: /var/lib/kafka -deployment: - type: stateful - service: cluster diff --git a/installers/charm/kafka/requirements-test.txt b/installers/charm/kafka/requirements-test.txt deleted file mode 100644 index 316f6d20..00000000 --- a/installers/charm/kafka/requirements-test.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net - -mock==4.0.3 diff --git a/installers/charm/kafka/requirements.txt b/installers/charm/kafka/requirements.txt deleted file mode 100644 index 1a8928c7..00000000 --- a/installers/charm/kafka/requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -git+https://github.com/charmed-osm/ops-lib-charmed-osm/@master \ No newline at end of file diff --git a/installers/charm/kafka/src/charm.py b/installers/charm/kafka/src/charm.py deleted file mode 100755 index 5be34047..00000000 --- a/installers/charm/kafka/src/charm.py +++ /dev/null @@ -1,245 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -# pylint: disable=E0213 - -import logging -from typing import NoReturn - - -from ops.framework import EventBase -from ops.main import main -from opslib.osm.charm import CharmedOsmBase, RelationsMissing -from opslib.osm.interfaces.kafka import KafkaCluster, KafkaServer -from opslib.osm.interfaces.zookeeper import ZookeeperClient -from opslib.osm.pod import ContainerV3Builder, PodSpecV3Builder -from opslib.osm.validator import ModelValidator, validator - -logger = logging.getLogger(__name__) - -KAFKA_PORT = 9092 -KAFKA_RESERVED_BROKER_MAX_ID = "999999999" - - -class ConfigModel(ModelValidator): - num_partitions: int - image_pull_policy: str - security_context: bool - - @validator("image_pull_policy") - def validate_image_pull_policy(cls, v): - values = { - "always": "Always", - "ifnotpresent": "IfNotPresent", - "never": "Never", - } - v = v.lower() - if v not in values.keys(): - raise ValueError("value must be always, ifnotpresent or never") - return values[v] - - -class KafkaCharm(CharmedOsmBase): - """Kafka Charm.""" - - def __init__(self, *args) -> NoReturn: - """Kafka Charm constructor.""" - super().__init__(*args, oci_image="image") - self.kafka_cluster = KafkaCluster(self, "cluster") - self.kafka_server = KafkaServer(self, "kafka") - self.zookeeper_client = ZookeeperClient(self, "zookeeper") - event_observer_mapping = { - self.on["cluster"].relation_changed: self.configure_pod, - self.on["kafka"].relation_joined: self._publish_info, - self.on["zookeeper"].relation_changed: self.configure_pod, - self.on["zookeeper"].relation_broken: self.configure_pod, - } - for event, observer in event_observer_mapping.items(): - self.framework.observe(event, observer) - - @property - def num_units(self): - return self.kafka_cluster.num_units - - def _publish_info(self, event: EventBase): - """Publishes Kafka information. - - Args: - event (EventBase): Kafka relation event. - """ - if self.unit.is_leader(): - self.kafka_server.publish_info(self.app.name, KAFKA_PORT) - - def _check_missing_dependencies(self): - if self.zookeeper_client.is_missing_data_in_app(): - raise RelationsMissing(["zookeeper"]) - - def build_pod_spec(self, image_info): - # Validate config - config = ConfigModel(**dict(self.config)) - - # Check relations - self._check_missing_dependencies() - - # Create Builder for the PodSpec - pod_spec_builder = PodSpecV3Builder( - enable_security_context=config.security_context - ) - - # Build Container - container_builder = ContainerV3Builder( - self.app.name, - image_info, - config.image_pull_policy, - run_as_non_root=config.security_context, - ) - - container_builder.add_port(name="kafka", port=KAFKA_PORT) - container_builder.add_tcpsocket_readiness_probe( - KAFKA_PORT, - initial_delay_seconds=10, - timeout_seconds=5, - period_seconds=5, - ) - container_builder.add_tcpsocket_liveness_probe( - KAFKA_PORT, - initial_delay_seconds=60, - timeout_seconds=10, - period_seconds=5, - ) - container_builder.add_envs( - { - "ENABLE_AUTO_EXTEND": "true", - "KAFKA_ADVERTISED_HOST_NAME": self.app.name, - "KAFKA_ADVERTISED_PORT": KAFKA_PORT, - "KAFKA_AUTO_CREATE_TOPICS_ENABLE": "true", - "KAFKA_RESERVED_BROKER_MAX_ID": KAFKA_RESERVED_BROKER_MAX_ID, - } - ) - container_builder.add_command( - [ - "sh", - "-c", - " ".join( - [ - "exec kafka-server-start.sh /opt/kafka/config/server.properties", - "--override broker.id=${HOSTNAME##*-}", - f"--override listeners=PLAINTEXT://:{KAFKA_PORT}", - f"--override zookeeper.connect={self.zookeeper_client.zookeeper_uri}", - "--override log.dir=/var/lib/kafka", - "--override auto.create.topics.enable=true", - "--override auto.leader.rebalance.enable=true", - "--override background.threads=10", - "--override compression.type=producer", - "--override delete.topic.enable=false", - "--override leader.imbalance.check.interval.seconds=300", - "--override leader.imbalance.per.broker.percentage=10", - "--override log.flush.interval.messages=9223372036854775807", - "--override log.flush.offset.checkpoint.interval.ms=60000", - "--override log.flush.scheduler.interval.ms=9223372036854775807", - "--override log.retention.bytes=-1", - "--override log.retention.hours=168", - "--override log.roll.hours=168", - "--override log.roll.jitter.hours=0", - "--override log.segment.bytes=1073741824", - "--override log.segment.delete.delay.ms=60000", - "--override message.max.bytes=1000012", - "--override min.insync.replicas=1", - "--override num.io.threads=8", - f"--override num.network.threads={self.num_units}", - "--override num.recovery.threads.per.data.dir=1", - "--override num.replica.fetchers=1", - "--override offset.metadata.max.bytes=4096", - "--override offsets.commit.required.acks=-1", - "--override offsets.commit.timeout.ms=5000", - "--override offsets.load.buffer.size=5242880", - "--override offsets.retention.check.interval.ms=600000", - "--override offsets.retention.minutes=1440", - "--override offsets.topic.compression.codec=0", - "--override offsets.topic.num.partitions=50", - f"--override offsets.topic.replication.factor={self.num_units}", - "--override offsets.topic.segment.bytes=104857600", - "--override queued.max.requests=500", - "--override quota.consumer.default=9223372036854775807", - "--override quota.producer.default=9223372036854775807", - "--override replica.fetch.min.bytes=1", - "--override replica.fetch.wait.max.ms=500", - "--override replica.high.watermark.checkpoint.interval.ms=5000", - "--override replica.lag.time.max.ms=10000", - "--override replica.socket.receive.buffer.bytes=65536", - "--override replica.socket.timeout.ms=30000", - "--override request.timeout.ms=30000", - "--override socket.receive.buffer.bytes=102400", - "--override socket.request.max.bytes=104857600", - "--override socket.send.buffer.bytes=102400", - "--override unclean.leader.election.enable=true", - "--override zookeeper.session.timeout.ms=6000", - "--override zookeeper.set.acl=false", - "--override broker.id.generation.enable=true", - "--override connections.max.idle.ms=600000", - "--override controlled.shutdown.enable=true", - "--override controlled.shutdown.max.retries=3", - "--override controlled.shutdown.retry.backoff.ms=5000", - "--override controller.socket.timeout.ms=30000", - "--override default.replication.factor=1", - "--override fetch.purgatory.purge.interval.requests=1000", - "--override group.max.session.timeout.ms=300000", - "--override group.min.session.timeout.ms=6000", - "--override log.cleaner.backoff.ms=15000", - "--override log.cleaner.dedupe.buffer.size=134217728", - "--override log.cleaner.delete.retention.ms=86400000", - "--override log.cleaner.enable=true", - "--override log.cleaner.io.buffer.load.factor=0.9", - "--override log.cleaner.io.buffer.size=524288", - "--override log.cleaner.io.max.bytes.per.second=1.7976931348623157E308", - "--override log.cleaner.min.cleanable.ratio=0.5", - "--override log.cleaner.min.compaction.lag.ms=0", - "--override log.cleaner.threads=1", - "--override log.cleanup.policy=delete", - "--override log.index.interval.bytes=4096", - "--override log.index.size.max.bytes=10485760", - "--override log.message.timestamp.difference.max.ms=9223372036854775807", - "--override log.message.timestamp.type=CreateTime", - "--override log.preallocate=false", - "--override log.retention.check.interval.ms=300000", - "--override max.connections.per.ip=2147483647", - f"--override num.partitions={config.num_partitions}", - "--override producer.purgatory.purge.interval.requests=1000", - "--override replica.fetch.backoff.ms=1000", - "--override replica.fetch.max.bytes=1048576", - "--override replica.fetch.response.max.bytes=10485760", - "--override reserved.broker.max.id=1000", - ] - ), - ] - ) - - container = container_builder.build() - - # Add container to pod spec - pod_spec_builder.add_container(container) - - return pod_spec_builder.build() - - -if __name__ == "__main__": - main(KafkaCharm) diff --git a/installers/charm/kafka/tests/__init__.py b/installers/charm/kafka/tests/__init__.py deleted file mode 100644 index 446d5cee..00000000 --- a/installers/charm/kafka/tests/__init__.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -"""Init mocking for unit tests.""" - -import sys - - -import mock - - -class OCIImageResourceErrorMock(Exception): - pass - - -sys.path.append("src") - -oci_image = mock.MagicMock() -oci_image.OCIImageResourceError = OCIImageResourceErrorMock -sys.modules["oci_image"] = oci_image -sys.modules["oci_image"].OCIImageResource().fetch.return_value = {} diff --git a/installers/charm/kafka/tests/test_charm.py b/installers/charm/kafka/tests/test_charm.py deleted file mode 100644 index 409dc0b8..00000000 --- a/installers/charm/kafka/tests/test_charm.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -from typing import NoReturn -import unittest -from unittest.mock import patch, PropertyMock - -from charm import KafkaCharm -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness - - -class TestCharm(unittest.TestCase): - """Kafka Charm unit tests.""" - - def setUp( - self, - ) -> NoReturn: - """Test setup""" - self.harness = Harness(KafkaCharm) - self.harness.set_leader(is_leader=True) - self.harness.begin() - self.config = {"num_partitions": 1} - self.harness.update_config(self.config) - - def test_config_changed_no_relations(self) -> NoReturn: - """Test config changed without relations.""" - self.harness.charm.on.config_changed.emit() - self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) - - def test_config_changed_non_leader(self) -> NoReturn: - """Test config changed without relations (non-leader).""" - self.harness.set_leader(is_leader=False) - self.harness.charm.on.config_changed.emit() - - # Assertions - self.assertIsInstance(self.harness.charm.unit.status, ActiveStatus) - - @patch("charm.KafkaCharm.num_units", new_callable=PropertyMock) - def test_with_relations_kafka(self, mock_num_units) -> NoReturn: - "Test with relations (kafka)" - mock_num_units.return_value = 1 - - # Initializing the kafka relation - zookeeper_relation_id = self.harness.add_relation("zookeeper", "zookeeper") - self.harness.add_relation_unit(zookeeper_relation_id, "zookeeper/0") - self.harness.update_relation_data( - zookeeper_relation_id, "zookeeper", {"zookeeper_uri": "zk-uri"} - ) - - # Verifying status - self.assertNotIsInstance(self.harness.charm.unit.status, BlockedStatus) - - -if __name__ == "__main__": - unittest.main() diff --git a/installers/charm/kafka/tox.ini b/installers/charm/kafka/tox.ini deleted file mode 100644 index 8e3318a4..00000000 --- a/installers/charm/kafka/tox.ini +++ /dev/null @@ -1,126 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## -####################################################################################### - -[tox] -envlist = black, cover, flake8, pylint, yamllint, safety -skipsdist = true - -[tox:jenkins] -toxworkdir = /tmp/.tox - -[testenv] -basepython = python3.8 -setenv = VIRTUAL_ENV={envdir} - PYTHONDONTWRITEBYTECODE = 1 -deps = -r{toxinidir}/requirements.txt - - -####################################################################################### -[testenv:black] -deps = black -commands = - black --check --diff src/ tests/ - - -####################################################################################### -[testenv:cover] -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - coverage - nose2 -commands = - sh -c 'rm -f nosetests.xml' - coverage erase - nose2 -C --coverage src - coverage report --omit='*tests*' - coverage html -d ./cover --omit='*tests*' - coverage xml -o coverage.xml --omit=*tests* -whitelist_externals = sh - - -####################################################################################### -[testenv:flake8] -deps = flake8 - flake8-import-order -commands = - flake8 src/ tests/ - - -####################################################################################### -[testenv:pylint] -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - pylint==2.10.2 -commands = - pylint -E src/ tests/ - - -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - safety -commands = - - safety check --full-report - - -####################################################################################### -[testenv:yamllint] -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - yamllint -commands = yamllint . - -####################################################################################### -[testenv:build] -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -whitelist_externals = - charmcraft - sh -commands = - charmcraft build - sh -c 'ubuntu_version=20.04; \ - architectures="amd64-aarch64-arm64"; \ - charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \ - mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm' - -####################################################################################### -[flake8] -ignore = - W291, - W293, - W503, - E123, - E125, - E226, - E241, -exclude = - .git, - __pycache__, - .tox, -max-line-length = 120 -show-source = True -builtins = _ -max-complexity = 10 -import-order-style = google diff --git a/installers/charm/lcm-k8s/.yamllint.yaml b/installers/charm/lcm-k8s/.yamllint.yaml deleted file mode 100644 index 86049d25..00000000 --- a/installers/charm/lcm-k8s/.yamllint.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. ---- - -extends: default - -yaml-files: - - '*.yaml' - - '*.yml' - - '.yamllint' -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/lcm-k8s/README.md b/installers/charm/lcm-k8s/README.md deleted file mode 100644 index 7b8d3fd6..00000000 --- a/installers/charm/lcm-k8s/README.md +++ /dev/null @@ -1,100 +0,0 @@ - - -# Overview - -LCM for Juju CAAS - -## Testing - -The tests of this charm are done using tox and Zaza. - - - -### Prepare environment - -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: - -``` -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dashboard dns - -juju bootstrap microk8s k8s-cloud -``` - -If /usr/bin/python does not exist, you should probably need to do this: - -``` -sudo ln -s /usr/bin/python3 /usr/bin/python -``` -### Build Charm - -**Download dependencies:** - -``` -mkdir -p ~/charm/layers ~/charm/build ~/charm/interfaces -git clone https://git.launchpad.net/canonical-osm ~/canonical-osm - -cd ~/charm/layers -git clone https://git.launchpad.net/charm-osm-lcm lcm-k8s -git clone https://git.launchpad.net/charm-osm-ro ro-k8s -git clone https://git.launchpad.net/charm-k8s-kafka kafka-k8s ~/charm/interfaces -git clone https://git.launchpad.net/charm-k8s-zookeeper zookeeper-k8s -git clone https://git.launchpad.net/charm-k8s-mongodb mongodb-k8s -git clone https://git.launchpad.net/charm-k8s-mariadb mariadb-k8s -git clone https://git.launchpad.net/charm-osm-ro ro-k8s - -cd ~/charm/interfaces -mv ~/canonical-osm/charms/interfaces/* . -git clone https://git.launchpad.net/interface-mongodb mongodb -git clone https://git.launchpad.net/interface-osm-ro osm-ro - -``` - -**Charm structure:** - -``` -├── config.yaml -├── icon.svg -├── layer.yaml -├── metadata.yaml -├── reactive -│ ├── spec_template.yaml -│ └── lcm.py -├── README.md -└── tox.ini -``` - -**Setup environment variables:** - -``` -export CHARM_LAYERS_DIR=~/charm/layers -export CHARM_BUILD_DIR=~/charm/build -export CHARM_INTERFACES_DIR=~/charm/interfaces -``` - -**Build:** - -``` -mkdir ~/charm/layers/lcm-k8s/tests/build -charm build ~/charm/layers/lcm-k8s -charm build ~/charm/layers/kafka-k8s -charm build ~/charm/layers/zookeeper-k8s -charm build ~/charm/layers/mongodb-k8s -charm build ~/charm/layers/mariadb-k8s -charm build ~/charm/layers/ro-k8s -mv ~/charm/build/* ~/charm/layers/lcm-k8s/tests/build/ -``` diff --git a/installers/charm/lcm-k8s/config.yaml b/installers/charm/lcm-k8s/config.yaml deleted file mode 100644 index 42282e60..00000000 --- a/installers/charm/lcm-k8s/config.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -options: - vca_host: - type: string - description: "The VCA host." - default: "admin" - vca_port: - type: int - description: "The VCA port." - default: 17070 - vca_user: - type: string - description: "The VCA user name." - default: "admin" - vca_password: - type: string - description: "The VCA user password." - default: "secret" - vca_pubkey: - type: string - description: "The VCA public key." - default: "secret" - vca_cacert: - type: string - description: "The VCA cacert." - default: "" - vca_apiproxy: - type: string - description: "The VCA api proxy (native charms)" - default: "" - vca_cloud: - type: string - description: "The VCA lxd cloud name" - default: "localhost" - vca_k8s_cloud: - type: string - description: "The VCA K8s cloud name" - default: "k8scloud" - advertised-hostname: - description: LCM Hostname - type: string - default: "lcm-k8s" - use_external_vca: - description: | - Boolean to deside whether LCM should wait - for an external VCA or not (using osm-vca interface) - type: boolean - default: false - DATABASE_COMMONKEY: - description: Database COMMONKEY - type: string - default: osm - image: - type: string - description: OCI image - default: opensourcemano/lcm:latest - image_username: - description: Docker repository username - type: string - default: "" - image_password: - description: Docker repository password - type: string - default: "" diff --git a/installers/charm/lcm-k8s/icon.svg b/installers/charm/lcm-k8s/icon.svg deleted file mode 100644 index da31b4ab..00000000 --- a/installers/charm/lcm-k8s/icon.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - image/svg+xml - - eclispe-che - - - - - - eclispe-che - Created with Sketch. - - - - - - - - - - - - - - - - - diff --git a/installers/charm/lcm-k8s/layer.yaml b/installers/charm/lcm-k8s/layer.yaml deleted file mode 100644 index 56b1af9a..00000000 --- a/installers/charm/lcm-k8s/layer.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -includes: - - "layer:caas-base" - - 'layer:status' - - 'layer:leadership' - - "layer:osm-common" - - 'interface:kafka' - - 'interface:mongodb' - - 'interface:osm-ro' - -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/lcm-k8s/metadata.yaml b/installers/charm/lcm-k8s/metadata.yaml deleted file mode 100644 index b44074c7..00000000 --- a/installers/charm/lcm-k8s/metadata.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -name: "lcm-k8s" -summary: "OSM LCM" -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy OSM's LCM. -tags: - - "application" -series: - - "kubernetes" -requires: - kafka: - interface: kafka - mongo: - interface: mongodb - ro: - interface: osm-ro -storage: - packages: - type: filesystem - location: /app/storage -deployment: - type: stateful - service: cluster diff --git a/installers/charm/lcm-k8s/reactive/lcm.py b/installers/charm/lcm-k8s/reactive/lcm.py deleted file mode 100644 index 87b6b2c2..00000000 --- a/installers/charm/lcm-k8s/reactive/lcm.py +++ /dev/null @@ -1,152 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import logging -import yaml - -from charmhelpers.core.hookenv import ( - log, - metadata, - config, -) -from charms import layer -from charms.layer.caas_base import pod_spec_set -from charms.reactive import endpoint_from_flag -from charms.reactive import when, when_not, hook -from charms.reactive.flags import set_flag, clear_flag - - -logger = logging.getLogger(__name__) - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("lcm-k8s.configured") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("lcm-k8s.configured") - - -@when_not("kafka.ready") -@when_not("lcm-k8s.configured") -@when("leadership.is_leader") -def waiting_for_kafka(): - layer.status.waiting("Waiting for kafka to be ready") - - -@when_not("mongo.ready") -@when_not("lcm-k8s.configured") -@when("leadership.is_leader") -def waiting_for_mongo(): - layer.status.waiting("Waiting for mongo to be ready") - - -@when_not("ro.ready") -@when_not("lcm-k8s.configured") -@when("leadership.is_leader") -def waiting_for_ro(): - layer.status.waiting("Waiting for ro to be ready") - - -@when("kafka.ready", "mongo.ready", "ro.ready") -@when_not("lcm-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring lcm container") - try: - kafka = endpoint_from_flag("kafka.ready") - mongo = endpoint_from_flag("mongo.ready") - osm_ro = endpoint_from_flag("ro.ready") - - if kafka and mongo and osm_ro: - kafka_units = kafka.kafkas() - kafka_unit = kafka_units[0] - - mongo_uri = mongo.connection_string() - log("Mongo URI: {}".format(mongo_uri)) - - ros = osm_ro.ros() - ro_unit = ros[0] - - if ( - mongo_uri - and kafka_unit["host"] - and kafka_unit["port"] - and ro_unit["host"] - and ro_unit["port"] - ): - spec = make_pod_spec( - ro_unit["host"], - ro_unit["port"], - kafka_unit["host"], - kafka_unit["port"], - mongo_uri, - ) - - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - layer.status.active("creating container") - set_flag("lcm-k8s.configured") - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - - -@when("kafka.ready", "mongo.ready", "ro.ready") -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -@when("lcm-k8s.configured") -@when("leadership.is_leader") -def set_lcm_active(): - layer.status.active("ready") - - -def make_pod_spec(ro_host, ro_port, kafka_host, kafka_port, mongo_uri): - """Make pod specification for Kubernetes - - Args: - ro_host (str): RO hostname or IP - ro_port (str): RO Port - kafka_host (str): Kafka hostname or IP - kafka_port (int): Kafka port - mongo_uri (str): Mongo URI - Returns: - pod_spec: Pod specification for Kubernetes - """ - - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - cfg = config() - md = metadata() - - data = { - "name": md.get("name"), - "ro_host": ro_host, - "ro_port": ro_port, - "kafka_host": kafka_host, - "kafka_port": kafka_port, - "mongo_uri": mongo_uri, - } - data.update(cfg) - logs = pod_spec_template % data - spec = yaml.safe_load(pod_spec_template % data) - if "vca_apiproxy" in cfg and cfg["vca_apiproxy"] != "": - spec["containers"][0]["config"]["OSMLCM_VCA_APIPROXY"] = cfg["vca_apiproxy"] - return spec diff --git a/installers/charm/lcm-k8s/reactive/spec_template.yaml b/installers/charm/lcm-k8s/reactive/spec_template.yaml deleted file mode 100644 index b5f508bc..00000000 --- a/installers/charm/lcm-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -version: 2 -containers: - - name: %(name)s - imageDetails: - imagePath: %(image)s - username: %(image_username)s - password: %(image_password)s - ports: - # This is a fake port; lcm doesn't listen, since it's just reading - # and responding to the kafka bus. Fix this in post. - - containerPort: 9999 - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - OSMLCM_RO_HOST: %(ro_host)s - OSMLCM_RO_PORT: %(ro_port)s - OSMLCM_RO_TENANT: osm - - OSMLCM_MESSAGE_DRIVER: kafka - OSMLCM_MESSAGE_HOST: %(kafka_host)s - OSMLCM_MESSAGE_PORT: %(kafka_port)s - - OSMLCM_DATABASE_DRIVER: mongo - OSMLCM_DATABASE_URI: %(mongo_uri)s - OSMLCM_DATABASE_COMMONKEY: %(DATABASE_COMMONKEY)s - - OSMLCM_STORAGE_DRIVER: mongo - OSMLCM_STORAGE_PATH: /app/storage - OSMLCM_STORAGE_COLLECTION: files - OSMLCM_STORAGE_URI: %(mongo_uri)s - - OSMLCM_VCA_HOST: %(vca_host)s - OSMLCM_VCA_PORT: %(vca_port)s - OSMLCM_VCA_USER: %(vca_user)s - OSMLCM_VCA_PUBKEY: %(vca_pubkey)s - OSMLCM_VCA_SECRET: %(vca_password)s - OSMLCM_VCA_CACERT: %(vca_cacert)s - OSMLCM_VCA_CLOUD: %(vca_cloud)s - OSMLCM_VCA_K8S_CLOUD: %(vca_k8s_cloud)s diff --git a/installers/charm/lcm-k8s/tox.ini b/installers/charm/lcm-k8s/tox.ini deleted file mode 100644 index 43934c26..00000000 --- a/installers/charm/lcm-k8s/tox.ini +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju - sleep -passenv = HOME TERM CS_API_* OS_* AMULET_* -install_command = - pip install {opts} {packages} - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = ../layers - CHARM_INTERFACES_DIR = ../interfaces/ -whitelist_externals = git - charm - rm - mv -commands = - rm -rf release - rm -rf ../interfaces/mongodb - git clone https://git.launchpad.net/interface-mongodb ../interfaces/mongodb - charm build . --build-dir /tmp - mv /tmp/lcm-k8s/ release/ - -[testenv:lint] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . --exclude "release/|.tox/" - yamllint . - flake8 reactive/ --max-line-length=100 - -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:func] -basepython = python3 -commands = python -c "print('Done')" - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/mon-k8s/.yamllint.yaml b/installers/charm/mon-k8s/.yamllint.yaml deleted file mode 100644 index d24a69d9..00000000 --- a/installers/charm/mon-k8s/.yamllint.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. ---- -extends: default - -yaml-files: - - "*.yaml" - - "*.yml" - - ".yamllint" -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/mon-k8s/README.md b/installers/charm/mon-k8s/README.md deleted file mode 100644 index 9b09230e..00000000 --- a/installers/charm/mon-k8s/README.md +++ /dev/null @@ -1,95 +0,0 @@ - - -# Overview - -MON for Juju CAAS - -## Testing - -The tests of this charm are done using tox and Zaza. - - - -### Prepare environment - -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: - -``` -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dashboard dns - -juju bootstrap microk8s k8s-cloud -``` - -If /usr/bin/python does not exist, you should probably need to do this: - -``` -sudo ln -s /usr/bin/python3 /usr/bin/python -``` -### Build Charm - -**Download dependencies:** - -``` -mkdir -p ~/charm/layers ~/charm/build ~/charm/interfaces -git clone https://git.launchpad.net/canonical-osm ~/canonical-osm - -cd ~/charm/layers -git clone https://git.launchpad.net/charm-osm-mon mon-k8s -git clone https://git.launchpad.net/charm-osm-ro ro-k8s -git clone https://git.launchpad.net/charm-k8s-kafka kafka-k8s ~/charm/interfaces -git clone https://git.launchpad.net/charm-k8s-zookeeper zookeeper-k8s -git clone https://git.launchpad.net/charm-k8s-mongodb mongodb-k8s - -cd ~/charm/interfaces -mv ~/canonical-osm/charms/interfaces/* . -git clone https://git.launchpad.net/interface-mongodb mongodb - -``` - -**Charm structure:** - -``` -├── config.yaml -├── icon.svg -├── layer.yaml -├── metadata.yaml -├── reactive -│ ├── spec_template.yaml -│ └── mon.py -├── README.md -└── tox.ini -``` - -**Setup environment variables:** - -``` -export CHARM_LAYERS_DIR=~/charm/layers -export CHARM_BUILD_DIR=~/charm/build -export CHARM_INTERFACES_DIR=~/charm/interfaces -``` - -**Build:** - -``` -mkdir ~/charm/layers/mon-k8s/tests/build -charm build ~/charm/layers/mon-k8s -charm build ~/charm/layers/kafka-k8s -charm build ~/charm/layers/zookeeper-k8s -charm build ~/charm/layers/mongodb-k8s -mv ~/charm/build/* ~/charm/layers/mon-k8s/tests/build/ -``` diff --git a/installers/charm/mon-k8s/config.yaml b/installers/charm/mon-k8s/config.yaml deleted file mode 100644 index cd903a52..00000000 --- a/installers/charm/mon-k8s/config.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -options: - advertised-hostname: - description: MON Hostname - type: string - default: "mon-k8s" - advertised-port: - description: MON Port - type: int - default: 8000 - OSMMON_OPENSTACK_DEFAULT_GRANULARITY: - description: Openstack default granularity - type: int - default: 300 - OSMMON_GLOBAL_REQUEST_TIMEOUT: - description: Global request timeout - type: int - default: 10 - OSMMON_GLOBAL_LOGLEVEL: - description: Global LOGLEVEL - type: string - default: INFO - OSMMON_DATABASE_COMMONKEY: - description: Database COMMONKEY - type: string - default: osm - OSMMON_COLLECTOR_INTERVAL: - description: Collector interval - type: int - default: 30 - OSMMON_EVALUATOR_INTERVAL: - description: Evaluator interval - type: int - default: 30 - vca_host: - type: string - description: "The VCA host." - default: "admin" - vca_user: - type: string - description: "The VCA user name." - default: "admin" - vca_password: - type: string - description: "The VCA user password." - default: "secret" - vca_cacert: - type: string - description: "The VCA cacert." - default: "" - use_external_vca: - description: Use an external VCA (deprecated) - type: boolean - default: false - image: - type: string - description: OCI image - default: opensourcemano/mon:latest - image_username: - description: Docker repository username - type: string - default: "" - image_password: - description: Docker repository password - type: string - default: "" - grafana_url: - description: Grafana URL - type: string - default: http://grafana-k8s:3000 - grafana_user: - description: Grafana user - type: string - default: admin - grafana_password: - description: Grafana password - type: string - default: admin diff --git a/installers/charm/mon-k8s/icon.svg b/installers/charm/mon-k8s/icon.svg deleted file mode 100644 index da31b4ab..00000000 --- a/installers/charm/mon-k8s/icon.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - image/svg+xml - - eclispe-che - - - - - - eclispe-che - Created with Sketch. - - - - - - - - - - - - - - - - - diff --git a/installers/charm/mon-k8s/layer.yaml b/installers/charm/mon-k8s/layer.yaml deleted file mode 100644 index 060f454d..00000000 --- a/installers/charm/mon-k8s/layer.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -includes: - - "layer:caas-base" - - "layer:status" - - "layer:leadership" - - "layer:osm-common" - - "interface:kafka" - - "interface:mongodb" - - "interface:prometheus" -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/mon-k8s/metadata.yaml b/installers/charm/mon-k8s/metadata.yaml deleted file mode 100644 index 41c33c5d..00000000 --- a/installers/charm/mon-k8s/metadata.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -name: mon-k8s -summary: "OSM Monitoring Interface (MON)" -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy OSM's Monitoring Interface (MON) -tags: - - "application" -series: - - "kubernetes" -requires: - kafka: - interface: kafka - mongo: - interface: mongodb - prometheus: - interface: prometheus -storage: - database: - type: filesystem - location: /app/database -deployment: - type: stateful - service: cluster diff --git a/installers/charm/mon-k8s/reactive/mon_k8s.py b/installers/charm/mon-k8s/reactive/mon_k8s.py deleted file mode 100644 index cd4d568d..00000000 --- a/installers/charm/mon-k8s/reactive/mon_k8s.py +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from charms.reactive import endpoint_from_flag -from charms.layer.caas_base import pod_spec_set -from charms.reactive import when, when_not, hook -from charms.reactive.flags import set_flag, clear_flag -from charmhelpers.core.hookenv import log, metadata, config -from charms import layer - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("mon-k8s.configured") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("mon-k8s.configured") - - -@when_not("kafka.ready") -@when_not("mon-k8s.configured") -@when("leadership.is_leader") -def waiting_for_kafka(): - layer.status.waiting("Waiting for kafka to be ready") - - -@when_not("mongo.ready") -@when_not("mon-k8s.configured") -@when("leadership.is_leader") -def waiting_for_mongo(): - layer.status.waiting("Waiting for mongo to be ready") - - -@when_not("endpoint.prometheus.available") -@when_not("mon-k8s.configured") -@when("leadership.is_leader") -def waiting_for_prometheus(): - layer.status.waiting("Waiting for prometheus to be ready") - - -@when("kafka.ready", "mongo.ready", "endpoint.prometheus.available") -@when_not("mon-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring mon container") - try: - kafka = endpoint_from_flag("kafka.ready") - mongo = endpoint_from_flag("mongo.ready") - prometheus = endpoint_from_flag("endpoint.prometheus.available") - - if kafka and mongo and prometheus: - kafka_units = kafka.kafkas() - kafka_unit = kafka_units[0] - - mongo_uri = mongo.connection_string() - log("Mongo URI: {}".format(mongo_uri)) - - prometheus_url = prometheus.targets()[0]["targets"][0] - - if mongo_uri and kafka_unit["host"]: - - spec = make_pod_spec( - kafka_unit["host"], kafka_unit["port"], mongo_uri, prometheus_url - ) - - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - set_flag("mon-k8s.configured") - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - - -@when("kafka.ready", "mongo.ready", "endpoint.prometheus.available") -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -@when("mon-k8s.configured") -def set_mon_active(): - layer.status.active("ready") - - -def make_pod_spec(kafka_host, kafka_port, mongo_uri, prometheus_url): - """Make pod specification for Kubernetes - - Args: - kafka_host (str): Kafka hostname or IP - kafka_port (int): Kafka port - mongo_uri (str): Mongo URI - Returns: - pod_spec: Pod specification for Kubernetes - """ - - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - md = metadata() - cfg = config() - - data = { - "name": md.get("name"), - "kafka_host": kafka_host, - "kafka_port": kafka_port, - "mongo_uri": mongo_uri, - "prometheus_url": prometheus_url, - } - data.update(cfg) - return pod_spec_template % data diff --git a/installers/charm/mon-k8s/reactive/spec_template.yaml b/installers/charm/mon-k8s/reactive/spec_template.yaml deleted file mode 100644 index 90c881d5..00000000 --- a/installers/charm/mon-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -version: 2 -containers: - - name: %(name)s - imageDetails: - imagePath: %(image)s - username: %(image_username)s - password: %(image_password)s - ports: - - containerPort: %(advertised-port)s - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - OSMMON_MESSAGE_DRIVER: kafka - OSMMON_MESSAGE_HOST: %(kafka_host)s - OSMMON_MESSAGE_PORT: %(kafka_port)s - - OSMMON_DATABASE_DRIVER: mongo - OSMMON_DATABASE_URI: %(mongo_uri)s - - OSMMON_OPENSTACK_DEFAULT_GRANULARITY: %(OSMMON_OPENSTACK_DEFAULT_GRANULARITY)s - OSMMON_GLOBAL_REQUEST_TIMEOUT: %(OSMMON_GLOBAL_REQUEST_TIMEOUT)s - OSMMON_GLOBAL_LOGLEVEL: %(OSMMON_GLOBAL_LOGLEVEL)s - OSMMON_VCA_HOST: %(vca_host)s - OSMMON_VCA_USER: %(vca_user)s - OSMMON_VCA_SECRET: %(vca_password)s - OSMMON_VCA_CACERT: %(vca_cacert)s - OSMMON_DATABASE_COMMONKEY: %(OSMMON_DATABASE_COMMONKEY)s - OSMMON_COLLECTOR_INTERVAL: %(OSMMON_COLLECTOR_INTERVAL)s - OSMMON_EVALUATOR_INTERVAL: %(OSMMON_EVALUATOR_INTERVAL)s - OSMMON_PROMETHEUS_URL: http://%(prometheus_url)s - OSMMON_GRAFANA_URL: %(grafana_url)s - OSMMON_GRAFANA_USER: %(grafana_user)s - OSMMON_GRAFANA_PASSWORD: %(grafana_password)s - kubernetes: - readinessProbe: - tcpSocket: - port: %(advertised-port)s - periodSeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 3 - livenessProbe: - tcpSocket: - port: %(advertised-port)s - initialDelaySeconds: 45 - periodSeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 3 \ No newline at end of file diff --git a/installers/charm/mon-k8s/tox.ini b/installers/charm/mon-k8s/tox.ini deleted file mode 100644 index 1954b2f9..00000000 --- a/installers/charm/mon-k8s/tox.ini +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju - sleep -passenv = HOME TERM CS_API_* OS_* AMULET_* -install_command = - pip install {opts} {packages} - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = ../layers - CHARM_INTERFACES_DIR = ../interfaces/ -whitelist_externals = git - charm - rm - mv -commands = - rm -rf release - rm -rf ../interfaces/mongodb - git clone https://git.launchpad.net/interface-mongodb ../interfaces/mongodb - charm build . --build-dir /tmp - mv /tmp/mon-k8s/ release/ - -[testenv:lint] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . --exclude "release/|.tox/" - yamllint . - flake8 reactive/ --max-line-length=100 - -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/mongodb-k8s/.gitignore b/installers/charm/mongodb-k8s/.gitignore deleted file mode 100644 index 712eb963..00000000 --- a/installers/charm/mongodb-k8s/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -release/ -__pycache__ -.tox diff --git a/installers/charm/mongodb-k8s/.yamllint.yaml b/installers/charm/mongodb-k8s/.yamllint.yaml deleted file mode 100644 index 21b95b5b..00000000 --- a/installers/charm/mongodb-k8s/.yamllint.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - ---- - -extends: default -rules: - line-length: disable -yaml-files: - - '*.yaml' - - '*.yml' - - '.yamllint' -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/mongodb-k8s/README.md b/installers/charm/mongodb-k8s/README.md deleted file mode 100755 index ce976d62..00000000 --- a/installers/charm/mongodb-k8s/README.md +++ /dev/null @@ -1,175 +0,0 @@ - - -# Overview - -Mongo for Juju CAAS - -## Actions - -### Backup - -Execute the following steps to do a backup. - -```bash -$ juju run-action mongodb-k8s/0 backup --wait -unit-mongodb-k8s-0: - UnitId: mongodb-k8s/0 - id: "7" - results: - Stderr: "2020-02-26T14:13:56.448+0000\twriting admin.system.version to archive - '/data/backup.archive'\n2020-02-26T14:13:56.451+0000\tdone dumping admin.system.version - (1 document)\n" - copy: - cmd: kubectl cp mongo-ha/mongodb-k8s-0:/data/backup.archive backup.archive - restore: - cmd: kubectl cp backup.archive mongo-ha/mongodb-k8s-0:/data/backup.archive - juju: juju action mongodb-k8s/0 restore --wait - status: completed - timing: - completed: 2020-02-26 14:13:57 +0000 UTC - enqueued: 2020-02-26 14:13:55 +0000 UTC - started: 2020-02-26 14:13:56 +0000 UTC -$ kubectl cp mongo-ha/mongodb-k8s-0:/data/backup.archive backup.archive -``` - -> Additional note: You can add `--string-args target=PRIMARY|SECONDARY` if you want this action to be run in a specific mongo unit. If `SECONDARY` is set, but the mongo unit isn't the `SECONDARY`, the action will fail. - -### Restore - -When the backup function is executed, you will see the commands you need to execute for restoring from a backup. - -```bash -$ kubectl cp backup.archive mongo-ha/mongodb-k8s-0:/data/backup.archive -Defaulting container name to mongodb-k8s. -$ juju run-action mongodb-k8s/0 restore --wait -unit-mongodb-k8s-0: - UnitId: mongodb-k8s/0 - id: "8" - results: - Stderr: "2020-02-26T14:17:00.300+0000\tpreparing collections to restore from\n2020-02-26T14:17:00.312+0000\t0 - document(s) restored successfully. 0 document(s) failed to restore.\n" - status: completed - timing: - completed: 2020-02-26 14:17:01 +0000 UTC - enqueued: 2020-02-26 14:16:57 +0000 UTC - started: 2020-02-26 14:17:00 +0000 UTC -``` - -### Remove backup - -When a backup is made, it is stored in the unit. To easily remove the backup, execute this action: - -```bash -$ juju run-action mongodb-k8s/0 remove-backup --wait -unit-mongodb-k8s-0: - UnitId: mongodb-k8s/0 - id: "4" - results: - Stdout: | - Backup successfully removed! - status: completed - timing: - completed: 2020-02-26 16:31:11 +0000 UTC - enqueued: 2020-02-26 16:31:08 +0000 UTC - started: 2020-02-26 16:31:10 +0000 UTC -``` - -### Is primary? - -To check if the unit is primary: - -```bash -$ juju run-action mongodb-k8s/0 is-primary --wait -unit-mongodb-k8s-0: - UnitId: mongodb-k8s/0 - id: "5" - results: - unit: - ip: 10.1.31.92 - primary: "true" - status: completed - timing: - completed: 2020-02-26 16:32:10 +0000 UTC - enqueued: 2020-02-26 16:32:08 +0000 UTC - started: 2020-02-26 16:32:09 +0000 UTC -$ juju run-action mongodb-k8s/1 is-primary --wait -unit-mongodb-k8s-1: - UnitId: mongodb-k8s/1 - id: "6" - results: - unit: - ip: 10.1.31.93 - primary: "false" - status: completed - timing: - completed: 2020-02-26 16:32:34 +0000 UTC - enqueued: 2020-02-26 16:32:32 +0000 UTC - started: 2020-02-26 16:32:33 +0000 UTC -``` - -## Backup remotely - -If we want to perform a backup remotely, follow the next steps: - -```bash -$ sudo apt install mongo-tools-y -$ juju status mongodb-k8s -Model Controller Cloud/Region Version SLA Timestamp -mongo-ha microk8s-localhost microk8s/localhost 2.7.2 unsupported 16:26:02+01:00 - -App Version Status Scale Charm Store Rev OS Address Notes -mongodb-k8s mongo:latest active 2 mongodb-k8s local 0 kubernetes 10.152.183.90 - -Unit Workload Agent Address Ports Message -mongodb-k8s/0* active idle 10.1.31.75 27017/TCP ready -mongodb-k8s/1 active idle 10.1.31.76 27017/TCP ready -$ mongodump --host 10.152.183.90 --port 27017 --gzip --archive=backup.archive --forceTableScan -2020-02-26T16:41:23.777+0100 writing admin.system.version to archive 'backup.archive' -2020-02-26T16:41:23.779+0100 done dumping admin.system.version (1 document) -$ mongorestore --host 10.152.183.90 --port 27017 --gzip --archive=backup.archive -``` - -## Testing - -The tests of this charm are done using tox and Zaza. - -### Prepare environment - -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: - -```bash -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dashboard dns - -juju bootstrap microk8s k8s-cloud -``` - -### Test charm with Tox - -```bash -tox -e black # Check syntax -tox -e build # Build the charm -tox -e func # Test charm -``` diff --git a/installers/charm/mongodb-k8s/actions.yaml b/installers/charm/mongodb-k8s/actions.yaml deleted file mode 100644 index b8572421..00000000 --- a/installers/charm/mongodb-k8s/actions.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -backup: - description: "Do a mongodb backup" - params: - target: - description: "The unit in which it should be performed the action. (ANY, PRIMARY, SECONDARY)" - type: string - default: "ANY" - path: - description: "Path for the backup inside the unit" - type: string - default: "/data" -restore: - description: "Restore from a MongoDB Backup" - params: - path: - description: "Path for the backup inside the unit" - type: string - default: "/data" -remove-backup: - description: "Remove backup from unit" - params: - path: - description: "Path for the backup inside the unit" - type: string - default: "/data" -is-primary: - description: "Check if the unit is the primary" diff --git a/installers/charm/mongodb-k8s/actions/backup b/installers/charm/mongodb-k8s/actions/backup deleted file mode 100755 index bd51d03b..00000000 --- a/installers/charm/mongodb-k8s/actions/backup +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -MASTER=`mongo --quiet --eval "d=db.isMaster(); print( d['ismaster'] );"` - -TARGET=`action-get target` -DB_BACKUP_PATH=`action-get path` - -mkdir -p $DB_BACKUP_PATH - -if [ "$TARGET" == "SECONDARY" ]; then - if [ "$MASTER" == "true" ]; then - action-fail "This action should be run in a Secondary" - exit - fi -elif [ "$TARGET" == "PRIMARY" ]; then - if [ "$MASTER" == "false" ]; then - action-fail "This action should be run in a Primary" - exit - fi -fi - -mongodump --gzip --archive=$DB_BACKUP_PATH/backup.archive -action-set copy.cmd="kubectl cp $JUJU_MODEL_NAME/$HOSTNAME:$DB_BACKUP_PATH/backup.archive backup.archive" -action-set restore.cmd="kubectl cp backup.archive $JUJU_MODEL_NAME/$HOSTNAME:$DB_BACKUP_PATH/backup.archive" -action-set restore.juju="juju run-action $JUJU_UNIT_NAME restore --wait" - diff --git a/installers/charm/mongodb-k8s/actions/is-primary b/installers/charm/mongodb-k8s/actions/is-primary deleted file mode 100755 index 2e8477b5..00000000 --- a/installers/charm/mongodb-k8s/actions/is-primary +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -MASTER=`mongo --quiet --eval "d=db.isMaster(); print( d['ismaster'] );"` -action-set unit.primary=$MASTER -action-set unit.ip=`network-get mongo --bind-address` \ No newline at end of file diff --git a/installers/charm/mongodb-k8s/actions/remove-backup b/installers/charm/mongodb-k8s/actions/remove-backup deleted file mode 100755 index 71918ed6..00000000 --- a/installers/charm/mongodb-k8s/actions/remove-backup +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -DB_BACKUP_PATH=`action-get path` -rm $DB_BACKUP_PATH/backup.archive || exit -echo Backup successfully removed! diff --git a/installers/charm/mongodb-k8s/actions/restore b/installers/charm/mongodb-k8s/actions/restore deleted file mode 100755 index 30ed2f9b..00000000 --- a/installers/charm/mongodb-k8s/actions/restore +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -DB_BACKUP_PATH=`action-get path` -mongorestore --gzip --archive=$DB_BACKUP_PATH/backup.archive --drop - diff --git a/installers/charm/mongodb-k8s/config.yaml b/installers/charm/mongodb-k8s/config.yaml deleted file mode 100755 index 74e3fc21..00000000 --- a/installers/charm/mongodb-k8s/config.yaml +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -options: - advertised-hostname: - description: MongoDB Hostname - type: string - default: mongodb-k8s - advertised-port: - description: MongoDB port - type: int - default: 27017 - replica-set: - description: Mongo Replica-set name - type: string - default: rs0 - namespace: - description: Kubernetes namespace - type: string - default: osm - service-name: - description: Headless service name - type: string - default: mongodb-k8s-endpoints - cluster-domain: - description: Cluster domain - type: string - default: cluster.local - enable-sidecar: - description: Enable sidecar - type: boolean - default: false - mongodb-image: - type: string - description: OCI image - default: rocks.canonical.com:443/mongo:latest - sidecar-image: - type: string - description: OCI image - default: rocks.canonical.com:443/cvallance/mongo-k8s-sidecar:latest diff --git a/installers/charm/mongodb-k8s/icon.svg b/installers/charm/mongodb-k8s/icon.svg deleted file mode 100644 index 811be4f8..00000000 --- a/installers/charm/mongodb-k8s/icon.svg +++ /dev/null @@ -1,395 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/installers/charm/mongodb-k8s/layer.yaml b/installers/charm/mongodb-k8s/layer.yaml deleted file mode 100644 index 3ffabb97..00000000 --- a/installers/charm/mongodb-k8s/layer.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -includes: - - "layer:caas-base" - - 'layer:status' - - 'layer:leadership' - - "layer:osm-common" - - 'interface:mongodb' - -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/mongodb-k8s/metadata.yaml b/installers/charm/mongodb-k8s/metadata.yaml deleted file mode 100755 index 4e279069..00000000 --- a/installers/charm/mongodb-k8s/metadata.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -name: "mongodb-k8s" -summary: "MongoDB charm for Kubernetes." -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy MongoDB. -tags: - - "application" -series: - - "kubernetes" -provides: - mongo: - interface: mongodb -storage: - database: - type: filesystem - location: /data/db -deployment: - type: stateful - service: cluster diff --git a/installers/charm/mongodb-k8s/reactive/mongo.py b/installers/charm/mongodb-k8s/reactive/mongo.py deleted file mode 100644 index 026f5ed0..00000000 --- a/installers/charm/mongodb-k8s/reactive/mongo.py +++ /dev/null @@ -1,128 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -from charms.layer.caas_base import pod_spec_set -from charms.reactive import endpoint_from_flag -from charms.reactive import when, when_not, hook -from charms.reactive.flags import set_flag, clear_flag -from charmhelpers.core.hookenv import log, metadata, config, goal_state -from charms import layer - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("mongodb-k8s.configured") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("mongodb-k8s.configured") - - -@when_not("mongodb-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring MongoDB container") - try: - spec = make_pod_spec() - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - set_flag("mongodb-k8s.configured") - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - - -@when("mongodb-k8s.configured") -def set_mongodb_active(): - layer.status.active("ready") - - -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -@when("mongodb-k8s.configured", "mongo.joined") -def send_config(): - layer.status.maintenance("Sending mongo configuration") - try: - mongo = endpoint_from_flag("mongo.joined") - if mongo: - cfg = config() - mongo_uri = "mongodb://" - for i, unit in enumerate(goal_state()["units"]): - pod_base_name = unit.split("/")[0] - service_name = cfg.get("service-name") - pod_name = "{}-{}".format(pod_base_name, i) - if i: - mongo_uri += "," - mongo_uri += "{}.{}:{}".format( - pod_name, service_name, get_mongodb_port() - ) - if cfg.get("enable-sidecar"): - mongo_uri += "/?replicaSet={}".format(get_mongodb_replset()) - log("Mongo URI: {}".format(mongo_uri)) - mongo.send_connection_string(mongo_uri) - clear_flag("mongo.joined") - except Exception as e: - log("Exception sending config: {}".format(e)) - clear_flag("mongo.joined") - - -def make_pod_spec(): - """Make pod specification for Kubernetes - - Returns: - pod_spec: Pod specification for Kubernetes - """ - md = metadata() - cfg = config() - - if cfg.get("enable-sidecar"): - with open("reactive/spec_template_ha.yaml") as spec_file: - pod_spec_template = spec_file.read() - else: - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - data = { - "name": md.get("name"), - "docker_image": cfg.get("mongodb-image"), - "sc_docker_image": cfg.get("sidecar-image"), - "pod_labels": "juju-app={}".format(cfg.get("advertised-hostname")), - } - - data.update(cfg) - return pod_spec_template % data - - -def get_mongodb_port(): - """Returns MongoDB port""" - cfg = config() - return cfg.get("advertised-port") - - -def get_mongodb_replset(): - """Returns MongoDB port""" - cfg = config() - return cfg.get("replica-set") diff --git a/installers/charm/mongodb-k8s/reactive/spec_template.yaml b/installers/charm/mongodb-k8s/reactive/spec_template.yaml deleted file mode 100644 index 035e9fb1..00000000 --- a/installers/charm/mongodb-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -version: 2 -containers: - - name: %(name)s - image: %(docker_image)s - command: - - mongod - - "--bind_ip" - - "0.0.0.0" - ports: - - containerPort: %(advertised-port)s - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - kubernetes: - readinessProbe: - tcpSocket: - port: %(advertised-port)s - timeoutSeconds: 5 - periodSeconds: 5 - initialDelaySeconds: 10 - livenessProbe: - exec: - command: - - /bin/sh - - -c - - mongo --port %(advertised-port)s --eval "rs.status()" | grep -vq "REMOVED" - initialDelaySeconds: 45 - timeoutSeconds: 5 diff --git a/installers/charm/mongodb-k8s/reactive/spec_template_ha.yaml b/installers/charm/mongodb-k8s/reactive/spec_template_ha.yaml deleted file mode 100644 index 60c44d4a..00000000 --- a/installers/charm/mongodb-k8s/reactive/spec_template_ha.yaml +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -version: 2 -serviceAccount: - rules: - - apiGroups: [""] - resources: ["pods"] - verbs: ["list"] -containers: - - name: %(name)s - image: %(docker_image)s - command: - - mongod - - "--replSet" - - %(replica-set)s - - "--bind_ip" - - "0.0.0.0" - ports: - - containerPort: %(advertised-port)s - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - kubernetes: - readinessProbe: - tcpSocket: - port: %(advertised-port)s - timeoutSeconds: 5 - periodSeconds: 5 - initialDelaySeconds: 10 - livenessProbe: - exec: - command: - - /bin/sh - - -c - - mongo --port %(advertised-port)s --eval "rs.status()" | grep -vq "REMOVED" - initialDelaySeconds: 45 - timeoutSeconds: 5 - - name: 'mongodb-sidecar-k8s' - image: %(sc_docker_image)s - config: - KUBERNETES_MONGO_SERVICE_NAME: %(service-name)s - KUBE_NAMESPACE: %(namespace)s - MONGO_SIDECAR_POD_LABELS: %(pod_labels)s - KUBERNETES_CLUSTER_DOMAIN: %(cluster-domain)s \ No newline at end of file diff --git a/installers/charm/mongodb-k8s/test-requirements.txt b/installers/charm/mongodb-k8s/test-requirements.txt deleted file mode 100644 index 4aac56da..00000000 --- a/installers/charm/mongodb-k8s/test-requirements.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -git+https://github.com/davigar15/zaza.git#egg=zaza -pymongo \ No newline at end of file diff --git a/installers/charm/mongodb-k8s/tests/basic_deployment.py b/installers/charm/mongodb-k8s/tests/basic_deployment.py deleted file mode 100644 index 3a8e9a35..00000000 --- a/installers/charm/mongodb-k8s/tests/basic_deployment.py +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/python3 -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -import unittest -import zaza.model as model -from pymongo import MongoClient - - -def get_mongo_uri(): - mongo_uri = "mongodb://" - mongo_units = model.get_status().applications["mongodb-k8s"]["units"] - for i, unit_name in enumerate(mongo_units.keys()): - if i: - mongo_uri += "," - unit_ip = mongo_units[unit_name]["address"] - unit_port = mongo_units[unit_name]["opened-ports"][0].split("/")[0] - mongo_uri += "{}:{}".format(unit_ip, unit_port) - - return mongo_uri - - -class BasicDeployment(unittest.TestCase): - def test_get_mongo_uri(self): - get_mongo_uri() - - def test_mongodb_connection(self): - mongo_uri = get_mongo_uri() - client = MongoClient(mongo_uri) - client.server_info() - - def test_mongodb_create_empty_database_collection(self): - mongo_uri = get_mongo_uri() - client = MongoClient(mongo_uri) - DB_NAME = "test_database" - COLLECTION_NAME = "test_collection" - - db = client[DB_NAME] - _ = client.list_database_names() - - collection = db[COLLECTION_NAME] - _ = db.list_collection_names() - - data = {} - - id = collection.insert_one(data) - - for x in collection.find({"_id": id.inserted_id}): - self.assertEqual(id.inserted_id, x["_id"]) - - def test_mongodb_insert_one(self): - mongo_uri = get_mongo_uri() - client = MongoClient(mongo_uri) - DB_NAME = "test_database" - COLLECTION_NAME = "test_collection" - - db = client[DB_NAME] - _ = client.list_database_names() - - collection = db[COLLECTION_NAME] - _ = db.list_collection_names() - - data = { - "name": "Canonical LTD", - "address": "5th Floor of the Blue Fin Building", - } - - id = collection.insert_one(data) - - for x in collection.find({"_id": id.inserted_id}): - self.assertEqual(id.inserted_id, x["_id"]) - - def test_mongodb_insert_many(self): - mongo_uri = get_mongo_uri() - client = MongoClient(mongo_uri) - DB_NAME = "test_database" - COLLECTION_NAME = "test_collection" - - db = client[DB_NAME] - _ = client.list_database_names() - - collection = db[COLLECTION_NAME] - _ = db.list_collection_names() - - data = [ - {"name": "Amy", "address": "Apple st 652"}, - {"name": "Hannah", "address": "Mountain 21"}, - {"name": "Michael", "address": "Valley 345"}, - {"name": "Sandy", "address": "Ocean blvd 2"}, - {"name": "Betty", "address": "Green Grass 1"}, - {"name": "Richard", "address": "Sky st 331"}, - {"name": "Susan", "address": "One way 98"}, - {"name": "Vicky", "address": "Yellow Garden 2"}, - {"name": "Ben", "address": "Park Lane 38"}, - {"name": "William", "address": "Central st 954"}, - {"name": "Chuck", "address": "Main Road 989"}, - {"name": "Viola", "address": "Sideway 1633"}, - ] - - ids = collection.insert_many(data) - - for id in ids.inserted_ids: - x = collection.find_one({"_id": id}) - self.assertEqual(x["_id"], id) diff --git a/installers/charm/mongodb-k8s/tests/bundles/mongodb-ha.yaml b/installers/charm/mongodb-k8s/tests/bundles/mongodb-ha.yaml deleted file mode 100644 index d08352bd..00000000 --- a/installers/charm/mongodb-k8s/tests/bundles/mongodb-ha.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -bundle: kubernetes -applications: - mongodb-k8s: - charm: '../../release/' - scale: 2 - options: - enable-sidecar: true - namespace: mongo-ha - series: kubernetes - storage: - database: 50M diff --git a/installers/charm/mongodb-k8s/tests/bundles/mongodb.yaml b/installers/charm/mongodb-k8s/tests/bundles/mongodb.yaml deleted file mode 100644 index 0f2cb1ab..00000000 --- a/installers/charm/mongodb-k8s/tests/bundles/mongodb.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -bundle: kubernetes -applications: - mongodb-k8s: - charm: '../../release/' - scale: 1 - series: kubernetes - storage: - database: 50M diff --git a/installers/charm/mongodb-k8s/tests/tests.yaml b/installers/charm/mongodb-k8s/tests/tests.yaml deleted file mode 100644 index f9a56072..00000000 --- a/installers/charm/mongodb-k8s/tests/tests.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -gate_bundles: - - mongodb -smoke_bundles: - - mongodb -tests: - - tests.basic_deployment.BasicDeployment diff --git a/installers/charm/mongodb-k8s/tox.ini b/installers/charm/mongodb-k8s/tox.ini deleted file mode 100644 index 354632fd..00000000 --- a/installers/charm/mongodb-k8s/tox.ini +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju -passenv = HOME TERM CS_API_* OS_* AMULET_* -deps = -r{toxinidir}/test-requirements.txt -install_command = - pip install {opts} {packages} - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = /tmp - CHARM_INTERFACES_DIR = /tmp/canonical-osm/charms/interfaces/ -whitelist_externals = git - charm - rm - mv -commands = - rm -rf /tmp/canonical-osm /tmp/osm-common - rm -rf release/ - git clone https://git.launchpad.net/canonical-osm /tmp/canonical-osm - git clone https://git.launchpad.net/charm-osm-common /tmp/osm-common - git clone https://git.launchpad.net/interface-mongodb /tmp/canonical-osm/charms/interfaces/mongodb - charm build . --build-dir /tmp - mv /tmp/mongodb-k8s/ release/ - -[testenv:black] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . - yamllint . - flake8 reactive/ --max-line-length=88 - flake8 tests/ --max-line-length=88 - -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:func-noop] -basepython = python3 -commands = - true - -[testenv:func] -basepython = python3 -commands = - functest-run-suite - functest-prepare -m mongo-ha - juju switch mongo-ha - functest-deploy -m mongo-ha -b ./tests/bundles/mongodb-ha.yaml - ; functest-test -m mongo-ha - functest-destroy -m mongo-ha - - -[testenv:func-smoke] -basepython = python3 -commands = functest-run-suite --keep-model --smoke - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/nbi-k8s/.yamllint.yaml b/installers/charm/nbi-k8s/.yamllint.yaml deleted file mode 100644 index d24a69d9..00000000 --- a/installers/charm/nbi-k8s/.yamllint.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. ---- -extends: default - -yaml-files: - - "*.yaml" - - "*.yml" - - ".yamllint" -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/nbi-k8s/README.md b/installers/charm/nbi-k8s/README.md deleted file mode 100755 index b4dc3d26..00000000 --- a/installers/charm/nbi-k8s/README.md +++ /dev/null @@ -1,95 +0,0 @@ - - -# Overview - -NBI for Juju CAAS - -## Testing - -The tests of this charm are done using tox and Zaza. - - - -### Prepare environment - -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: - -``` -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dashboard dns - -juju bootstrap microk8s k8s-cloud -``` - -If /usr/bin/python does not exist, you should probably need to do this: - -``` -sudo ln -s /usr/bin/python3 /usr/bin/python -``` -### Build Charm - -**Download dependencies:** - -``` -mkdir -p ~/charm/layers ~/charm/build ~/charm/interfaces -git clone https://git.launchpad.net/canonical-osm ~/canonical-osm - -cd ~/charm/layers -git clone https://git.launchpad.net/charm-osm-nbi nbi-k8s -git clone https://git.launchpad.net/charm-osm-ro ro-k8s -git clone https://git.launchpad.net/charm-k8s-kafka kafka-k8s ~/charm/interfaces -git clone https://git.launchpad.net/charm-k8s-zookeeper zookeeper-k8s -git clone https://git.launchpad.net/charm-k8s-mongodb mongodb-k8s - -cd ~/charm/interfaces -mv ~/canonical-osm/charms/interfaces/* . -git clone https://git.launchpad.net/interface-mongodb mongodb - -``` - -**Charm structure:** - -``` -├── config.yaml -├── icon.svg -├── layer.yaml -├── metadata.yaml -├── reactive -│ ├── spec_template.yaml -│ └── nbi.py -├── README.md -└── tox.ini -``` - -**Setup environment variables:** - -``` -export CHARM_LAYERS_DIR=~/charm/layers -export CHARM_BUILD_DIR=~/charm/build -export CHARM_INTERFACES_DIR=~/charm/interfaces -``` - -**Build:** - -``` -mkdir ~/charm/layers/nbi-k8s/tests/build -charm build ~/charm/layers/nbi-k8s -charm build ~/charm/layers/kafka-k8s -charm build ~/charm/layers/zookeeper-k8s -charm build ~/charm/layers/mongodb-k8s -mv ~/charm/build/* ~/charm/layers/nbi-k8s/tests/build/ -``` diff --git a/installers/charm/nbi-k8s/config.yaml b/installers/charm/nbi-k8s/config.yaml deleted file mode 100755 index 371fdf48..00000000 --- a/installers/charm/nbi-k8s/config.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -options: - advertised-hostname: - description: NBI Hostname - type: string - default: "nbi-k8s" - advertised-port: - description: NBI Port - type: int - default: 9999 - log_level: - description: "Log Level" - type: string - default: "DEBUG" - DATABASE_COMMONKEY: - description: Database COMMON KEY - type: string - default: osm - image: - type: string - description: OCI image - default: opensourcemano/nbi:latest - image_username: - description: Docker repository username - type: string - default: "" - image_password: - description: Docker repository password - type: string - default: "" - auth-backend: - type: string - description: Authentication backend ('internal' or 'keystone') - default: internal diff --git a/installers/charm/nbi-k8s/icon.svg b/installers/charm/nbi-k8s/icon.svg deleted file mode 100644 index da31b4ab..00000000 --- a/installers/charm/nbi-k8s/icon.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - image/svg+xml - - eclispe-che - - - - - - eclispe-che - Created with Sketch. - - - - - - - - - - - - - - - - - diff --git a/installers/charm/nbi-k8s/layer.yaml b/installers/charm/nbi-k8s/layer.yaml deleted file mode 100644 index 8bc365f9..00000000 --- a/installers/charm/nbi-k8s/layer.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -includes: - - "layer:caas-base" - - "layer:status" - - "layer:leadership" - - "layer:osm-common" - - "interface:kafka" - - "interface:mongodb" - - "interface:osm-nbi" - - "interface:prometheus" - - "interface:keystone" - -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/nbi-k8s/metadata.yaml b/installers/charm/nbi-k8s/metadata.yaml deleted file mode 100755 index 404cd2f0..00000000 --- a/installers/charm/nbi-k8s/metadata.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -name: "nbi-k8s" -summary: "OSM Northbound Interface (NBI)" -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy OSM's Northbound Interface (NBI). -tags: - - "application" -series: - - "kubernetes" -requires: - kafka: - interface: kafka - mongo: - interface: mongodb - keystone: - interface: keystone - prometheus: - interface: prometheus -provides: - nbi: - interface: osm-nbi -storage: - packages: - type: filesystem - location: /app/storage -deployment: - type: stateful - service: cluster diff --git a/installers/charm/nbi-k8s/reactive/nbi.py b/installers/charm/nbi-k8s/reactive/nbi.py deleted file mode 100644 index 50187ad8..00000000 --- a/installers/charm/nbi-k8s/reactive/nbi.py +++ /dev/null @@ -1,246 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from charms.layer.caas_base import pod_spec_set -from charms.reactive import endpoint_from_flag -from charms.reactive import when, when_not, hook -from charms.reactive.flags import set_flag, clear_flag -from charmhelpers.core.hookenv import ( - log, - metadata, - config, -) -from charms import layer -from charms.osm.k8s import get_service_ip -import urllib.parse -import yaml -import traceback - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("nbi-k8s.configured") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("nbi-k8s.configured") - - -@when("config.changed.auth-backend") -def clear_keystone_ready(): - clear_flag("keystone.ready") - - -@when_not("kafka.ready") -@when_not("nbi-k8s.configured") -@when("leadership.is_leader") -def waiting_for_kafka(): - layer.status.waiting("Waiting for kafka to be ready") - - -@when_not("mongo.ready") -@when_not("nbi-k8s.configured") -@when("leadership.is_leader") -def waiting_for_mongo(): - layer.status.waiting("Waiting for mongo to be ready") - - -@when_not("endpoint.prometheus.available") -@when_not("nbi-k8s.configured") -@when("leadership.is_leader") -def waiting_for_prometheus(): - layer.status.waiting("Waiting for prometheus to be ready") - - -@when_not("keystone.ready") -@when("leadership.is_leader") -@when_not("nbi-k8s.configured") -def waiting_for_keystone(): - auth_backend = config().get("auth-backend") - if auth_backend == "keystone": - layer.status.waiting("Waiting for Keystone to be ready") - else: - set_flag("keystone.ready") - - -@when_not("keystone.ready") -@when("leadership.is_leader") -@when_not("nbi-k8s.configured") -def waiting_for_keystone(): - auth_backend = config().get("auth-backend") - if auth_backend == "keystone": - layer.status.waiting("Waiting for Keystone to be ready") - else: - set_flag("keystone.ready") - - -@when("kafka.ready", "mongo.ready", "endpoint.prometheus.available", "keystone.ready") -@when_not("nbi-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring nbi container") - try: - kafka = endpoint_from_flag("kafka.ready") - mongo = endpoint_from_flag("mongo.ready") - prometheus = endpoint_from_flag("endpoint.prometheus.available") - - if kafka and mongo and prometheus: - kafka_units = kafka.kafkas() - kafka_unit = kafka_units[0] - - mongo_uri = mongo.connection_string() - log("Mongo URI: {}".format(mongo_uri)) - - prometheus_uri = prometheus.targets()[0]["targets"][0] - - if ( - mongo_uri - and kafka_unit["host"] - and kafka_unit["port"] - and prometheus_uri - ): - spec = yaml.load( - make_pod_spec( - kafka_unit["host"], - kafka_unit["port"], - mongo_uri, - prometheus_uri, - ) - ) - - auth_backend = config().get("auth-backend") - - if auth_backend == "keystone": - keystone = endpoint_from_flag("keystone.ready") - if keystone: - keystone_units = keystone.keystones() - keystone_unit = keystone_units[0] - if ( - keystone_unit["host"] - and keystone_unit["port"] - and keystone_unit["user_domain_name"] - and keystone_unit["project_domain_name"] - and keystone_unit["username"] - and keystone_unit["password"] - and keystone_unit["service"] - ): - auth_keystone = { - "OSMNBI_AUTHENTICATION_BACKEND": "keystone", - "OSMNBI_AUTHENTICATION_AUTH_URL": keystone_unit["host"], - "OSMNBI_AUTHENTICATION_AUTH_PORT": keystone_unit[ - "port" - ], - "OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME": keystone_unit[ - "user_domain_name" - ], - "OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME": keystone_unit[ - "project_domain_name" - ], - "OSMNBI_AUTHENTICATION_SERVICE_USERNAME": keystone_unit[ - "username" - ], - "OSMNBI_AUTHENTICATION_SERVICE_PASSWORD": keystone_unit[ - "password" - ], - "OSMNBI_AUTHENTICATION_SERVICE_PROJECT": keystone_unit[ - "service" - ], - } - spec["containers"][0]["config"].update(auth_keystone) - elif auth_backend == "internal": - spec["containers"][0]["config"][ - "OSMNBI_AUTHENTICATION_BACKEND" - ] = auth_backend - else: - layer.status.blocked( - "Unknown authentication method: {}".format(auth_backend) - ) - raise - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - set_flag("nbi-k8s.configured") - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - log("Error: {}".format(traceback.format_exc())) - - -@when("kafka.ready", "mongo.ready", "endpoint.prometheus.available") -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -@when("nbi-k8s.configured") -def set_nbi_active(): - layer.status.active("ready") - - -@when("nbi-k8s.configured", "nbi.joined") -def send_config(): - layer.status.maintenance("Sending NBI configuration") - try: - nbi = endpoint_from_flag("nbi.joined") - if nbi: - service_ip = get_service_ip("nbi") - if service_ip: - nbi.send_connection(service_ip, get_nbi_port()) - clear_flag("nbi.joined") - except Exception as e: - log("Fail sending NBI configuration: {}".format(e)) - - -def make_pod_spec(kafka_host, kafka_port, mongo_uri, prometheus_uri): - """Make pod specification for Kubernetes - - Args: - kafka_host (str): Kafka hostname or IP - kafka_port (int): Kafka port - mongo_uri (str): Mongo URI - prometheus_uri (str): Prometheus URI - Returns: - pod_spec: Pod specification for Kubernetes - """ - - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - md = metadata() - cfg = config() - prometheus_host, prometheus_port = parse_hostport(prometheus_uri) - data = { - "name": md.get("name"), - "mongo_uri": mongo_uri, - "kafka_host": "{}".format(kafka_host), - "kafka_port": "{}".format(kafka_port), - "prometheus_host": "{}".format(prometheus_host), - "prometheus_port": "{}".format(prometheus_port), - } - data.update(cfg) - - return pod_spec_template % data - - -def parse_hostport(uri): - if "//" in uri: - uri = uri.split("//")[1] - result = urllib.parse.urlsplit("//" + uri) - return result.hostname, result.port - - -def get_nbi_port(): - """Returns NBI port""" - cfg = config() - return cfg.get("advertised-port") diff --git a/installers/charm/nbi-k8s/reactive/spec_template.yaml b/installers/charm/nbi-k8s/reactive/spec_template.yaml deleted file mode 100644 index f9a35b69..00000000 --- a/installers/charm/nbi-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -version: 2 -containers: - - name: %(name)s - imageDetails: - imagePath: %(image)s - username: %(image_username)s - password: %(image_password)s - ports: - - containerPort: %(advertised-port)s - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - - OSMNBI_MESSAGE_HOST: %(kafka_host)s - OSMNBI_MESSAGE_DRIVER: kafka - OSMNBI_MESSAGE_PORT: %(kafka_port)s - - OSMNBI_DATABASE_DRIVER: mongo - OSMNBI_DATABASE_URI: %(mongo_uri)s - OSMNBI_DATABASE_COMMONKEY: %(DATABASE_COMMONKEY)s - - OSMNBI_STORAGE_DRIVER: mongo - OSMNBI_STORAGE_PATH: /app/storage - OSMNBI_STORAGE_COLLECTION: files - OSMNBI_STORAGE_URI: %(mongo_uri)s - - OSMNBI_STATIC_DIR: /app/osm_nbi/html_public - - OSMNBI_PROMETHEUS_HOST: %(prometheus_host)s - OSMNBI_PROMETHEUS_PORT: %(prometheus_port)s - OSMNBI_LOG_LEVEL: %(log_level)s diff --git a/installers/charm/nbi-k8s/tox.ini b/installers/charm/nbi-k8s/tox.ini deleted file mode 100644 index 537014a5..00000000 --- a/installers/charm/nbi-k8s/tox.ini +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju - sleep -passenv = HOME TERM CS_API_* OS_* AMULET_* -install_command = - pip install {opts} {packages} - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = ../layers - CHARM_INTERFACES_DIR = ../interfaces/ -whitelist_externals = git - charm - rm - mv -commands = - rm -rf release - rm -rf ../interfaces/mongodb - git clone https://git.launchpad.net/interface-mongodb ../interfaces/mongodb - charm build . --build-dir /tmp - mv /tmp/nbi-k8s/ release/ - -[testenv:lint] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . --exclude "release/|.tox/" - yamllint . - flake8 reactive/ --max-line-length=100 - -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/nbi-k8s/wheelhouse.txt b/installers/charm/nbi-k8s/wheelhouse.txt deleted file mode 100644 index 7c2badcd..00000000 --- a/installers/charm/nbi-k8s/wheelhouse.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -PyYAML \ No newline at end of file diff --git a/installers/charm/pol-k8s/.yamllint.yaml b/installers/charm/pol-k8s/.yamllint.yaml deleted file mode 100644 index d24a69d9..00000000 --- a/installers/charm/pol-k8s/.yamllint.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. ---- -extends: default - -yaml-files: - - "*.yaml" - - "*.yml" - - ".yamllint" -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/pol-k8s/README.md b/installers/charm/pol-k8s/README.md deleted file mode 100644 index a0227ac7..00000000 --- a/installers/charm/pol-k8s/README.md +++ /dev/null @@ -1,95 +0,0 @@ - - -# Overview - -POL for Juju CAAS - -## Testing - -The tests of this charm are done using tox and Zaza. - - - -### Prepare environment - -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: - -``` -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dashboard dns - -juju bootstrap microk8s k8s-cloud -``` - -If /usr/bin/python does not exist, you should probably need to do this: - -``` -sudo ln -s /usr/bin/python3 /usr/bin/python -``` -### Build Charm - -**Download dependencies:** - -``` -mkdir -p ~/charm/layers ~/charm/build ~/charm/interfaces -git clone https://git.launchpad.net/canonical-osm ~/canonical-osm - -cd ~/charm/layers -git clone https://git.launchpad.net/charm-osm-pol pol-k8s -git clone https://git.launchpad.net/charm-osm-ro ro-k8s -git clone https://git.launchpad.net/charm-k8s-kafka kafka-k8s ~/charm/interfaces -git clone https://git.launchpad.net/charm-k8s-zookeeper zookeeper-k8s -git clone https://git.launchpad.net/charm-k8s-mongodb mongodb-k8s - -cd ~/charm/interfaces -mv ~/canonical-osm/charms/interfaces/* . -git clone https://git.launchpad.net/interface-mongodb mongodb - -``` - -**Charm structure:** - -``` -├── config.yaml -├── icon.svg -├── layer.yaml -├── metadata.yaml -├── reactive -│ ├── spec_template.yaml -│ └── pol.py -├── README.md -└── tox.ini -``` - -**Setup environment variables:** - -``` -export CHARM_LAYERS_DIR=~/charm/layers -export CHARM_BUILD_DIR=~/charm/build -export CHARM_INTERFACES_DIR=~/charm/interfaces -``` - -**Build:** - -``` -mkdir ~/charm/layers/pol-k8s/tests/build -charm build ~/charm/layers/pol-k8s -charm build ~/charm/layers/kafka-k8s -charm build ~/charm/layers/zookeeper-k8s -charm build ~/charm/layers/mongodb-k8s -mv ~/charm/build/* ~/charm/layers/pol-k8s/tests/build/ -``` diff --git a/installers/charm/pol-k8s/config.yaml b/installers/charm/pol-k8s/config.yaml deleted file mode 100644 index b20fe919..00000000 --- a/installers/charm/pol-k8s/config.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -options: - advertised-hostname: - description: POL Hostname - type: string - default: "pol-k8s" - log_level: - description: "Log Level" - type: string - default: "INFO" - image: - type: string - description: OCI image - default: opensourcemano/pol:latest - image_username: - description: Docker repository username - type: string - default: "" - image_password: - description: Docker repository password - type: string - default: "" diff --git a/installers/charm/pol-k8s/icon.svg b/installers/charm/pol-k8s/icon.svg deleted file mode 100644 index da31b4ab..00000000 --- a/installers/charm/pol-k8s/icon.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - image/svg+xml - - eclispe-che - - - - - - eclispe-che - Created with Sketch. - - - - - - - - - - - - - - - - - diff --git a/installers/charm/pol-k8s/layer.yaml b/installers/charm/pol-k8s/layer.yaml deleted file mode 100644 index 4ed526bf..00000000 --- a/installers/charm/pol-k8s/layer.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -includes: - - "layer:caas-base" - - "layer:status" - - "layer:leadership" - - "layer:osm-common" - - "interface:kafka" - - "interface:mongodb" -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/pol-k8s/metadata.yaml b/installers/charm/pol-k8s/metadata.yaml deleted file mode 100644 index 9e8d646d..00000000 --- a/installers/charm/pol-k8s/metadata.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -name: pol-k8s -summary: "OSM Policy Module (POL)" -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy OSM's Policy Module (POL) -tags: - - "application" -series: - - "kubernetes" -requires: - kafka: - interface: kafka - mongo: - interface: mongodb -storage: - database: - type: filesystem - location: /app/database -deployment: - type: stateful - service: cluster diff --git a/installers/charm/pol-k8s/reactive/pol_k8s.py b/installers/charm/pol-k8s/reactive/pol_k8s.py deleted file mode 100644 index 5d56c27d..00000000 --- a/installers/charm/pol-k8s/reactive/pol_k8s.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from charms.reactive import endpoint_from_flag -from charms.layer.caas_base import pod_spec_set -from charms.reactive import when, when_not, hook -from charms.reactive.flags import set_flag, clear_flag -from charmhelpers.core.hookenv import log, metadata, config -from charms import layer - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("pol-k8s.configured") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("pol-k8s.configured") - - -@when_not("kafka.ready") -@when("leadership.is_leader") -@when_not("pol-k8s.configured") -def waiting_for_kafka(): - layer.status.waiting("Waiting for kafka to be ready") - - -@when_not("mongo.ready") -@when("leadership.is_leader") -@when_not("pol-k8s.configured") -def waiting_for_mongo(): - layer.status.waiting("Waiting for mongo to be ready") - - -@when("kafka.ready", "mongo.ready") -@when_not("pol-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring pol container") - try: - kafka = endpoint_from_flag("kafka.ready") - mongo = endpoint_from_flag("mongo.ready") - - if kafka and mongo: - kafka_units = kafka.kafkas() - kafka_unit = kafka_units[0] - - mongo_uri = mongo.connection_string() - log("Mongo URI: {}".format(mongo_uri)) - - if mongo_uri and kafka_unit["host"]: - spec = make_pod_spec(kafka_unit["host"], kafka_unit["port"], mongo_uri) - - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - set_flag("pol-k8s.configured") - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - - -@when("kafka.ready", "mongo.ready") -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -@when("pol-k8s.configured") -def set_pol_active(): - layer.status.active("ready") - - -def make_pod_spec(kafka_host, kafka_port, mongo_uri): - """Make pod specification for Kubernetes - - Args: - kafka_host (str): Kafka hostname or IP - kafka_port (int): Kafka port - mongo_host (str): Mongo URI - Returns: - pod_spec: Pod specification for Kubernetes - """ - - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - md = metadata() - cfg = config() - data = { - "name": md.get("name"), - "kafka_host": kafka_host, - "kafka_port": kafka_port, - "mongo_uri": mongo_uri, - } - data.update(cfg) - return pod_spec_template % data diff --git a/installers/charm/pol-k8s/reactive/spec_template.yaml b/installers/charm/pol-k8s/reactive/spec_template.yaml deleted file mode 100644 index d0c5823f..00000000 --- a/installers/charm/pol-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -version: 2 -containers: - - name: %(name)s - imageDetails: - imagePath: %(image)s - username: %(image_username)s - password: %(image_password)s - ports: - # This is a fake port; lcm doesn't listen, since it's just reading - # and responding to the kafka bus. Fix this in post. - - containerPort: 80 - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - OSMPOL_MESSAGE_DRIVER: kafka - OSMPOL_MESSAGE_HOST: %(kafka_host)s - OSMPOL_MESSAGE_PORT: %(kafka_port)s - - OSMPOL_DATABASE_DRIVER: mongo - OSMPOL_DATABASE_URI: %(mongo_uri)s - - OSMPOL_GLOBAL_LOGLEVEL: %(log_level)s - # kubernetes: - # readinessProbe: - # exec: - # command: ["sh", "-c", "osm-pol-healthcheck || exit 1"] - # periodSeconds: 10 - # timeoutSeconds: 5 - # successThreshold: 1 - # failureThreshold: 3 - # livenessProbe: - # exec: - # command: ["sh", "-c", "osm-pol-healthcheck || exit 1"] - # initialDelaySeconds: 45 - # periodSeconds: 10 - # timeoutSeconds: 5 - # successThreshold: 1 - # failureThreshold: 3 \ No newline at end of file diff --git a/installers/charm/pol-k8s/tox.ini b/installers/charm/pol-k8s/tox.ini deleted file mode 100644 index f8f69908..00000000 --- a/installers/charm/pol-k8s/tox.ini +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju - sleep -passenv = HOME TERM CS_API_* OS_* AMULET_* -install_command = - pip install {opts} {packages} - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = ../layers - CHARM_INTERFACES_DIR = ../interfaces/ -whitelist_externals = git - charm - rm - mv -commands = - rm -rf release - rm -rf ../interfaces/mongodb - git clone https://git.launchpad.net/interface-mongodb ../interfaces/mongodb - charm build . --build-dir /tmp - mv /tmp/pol-k8s/ release/ - -[testenv:lint] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . --exclude "release/|.tox/" - yamllint . - flake8 reactive/ --max-line-length=100 - -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/prometheus-k8s/.gitignore b/installers/charm/prometheus-k8s/.gitignore deleted file mode 100644 index 712eb963..00000000 --- a/installers/charm/prometheus-k8s/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -release/ -__pycache__ -.tox diff --git a/installers/charm/prometheus-k8s/.yamllint.yaml b/installers/charm/prometheus-k8s/.yamllint.yaml deleted file mode 100644 index 21b95b5b..00000000 --- a/installers/charm/prometheus-k8s/.yamllint.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - ---- - -extends: default -rules: - line-length: disable -yaml-files: - - '*.yaml' - - '*.yml' - - '.yamllint' -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/prometheus-k8s/README.md b/installers/charm/prometheus-k8s/README.md deleted file mode 100755 index e6ae8017..00000000 --- a/installers/charm/prometheus-k8s/README.md +++ /dev/null @@ -1,108 +0,0 @@ - - -# Overview - -Prometheus for Juju CAAS - -## Testing - -The tests of this charm are done using tox and Zaza. - - - -### Prepare environment - -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: - -``` -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dashboard dns - -juju bootstrap microk8s k8s-cloud -``` - -If /usr/bin/python does not exist, you should probably need to do this: - -``` -sudo ln -s /usr/bin/python3 /usr/bin/python -``` -### Build Charm - -**Download dependencies:** - -``` -mkdir -p ~/charm/layers ~/charm/build ~/charm/interfaces -git clone https://git.launchpad.net/canonical-osm ~/canonical-osm - -cd ~/charm/layers -git clone https://git.launchpad.net/charm-k8s-prometheus prometheus-k8s - -cd ~/charm/interfaces -mv ~/canonical-osm/charms/interfaces/* . -``` - -**Charm structure:** - -``` -├── config.yaml -├── icon.svg -├── layer.yaml -├── metadata.yaml -├── reactive -│ ├── spec_template.yaml -│ └── prometheus.py -├── README.md -├── test-requirements.txt -├── tests -│ ├── basic_deployment.py -│ ├── bundles -│ │ ├── prometheus-ha.yaml -│ │ └── prometheus.yaml -│ └── tests.yaml -└── tox.ini -``` - -**Setup environment variables:** - -``` -export CHARM_LAYERS_DIR=~/charm/layers -export CHARM_BUILD_DIR=~/charm/build -export CHARM_INTERFACES_DIR=~/charm/interfaces -``` - -**Build:** - -``` -mkdir ~/charm/layers/prometheus-k8s/tests/build -charm build ~/charm/layers/prometheus-k8s -mv ~/charm/build/* ~/charm/layers/prometheus-k8s/tests/build/ -``` - -### Test charm with Tox - -``` -cd ~/charm/layers/prometheus-k8s -tox -e func -``` diff --git a/installers/charm/prometheus-k8s/config.yaml b/installers/charm/prometheus-k8s/config.yaml deleted file mode 100755 index 3c3e9c6c..00000000 --- a/installers/charm/prometheus-k8s/config.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -options: - advertised-hostname: - description: Advertised hostname - type: string - default: "prometheus" - advertised-port: - description: Prometheus Port - type: int - default: 9090 - web-subpath: - description: Subpath for accessing Prometheus - type: string - default: / - default-target: - description: Default target to be added in Prometheus - type: string - default: "" - prometheus-image: - type: string - description: OCI image - default: rocks.canonical.com:443/prom/prometheus:latest - alpine-image: - type: string - description: OCI image - default: rocks.canonical.com:443/alpine:latest diff --git a/installers/charm/prometheus-k8s/icon.svg b/installers/charm/prometheus-k8s/icon.svg deleted file mode 100644 index ffa6296e..00000000 --- a/installers/charm/prometheus-k8s/icon.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - prometheus - Created with Sketch. - - - - - - - \ No newline at end of file diff --git a/installers/charm/prometheus-k8s/layer.yaml b/installers/charm/prometheus-k8s/layer.yaml deleted file mode 100644 index b58fad55..00000000 --- a/installers/charm/prometheus-k8s/layer.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -includes: - - "layer:caas-base" - - 'layer:status' - - 'layer:leadership' - - 'interface:prometheus' - -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/prometheus-k8s/metadata.yaml b/installers/charm/prometheus-k8s/metadata.yaml deleted file mode 100755 index 78aa7788..00000000 --- a/installers/charm/prometheus-k8s/metadata.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -name: "prometheus-k8s" -summary: "Prometheus Charm" -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy Prometheus. -tags: - - "application" -series: - - "kubernetes" -provides: - prometheus: - interface: prometheus -storage: - database: - type: filesystem - location: /prometheus -deployment: - type: stateful - service: cluster diff --git a/installers/charm/prometheus-k8s/reactive/prometheus.py b/installers/charm/prometheus-k8s/reactive/prometheus.py deleted file mode 100644 index 9aa4f26e..00000000 --- a/installers/charm/prometheus-k8s/reactive/prometheus.py +++ /dev/null @@ -1,107 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -from charms.reactive import when, when_not, hook -from charms.reactive.flags import set_flag, clear_flag -from charmhelpers.core.hookenv import ( - log, - metadata, - config, - network_get, - relation_id, -) -from charms import layer -from charmhelpers.core import hookenv -import traceback - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("prometheus-k8s.configured") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("prometheus-k8s.configured") - - -@when_not("prometheus-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring prometheus container") - try: - spec = make_pod_spec() - log("set pod spec:\n{}".format(spec)) - layer.caas_base.pod_spec_set(spec) - set_flag("prometheus-k8s.configured") - layer.status.active("ready") - - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - log(traceback.format_exc(), level=hookenv.ERROR) - - -@when("prometheus-k8s.configured") -def set_prometheus_active(): - layer.status.active("ready") - - -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -@when("prometheus-k8s.configured", "endpoint.prometheus.available") -def send_config(prometheus): - layer.status.maintenance("Sending prometheus configuration") - cfg = config() - try: - info = network_get("prometheus", relation_id()) - log("network info {0}".format(info)) - host = info.get("ingress-addresses", [""])[0] - - prometheus.configure(hostname=host, port=cfg.get("advertised-port")) - clear_flag("endpoint.prometheus.available") - except Exception as e: - log("Exception sending config: {}".format(e)) - - -def make_pod_spec(): - """Make pod specification for Kubernetes - - Returns: - pod_spec: Pod specification for Kubernetes - """ - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - md = metadata() - cfg = config() - - data = { - "name": md.get("name"), - "docker_image": cfg.get("prometheus-image"), - "a_docker_image": cfg.get("alpine-image"), - } - data.update(cfg) - return pod_spec_template % data diff --git a/installers/charm/prometheus-k8s/reactive/spec_template.yaml b/installers/charm/prometheus-k8s/reactive/spec_template.yaml deleted file mode 100644 index 018b74f1..00000000 --- a/installers/charm/prometheus-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -version: 2 -containers: - - name: "init-chown-data" - image: %(a_docker_image)s - imagePullPolicy: "IfNotPresent" - command: ["/bin/sh", "-c", "chown -R 65534:65534 /prometheus && while true; do sleep 86400; done"] - - name: %(name)s - image: %(docker_image)s - ports: - - containerPort: %(advertised-port)s - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - kubernetes: - readinessProbe: - httpGet: - path: /-/ready - port: %(advertised-port)s - initialDelaySeconds: 10 - timeoutSeconds: 30 - livenessProbe: - httpGet: - path: /-/healthy - port: %(advertised-port)s - initialDelaySeconds: 30 - timeoutSeconds: 30 - command: - - "sh" - - "-c" - - "/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --web.console.libraries=/usr/share/prometheus/console_libraries --web.console.templates=/usr/share/prometheus/consoles --web.route-prefix=%(web-subpath)s --web.external-url=http://localhost:%(advertised-port)s%(web-subpath)s" - files: - - name: config - mountPath: /etc/prometheus - files: - prometheus.yml: | - global: - scrape_interval: 15s - evaluation_interval: 15s - alerting: - alertmanagers: - - static_configs: - - targets: - rule_files: - scrape_configs: - - job_name: 'prometheus' - static_configs: - - targets: ['%(default-target)s'] diff --git a/installers/charm/prometheus-k8s/test-requirements.txt b/installers/charm/prometheus-k8s/test-requirements.txt deleted file mode 100644 index b302c2e7..00000000 --- a/installers/charm/prometheus-k8s/test-requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -git+https://github.com/davigar15/zaza.git#egg=zaza diff --git a/installers/charm/prometheus-k8s/tests/basic_deployment.py b/installers/charm/prometheus-k8s/tests/basic_deployment.py deleted file mode 100644 index 5adfb244..00000000 --- a/installers/charm/prometheus-k8s/tests/basic_deployment.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/python3 -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -import unittest -import zaza.model as model -import requests as http - - -def get_prometheus_uri(): - ip = model.get_status().applications["prometheus-k8s"]["public-address"] - port = 9090 - return "http://{}:{}".format(ip, port) - - -class BasicDeployment(unittest.TestCase): - def test_get_prometheus_uri(self): - get_prometheus_uri() - - def test_prometheus_get_series(self): - prometheus_uri = get_prometheus_uri() - body = http.get("{}/api/v1/series?match[]=up".format(prometheus_uri)) - self.assertEqual(body.status_code, 200) - - def test_prometheus_get_labels(self): - prometheus_uri = get_prometheus_uri() - body = http.get("{}/api/v1/labels".format(prometheus_uri)) - self.assertEqual(body.status_code, 200) - - def test_prometheus_get_targets(self): - prometheus_uri = get_prometheus_uri() - body = http.get("{}/api/v1/targets".format(prometheus_uri)) - self.assertEqual(body.status_code, 200) - - def test_prometheus_get_alerts(self): - prometheus_uri = get_prometheus_uri() - body = http.get("{}/api/v1/alerts".format(prometheus_uri)) - self.assertEqual(body.status_code, 200) - - def test_prometheus_get_status_config(self): - prometheus_uri = get_prometheus_uri() - body = http.get("{}/api/v1/status/config".format(prometheus_uri)) - self.assertEqual(body.status_code, 200) diff --git a/installers/charm/prometheus-k8s/tests/bundles/prometheus-ha.yaml b/installers/charm/prometheus-k8s/tests/bundles/prometheus-ha.yaml deleted file mode 100644 index fa661660..00000000 --- a/installers/charm/prometheus-k8s/tests/bundles/prometheus-ha.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -bundle: kubernetes -applications: - prometheus-k8s: - charm: '../../release' - scale: 2 - options: - default-target: "mon-k8s:8000" - series: kubernetes - storage: - database: 50M diff --git a/installers/charm/prometheus-k8s/tests/bundles/prometheus.yaml b/installers/charm/prometheus-k8s/tests/bundles/prometheus.yaml deleted file mode 100644 index 957cabdd..00000000 --- a/installers/charm/prometheus-k8s/tests/bundles/prometheus.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -bundle: kubernetes -applications: - prometheus-k8s: - charm: '../../release' - scale: 1 - options: - default-target: "mon-k8s:8000" - series: kubernetes - storage: - database: 50M diff --git a/installers/charm/prometheus-k8s/tests/tests.yaml b/installers/charm/prometheus-k8s/tests/tests.yaml deleted file mode 100644 index f5581a35..00000000 --- a/installers/charm/prometheus-k8s/tests/tests.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -gate_bundles: - - prometheus - - prometheus-ha -smoke_bundles: - - prometheus -tests: - - tests.basic_deployment.BasicDeployment diff --git a/installers/charm/prometheus-k8s/tox.ini b/installers/charm/prometheus-k8s/tox.ini deleted file mode 100644 index c242072f..00000000 --- a/installers/charm/prometheus-k8s/tox.ini +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju -passenv = HOME TERM CS_API_* OS_* AMULET_* -deps = -r{toxinidir}/test-requirements.txt -install_command = - pip install {opts} {packages} - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = /tmp -whitelist_externals = git - charm - rm - mv -commands = - rm -rf /tmp/canonical-osm /tmp/osm-common - rm -rf release/ - git clone https://git.launchpad.net/charm-osm-common /tmp/osm-common - charm build . --build-dir /tmp - mv /tmp/prometheus-k8s/ release/ - -[testenv:black] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . - yamllint . - flake8 reactive/ --max-line-length=88 - flake8 tests/ --max-line-length=88 - -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:func-noop] -basepython = python3 -commands = - true - -[testenv:func] -basepython = python3 -commands = functest-run-suite - - -[testenv:func-smoke] -basepython = python3 -commands = functest-run-suite --keep-model --smoke - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/ro-k8s/.yamllint.yaml b/installers/charm/ro-k8s/.yamllint.yaml deleted file mode 100644 index d24a69d9..00000000 --- a/installers/charm/ro-k8s/.yamllint.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. ---- -extends: default - -yaml-files: - - "*.yaml" - - "*.yml" - - ".yamllint" -ignore: | - reactive/ - .tox - release/ diff --git a/installers/charm/ro-k8s/README.md b/installers/charm/ro-k8s/README.md deleted file mode 100755 index 5571622e..00000000 --- a/installers/charm/ro-k8s/README.md +++ /dev/null @@ -1,91 +0,0 @@ - - -# Overview - -OSM RO charm for Kubernetes - -## Testing - -The tests of this charm are done using tox and Zaza. - - - -### Prepare environment - -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: - -``` -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dashboard dns - -juju bootstrap microk8s k8s-cloud -``` - -If /usr/bin/python does not exist, you should probably need to do this: - -``` -sudo ln -s /usr/bin/python3 /usr/bin/python -``` - -### Build Charm - -**Download dependencies:** - -``` -mkdir -p ~/charm/layers ~/charm/build ~/charm/interfaces -git clone https://git.launchpad.net/canonical-osm ~/canonical-osm - -cd ~/charm/layers -git clone https://git.launchpad.net/charm-k8s-mariadb mariadb-k8s -git clone https://git.launchpad.net/charm-osm-ro ro-k8s - -cd ~/charm/interfaces -mv ~/canonical-osm/charms/interfaces/* . -git clone https://git.launchpad.net/interface-osm-ro osm-ro - -``` - -**Charm structure:** - -``` -├── config.yaml -├── icon.svg -├── layer.yaml -├── metadata.yaml -├── reactive -│ ├── spec_template.yaml -│ └── ui.py -├── README.md -└── tox.ini -``` - -**Setup environment variables:** - -``` -export CHARM_LAYERS_DIR=~/charm/layers -export CHARM_BUILD_DIR=~/charm/build -export CHARM_INTERFACES_DIR=~/charm/interfaces -``` - -**Build:** - -``` -mkdir ~/charm/layers/ro-k8s/tests/build -charm build ~/charm/layers/mariadb-k8s -charm build ~/charm/layers/ro-k8s -mv ~/charm/build/* ~/charm/layers/ro-k8s/tests/build/ -``` diff --git a/installers/charm/ro-k8s/config.yaml b/installers/charm/ro-k8s/config.yaml deleted file mode 100755 index cc6076c8..00000000 --- a/installers/charm/ro-k8s/config.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -options: - advertised-port: - description: RO port - type: int - default: 9090 - vim_database: - type: string - description: "The database name." - default: "mano_vim_db" - ro_database: - type: string - description: "The database name." - default: "mano_db" - OPENMANO_TENANT: - type: string - description: "Openmano Tenant" - default: "osm" - image: - type: string - description: OCI image - default: opensourcemano/ro:latest - image_username: - description: Docker repository username - type: string - default: "" - image_password: - description: Docker repository password - type: string - default: "" - database_commonkey: - description: Database common key - type: string - default: osm \ No newline at end of file diff --git a/installers/charm/ro-k8s/icon.svg b/installers/charm/ro-k8s/icon.svg deleted file mode 100644 index da31b4ab..00000000 --- a/installers/charm/ro-k8s/icon.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - image/svg+xml - - eclispe-che - - - - - - eclispe-che - Created with Sketch. - - - - - - - - - - - - - - - - - diff --git a/installers/charm/ro-k8s/layer.yaml b/installers/charm/ro-k8s/layer.yaml deleted file mode 100644 index 04d1612e..00000000 --- a/installers/charm/ro-k8s/layer.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -includes: - - "layer:caas-base" - - "layer:status" - - "layer:leadership" - - "layer:osm-common" - - "interface:kafka" - - "interface:mongodb" - - "interface:juju-relation-mysql" - - "interface:osm-ro" - -repo: https://code.launchpad.net/osm-k8s-bundle diff --git a/installers/charm/ro-k8s/metadata.yaml b/installers/charm/ro-k8s/metadata.yaml deleted file mode 100755 index 102851ab..00000000 --- a/installers/charm/ro-k8s/metadata.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -name: "ro-k8s" -summary: "OSM Resource Orchestrator (RO)" -maintainers: - - "SolutionsQA " -description: | - A CAAS charm to deploy OSM's Resource Orchestrator (RO). -tags: - - "application" -series: - - "kubernetes" -provides: - ro: - interface: osm-ro -requires: - mysql: - interface: mysql - kafka: - interface: kafka - mongo: - interface: mongodb -storage: - log: - type: filesystem - location: /var/log/osm -deployment: - type: stateful - service: cluster diff --git a/installers/charm/ro-k8s/reactive/ro.py b/installers/charm/ro-k8s/reactive/ro.py deleted file mode 100644 index 062cc078..00000000 --- a/installers/charm/ro-k8s/reactive/ro.py +++ /dev/null @@ -1,219 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import yaml - -from charmhelpers.core.hookenv import log, metadata, config -from charms import layer -from charms.layer.caas_base import pod_spec_set -from charms.osm.k8s import get_service_ip -from charms.reactive import endpoint_from_flag -from charms.reactive import when, when_not, hook -from charms.reactive.flags import set_flag, clear_flag - - -@hook("upgrade-charm") -@when("leadership.is_leader") -def upgrade(): - clear_flag("ro-k8s.configured") - clear_flag("ro-k8s.ready") - - -@when("config.changed") -@when("leadership.is_leader") -def restart(): - clear_flag("ro-k8s.configured") - clear_flag("ro-k8s.ready") - - -@when_not("mongo.ready") -@when_not("mysql.available") -@when_not("ro-k8s.configured") -@when("leadership.is_leader") -def waiting_for_mysql(): - layer.status.waiting("Waiting for db to be ready") - clear_flag("ro-k8s.ready") - - -@when_not("kafka.ready") -@when_not("ro-k8s.configured") -@when("leadership.is_leader") -def waiting_for_kafka(): - layer.status.waiting("Waiting for kafka to be ready") - clear_flag("ro-k8s.ready") - - -@when_not("ro-k8s.ready") -@when("mysql.available") -def ro_k8s_mysql_ready(): - set_flag("ro-k8s.ready") - - -@when_not("ro-k8s.ready") -@when("kafka.ready") -@when("mongo.ready") -def ro_k8s_kafka_mongo_ready(): - set_flag("ro-k8s.ready") - - -@when("ro-k8s.ready") -@when_not("ro-k8s.configured") -@when("leadership.is_leader") -def configure(): - layer.status.maintenance("Configuring ro container") - try: - mysql = endpoint_from_flag("mysql.available") - kafka = endpoint_from_flag("kafka.ready") - mongo = endpoint_from_flag("mongo.ready") - spec = None - if mysql: - if mysql.host() is not None: - spec = make_pod_spec( - mysql.host(), - mysql.port(), - mysql.user(), - mysql.password(), - mysql.root_password(), - ) - elif kafka and mongo: - kafka_units = kafka.kafkas() - kafka_unit = kafka_units[0] - mongo_uri = mongo.connection_string() - - if ( - mongo_uri - and kafka_unit["host"] - # and kafka_unit["port"] - ): - spec = make_pod_spec_new_ro( - kafka_unit["host"], - # kafka_unit["port"], - mongo_uri, - ) - if spec: - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - layer.status.active("creating container") - set_flag("ro-k8s.configured") - except Exception as e: - layer.status.blocked("k8s spec failed to deploy: {}".format(e)) - - -@when("ro-k8s.ready") -@when_not("leadership.is_leader") -def non_leaders_active(): - layer.status.active("ready") - - -@when("ro-k8s.configured") -def set_ro_active(): - layer.status.active("ready") - - -@when("ro-k8s.configured", "ro.joined") -def send_config(): - layer.status.maintenance("Sending RO configuration") - try: - ro = endpoint_from_flag("ro.joined") - if ro: - service_ip = get_service_ip("ro") - if service_ip: - ro.send_connection( - service_ip, - get_ro_port(), - ) - clear_flag("ro.joined") - except Exception as e: - log("Fail sending RO configuration: {}".format(e)) - - -def make_pod_spec( - mysql_host, mysql_port, mysql_user, mysql_password, mysql_root_password -): - """Make pod specification for Kubernetes - - Args: - mysql_name (str): RO DB name - mysql_host (str): RO DB host - mysql_port (int): RO DB port - mysql_user (str): RO DB user - mysql_password (str): RO DB password - Returns: - pod_spec: Pod specification for Kubernetes - """ - - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - md = metadata() - cfg = config() - - data = { - "name": md.get("name"), - } - data.update(cfg) - spec = yaml.safe_load(pod_spec_template % data) - spec["containers"][0]["config"].update( - { - "RO_DB_HOST": mysql_host, - "RO_DB_PORT": mysql_port, - "RO_DB_NAME": cfg.get("ro_database"), - "RO_DB_USER": mysql_user, - "RO_DB_ROOT_PASSWORD": mysql_root_password, - "RO_DB_PASSWORD": mysql_password, - "RO_DB_OVIM_PASSWORD": mysql_password, - "RO_DB_OVIM_HOST": mysql_host, - "RO_DB_OVIM_PORT": mysql_port, - "RO_DB_OVIM_USER": mysql_user, - "RO_DB_OVIM_ROOT_PASSWORD": mysql_root_password, - "RO_DB_OVIM_NAME": cfg.get("vim_database"), - } - ) - return spec - - -def make_pod_spec_new_ro(kafka_host, mongodb_uri): - """Make pod specification for Kubernetes - - Args: - kafka_host (str): Kafka host - mongodb_uri (str): Mongodb URI - Returns: - pod_spec: Pod specification for Kubernetes - """ - - with open("reactive/spec_template.yaml") as spec_file: - pod_spec_template = spec_file.read() - - md = metadata() - cfg = config() - - data = { - "name": md.get("name"), - } - data.update(cfg) - spec = yaml.safe_load(pod_spec_template % data) - spec["containers"][0]["config"].update( - { - "OSMRO_DATABASE_URI": mongodb_uri, - "OSMRO_MESSAGE_HOST": kafka_host, - "OSMRO_DATABASE_COMMONKEY": cfg.get("database_commonkey"), - } - ) - return spec - - -def get_ro_port(): - """Returns RO port""" - cfg = config() - return cfg.get("advertised-port") diff --git a/installers/charm/ro-k8s/reactive/spec_template.yaml b/installers/charm/ro-k8s/reactive/spec_template.yaml deleted file mode 100644 index 499acd79..00000000 --- a/installers/charm/ro-k8s/reactive/spec_template.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -version: 2 -service: - scalePolicy: serial -containers: - - name: %(name)s - imageDetails: - imagePath: %(image)s - username: %(image_username)s - password: %(image_password)s - kubernetes: - livenessProbe: - tcpSocket: - port: %(advertised-port)s - initialDelaySeconds: 600 - periodSeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 3 - ports: - - containerPort: %(advertised-port)s - protocol: TCP - config: - ALLOW_ANONYMOUS_LOGIN: 'yes' - OPENMANO_TENANT: %(OPENMANO_TENANT)s diff --git a/installers/charm/ro-k8s/tox.ini b/installers/charm/ro-k8s/tox.ini deleted file mode 100644 index badd81e4..00000000 --- a/installers/charm/ro-k8s/tox.ini +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -[tox] -envlist = pep8 -skipsdist = True - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -whitelist_externals = juju - sleep -passenv = HOME TERM CS_API_* OS_* AMULET_* -install_command = - pip install {opts} {packages} - - -[testenv:build] -basepython = python3 -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -setenv = CHARM_LAYERS_DIR = ../layers - CHARM_INTERFACES_DIR = ../interfaces/ -whitelist_externals = git - charm - rm - mv -commands = - rm -rf release - rm -rf ../interfaces/mongodb - rm -rf ../interfaces/juju-relation-mysql - rm -rf /tmp/canonical-osm - git clone https://git.launchpad.net/interface-mongodb ../interfaces/mongodb - git clone https://git.launchpad.net/canonical-osm/ /tmp/canonical-osm - mv /tmp/canonical-osm/charms/interfaces/juju-relation-mysql ../interfaces/juju-relation-mysql - charm build . --build-dir /tmp - mv /tmp/ro-k8s/ release/ - -[testenv:lint] -basepython = python3 -deps = - black - yamllint - flake8 -commands = - black --check --diff . --exclude "release/|.tox/" - yamllint . - flake8 reactive/ --max-line-length=100 - -[testenv:pep8] -basepython = python3 -deps=charm-tools -commands = charm-proof - -[testenv:venv] -commands = {posargs} diff --git a/installers/charm/zookeeper/.gitignore b/installers/charm/zookeeper/.gitignore deleted file mode 100644 index a85ce6d9..00000000 --- a/installers/charm/zookeeper/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -venv -.vscode -*.charm -.coverage -coverage.xml -.stestr -cover \ No newline at end of file diff --git a/installers/charm/zookeeper/.jujuignore b/installers/charm/zookeeper/.jujuignore deleted file mode 100644 index 3738c1c2..00000000 --- a/installers/charm/zookeeper/.jujuignore +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -venv -.vscode -*.charm -.coverage -coverage.xml -.gitignore -.stestr -cover -tests/ -requirements* -tox.ini diff --git a/installers/charm/zookeeper/.yamllint.yaml b/installers/charm/zookeeper/.yamllint.yaml deleted file mode 100644 index 5244c94f..00000000 --- a/installers/charm/zookeeper/.yamllint.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - ---- -extends: default - -yaml-files: - - "*.yaml" - - "*.yml" - - ".yamllint" -ignore: | - .tox - cover/ - venv diff --git a/installers/charm/zookeeper/README.md b/installers/charm/zookeeper/README.md deleted file mode 100644 index bc6aec71..00000000 --- a/installers/charm/zookeeper/README.md +++ /dev/null @@ -1,22 +0,0 @@ - - -# Zookeeper operator Charm for Kubernetes - diff --git a/installers/charm/zookeeper/charmcraft.yaml b/installers/charm/zookeeper/charmcraft.yaml deleted file mode 100644 index 0a285a9d..00000000 --- a/installers/charm/zookeeper/charmcraft.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -type: charm -bases: - - build-on: - - name: ubuntu - channel: "20.04" - architectures: ["amd64"] - run-on: - - name: ubuntu - channel: "20.04" - architectures: - - amd64 - - aarch64 - - arm64 -parts: - charm: - build-packages: [git] diff --git a/installers/charm/zookeeper/config.yaml b/installers/charm/zookeeper/config.yaml deleted file mode 100644 index 149d3881..00000000 --- a/installers/charm/zookeeper/config.yaml +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -options: - log_level: - description: | - Log level - type: string - default: INFO - image_pull_policy: - description: | - ImagePullPolicy configuration for the pod. - Possible values: always, ifnotpresent, never - type: string - default: always - min_session_timeout: - description: Min session timeout - type: int - default: 4000 - max_session_timeout: - description: Max session timeout - type: int - default: 40000 - purge_interval: - description: | - The time interval in hours for which the purge task has to be triggered. - Set to a positive integer (1 and above) to enable the auto purging. - type: int - default: 12 - snap_retain_count: - description: | - When enabled, ZooKeeper auto purge feature retains the - autopurge.snapRetainCount most recent snapshots and - the corresponding transaction logs in the dataDir and - dataLogDir respectively and deletes the rest. - Defaults to 3. Minimum value is 3. - type: int - default: 3 - max_client_cnxns: - description: | - Limits the number of concurrent connections (at the socket level) - that a single client, identified by IP address, may make to a single - member of the ZooKeeper ensemble. - type: int - default: 60 - heap: - description: Heap memory in Mega-bytes - type: int - default: 512 - sync_limit: - description: | - Amount of time, in ticks (see tickTime), to allow followers to sync - with ZooKeeper. - If followers fall too far behind a leader, they will be dropped. - type: int - default: 5 - init_limit: - description: | - Amount of time, in ticks (see tickTime), to allow followers to connect - and sync to a leader. Increased this value as needed, - if the amount of data managed by ZooKeeper is large. - type: int - default: 5 - tick_time: - description: | - The length of a single tick, which is the basic time unit used - by ZooKeeper, as measured in milliseconds. It is used to regulate - heartbeats, and timeouts. - For example, the minimum session timeout will be two ticks. - type: int - default: 2000 - security_context: - description: Enables the security context of the pods - type: boolean - default: false diff --git a/installers/charm/zookeeper/icon.svg b/installers/charm/zookeeper/icon.svg deleted file mode 100644 index 0185a7e1..00000000 --- a/installers/charm/zookeeper/icon.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - zookeeper - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/installers/charm/zookeeper/metadata.yaml b/installers/charm/zookeeper/metadata.yaml deleted file mode 100644 index d352a6cd..00000000 --- a/installers/charm/zookeeper/metadata.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -name: osm-zookeeper -summary: "Zookeeper charm for Kubernetes." -description: | - A CAAS charm to deploy zookeeper. -series: - - kubernetes -tags: - - kubernetes - - osm - - zookeeper -min-juju-version: 2.8.0 -resources: - image: - type: oci-image - description: OSM docker image for zookeeper - upstream-source: | - "rocks.canonical.com:443/k8s.gcr.io/kubernetes-zookeeper:1.0-3.4.10" -provides: - zookeeper: - interface: zookeeper -peers: - cluster: - interface: zookeeper-cluster -storage: - database: - type: filesystem - location: /var/lib/zookeeper -deployment: - type: stateful - service: cluster diff --git a/installers/charm/zookeeper/requirements-test.txt b/installers/charm/zookeeper/requirements-test.txt deleted file mode 100644 index 316f6d20..00000000 --- a/installers/charm/zookeeper/requirements-test.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net - -mock==4.0.3 diff --git a/installers/charm/zookeeper/requirements.txt b/installers/charm/zookeeper/requirements.txt deleted file mode 100644 index 1a8928c7..00000000 --- a/installers/charm/zookeeper/requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -git+https://github.com/charmed-osm/ops-lib-charmed-osm/@master \ No newline at end of file diff --git a/installers/charm/zookeeper/src/charm.py b/installers/charm/zookeeper/src/charm.py deleted file mode 100755 index c2acf0be..00000000 --- a/installers/charm/zookeeper/src/charm.py +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -# pylint: disable=E0213 - -import logging -from typing import NoReturn - - -from ops.framework import EventBase -from ops.main import main -from opslib.osm.charm import CharmedOsmBase -from opslib.osm.interfaces.zookeeper import ZookeeperCluster, ZookeeperServer -from opslib.osm.pod import ContainerV3Builder, PodSpecV3Builder -from opslib.osm.validator import ModelValidator, validator - -logger = logging.getLogger(__name__) - -CLIENT_PORT = 2181 -SERVER_PORT = 2888 -LEADER_ELECTION_PORT = 3888 - - -class ConfigModel(ModelValidator): - log_level: str - image_pull_policy: str - min_session_timeout: int - max_session_timeout: int - purge_interval: int - snap_retain_count: int - max_client_cnxns: int - heap: int - sync_limit: int - init_limit: int - tick_time: int - security_context: bool - - @validator("log_level") - def validate_log_level(cls, v): - if v not in {"INFO", "DEBUG"}: - raise ValueError("value must be INFO or DEBUG") - return v - - @validator("image_pull_policy") - def validate_image_pull_policy(cls, v): - values = { - "always": "Always", - "ifnotpresent": "IfNotPresent", - "never": "Never", - } - v = v.lower() - if v not in values.keys(): - raise ValueError("value must be always, ifnotpresent or never") - return values[v] - - -class ZookeeperCharm(CharmedOsmBase): - """Zookeeper Charm.""" - - def __init__(self, *args) -> NoReturn: - """Zookeeper Charm constructor.""" - super().__init__(*args, oci_image="image") - # Initialize Zookeeper cluster relation - self.zookeeper_cluster = ZookeeperCluster(self, "cluster", CLIENT_PORT) - self.framework.observe(self.on["cluster"].relation_changed, self._setup_cluster) - # Initialize Zookeeper relation - self.zookeeper_server = ZookeeperServer(self, "zookeeper") - self.framework.observe(self.on["zookeeper"].relation_joined, self._publish_info) - - @property - def num_units(self): - return self.zookeeper_cluster.num_units - - @property - def zookeeper_uri(self): - return self.zookeeper_cluster.zookeeper_uri - - def _setup_cluster(self, event: EventBase): - """Publishes Zookeeper information and reconfigures the pod. - - Args: - event (EventBase): Zookeeper Cluster relation event. - """ - self._publish_info(event) - self.configure_pod() - - def _publish_info(self, event: EventBase): - """Publishes Zookeeper information. - - Args: - event (EventBase): Zookeeper relation event. - """ - if self.unit.is_leader(): - zk_uri = self.zookeeper_uri - if zk_uri: - self.zookeeper_server.publish_info(zk_uri) - else: - event.defer() - - def build_pod_spec(self, image_info): - # Validate config - config = ConfigModel(**dict(self.config)) - - # Create Builder for the PodSpec - pod_spec_builder = PodSpecV3Builder( - enable_security_context=config.security_context - ) - - # Build Container - container_builder = ContainerV3Builder( - self.app.name, - image_info, - config.image_pull_policy, - run_as_non_root=config.security_context, - ) - - container_builder.add_port(name="client", port=CLIENT_PORT) - container_builder.add_port(name="server", port=SERVER_PORT) - container_builder.add_port(name="leader-election", port=LEADER_ELECTION_PORT) - container_builder.add_tcpsocket_readiness_probe( - CLIENT_PORT, - initial_delay_seconds=10, - timeout_seconds=5, - failure_threshold=6, - success_threshold=1, - ) - container_builder.add_tcpsocket_liveness_probe( - CLIENT_PORT, initial_delay_seconds=20 - ) - container_builder.add_command( - [ - "sh", - "-c", - " ".join( - [ - "start-zookeeper", - f"--servers={self.num_units}", - "--data_dir=/var/lib/zookeeper/data", - "--data_log_dir=/var/lib/zookeeper/data/log", - "--conf_dir=/opt/zookeeper/conf", - f"--client_port={CLIENT_PORT}", - f"--election_port={LEADER_ELECTION_PORT}", - f"--server_port={SERVER_PORT}", - f"--tick_time={config.tick_time}", - f"--init_limit={config.init_limit}", - f"--sync_limit={config.sync_limit}", - f"--heap={config.heap}M", - f"--max_client_cnxns={config.max_client_cnxns}", - f"--snap_retain_count={config.snap_retain_count}", - f"--purge_interval={config.purge_interval}", - f"--max_session_timeout={config.max_session_timeout}", - f"--min_session_timeout={config.min_session_timeout}", - f"--log_level={config.log_level}", - ] - ), - ] - ) - - container = container_builder.build() - - # Add container to pod spec - pod_spec_builder.add_container(container) - - return pod_spec_builder.build() - - -if __name__ == "__main__": - main(ZookeeperCharm) diff --git a/installers/charm/zookeeper/tests/__init__.py b/installers/charm/zookeeper/tests/__init__.py deleted file mode 100644 index 446d5cee..00000000 --- a/installers/charm/zookeeper/tests/__init__.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -"""Init mocking for unit tests.""" - -import sys - - -import mock - - -class OCIImageResourceErrorMock(Exception): - pass - - -sys.path.append("src") - -oci_image = mock.MagicMock() -oci_image.OCIImageResourceError = OCIImageResourceErrorMock -sys.modules["oci_image"] = oci_image -sys.modules["oci_image"].OCIImageResource().fetch.return_value = {} diff --git a/installers/charm/zookeeper/tests/test_charm.py b/installers/charm/zookeeper/tests/test_charm.py deleted file mode 100644 index 27d3401c..00000000 --- a/installers/charm/zookeeper/tests/test_charm.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2020 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## - -from typing import NoReturn -import unittest -from unittest.mock import patch, PropertyMock - -from charm import ZookeeperCharm -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness - - -class TestCharm(unittest.TestCase): - """Zookeeper Charm unit tests.""" - - def setUp( - self, - ) -> NoReturn: - """Test setup""" - self.harness = Harness(ZookeeperCharm) - self.harness.set_leader(is_leader=True) - self.config = {"log_level": "INFO", "image_pull_pulicy": "always"} - self.harness.begin() - - def test_config_invalid_log_level(self) -> NoReturn: - """Test invalid log_level config.""" - self.config.update({"log_level": "invalid log level"}) - self.harness.update_config(self.config) - self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) - - def test_config_invalid_image_pull_pulicy(self) -> NoReturn: - """Test invalid image_pull_pulicy config.""" - self.config.update({"image_pull_policy": "invalid image_pull_policy"}) - self.harness.update_config(self.config) - self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) - - @patch("charm.ZookeeperCharm.num_units", new_callable=PropertyMock) - def test_config_changed_no_relations(self, mock_num_units) -> NoReturn: - """Test config changed without relations.""" - mock_num_units.return_value = 1 - self.harness.charm.on.config_changed.emit() - self.assertNotIsInstance(self.harness.charm.unit.status, BlockedStatus) - - @patch("charm.ZookeeperCharm.num_units", new_callable=PropertyMock) - def test_config_changed_non_leader(self, mock_num_units) -> NoReturn: - """Test config changed without relations (non-leader).""" - mock_num_units.return_value = 1 - self.harness.set_leader(is_leader=False) - self.harness.charm.on.config_changed.emit() - - # Assertions - self.assertIsInstance(self.harness.charm.unit.status, ActiveStatus) - - @patch("charm.ZookeeperCharm.num_units", new_callable=PropertyMock) - @patch("charm.ZookeeperCharm.zookeeper_uri", new_callable=PropertyMock) - def test_with_relations_zookeeper( - self, mock_zookeeper_uri, mock_num_units - ) -> NoReturn: - "Test with relations (zookeeper)" - mock_num_units.return_value = 1 - mock_zookeeper_uri.return_value = "zk-uri" - - # Initializing the zookeeper relation - zookeeper_relation_id = self.harness.add_relation("zookeeper", "kafka") - self.harness.add_relation_unit(zookeeper_relation_id, "kafka/0") - # self.harness.update_relation_data( - # zookeeper_relation_id, "kafka/0", {"host": "zookeeper", "port": 9092} - # ) - - # Verifying status - self.assertNotIsInstance(self.harness.charm.unit.status, BlockedStatus) - - -if __name__ == "__main__": - unittest.main() diff --git a/installers/charm/zookeeper/tox.ini b/installers/charm/zookeeper/tox.ini deleted file mode 100644 index 8e3318a4..00000000 --- a/installers/charm/zookeeper/tox.ini +++ /dev/null @@ -1,126 +0,0 @@ -# Copyright 2021 Canonical Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# For those usages not covered by the Apache License, Version 2.0 please -# contact: legal@canonical.com -# -# To get in touch with the maintainers, please contact: -# osm-charmers@lists.launchpad.net -## -####################################################################################### - -[tox] -envlist = black, cover, flake8, pylint, yamllint, safety -skipsdist = true - -[tox:jenkins] -toxworkdir = /tmp/.tox - -[testenv] -basepython = python3.8 -setenv = VIRTUAL_ENV={envdir} - PYTHONDONTWRITEBYTECODE = 1 -deps = -r{toxinidir}/requirements.txt - - -####################################################################################### -[testenv:black] -deps = black -commands = - black --check --diff src/ tests/ - - -####################################################################################### -[testenv:cover] -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - coverage - nose2 -commands = - sh -c 'rm -f nosetests.xml' - coverage erase - nose2 -C --coverage src - coverage report --omit='*tests*' - coverage html -d ./cover --omit='*tests*' - coverage xml -o coverage.xml --omit=*tests* -whitelist_externals = sh - - -####################################################################################### -[testenv:flake8] -deps = flake8 - flake8-import-order -commands = - flake8 src/ tests/ - - -####################################################################################### -[testenv:pylint] -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - pylint==2.10.2 -commands = - pylint -E src/ tests/ - - -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - safety -commands = - - safety check --full-report - - -####################################################################################### -[testenv:yamllint] -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - yamllint -commands = yamllint . - -####################################################################################### -[testenv:build] -passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -whitelist_externals = - charmcraft - sh -commands = - charmcraft build - sh -c 'ubuntu_version=20.04; \ - architectures="amd64-aarch64-arm64"; \ - charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \ - mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm' - -####################################################################################### -[flake8] -ignore = - W291, - W293, - W503, - E123, - E125, - E226, - E241, -exclude = - .git, - __pycache__, - .tox, -max-line-length = 120 -show-source = True -builtins = _ -max-complexity = 10 -import-order-style = google -- 2.25.1