turbonomic / orm

Operator Resource Mapping
Apache License 2.0
5 stars 13 forks source link

OM-100176 ORM v2 for Turbo on Turbo #30

Closed tian-ma closed 1 year ago

tian-ma commented 1 year ago

This PR is to update the obsoleted cr in https://github.com/turbonomic/orm/blob/master/archive/samples/turbo_operator_resource_mapping_sample_cr.yaml

kuanf commented 1 year ago

The duplicated long list of label selector looks clumsy. I think we can allow predefined selector (like parameters) to be reused. something like this:

...
spec:
...
  mappings:
    selectors:
      core: 
        matchExpressions:
        - key: app.kubernetes.io/name
          operator: In
          values:
          - action-orchestrator
          - api
          - auth
          - clustermgr
          ...
    patterns:
    - ownerPath: .spec.{{.owned.name}}.resources
      owned:
        path: .spec.template.spec.containers[?(@.name=="{{.owned.name}}")].resources
        apiVersion: apps/v1
        kind: Deployment
        selector: core
    - ownerPath: .spec.{{.owned.name}}.replicaCount
      owned:
        path: .spec.replicas
        apiVersion: apps/v1
        kind: Deployment
        selector: core    

Adding this to issue #29 @tian-ma @evat-pm @pallavidn please comment.

kuanf commented 1 year ago

@tian-ma Please update the example using spec.selector to kill the duplicated long list. Thanks you.

tian-ma commented 1 year ago

@tian-ma Please update the example using spec.selector to kill the duplicated long list. Thanks you.

Done. https://github.com/turbonomic/orm/pull/30/commits/78c2244e1dffb96576edba6165fd55e61bbd3685

tian-ma commented 1 year ago

Output of

k get orm turbonomicxl -oyaml
apiVersion: devops.turbonomic.io/v1alpha1
kind: OperatorResourceMapping
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"devops.turbonomic.io/v1alpha1","kind":"OperatorResourceMapping","metadata":{"annotations":{},"name":"turbonomicxl","namespace":"turbonomic"},"spec":{"mappings":{"patterns":[{"owned":{"apiVersion":"apps/v1","kind":"Deployment","path":".spec.template.spec.containers[?(@.name==\"{{.owned.name}}\")].resources","selector":"turbo_core_components"},"ownerPath":".spec.{{.owned.name}}.resources"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","path":".spec.replicas","selector":"turbo_core_components"},"ownerPath":".spec.{{.owned.name}}.replicaCount"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","matchExpressions":[{"key":"app.kubernetes.io/name","operator":"In","values":["arangodb","influxdb","kafka","zookeeper"]}],"path":".spec.template.spec.containers[?(@.name==\"{{.owned.name}}\")].resources"},"ownerPath":".spec.{{.owned.name}}.resources"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","name":"chronograf","path":".spec.replicas"},"ownerPath":".{{.owned.name}}.service.replicas"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","name":"chronograf","path":".spec.replicas"},"ownerPath":".spec.{{.owned.name}}.resources"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","name":"elasticsearch","path":".spec.template.spec.containers[?(@.name==\"{{.owned.name}}\")].resources"},"ownerPath":".{{.owned.name}}.client.resources"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","name":"grafana","path":".spec.replicas"},"ownerPath":".{{.owned.name}}.replicas"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","matchExpressions":[{"key":"app.kubernetes.io/name","operator":"In","values":["kibana","nginx","prometheus-mysql-exporter","rsyslog"]}],"path":".spec.replicas"},"ownerPath":".{{.owned.name}}.replicaCount"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","name":"prometheus-alertmanager","path":".spec.replicas"},"ownerPath":".{{.owned.name}}.alertmanager.replicaCount"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","name":"prometheus-kube-state-metrics","path":".spec.replicas"},"ownerPath":".spec.{{.owned.name}}.kubeStateMetrics.replicaCount"},{"owned":{"apiVersion":"apps/v1","kind":"Deployment","name":"prometheus-pushgateway","path":".spec.replicas"},"ownerPath":".spec.{{.owned.name}}.pushgateway.replicaCount"}],"selectors":{"turbo_core_components":{"matchExpressions":[{"key":"app.kubernetes.io/name","operator":"In","values":["action-orchestrator","api","auth","clustermgr","cost","extractor","db","group","history","intersight-integration","kafka","kubeturbo","market","mediation-acims","mediation-actionscript","mediation-actionstream-kafka","mediation-aix","mediation-apic","mediation-appdynamics","mediation-appinsights","mediation-aws","mediation-awsbilling","mediation-awscloudbilling","mediation-awscost","mediation-awslambda","mediation-azure","mediation-azurecost","mediation-azureea","mediation-azuresp","mediation-azurevolumes","mediation-baremetal","mediation-cloudfoundry","mediation-compellent","mediation-datadog","mediation-dynatrace","mediation-flexera","mediation-gcpproject","mediation-gcpbilling","mediation-gcpcost","mediation-gcpsa","mediation-hds","mediation-horizon","mediation-hpe3par","mediation-hyperflex","mediation-hyperv","mediation-ibmstorage-flashsystem","mediation-instana","mediation-intersight","mediation-intersighthyperflex","mediation-intersightucs","mediation-istio","mediation-jboss","mediation-jvm","mediation-mssql","mediation-mysql","mediation-netapp","mediation-netflow","mediation-newrelic","mediation-nutanix","mediation-oneview","mediation-openstack","mediation-oracle","mediation-pivotal","mediation-pure","mediation-rhv","mediation-scaleio","mediation-servicenow","mediation-snmp","mediation-tanium","mediation-terraform","mediation-tetration","mediation-tomcat","mediation-ucs","mediation-ucsdirector","mediation-udt","mediation-vcd","mediation-vcenter","mediation-vcenterbrowsing","mediation-vmax","mediation-vmm","mediation-vplex","mediation-webhook","mediation-weblogic","mediation-websphere","mediation-wmi","mediation-xtremio","ml-datastore","ml-training","plan-orchestrator","reporting","repository","topology-processorws"]}]}}},"owner":{"apiVersion":"charts.helm.k8s.io/v1","kind":"Xl","name":"xl-release","namespace":"turbonomic"}}}
  creationTimestamp: "2023-05-01T04:14:17Z"
  generation: 1
  name: turbonomicxl
  namespace: turbonomic
  resourceVersion: "783300"
  uid: b93f7542-2209-45a1-b5f4-52db8fd0bd5f
spec:
  mappings:
    patterns:
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        path: .spec.template.spec.containers[?(@.name=="{{.owned.name}}")].resources
        selector: turbo_core_components
      ownerPath: .spec.{{.owned.name}}.resources
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        path: .spec.replicas
        selector: turbo_core_components
      ownerPath: .spec.{{.owned.name}}.replicaCount
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        matchExpressions:
        - key: app.kubernetes.io/name
          operator: In
          values:
          - arangodb
          - influxdb
          - kafka
          - zookeeper
        path: .spec.template.spec.containers[?(@.name=="{{.owned.name}}")].resources
      ownerPath: .spec.{{.owned.name}}.resources
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        name: chronograf
        path: .spec.replicas
      ownerPath: .{{.owned.name}}.service.replicas
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        name: chronograf
        path: .spec.replicas
      ownerPath: .spec.{{.owned.name}}.resources
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        name: elasticsearch
        path: .spec.template.spec.containers[?(@.name=="{{.owned.name}}")].resources
      ownerPath: .{{.owned.name}}.client.resources
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        name: grafana
        path: .spec.replicas
      ownerPath: .{{.owned.name}}.replicas
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        matchExpressions:
        - key: app.kubernetes.io/name
          operator: In
          values:
          - kibana
          - nginx
          - prometheus-mysql-exporter
          - rsyslog
        path: .spec.replicas
      ownerPath: .{{.owned.name}}.replicaCount
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        name: prometheus-alertmanager
        path: .spec.replicas
      ownerPath: .{{.owned.name}}.alertmanager.replicaCount
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        name: prometheus-kube-state-metrics
        path: .spec.replicas
      ownerPath: .spec.{{.owned.name}}.kubeStateMetrics.replicaCount
    - owned:
        apiVersion: apps/v1
        kind: Deployment
        name: prometheus-pushgateway
        path: .spec.replicas
      ownerPath: .spec.{{.owned.name}}.pushgateway.replicaCount
    selectors:
      turbo_core_components:
        matchExpressions:
        - key: app.kubernetes.io/name
          operator: In
          values:
          - action-orchestrator
          - api
          - auth
          - clustermgr
          - cost
          - extractor
          - db
          - group
          - history
          - intersight-integration
          - kafka
          - kubeturbo
          - market
          - mediation-acims
          - mediation-actionscript
          - mediation-actionstream-kafka
          - mediation-aix
          - mediation-apic
          - mediation-appdynamics
          - mediation-appinsights
          - mediation-aws
          - mediation-awsbilling
          - mediation-awscloudbilling
          - mediation-awscost
          - mediation-awslambda
          - mediation-azure
          - mediation-azurecost
          - mediation-azureea
          - mediation-azuresp
          - mediation-azurevolumes
          - mediation-baremetal
          - mediation-cloudfoundry
          - mediation-compellent
          - mediation-datadog
          - mediation-dynatrace
          - mediation-flexera
          - mediation-gcpproject
          - mediation-gcpbilling
          - mediation-gcpcost
          - mediation-gcpsa
          - mediation-hds
          - mediation-horizon
          - mediation-hpe3par
          - mediation-hyperflex
          - mediation-hyperv
          - mediation-ibmstorage-flashsystem
          - mediation-instana
          - mediation-intersight
          - mediation-intersighthyperflex
          - mediation-intersightucs
          - mediation-istio
          - mediation-jboss
          - mediation-jvm
          - mediation-mssql
          - mediation-mysql
          - mediation-netapp
          - mediation-netflow
          - mediation-newrelic
          - mediation-nutanix
          - mediation-oneview
          - mediation-openstack
          - mediation-oracle
          - mediation-pivotal
          - mediation-pure
          - mediation-rhv
          - mediation-scaleio
          - mediation-servicenow
          - mediation-snmp
          - mediation-tanium
          - mediation-terraform
          - mediation-tetration
          - mediation-tomcat
          - mediation-ucs
          - mediation-ucsdirector
          - mediation-udt
          - mediation-vcd
          - mediation-vcenter
          - mediation-vcenterbrowsing
          - mediation-vmax
          - mediation-vmm
          - mediation-vplex
          - mediation-webhook
          - mediation-weblogic
          - mediation-websphere
          - mediation-wmi
          - mediation-xtremio
          - ml-datastore
          - ml-training
          - plan-orchestrator
          - reporting
          - repository
          - topology-processorws
  owner:
    apiVersion: charts.helm.k8s.io/v1
    kind: Xl
    name: xl-release
    namespace: turbonomic
status:
  owner:
    apiVersion: charts.helm.k8s.io/v1
    kind: Xl
    name: xl-release
    namespace: turbonomic
  ownerValues:
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:elasticsearch,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .elasticsearch.client.resources
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:prometheus-pushgateway,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .prometheus-pushgateway.alertmanager.replicaCount
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:prometheus-pushgateway,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .spec.prometheus-pushgateway.kubeStateMetrics.replicaCount
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:prometheus-pushgateway,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .spec.prometheus-pushgateway.resources
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:elasticsearch,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .spec.elasticsearch.resources
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:prometheus-pushgateway,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .spec.prometheus-pushgateway.pushgateway.replicaCount
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:prometheus-pushgateway,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .spec.prometheus-pushgateway.replicaCount
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:prometheus-pushgateway,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .prometheus-pushgateway.service.replicas
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:prometheus-pushgateway,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .prometheus-pushgateway.replicas
    reason: OwnedResourceError
  - message: 'Failed to locate owned resource: &ObjectReference{Kind:Deployment,Namespace:turbonomic,Name:prometheus-pushgateway,UID:,APIVersion:apps/v1,ResourceVersion:,FieldPath:,}'
    ownerPath: .prometheus-pushgateway.replicaCount
    reason: OwnedResourceError
  state: ok
kuanf commented 1 year ago

@tian-ma we did some change to the location of the samples last week: moved it up to root in library while keeping samples in original place of operator bundling purpose (so that it complies with operator sdk build process). Please move the turbo on turbo in your branch exmaples as well. thanks

tian-ma commented 1 year ago

@tian-ma we did some change to the location of the samples last week: moved it up to root in library while keeping samples in original place of operator bundling purpose (so that it complies with operator sdk build process). Please move the turbo on turbo in your branch exmaples as well. thanks

Merged