From 7ab44ee132d7a865b47d605afedf522221120ceb Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Sat, 6 Jun 2020 17:47:49 -0400 Subject: [PATCH] Added ceilometer-agent-notification Change-Id: I0e05f59a48ff9639fa8cf209665ebea39b72907c --- openstack_operator/ceilometer.py | 31 ++++++++ openstack_operator/operator.py | 3 + .../deployment-agent-notification.yml.j2 | 70 +++++++++++++++++++ .../templates/ceilometer/secret.yml.j2 | 45 ++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 openstack_operator/ceilometer.py create mode 100644 openstack_operator/templates/ceilometer/deployment-agent-notification.yml.j2 create mode 100644 openstack_operator/templates/ceilometer/secret.yml.j2 diff --git a/openstack_operator/ceilometer.py b/openstack_operator/ceilometer.py new file mode 100644 index 00000000..4c3561b3 --- /dev/null +++ b/openstack_operator/ceilometer.py @@ -0,0 +1,31 @@ +# Copyright 2020 VEXXHOST, Inc. +# +# 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. + +"""Ceilometer + +The following modules maintains all the operations for deploying Ceilometer +alongside Atmosphere. +""" + +from openstack_operator import utils + + +def create_or_resume(spec): + """Create or start-up Ceilometer.""" + + config_hash = utils.generate_hash(spec) + + utils.create_or_update('ceilometer/secret.yml.j2', spec=spec) + utils.create_or_update('ceilometer/deployment-agent-notification.yml.j2', + spec=spec, config_hash=config_hash) diff --git a/openstack_operator/operator.py b/openstack_operator/operator.py index 1204bc03..6b9d05db 100644 --- a/openstack_operator/operator.py +++ b/openstack_operator/operator.py @@ -22,6 +22,7 @@ the appropriate deployments, an instance of Keystone, Heat and Horizon import os import kopf +from openstack_operator import ceilometer from openstack_operator import chronyd from openstack_operator import heat from openstack_operator import horizon @@ -61,3 +62,5 @@ def deploy(name, namespace, new, **_): heat.create_or_resume("heat", config["heat"]) if "chronyd" in config: chronyd.create_or_resume(config["chronyd"]) + if "ceilometer" in config: + ceilometer.create_or_resume(config["ceilometer"]) diff --git a/openstack_operator/templates/ceilometer/deployment-agent-notification.yml.j2 b/openstack_operator/templates/ceilometer/deployment-agent-notification.yml.j2 new file mode 100644 index 00000000..2ae86bcc --- /dev/null +++ b/openstack_operator/templates/ceilometer/deployment-agent-notification.yml.j2 @@ -0,0 +1,70 @@ +--- +# Copyright 2020 VEXXHOST, Inc. +# +# 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. + +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: openstack + name: ceilometer-agent-notification + labels: + {{ labels("ceilometer", "ceilometer") | indent(4) }} +spec: + replicas: 3 + selector: + matchLabels: + {{ labels("ceilometer", "ceilometer") | indent(6) }} + template: + metadata: + annotations: + checksum/config: "{{ config_hash }}" + labels: + {{ labels("ceilometer", "ceilometer") | indent(8) }} + spec: + containers: + - name: ceilometer-notification-agent + image: vexxhost/ceilometer-agent-notification:latest + volumeMounts: + - name: ceilometer-config + mountPath: /etc/ceilometer + resources: + limits: + cpu: 1000m + ephemeral-storage: 1G + memory: 256M + requests: + cpu: 500m + ephemeral-storage: 1G + memory: 128M + - name: atmosphere-ingress + image: jmalloc/echo-server + env: + - name: LOG_HTTP_BODY + value: 'true' + volumes: + - name: ceilometer-config + secret: + secretName: ceilometer-config + securityContext: + runAsUser: 65534 + runAsGroup: 65534 + fsGroup: 65534 +{% if 'nodeSelector' in spec %} + nodeSelector: + {{ spec.nodeSelector | to_yaml | indent(8) }} +{% endif %} +{% if 'tolerations' in spec %} + tolerations: + {{ spec.tolerations | to_yaml | indent(8) }} +{% endif %} diff --git a/openstack_operator/templates/ceilometer/secret.yml.j2 b/openstack_operator/templates/ceilometer/secret.yml.j2 new file mode 100644 index 00000000..cd01fef5 --- /dev/null +++ b/openstack_operator/templates/ceilometer/secret.yml.j2 @@ -0,0 +1,45 @@ +--- +# Copyright 2020 VEXXHOST, Inc. +# +# 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. + +apiVersion: v1 +kind: Secret +metadata: + namespace: openstack + name: ceilometer-config +stringData: + ceilometer.conf: | + [DEFAULT] + transport_url = fake:/ + [notification] + ack_on_event_error = false + {% for transport in spec.get('transports', []) %} + messaging_urls = {{ transport }} + {% endfor %} + pipeline.yaml: | + --- + sources: [] + sinks: [] + event_pipeline.yaml: | + --- + sources: + - name: all + events: + - "*" + sinks: + - atmosphere + sinks: + - name: atmosphere + publishers: + - http://localhost:8080/v1/events