I have the following manifest to export some RabbitMQ stats:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: rabbitmq-exporter
labels:
app: rabbitmq
spec:
selector:
matchLabels:
app: rabbitmq
endpoints:
- port: prometheus
path: /metrics
interval: 10s
The ServiceMonitor CRD already exists on my cluster, I would like to send the yml via the python client's create_from_yaml
function, but I get the following error:
File /virtualenv/lib/python3.9/site-packages/kubernetes/utils/create_from_yaml.py:242, in create_from_yaml_single_item(k8s_client, yml_object, verbose, **kwargs)
240 group = "".join(word.capitalize() for word in group.split('.'))
241 fcn_to_call = "{0}{1}Api".format(group, version.capitalize())
--> 242 k8s_api = getattr(client, fcn_to_call)(k8s_client)
243 # Replace CamelCased action_type into snake_case
244 kind = yml_object["kind"]
AttributeError: module 'kubernetes.client' has no attribute 'MonitoringCoreosComV1Api'
I've been reading a lot of issues regarding CRD and create_from_yaml
, in this case I believe I just need the a create_namespaced_servicemonitor
method inside a MonitoringCoreosComV1Api
class but I don't really know what to base the body of the method on, etc..