From 7112f2d3e18d84e4fdc5e2a5c448361f3e0b3805 Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Mon, 8 Jul 2024 13:26:57 +0600 Subject: [PATCH] Update descriptors, editors & tabledefinitions for kubedb api v1 Signed-off-by: Arnob kumar saha --- go.mod | 2 +- go.sum | 4 +- .../kubedb.com/v1/elasticsearches.yaml | 102 +++++++++ .../kubedb.com/v1/kafkas.yaml | 96 ++++++++ .../kubedb.com/v1/mariadbs.yaml | 104 +++++++++ .../kubedb.com/v1/memcacheds.yaml | 65 ++++++ .../kubedb.com/v1/mongodbs.yaml | 123 +++++++++++ .../kubedb.com/v1/mysqls.yaml | 143 ++++++++++++ .../kubedb.com/v1/perconaxtradbs.yaml | 61 ++++++ .../kubedb.com/v1/pgbouncers.yaml | 51 +++++ .../kubedb.com/v1/postgreses.yaml | 120 ++++++++++ .../kubedb.com/v1/proxysqls.yaml | 79 +++++++ .../kubedb.com/v1/redises.yaml | 102 +++++++++ .../kubedb.com/v1/elasticsearches.yaml | 163 ++++++++++++++ hub/resourceeditors/kubedb.com/v1/kafkas.yaml | 43 ++++ .../kubedb.com/v1/mariadbs.yaml | 177 +++++++++++++++ .../kubedb.com/v1/memcacheds.yaml | 26 +++ .../kubedb.com/v1/mongodbs.yaml | 207 ++++++++++++++++++ hub/resourceeditors/kubedb.com/v1/mysqls.yaml | 177 +++++++++++++++ .../kubedb.com/v1/perconaxtradbs.yaml | 26 +++ .../kubedb.com/v1/pgbouncers.yaml | 26 +++ .../kubedb.com/v1/postgreses.yaml | 177 +++++++++++++++ .../kubedb.com/v1/proxysqls.yaml | 131 +++++++++++ .../kubedb.com/v1/redises.yaml | 177 +++++++++++++++ .../kubedb.com/v1/redissentinels.yaml | 19 ++ .../kubedb.com/v1/elasticsearches.yaml | 73 ++++++ .../kubedb.com/v1/kafkas.yaml | 69 ++++++ .../kubedb.com/v1/mariadbs.yaml | 77 +++++++ .../kubedb.com/v1/memcacheds.yaml | 73 ++++++ .../kubedb.com/v1/mongodbs.yaml | 85 +++++++ .../kubedb.com/v1/mysqls.yaml | 89 ++++++++ .../kubedb.com/v1/perconaxtradbs.yaml | 73 ++++++ .../kubedb.com/v1/pgbouncers.yaml | 73 ++++++ .../kubedb.com/v1/postgreses.yaml | 77 +++++++ .../kubedb.com/v1/proxysqls.yaml | 73 ++++++ .../kubedb.com/v1/redises.yaml | 73 ++++++ .../kubedb.com/v1/redissentinels.yaml | 73 ++++++ .../resource-metrics/api/constants.go | 29 +++ .../resource-metrics/api/interface.go | 89 +++++++- .../resource-metrics/apps/v1/daemonset.go | 10 +- .../resource-metrics/apps/v1/deployment.go | 10 +- .../resource-metrics/apps/v1/replicaset.go | 10 +- .../resource-metrics/apps/v1/statefulset.go | 10 +- .../resource-metrics/batch/v1/cronjob.go | 10 +- .../resource-metrics/batch/v1/job.go | 10 +- .../resource-metrics/batch/v1beta1/cronjob.go | 10 +- .../resource-metrics/calculator.go | 17 ++ .../resource-metrics/core/v1/pod.go | 10 +- .../resource-metrics/core/v1/rc.go | 10 +- .../v1alpha1/connectcluster.go | 10 +- .../kubedb.com/v1/constants.go | 43 ++++ .../kubedb.com/v1/elasticsearch.go | 173 +++++++++++++++ .../resource-metrics/kubedb.com/v1/kafka.go | 140 ++++++++++++ .../resource-metrics/kubedb.com/v1/mariadb.go | 94 ++++++++ .../kubedb.com/v1/memcached.go | 94 ++++++++ .../resource-metrics/kubedb.com/v1/mongodb.go | 171 +++++++++++++++ .../resource-metrics/kubedb.com/v1/mysql.go | 132 +++++++++++ .../kubedb.com/v1/perconaxtradb.go | 94 ++++++++ .../kubedb.com/v1/pgbouncer.go | 94 ++++++++ .../kubedb.com/v1/postgres.go | 95 ++++++++ .../kubedb.com/v1/proxysql.go | 94 ++++++++ .../resource-metrics/kubedb.com/v1/redis.go | 137 ++++++++++++ .../kubedb.com/v1/redissentinel.go | 82 +++++++ .../kubedb.com/v1alpha2/druid.go | 39 ++-- .../kubedb.com/v1alpha2/elasticsearch.go | 29 +-- .../kubedb.com/v1alpha2/ferretdb.go | 10 +- .../kubedb.com/v1alpha2/kafka.go | 29 +-- .../kubedb.com/v1alpha2/mariadb.go | 10 +- .../kubedb.com/v1alpha2/memcached.go | 10 +- .../kubedb.com/v1alpha2/mongodb.go | 20 +- .../kubedb.com/v1alpha2/mysql.go | 12 +- .../kubedb.com/v1alpha2/perconaxtradb.go | 10 +- .../kubedb.com/v1alpha2/pgbouncer.go | 10 +- .../kubedb.com/v1alpha2/pgpool.go | 10 +- .../kubedb.com/v1alpha2/postgres.go | 10 +- .../kubedb.com/v1alpha2/proxysql.go | 10 +- .../kubedb.com/v1alpha2/rabbitmq.go | 10 +- .../kubedb.com/v1alpha2/redis.go | 10 +- .../kubedb.com/v1alpha2/redissentinel.go | 10 +- .../kubedb.com/v1alpha2/singlestore.go | 18 +- .../kubedb.com/v1alpha2/solr.go | 32 +-- .../kubedb.com/v1alpha2/zookeeper.go | 10 +- .../kubevault.com/v1alpha2/vaultserver.go | 10 +- .../ops.kubedb.com/v1alpha1/calculator.go | 14 +- vendor/modules.txt | 3 +- 85 files changed, 5086 insertions(+), 227 deletions(-) create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/constants.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/elasticsearch.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/kafka.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mariadb.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/memcached.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mongodb.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mysql.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/perconaxtradb.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/pgbouncer.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/postgres.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/proxysql.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/redis.go create mode 100644 vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/redissentinel.go diff --git a/go.mod b/go.mod index fc6c05136..e2108b049 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( kmodules.xyz/client-go v0.30.9 kmodules.xyz/crd-schema-fuzz v0.29.1 kmodules.xyz/go-containerregistry v0.0.12 - kmodules.xyz/resource-metrics v0.30.1 + kmodules.xyz/resource-metrics v0.30.2-0.20240711131537-5e9d22977a2c kmodules.xyz/schema-checker v0.4.1 sigs.k8s.io/cli-utils v0.34.0 sigs.k8s.io/controller-runtime v0.18.4 diff --git a/go.sum b/go.sum index ba46d6c37..f624ef4a4 100644 --- a/go.sum +++ b/go.sum @@ -348,8 +348,8 @@ kmodules.xyz/go-containerregistry v0.0.12 h1:Tl32QGmSqRVm9PUEb/f3dgDeu9zW5fVzt3q kmodules.xyz/go-containerregistry v0.0.12/go.mod h1:KgeNg0hDsgeda+qc0NzWk0iVRdF0+ZIg/oRzGoYh78I= kmodules.xyz/offshoot-api v0.29.4 h1:WQV2BIUIoVKKiqZNmZ4gAy367jEdwBhEl3dFCLZM1qA= kmodules.xyz/offshoot-api v0.29.4/go.mod h1:e+NQ0s4gW/YTPWBWEfdISZcmk+tlTq8IjvP5SLdqvko= -kmodules.xyz/resource-metrics v0.30.1 h1:o7mVY8ZwSe5iEILy1eMG4EPZCli7mXZCkgQONjoY9uU= -kmodules.xyz/resource-metrics v0.30.1/go.mod h1:UYcQQLN+3o8rNPQJwJa2D9bt5ihJCeo5bCDuQ4O3MPY= +kmodules.xyz/resource-metrics v0.30.2-0.20240711131537-5e9d22977a2c h1:lh7s0AXSRezZx0YnKSmB5GqGpTk3PQ9xCYxhqdbNFjU= +kmodules.xyz/resource-metrics v0.30.2-0.20240711131537-5e9d22977a2c/go.mod h1:UYcQQLN+3o8rNPQJwJa2D9bt5ihJCeo5bCDuQ4O3MPY= kmodules.xyz/schema-checker v0.4.1 h1:V5UEjR6UMAXf307lTgw+9rDRfHLTNA8g/q9DngqYI9M= kmodules.xyz/schema-checker v0.4.1/go.mod h1:BRXLB3Osuc9raHRJxHOgZFGecZ2aZumLXCHAOa5NPdA= sigs.k8s.io/cli-utils v0.34.0 h1:zCUitt54f0/MYj/ajVFnG6XSXMhpZ72O/3RewIchW8w= diff --git a/hub/resourcedescriptors/kubedb.com/v1/elasticsearches.yaml b/hub/resourcedescriptors/kubedb.com/v1/elasticsearches.yaml index 1793d5636..8a56870ac 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/elasticsearches.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/elasticsearches.yaml @@ -9,6 +9,108 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-elasticsearches spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: elasticsearches.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - auth_secret + references: + - '{.spec.authSecret.name}' + target: + apiVersion: v1 + kind: Secret + type: MatchRef + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: ElasticsearchVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~Elasticsearch.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}~Elasticsearch.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResourceService + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: ElasticsearchInsight + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: ElasticsearchNodesStats + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: ElasticsearchSchemaOverview + type: MatchName + exec: + - alias: Primary + command: + - bash + container: elasticsearch + help: | + curl -XGET -k -u "$ELASTIC_USER:$ELASTIC_PASSWORD" "https://localhost:9200/_cluster/health?pretty" + serviceNameTemplate: '{{- .metadata.name -}}' resource: group: kubedb.com kind: Elasticsearch diff --git a/hub/resourcedescriptors/kubedb.com/v1/kafkas.yaml b/hub/resourcedescriptors/kubedb.com/v1/kafkas.yaml index 3dd66287c..62c8cc321 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/kafkas.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/kafkas.yaml @@ -9,6 +9,102 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-kafkas spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: kafkas.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - connect_via + level: Controller + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: appcatalog.appscode.com/v1alpha1 + kind: AppBinding + type: MatchName + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: KafkaVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~Kafka.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}~Kafka.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResourceService + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: KafkaInsight + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: KafkaNodesStats + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: KafkaSchemaOverview + type: MatchName resource: group: kubedb.com kind: Kafka diff --git a/hub/resourcedescriptors/kubedb.com/v1/mariadbs.yaml b/hub/resourcedescriptors/kubedb.com/v1/mariadbs.yaml index 0d0a4053a..58d7fa6ba 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/mariadbs.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/mariadbs.yaml @@ -9,6 +9,110 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mariadbs spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: mariadbs.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - auth_secret + references: + - '{.spec.authSecret.name}' + target: + apiVersion: v1 + kind: Secret + type: MatchRef + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: MariaDBVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~MariaDB.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}~MariaDB.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResourceService + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MariaDBInsight + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MariaDBQueries + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MariaDBSchemaOverview + type: MatchName + exec: + - alias: Primary + command: + - bash + - -c + - mariadb -u"$MYSQL_ROOT_USERNAME" -p"$MYSQL_ROOT_PASSWORD" + container: mariadb + help: | + show databases; + serviceNameTemplate: '{{- .metadata.name -}}' resource: group: kubedb.com kind: MariaDB diff --git a/hub/resourcedescriptors/kubedb.com/v1/memcacheds.yaml b/hub/resourcedescriptors/kubedb.com/v1/memcacheds.yaml index 612bb11ab..e56bb0ce7 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/memcacheds.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/memcacheds.yaml @@ -9,6 +9,71 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-memcacheds spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: memcacheds.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - connect_via + level: Controller + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: appcatalog.appscode.com/v1alpha1 + kind: AppBinding + type: MatchName + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: MemcachedVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~Memcached.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + exec: + - alias: Primary + command: + - bash + serviceNameTemplate: '{{- .metadata.name -}}' resource: group: kubedb.com kind: Memcached diff --git a/hub/resourcedescriptors/kubedb.com/v1/mongodbs.yaml b/hub/resourcedescriptors/kubedb.com/v1/mongodbs.yaml index 46fb47484..5bc02444f 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/mongodbs.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/mongodbs.yaml @@ -9,6 +9,129 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mongodbs spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: mongodbs.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - auth_secret + references: + - '{.spec.authSecret.name}' + target: + apiVersion: v1 + kind: Secret + type: MatchRef + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: MongoDBVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~MongoDB.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}~MongoDB.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResourceService + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MongoDBInsight + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MongoDBQueries + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MongoDBSchemaOverview + type: MatchName + exec: + - alias: Primary + command: + - bash + - -c + - mongo admin -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" + container: mongodb + help: | + show dbs; + if: + condition: '{{- if or (hasPrefix "percona-3" .spec.version) (hasPrefix "percona-4" + .spec.version) (hasPrefix "percona-5" .spec.version) (hasPrefix "3." .spec.version) + (hasPrefix "4." .spec.version) (hasPrefix "5." .spec.version) }}true{{ else + }}false{{ end -}}' + serviceNameTemplate: '{{- .metadata.name -}}' + - alias: Primary + command: + - bash + - -c + - mongosh admin -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" + container: mongodb + help: | + show dbs; + if: + condition: '{{- if or (hasPrefix "percona-3" .spec.version) (hasPrefix "percona-4" + .spec.version) (hasPrefix "percona-5" .spec.version) (hasPrefix "3." .spec.version) + (hasPrefix "4." .spec.version) (hasPrefix "5." .spec.version) }}false{{ else + }}true{{ end -}}' + serviceNameTemplate: '{{- .metadata.name -}}' resource: group: kubedb.com kind: MongoDB diff --git a/hub/resourcedescriptors/kubedb.com/v1/mysqls.yaml b/hub/resourcedescriptors/kubedb.com/v1/mysqls.yaml index bcc1854dc..1aeaa0bea 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/mysqls.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/mysqls.yaml @@ -9,6 +9,149 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mysqls spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: mysqls.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - auth_secret + references: + - '{.spec.authSecret.name}' + target: + apiVersion: v1 + kind: Secret + type: MatchRef + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: MySQLVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~MySQL.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}~MySQL.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResourceService + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MySQLInsight + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MySQLQueries + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: MySQLSchemaOverview + type: MatchName + exec: + - alias: Primary + command: + - bash + - -c + - mysql -u"$MYSQL_ROOT_USERNAME" -p"$MYSQL_ROOT_PASSWORD" + container: mysql + help: | + show databases; + if: + condition: '{{- if or (eq .spec.topology.mode "GroupReplication") (eq .spec.replicas + 1) }}true{{ else }}false{{ end -}}' + serviceNameTemplate: '{{- .metadata.name -}}' + - alias: Primary + command: + - bash + - -c + - mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" + container: mysql-router + help: | + show databases; + if: + condition: '{{- if eq .spec.topology.mode "InnoDBCluster" }}true{{ else }}false{{ + end -}}' + serviceNameTemplate: '{{- .metadata.name -}}' + - alias: StandBy + command: + - bash + - -c + - mysql -u"$MYSQL_ROOT_USERNAME" -p"$MYSQL_ROOT_PASSWORD" + container: mysql + help: | + show databases; + if: + condition: '{{- if eq .spec.topology.mode "GroupReplication" }}true{{ else }}false{{ + end -}}' + serviceNameTemplate: '{{- printf "%s-standby" .metadata.name -}}' + - alias: StandBy + command: + - bash + - -c + - mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" + container: mysql-router + help: | + show databases; + if: + condition: '{{- if eq .spec.topology.mode "InnoDBCluster" }}true{{ else }}false{{ + end -}}' + serviceNameTemplate: '{{- printf "%s-standby" .metadata.name -}}' resource: group: kubedb.com kind: MySQL diff --git a/hub/resourcedescriptors/kubedb.com/v1/perconaxtradbs.yaml b/hub/resourcedescriptors/kubedb.com/v1/perconaxtradbs.yaml index 8d70a2efe..fbdedfa71 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/perconaxtradbs.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/perconaxtradbs.yaml @@ -9,6 +9,67 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-perconaxtradbs spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: perconaxtradbs.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - connect_via + level: Controller + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: appcatalog.appscode.com/v1alpha1 + kind: AppBinding + type: MatchName + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: PerconaXtraDBVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + exec: + - alias: Primary + command: + - bash + - -c + - mysql -u"$MYSQL_ROOT_USERNAME" -p"$MYSQL_ROOT_PASSWORD" + container: perconaxtradb + help: | + show databases; + serviceNameTemplate: '{{- .metadata.name -}}' resource: group: kubedb.com kind: PerconaXtraDB diff --git a/hub/resourcedescriptors/kubedb.com/v1/pgbouncers.yaml b/hub/resourcedescriptors/kubedb.com/v1/pgbouncers.yaml index efb543086..8f9fdbc30 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/pgbouncers.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/pgbouncers.yaml @@ -9,6 +9,57 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-pgbouncers spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: pgbouncers.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - connect_via + level: Controller + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: appcatalog.appscode.com/v1alpha1 + kind: AppBinding + type: MatchName + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: PgBouncerVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef resource: group: kubedb.com kind: PgBouncer diff --git a/hub/resourcedescriptors/kubedb.com/v1/postgreses.yaml b/hub/resourcedescriptors/kubedb.com/v1/postgreses.yaml index 5dbbf274d..00f7b65ca 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/postgreses.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/postgreses.yaml @@ -9,6 +9,126 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-postgreses spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: postgreses.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - auth_secret + references: + - '{.spec.authSecret.name}' + target: + apiVersion: v1 + kind: Secret + type: MatchRef + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: PostgresVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~Postgres.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}~Postgres.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResourceService + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: PostgresInsight + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: PostgresQueries + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: PostgresSchemaOverview + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: PostgresSettings + type: MatchName + exec: + - alias: Primary + command: + - psql + container: postgres + help: | + \l + serviceNameTemplate: '{{- .metadata.name -}}' + - alias: StandBy + command: + - psql + container: postgres + help: | + \l + if: + condition: '{{- if gt .spec.replicas 1 }}true{{ else }}false{{ end -}}' + serviceNameTemplate: '{{- printf "%s-standby" .metadata.name -}}' resource: group: kubedb.com kind: Postgres diff --git a/hub/resourcedescriptors/kubedb.com/v1/proxysqls.yaml b/hub/resourcedescriptors/kubedb.com/v1/proxysqls.yaml index 147b7e4bd..f5a7688ad 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/proxysqls.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/proxysqls.yaml @@ -9,6 +9,85 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-proxysqls spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: proxysqls.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - connect_via + level: Controller + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: appcatalog.appscode.com/v1alpha1 + kind: AppBinding + type: MatchName + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: ProxySQLVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~ProxySQL.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}~ProxySQL.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResourceService + type: MatchName + exec: + - alias: Primary + command: + - bash + - -c + - mysql -uadmin -padmin -h127.0.0.1 -P6032 --prompt="ProxySQLAdmin > " + container: proxysql + help: | + SELECT * FROM mysql_servers; + serviceNameTemplate: '{{- .metadata.name -}}' resource: group: kubedb.com kind: ProxySQL diff --git a/hub/resourcedescriptors/kubedb.com/v1/redises.yaml b/hub/resourcedescriptors/kubedb.com/v1/redises.yaml index 68f0267a9..31c861dd8 100644 --- a/hub/resourcedescriptors/kubedb.com/v1/redises.yaml +++ b/hub/resourcedescriptors/kubedb.com/v1/redises.yaml @@ -9,6 +9,108 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-redises spec: + connections: + - labels: + - offshoot + level: Controller + namespace: + path: metadata.namespace + selector: + matchLabels: + app.kubernetes.io/instance: '{.metadata.name}' + app.kubernetes.io/managed-by: kubedb.com + app.kubernetes.io/name: redises.kubedb.com + target: + apiVersion: apps/v1 + kind: StatefulSet + type: MatchSelector + - labels: + - auth_secret + references: + - '{.spec.authSecret.name}' + target: + apiVersion: v1 + kind: Secret + type: MatchRef + - labels: + - catalog + references: + - '{.spec.version}' + target: + apiVersion: catalog.kubedb.com/v1alpha1 + kind: RedisVersion + type: MatchRef + - labels: + - cert_issuer + namespace: + path: metadata.namespace + references: + - '{.spec.tls.issuerRef.name},{.metadata.namespace}' + target: + apiVersion: cert-manager.io/v1 + kind: Issuer + type: MatchRef + - labels: + - cert_issuer + references: + - '{.spec.tls.issuerRef.name}' + target: + apiVersion: cert-manager.io/v1 + kind: ClusterIssuer + type: MatchRef + - labels: + - view + nameTemplate: '{.metadata.name}~Redis.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResource + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}~Redis.kubedb.com' + namespace: + path: metadata.namespace + target: + apiVersion: core.k8s.appscode.com/v1alpha1 + kind: GenericResourceService + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: RedisInsight + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: RedisQueries + type: MatchName + - labels: + - view + nameTemplate: '{.metadata.name}' + namespace: + path: metadata.namespace + target: + apiVersion: ui.kubedb.com/v1alpha1 + kind: RedisSchemaOverview + type: MatchName + exec: + - alias: Primary + command: + - redis-cli + container: redis + help: | + ping + serviceNameTemplate: '{{- .metadata.name -}}' resource: group: kubedb.com kind: Redis diff --git a/hub/resourceeditors/kubedb.com/v1/elasticsearches.yaml b/hub/resourceeditors/kubedb.com/v1/elasticsearches.yaml index a9e885b3e..bfadced08 100644 --- a/hub/resourceeditors/kubedb.com/v1/elasticsearches.yaml +++ b/hub/resourceeditors/kubedb.com/v1/elasticsearches.yaml @@ -9,9 +9,172 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-elasticsearches spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/elasticsearches.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/elasticsearches.png + type: image/png resource: group: kubedb.com kind: Elasticsearch name: elasticsearches scope: Namespaced version: v1 + ui: + actions: + - items: + - editor: + name: kubedbcom-elasticsearch-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/backup.svg + type: image/svg+xml + name: Backup + operationId: edit-self-backupconfiguration + - editor: + name: stashappscodecom-restoresession-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restore.svg + type: image/svg+xml + name: Restore + operationId: create-restoresession + name: Backups + - items: + - editor: + name: opskubedbcom-elasticsearchopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/version.svg + type: image/svg+xml + name: Update Version + operationId: create-opsrequest-upgrade + - editor: + name: opskubedbcom-elasticsearchopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restart.svg + type: image/svg+xml + name: Restart + operationId: create-opsrequest-restart + name: Operations + - items: + - editor: + name: opskubedbcom-elasticsearchopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/horizontal_scale.svg + type: image/svg+xml + name: Horizontal Scale + operationId: create-opsrequest-horizontalscaling + - editor: + name: opskubedbcom-elasticsearchopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/vertical_scale.svg + type: image/svg+xml + name: Vertical Scale + operationId: create-opsrequest-verticalscaling + - editor: + name: opskubedbcom-elasticsearchopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/expand.svg + type: image/svg+xml + name: Expand Volume + operationId: create-opsrequest-volumeexpansion + name: Scaling + - items: + - disabledTemplate: | + {{ not (and (hasKey .spec "tls") ( hasKey .spec.tls "issuerRef"))}} + editor: + name: opskubedbcom-elasticsearchopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/configure.svg + type: image/svg+xml + name: TLS Configure + operationId: create-opsrequest-reconfiguretls + - editor: + name: kubedbcom-elasticsearch-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/monitor.svg + type: image/svg+xml + name: Monitoring + operationId: edit-self-monitoring + name: Security & Monitoring + editor: + name: kubedbcom-elasticsearch-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: true + options: + name: kubedbcom-elasticsearch-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/kafkas.yaml b/hub/resourceeditors/kubedb.com/v1/kafkas.yaml index 2f7bfe7a4..f5d785347 100644 --- a/hub/resourceeditors/kubedb.com/v1/kafkas.yaml +++ b/hub/resourceeditors/kubedb.com/v1/kafkas.yaml @@ -9,9 +9,52 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-kafkas spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/kafkas.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/kafkas.png + type: image/png resource: group: kubedb.com kind: Kafka name: kafkas scope: Namespaced version: v1 + ui: + actions: + - items: + - editor: + name: kubedbcom-kafka-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/monitor.svg + type: image/svg+xml + name: Monitoring + operationId: edit-self-monitoring + name: Security & Monitoring + editor: + name: kubedbcom-kafka-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: true + options: + name: kubedbcom-kafka-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/mariadbs.yaml b/hub/resourceeditors/kubedb.com/v1/mariadbs.yaml index 3ed03f362..26e3d8e20 100644 --- a/hub/resourceeditors/kubedb.com/v1/mariadbs.yaml +++ b/hub/resourceeditors/kubedb.com/v1/mariadbs.yaml @@ -9,9 +9,186 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mariadbs spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/mariadbs.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/mariadbs.png + type: image/png resource: group: kubedb.com kind: MariaDB name: mariadbs scope: Namespaced version: v1 + ui: + actions: + - items: + - editor: + name: kubedbcom-mariadb-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/backup.svg + type: image/svg+xml + name: Backup + operationId: edit-self-backupconfiguration + - editor: + name: stashappscodecom-restoresession-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restore.svg + type: image/svg+xml + name: Restore + operationId: create-restoresession + name: Backups + - items: + - editor: + name: opskubedbcom-mariadbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/version.svg + type: image/svg+xml + name: Update Version + operationId: create-opsrequest-upgrade + - editor: + name: opskubedbcom-mariadbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restart.svg + type: image/svg+xml + name: Restart + operationId: create-opsrequest-restart + - editor: + name: opskubedbcom-mariadbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/reconfigure.svg + type: image/svg+xml + name: Reconfigure + operationId: create-opsrequest-reconfigure + name: Operations + - items: + - disabledTemplate: | + {{ not (gt .spec.replicas 1) }} + editor: + name: opskubedbcom-mariadbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/horizontal_scale.svg + type: image/svg+xml + name: Horizontal Scale + operationId: create-opsrequest-horizontalscaling + - editor: + name: opskubedbcom-mariadbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/vertical_scale.svg + type: image/svg+xml + name: Vertical Scale + operationId: create-opsrequest-verticalscaling + - editor: + name: opskubedbcom-mariadbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/expand.svg + type: image/svg+xml + name: Expand Volume + operationId: create-opsrequest-volumeexpansion + name: Scaling + - items: + - editor: + name: opskubedbcom-mariadbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/configure.svg + type: image/svg+xml + name: TLS Configure + operationId: create-opsrequest-reconfiguretls + - editor: + name: kubedbcom-mariadb-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/monitor.svg + type: image/svg+xml + name: Monitoring + operationId: edit-self-monitoring + name: Security & Monitoring + editor: + name: kubedbcom-mariadb-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: true + options: + name: kubedbcom-mariadb-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/memcacheds.yaml b/hub/resourceeditors/kubedb.com/v1/memcacheds.yaml index 1e788f8e9..ad503b1bb 100644 --- a/hub/resourceeditors/kubedb.com/v1/memcacheds.yaml +++ b/hub/resourceeditors/kubedb.com/v1/memcacheds.yaml @@ -9,9 +9,35 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-memcacheds spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/memcacheds.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/memcacheds.png + type: image/png resource: group: kubedb.com kind: Memcached name: memcacheds scope: Namespaced version: v1 + ui: + editor: + name: kubedbcom-memcached-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: false + options: + name: kubedbcom-memcached-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/mongodbs.yaml b/hub/resourceeditors/kubedb.com/v1/mongodbs.yaml index daeded46a..857951fed 100644 --- a/hub/resourceeditors/kubedb.com/v1/mongodbs.yaml +++ b/hub/resourceeditors/kubedb.com/v1/mongodbs.yaml @@ -9,9 +9,216 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mongodbs spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/mongodbs.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/mongodbs.png + type: image/png resource: group: kubedb.com kind: MongoDB name: mongodbs scope: Namespaced version: v1 + ui: + actions: + - items: + - editor: + name: kubedbcom-mongodb-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/backup.svg + type: image/svg+xml + name: Backup + operationId: edit-self-backupconfiguration + - editor: + name: stashappscodecom-restoresession-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restore.svg + type: image/svg+xml + name: Restore + operationId: create-restoresession + name: Backups + - items: + - editor: + name: opskubedbcom-mongodbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/version.svg + type: image/svg+xml + name: Update Version + operationId: create-opsrequest-upgrade + - editor: + name: opskubedbcom-mongodbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restart.svg + type: image/svg+xml + name: Restart + operationId: create-opsrequest-restart + - editor: + name: opskubedbcom-mongodbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/reconfigure.svg + type: image/svg+xml + name: Reconfigure + operationId: create-opsrequest-reconfigure + name: Operations + - items: + - disabledTemplate: | + {{ not (or (hasKey .spec "shardTopology") ( hasKey .spec "replicaSet"))}} + editor: + name: opskubedbcom-mongodbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/horizontal_scale.svg + type: image/svg+xml + name: Horizontal Scale + operationId: create-opsrequest-horizontalscaling + - editor: + name: opskubedbcom-mongodbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/vertical_scale.svg + type: image/svg+xml + name: Vertical Scale + operationId: create-opsrequest-verticalscaling + - editor: + name: opskubedbcom-mongodbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/expand.svg + type: image/svg+xml + name: Expand Volume + operationId: create-opsrequest-volumeexpansion + name: Scaling + - items: + - editor: + name: autoscalingkubedbcom-mongodbautoscaler-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/compute.svg + type: image/svg+xml + name: Compute + operationId: create-opsrequest-compute + - editor: + name: autoscalingkubedbcom-mongodbautoscaler-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/storage.svg + type: image/svg+xml + name: Storage + operationId: create-opsrequest-storage + name: Autoscaling + - items: + - editor: + name: opskubedbcom-mongodbopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/configure.svg + type: image/svg+xml + name: TLS Configure + operationId: create-opsrequest-reconfiguretls + - editor: + name: kubedbcom-mongodb-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/monitor.svg + type: image/svg+xml + name: Monitoring + operationId: edit-self-monitoring + name: Security & Monitoring + editor: + name: kubedbcom-mongodb-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: true + options: + name: kubedbcom-mongodb-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/mysqls.yaml b/hub/resourceeditors/kubedb.com/v1/mysqls.yaml index b202cb24a..8d2cb8b28 100644 --- a/hub/resourceeditors/kubedb.com/v1/mysqls.yaml +++ b/hub/resourceeditors/kubedb.com/v1/mysqls.yaml @@ -9,9 +9,186 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mysqls spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/mysqls.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/mysqls.png + type: image/png resource: group: kubedb.com kind: MySQL name: mysqls scope: Namespaced version: v1 + ui: + actions: + - items: + - editor: + name: kubedbcom-mysql-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/backup.svg + type: image/svg+xml + name: Backup + operationId: edit-self-backupconfiguration + - editor: + name: stashappscodecom-restoresession-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restore.svg + type: image/svg+xml + name: Restore + operationId: create-restoresession + name: Backups + - items: + - editor: + name: opskubedbcom-mysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/version.svg + type: image/svg+xml + name: Update Version + operationId: create-opsrequest-upgrade + - editor: + name: opskubedbcom-mysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restart.svg + type: image/svg+xml + name: Restart + operationId: create-opsrequest-restart + - editor: + name: opskubedbcom-mysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/reconfigure.svg + type: image/svg+xml + name: Reconfigure + operationId: create-opsrequest-reconfigure + name: Operations + - items: + - disabledTemplate: | + {{ not (and (hasKey .spec "topology") (hasKey .spec.topology "mode")) }} + editor: + name: opskubedbcom-mysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/horizontal_scale.svg + type: image/svg+xml + name: Horizontal Scale + operationId: create-opsrequest-horizontalscaling + - editor: + name: opskubedbcom-mysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/vertical_scale.svg + type: image/svg+xml + name: Vertical Scale + operationId: create-opsrequest-verticalscaling + - editor: + name: opskubedbcom-mysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/expand.svg + type: image/svg+xml + name: Expand Volume + operationId: create-opsrequest-volumeexpansion + name: Scaling + - items: + - editor: + name: opskubedbcom-mysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/configure.svg + type: image/svg+xml + name: TLS Configure + operationId: create-opsrequest-reconfiguretls + - editor: + name: kubedbcom-mysql-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/monitor.svg + type: image/svg+xml + name: Monitoring + operationId: edit-self-monitoring + name: Security & Monitoring + editor: + name: kubedbcom-mysql-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: true + options: + name: kubedbcom-mysql-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/perconaxtradbs.yaml b/hub/resourceeditors/kubedb.com/v1/perconaxtradbs.yaml index 37384f29f..b13b556cc 100644 --- a/hub/resourceeditors/kubedb.com/v1/perconaxtradbs.yaml +++ b/hub/resourceeditors/kubedb.com/v1/perconaxtradbs.yaml @@ -9,9 +9,35 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-perconaxtradbs spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/perconaxtradbs.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/perconaxtradbs.png + type: image/png resource: group: kubedb.com kind: PerconaXtraDB name: perconaxtradbs scope: Namespaced version: v1 + ui: + editor: + name: kubedbcom-perconaxtradb-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: true + options: + name: kubedbcom-perconaxtradb-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/pgbouncers.yaml b/hub/resourceeditors/kubedb.com/v1/pgbouncers.yaml index 33a253064..a50b9342f 100644 --- a/hub/resourceeditors/kubedb.com/v1/pgbouncers.yaml +++ b/hub/resourceeditors/kubedb.com/v1/pgbouncers.yaml @@ -9,9 +9,35 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-pgbouncers spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/pgbouncers.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/pgbouncers.png + type: image/png resource: group: kubedb.com kind: PgBouncer name: pgbouncers scope: Namespaced version: v1 + ui: + editor: + name: kubedbcom-pgbouncer-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: false + options: + name: kubedbcom-pgbouncer-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/postgreses.yaml b/hub/resourceeditors/kubedb.com/v1/postgreses.yaml index 6185d2941..ebbd938e6 100644 --- a/hub/resourceeditors/kubedb.com/v1/postgreses.yaml +++ b/hub/resourceeditors/kubedb.com/v1/postgreses.yaml @@ -9,9 +9,186 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-postgreses spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/postgreses.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/postgreses.png + type: image/png resource: group: kubedb.com kind: Postgres name: postgreses scope: Namespaced version: v1 + ui: + actions: + - items: + - editor: + name: kubedbcom-postgres-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/backup.svg + type: image/svg+xml + name: Backup + operationId: edit-self-backupconfiguration + - editor: + name: stashappscodecom-restoresession-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restore.svg + type: image/svg+xml + name: Restore + operationId: create-restoresession + name: Backups + - items: + - editor: + name: opskubedbcom-postgresopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/version.svg + type: image/svg+xml + name: Update Version + operationId: create-opsrequest-upgrade + - editor: + name: opskubedbcom-postgresopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restart.svg + type: image/svg+xml + name: Restart + operationId: create-opsrequest-restart + - editor: + name: opskubedbcom-postgresopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/reconfigure.svg + type: image/svg+xml + name: Reconfigure + operationId: create-opsrequest-reconfigure + name: Operations + - items: + - disabledTemplate: | + {{ not (hasKey .spec "standbyMode") }} + editor: + name: opskubedbcom-postgresopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/horizontal_scale.svg + type: image/svg+xml + name: Horizontal Scale + operationId: create-opsrequest-horizontalscaling + - editor: + name: opskubedbcom-postgresopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/vertical_scale.svg + type: image/svg+xml + name: Vertical Scale + operationId: create-opsrequest-verticalscaling + - editor: + name: opskubedbcom-postgresopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/expand.svg + type: image/svg+xml + name: Expand Volume + operationId: create-opsrequest-volumeexpansion + name: Scaling + - items: + - editor: + name: opskubedbcom-postgresopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/configure.svg + type: image/svg+xml + name: TLS Configure + operationId: create-opsrequest-reconfiguretls + - editor: + name: kubedbcom-postgres-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/monitor.svg + type: image/svg+xml + name: Monitoring + operationId: edit-self-monitoring + name: Security & Monitoring + editor: + name: kubedbcom-postgres-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: true + options: + name: kubedbcom-postgres-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/proxysqls.yaml b/hub/resourceeditors/kubedb.com/v1/proxysqls.yaml index a8c5099a6..3a7a7b9b5 100644 --- a/hub/resourceeditors/kubedb.com/v1/proxysqls.yaml +++ b/hub/resourceeditors/kubedb.com/v1/proxysqls.yaml @@ -9,9 +9,140 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-proxysqls spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/proxysqls.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/proxysqls.png + type: image/png resource: group: kubedb.com kind: ProxySQL name: proxysqls scope: Namespaced version: v1 + ui: + actions: + - items: + - editor: + name: opskubedbcom-proxysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/version.svg + type: image/svg+xml + name: Update Version + operationId: create-opsrequest-upgrade + - editor: + name: opskubedbcom-proxysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restart.svg + type: image/svg+xml + name: Restart + operationId: create-opsrequest-restart + - editor: + name: opskubedbcom-proxysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/reconfigure.svg + type: image/svg+xml + name: Reconfigure + operationId: create-opsrequest-reconfigure + name: Operations + - items: + - editor: + name: opskubedbcom-proxysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/horizontal_scale.svg + type: image/svg+xml + name: Horizontal Scale + operationId: create-opsrequest-horizontalscaling + - editor: + name: opskubedbcom-proxysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/vertical_scale.svg + type: image/svg+xml + name: Vertical Scale + operationId: create-opsrequest-verticalscaling + name: Scaling + - items: + - editor: + name: opskubedbcom-proxysqlopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/configure.svg + type: image/svg+xml + name: TLS Configure + operationId: create-opsrequest-reconfiguretls + - editor: + name: kubedbcom-proxysql-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/monitor.svg + type: image/svg+xml + name: Monitoring + operationId: edit-self-monitoring + name: Security & Monitoring + editor: + name: kubedbcom-proxysql-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: false + options: + name: kubedbcom-proxysql-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/redises.yaml b/hub/resourceeditors/kubedb.com/v1/redises.yaml index 1d62040a8..be7798c7e 100644 --- a/hub/resourceeditors/kubedb.com/v1/redises.yaml +++ b/hub/resourceeditors/kubedb.com/v1/redises.yaml @@ -9,9 +9,186 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-redises spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/redises.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/redises.png + type: image/png resource: group: kubedb.com kind: Redis name: redises scope: Namespaced version: v1 + ui: + actions: + - items: + - editor: + name: kubedbcom-redis-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/backup.svg + type: image/svg+xml + name: Backup + operationId: edit-self-backupconfiguration + - editor: + name: stashappscodecom-restoresession-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restore.svg + type: image/svg+xml + name: Restore + operationId: create-restoresession + name: Backups + - items: + - editor: + name: opskubedbcom-redisopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/version.svg + type: image/svg+xml + name: Update Version + operationId: create-opsrequest-upgrade + - editor: + name: opskubedbcom-redisopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/restart.svg + type: image/svg+xml + name: Restart + operationId: create-opsrequest-restart + - editor: + name: opskubedbcom-redisopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/reconfigure.svg + type: image/svg+xml + name: Reconfigure + operationId: create-opsrequest-reconfigure + name: Operations + - items: + - disabledTemplate: | + {{ or (not (hasKey .spec "mode")) (eq .spec.mode "Standalone") }} + editor: + name: opskubedbcom-redisopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/horizontal_scale.svg + type: image/svg+xml + name: Horizontal Scale + operationId: create-opsrequest-horizontalscaling + - editor: + name: opskubedbcom-redisopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/vertical_scale.svg + type: image/svg+xml + name: Vertical Scale + operationId: create-opsrequest-verticalscaling + - editor: + name: opskubedbcom-redisopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: true + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/expand.svg + type: image/svg+xml + name: Expand Volume + operationId: create-opsrequest-volumeexpansion + name: Scaling + - items: + - editor: + name: opskubedbcom-redisopsrequest-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-create + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/configure.svg + type: image/svg+xml + name: TLS Configure + operationId: create-opsrequest-reconfiguretls + - editor: + name: kubedbcom-redis-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + enforceQuota: false + flow: standalone-edit + icons: + - src: https://cdn.appscode.com/k8s/icons/action-icons/monitor.svg + type: image/svg+xml + name: Monitoring + operationId: edit-self-monitoring + name: Security & Monitoring + editor: + name: kubedbcom-redis-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: true + options: + name: kubedbcom-redis-editor-options + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.20 + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourceeditors/kubedb.com/v1/redissentinels.yaml b/hub/resourceeditors/kubedb.com/v1/redissentinels.yaml index 4ab4be905..ba91a630a 100644 --- a/hub/resourceeditors/kubedb.com/v1/redissentinels.yaml +++ b/hub/resourceeditors/kubedb.com/v1/redissentinels.yaml @@ -9,9 +9,28 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-redissentinels spec: + icons: + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/redissentinels.svg + type: image/svg+xml + - src: https://cdn.appscode.com/k8s/icons/kubedb.com/redissentinels.png + type: image/png resource: group: kubedb.com kind: RedisSentinel name: redissentinels scope: Namespaced version: v1 + ui: + editor: + name: kubedbcom-redissentinel-editor + sourceRef: + apiGroup: source.toolkit.fluxcd.io + kind: HelmRepository + name: appscode-charts-oci + version: v0.4.21 + enforceQuota: false + variants: + - name: default + selector: + matchLabels: + charts.x-helm.dev/is-default-preset: "true" diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/elasticsearches.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/elasticsearches.yaml index 7195ad40b..d0f187b50 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/elasticsearches.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/elasticsearches.yaml @@ -9,6 +9,79 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-elasticsearches spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: object + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: HTTPS + pathTemplate: '{{ .spec.enableSSL }}' + priority: 3 + type: string + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/kafkas.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/kafkas.yaml index 663aacb37..02b701b98 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/kafkas.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/kafkas.yaml @@ -9,6 +9,75 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-kafkas spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: object + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: HTTPS + pathTemplate: '{{ .spec.enableSSL }}' + priority: 3 + type: string + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/mariadbs.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/mariadbs.yaml index 9eaf3221a..2369776ac 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/mariadbs.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/mariadbs.yaml @@ -9,6 +9,83 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mariadbs spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: SSL Required + pathTemplate: '{{ .spec.requireSSL }}' + priority: 3 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/memcacheds.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/memcacheds.yaml index 41eac5f6b..747237033 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/memcacheds.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/memcacheds.yaml @@ -9,6 +9,79 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-memcacheds spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/mongodbs.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/mongodbs.yaml index a3e1cf0f1..eb909c07d 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/mongodbs.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/mongodbs.yaml @@ -9,6 +9,91 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mongodbs spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: SSL Mode + pathTemplate: '{{ .spec.sslMode }}' + priority: 3 + type: string + - name: Cluster Auth Mode + pathTemplate: '{{ .spec.clusterAuthMode }}' + priority: 1 + type: string + - name: Storage Engine + pathTemplate: '{{ .spec.storageEngine }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/mysqls.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/mysqls.yaml index 999340fef..2874284e5 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/mysqls.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/mysqls.yaml @@ -9,6 +9,95 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-mysqls spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: SSL Required + pathTemplate: '{{ .spec.requireSSL }}' + priority: 3 + type: string + - name: Cluster Auth Mode + pathTemplate: '{{ .spec.clusterAuthMode }}' + priority: 1 + type: string + - name: Storage Engine + pathTemplate: '{{ .spec.storageEngine }}' + priority: 1 + type: string + - name: Address Type + pathTemplate: '{{ .spec.useAddressType }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/perconaxtradbs.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/perconaxtradbs.yaml index fd039b51c..09f9c836e 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/perconaxtradbs.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/perconaxtradbs.yaml @@ -9,6 +9,79 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-perconaxtradbs spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/pgbouncers.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/pgbouncers.yaml index d007481f6..8a8580cb1 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/pgbouncers.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/pgbouncers.yaml @@ -9,6 +9,79 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-pgbouncers spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/postgreses.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/postgreses.yaml index 579c67502..16717b9ab 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/postgreses.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/postgreses.yaml @@ -9,6 +9,83 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-postgreses spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Standby Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Client Auth Mode + pathTemplate: '{{ .spec.clientAuthMode }}' + priority: 3 + type: string + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/proxysqls.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/proxysqls.yaml index 8501de0c3..e9af6cb33 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/proxysqls.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/proxysqls.yaml @@ -9,6 +9,79 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-proxysqls spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/redises.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/redises.yaml index 76a3a5ba2..619d17d36 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/redises.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/redises.yaml @@ -9,6 +9,79 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-redises spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/hub/resourcetabledefinitions/kubedb.com/v1/redissentinels.yaml b/hub/resourcetabledefinitions/kubedb.com/v1/redissentinels.yaml index dd51ac44d..ab0c08470 100644 --- a/hub/resourcetabledefinitions/kubedb.com/v1/redissentinels.yaml +++ b/hub/resourcetabledefinitions/kubedb.com/v1/redissentinels.yaml @@ -9,6 +9,79 @@ metadata: k8s.io/version: v1 name: kubedb.com-v1-redissentinels spec: + columns: + - name: Name + pathTemplate: '{{ .metadata.name }}' + priority: 3 + type: string + - name: Namespace + pathTemplate: '{{ .metadata.namespace }}' + priority: 3 + type: string + - name: Labels + pathTemplate: '{{ .metadata.labels | toRawJson }}' + priority: 3 + type: object + - name: Annotations + pathTemplate: '{{ .metadata.annotations | toRawJson }}' + priority: 1 + type: object + - name: Version + pathTemplate: '{{ .spec.version }}' + priority: 3 + type: string + - name: Mode + pathTemplate: '{{ k8s_resource_mode . }}' + priority: 3 + type: string + - name: Replicas + pathTemplate: '{{ k8s_resource_replicas_by_roles . | toRawJson }}' + priority: 3 + type: string + - color: + template: | + {{ $status := .status.phase }} + {{ $color := "gray" }} + {{ if list "Provisioning" "DataRestoring" | has $status }} + {{ $color = "info" }} + {{ else if list "Ready" | has $status }} + {{ $color = "success" }} + {{ else if list "Critical" | has $status }} + {{ $color = "warning" }} + {{ else if list "NotReady" | has $status }} + {{ $color = "danger" }} + {{ else if list "Halted" | has $status }} + {{ $color = "gray" }} + {{ end }} + {{- printf "%s" $color -}} + name: Phase + pathTemplate: '{{ .status.phase }}' + priority: 3 + type: string + - name: Total Resources + pathTemplate: '{{ k8s_total_resource_limits . | toRawJson }}' + priority: 3 + type: object + - name: Auth Secret + pathTemplate: '{{ .spec.authSecret.name }}' + priority: 1 + type: string + - name: Termination Policy + pathTemplate: '{{ .spec.terminationPolicy }}' + priority: 3 + type: string + - name: Halted + pathTemplate: '{{ .spec.halted }}' + priority: 1 + type: string + - name: Age + pathTemplate: '{{ .metadata.creationTimestamp }}' + priority: 3 + sort: + enable: true + template: '{{ .metadata.creationTimestamp | toDate "2006-01-02T15:04:05Z07:00" | unixEpoch }}' + type: integer + type: date defaultView: true resource: group: kubedb.com diff --git a/vendor/kmodules.xyz/resource-metrics/api/constants.go b/vendor/kmodules.xyz/resource-metrics/api/constants.go index 65a5ebf9d..316ea1639 100644 --- a/vendor/kmodules.xyz/resource-metrics/api/constants.go +++ b/vendor/kmodules.xyz/resource-metrics/api/constants.go @@ -16,6 +16,8 @@ limitations under the License. package api +import core "k8s.io/api/core/v1" + type PodRole string const ( @@ -30,6 +32,33 @@ const ( PodRoleMongos PodRole = "mongos" PodRoleAggregator PodRole = "aggregator" PodRoleLeaf PodRole = "leaf" + PodRoleMaster PodRole = "master" + PodRoleData PodRole = "data" + PodRoleIngest PodRole = "ingest" + PodRoleDataContent PodRole = "dataContent" + PodRoleDataHot PodRole = "dataHot" + PodRoleDataWarm PodRole = "dataWarm" + PodRoleDataCold PodRole = "dataCold" + PodRoleDataFrozen PodRole = "dataFrozen" + PodRoleML PodRole = "ml" + PodRoleTransform PodRole = "transform" + PodRoleCoordinating PodRole = "coordinating" + PodRoleOverseer PodRole = "overseer" + PodRoleCoordinator PodRole = "coordinator" + PodRoleCoordinators PodRole = "coordinators" + PodRoleBroker PodRole = "broker" + PodRoleBrokers PodRole = "brokers" + PodRoleController PodRole = "controller" + PodRoleCombined PodRole = "combined" + PodRoleOverlords PodRole = "overlords" + PodRoleMiddleManagers PodRole = "middleManagers" + PodRoleHistoricals PodRole = "historicals" + PodRoleRouters PodRole = "routers" ) type ReplicaList map[PodRole]int64 + +type PodInfo struct { + Resource core.ResourceList + Replicas int64 +} diff --git a/vendor/kmodules.xyz/resource-metrics/api/interface.go b/vendor/kmodules.xyz/resource-metrics/api/interface.go index ed3735f43..e34a05fcf 100644 --- a/vendor/kmodules.xyz/resource-metrics/api/interface.go +++ b/vendor/kmodules.xyz/resource-metrics/api/interface.go @@ -17,10 +17,15 @@ limitations under the License. package api import ( + "slices" + core "k8s.io/api/core/v1" ) type ResourceCalculator interface { + GetRoleResourceLimitsFn() func(obj map[string]interface{}) (map[PodRole]PodInfo, error) + GetRoleResourceRequestsFn() func(obj map[string]interface{}) (map[PodRole]PodInfo, error) + Replicas(obj map[string]interface{}) (int64, error) RoleReplicas(obj map[string]interface{}) (ReplicaList, error) @@ -35,6 +40,9 @@ type ResourceCalculator interface { RoleResourceLimits(obj map[string]interface{}) (map[PodRole]core.ResourceList, error) RoleResourceRequests(obj map[string]interface{}) (map[PodRole]core.ResourceList, error) + + PodResourceRequests(obj map[string]interface{}) (core.ResourceList, error) + PodResourceLimits(obj map[string]interface{}) (core.ResourceList, error) } type ResourceCalculatorFuncs struct { @@ -48,12 +56,20 @@ type ResourceCalculatorFuncs struct { RoleReplicasFn func(obj map[string]interface{}) (ReplicaList, error) ModeFn func(obj map[string]interface{}) (string, error) UsesTLSFn func(obj map[string]interface{}) (bool, error) - RoleResourceLimitsFn func(obj map[string]interface{}) (map[PodRole]core.ResourceList, error) - RoleResourceRequestsFn func(obj map[string]interface{}) (map[PodRole]core.ResourceList, error) + RoleResourceLimitsFn func(obj map[string]interface{}) (map[PodRole]PodInfo, error) + RoleResourceRequestsFn func(obj map[string]interface{}) (map[PodRole]PodInfo, error) } var _ ResourceCalculator = &ResourceCalculatorFuncs{} +func (c ResourceCalculatorFuncs) GetRoleResourceLimitsFn() func(obj map[string]interface{}) (map[PodRole]PodInfo, error) { + return c.RoleResourceLimitsFn +} + +func (c ResourceCalculatorFuncs) GetRoleResourceRequestsFn() func(obj map[string]interface{}) (map[PodRole]PodInfo, error) { + return c.RoleResourceRequestsFn +} + func (c ResourceCalculatorFuncs) Replicas(obj map[string]interface{}) (int64, error) { replicas, err := c.RoleReplicas(obj) if err != nil { @@ -123,9 +139,74 @@ func (c ResourceCalculatorFuncs) AppResourceRequests(obj map[string]interface{}) } func (c ResourceCalculatorFuncs) RoleResourceLimits(obj map[string]interface{}) (map[PodRole]core.ResourceList, error) { - return c.RoleResourceLimitsFn(obj) + ret := make(map[PodRole]core.ResourceList) + rr, err := c.RoleResourceLimitsFn(obj) + if err != nil { + return nil, err + } + for role, info := range rr { + ret[role] = MulResourceList(info.Resource, info.Replicas) + } + return ret, nil } func (c ResourceCalculatorFuncs) RoleResourceRequests(obj map[string]interface{}) (map[PodRole]core.ResourceList, error) { - return c.RoleResourceRequestsFn(obj) + ret := make(map[PodRole]core.ResourceList) + rr, err := c.RoleResourceRequestsFn(obj) + if err != nil { + return nil, err + } + for role, info := range rr { + ret[role] = MulResourceList(info.Resource, info.Replicas) + } + return ret, nil +} + +func (c ResourceCalculatorFuncs) PodResourceLimits(obj map[string]interface{}) (core.ResourceList, error) { + rl, err := c.RoleResourceLimitsFn(obj) + if err != nil { + return nil, err + } + return c.calcForPod(rl), nil +} + +func (c ResourceCalculatorFuncs) PodResourceRequests(obj map[string]interface{}) (core.ResourceList, error) { + rr, err := c.RoleResourceRequestsFn(obj) + if err != nil { + return nil, err + } + return c.calcForPod(rr), nil +} + +func (c ResourceCalculatorFuncs) calcForPod(roleInfoMap map[PodRole]PodInfo) core.ResourceList { + mx := core.ResourceList{} + extraRoles := c.getExtraRoles() + for _, role := range c.AppRoles { + if _, exist := roleInfoMap[role]; !exist { + continue + } + res := roleInfoMap[role].Resource + for _, extraRole := range extraRoles { + if _, exist := roleInfoMap[extraRole]; !exist { + continue + } + extraRes := roleInfoMap[extraRole].Resource + res = AddResourceList(res, extraRes) + } + if initInfo, exist := roleInfoMap[PodRoleInit]; exist { + res = MaxResourceList(res, initInfo.Resource) + } + mx = MaxResourceList(res, mx) + } + return mx +} + +func (c ResourceCalculatorFuncs) getExtraRoles() []PodRole { + roles := make([]PodRole, 0) + for _, role := range c.RuntimeRoles { + if !slices.Contains(c.AppRoles, role) { + roles = append(roles, role) + } + } + return roles } diff --git a/vendor/kmodules.xyz/resource-metrics/apps/v1/daemonset.go b/vendor/kmodules.xyz/resource-metrics/apps/v1/daemonset.go index 813dd80f6..dc746a34d 100644 --- a/vendor/kmodules.xyz/resource-metrics/apps/v1/daemonset.go +++ b/vendor/kmodules.xyz/resource-metrics/apps/v1/daemonset.go @@ -43,8 +43,8 @@ func (_ DaemonSet) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, return nil, nil } -func (r DaemonSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r DaemonSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { containers, err := api.AggregateContainerResources(obj, fn, api.AddResourceList, "spec", "template", "spec", "containers") if err != nil { return nil, err @@ -53,9 +53,9 @@ func (r DaemonSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.Res if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: containers, - api.PodRoleInit: initContainers, + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: containers, Replicas: 1}, + api.PodRoleInit: {Resource: initContainers, Replicas: 1}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/apps/v1/deployment.go b/vendor/kmodules.xyz/resource-metrics/apps/v1/deployment.go index 5cc23c256..b26bed4bd 100644 --- a/vendor/kmodules.xyz/resource-metrics/apps/v1/deployment.go +++ b/vendor/kmodules.xyz/resource-metrics/apps/v1/deployment.go @@ -53,8 +53,8 @@ func (_ Deployment) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, return api.ReplicaList{api.PodRoleDefault: replicas}, nil } -func (r Deployment) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Deployment) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { rr, err := r.roleReplicasFn(obj) if err != nil { return nil, err @@ -69,9 +69,9 @@ func (r Deployment) roleResourceFn(fn func(rr core.ResourceRequirements) core.Re if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(containers, replicas), - api.PodRoleInit: api.MulResourceList(initContainers, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: containers, Replicas: replicas}, + api.PodRoleInit: {Resource: initContainers, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/apps/v1/replicaset.go b/vendor/kmodules.xyz/resource-metrics/apps/v1/replicaset.go index 9a21294b8..22ee9f487 100644 --- a/vendor/kmodules.xyz/resource-metrics/apps/v1/replicaset.go +++ b/vendor/kmodules.xyz/resource-metrics/apps/v1/replicaset.go @@ -53,8 +53,8 @@ func (_ ReplicaSet) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, return api.ReplicaList{api.PodRoleDefault: replicas}, nil } -func (r ReplicaSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r ReplicaSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { rr, err := r.roleReplicasFn(obj) if err != nil { return nil, err @@ -69,9 +69,9 @@ func (r ReplicaSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.Re if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(containers, replicas), - api.PodRoleInit: api.MulResourceList(initContainers, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: containers, Replicas: replicas}, + api.PodRoleInit: {Resource: initContainers, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/apps/v1/statefulset.go b/vendor/kmodules.xyz/resource-metrics/apps/v1/statefulset.go index 9eda6d739..fb81f94aa 100644 --- a/vendor/kmodules.xyz/resource-metrics/apps/v1/statefulset.go +++ b/vendor/kmodules.xyz/resource-metrics/apps/v1/statefulset.go @@ -53,8 +53,8 @@ func (_ StatefulSet) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList return api.ReplicaList{api.PodRoleDefault: replicas}, nil } -func (r StatefulSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r StatefulSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { rr, err := r.roleReplicasFn(obj) if err != nil { return nil, err @@ -69,9 +69,9 @@ func (r StatefulSet) roleResourceFn(fn func(rr core.ResourceRequirements) core.R if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(containers, replicas), - api.PodRoleInit: api.MulResourceList(initContainers, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: containers, Replicas: replicas}, + api.PodRoleInit: {Resource: initContainers, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/batch/v1/cronjob.go b/vendor/kmodules.xyz/resource-metrics/batch/v1/cronjob.go index e44ff8ff7..a1bc877f4 100644 --- a/vendor/kmodules.xyz/resource-metrics/batch/v1/cronjob.go +++ b/vendor/kmodules.xyz/resource-metrics/batch/v1/cronjob.go @@ -43,8 +43,8 @@ func (_ CronJob) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, er return nil, nil } -func (r CronJob) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r CronJob) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { containers, err := api.AggregateContainerResources(obj, fn, api.AddResourceList, "spec", "jobTemplate", "spec", "template", "spec", "containers") if err != nil { return nil, err @@ -53,9 +53,9 @@ func (r CronJob) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resou if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: containers, - api.PodRoleInit: initContainers, + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: containers, Replicas: 1}, + api.PodRoleInit: {Resource: initContainers, Replicas: 1}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/batch/v1/job.go b/vendor/kmodules.xyz/resource-metrics/batch/v1/job.go index 07cb3b892..6514df6b8 100644 --- a/vendor/kmodules.xyz/resource-metrics/batch/v1/job.go +++ b/vendor/kmodules.xyz/resource-metrics/batch/v1/job.go @@ -43,8 +43,8 @@ func (_ Job) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) return nil, nil } -func (r Job) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Job) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { containers, err := api.AggregateContainerResources(obj, fn, api.AddResourceList, "spec", "template", "spec", "containers") if err != nil { return nil, err @@ -53,9 +53,9 @@ func (r Job) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceL if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: containers, - api.PodRoleInit: initContainers, + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: containers, Replicas: 1}, + api.PodRoleInit: {Resource: initContainers, Replicas: 1}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/batch/v1beta1/cronjob.go b/vendor/kmodules.xyz/resource-metrics/batch/v1beta1/cronjob.go index f77da7295..7ad9274a3 100644 --- a/vendor/kmodules.xyz/resource-metrics/batch/v1beta1/cronjob.go +++ b/vendor/kmodules.xyz/resource-metrics/batch/v1beta1/cronjob.go @@ -43,8 +43,8 @@ func (_ CronJob) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, er return nil, nil } -func (r CronJob) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r CronJob) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { containers, err := api.AggregateContainerResources(obj, fn, api.AddResourceList, "spec", "jobTemplate", "spec", "template", "spec", "containers") if err != nil { return nil, err @@ -53,9 +53,9 @@ func (r CronJob) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resou if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: containers, - api.PodRoleInit: initContainers, + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: containers, Replicas: 1}, + api.PodRoleInit: {Resource: initContainers, Replicas: 1}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/calculator.go b/vendor/kmodules.xyz/resource-metrics/calculator.go index b50dae49b..22399bd46 100644 --- a/vendor/kmodules.xyz/resource-metrics/calculator.go +++ b/vendor/kmodules.xyz/resource-metrics/calculator.go @@ -23,6 +23,7 @@ import ( _ "kmodules.xyz/resource-metrics/batch/v1beta1" _ "kmodules.xyz/resource-metrics/core/v1" _ "kmodules.xyz/resource-metrics/kafka.kubedb.com/v1alpha1" + _ "kmodules.xyz/resource-metrics/kubedb.com/v1" _ "kmodules.xyz/resource-metrics/kubedb.com/v1alpha2" _ "kmodules.xyz/resource-metrics/kubevault.com/v1alpha2" _ "kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1" @@ -109,3 +110,19 @@ func RoleResourceRequests(obj map[string]interface{}) (map[api.PodRole]core.Reso } return c.RoleResourceRequests(obj) } + +func PodResourceLimits(obj map[string]interface{}) (core.ResourceList, error) { + c, err := api.Load(obj) + if err != nil { + return nil, err + } + return c.PodResourceLimits(obj) +} + +func PodResourceRequests(obj map[string]interface{}) (core.ResourceList, error) { + c, err := api.Load(obj) + if err != nil { + return nil, err + } + return c.PodResourceRequests(obj) +} diff --git a/vendor/kmodules.xyz/resource-metrics/core/v1/pod.go b/vendor/kmodules.xyz/resource-metrics/core/v1/pod.go index 24824d8eb..1dd68088c 100644 --- a/vendor/kmodules.xyz/resource-metrics/core/v1/pod.go +++ b/vendor/kmodules.xyz/resource-metrics/core/v1/pod.go @@ -42,8 +42,8 @@ func (_ Pod) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) return api.ReplicaList{api.PodRoleDefault: 1}, nil } -func (r Pod) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Pod) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { containers, err := api.AggregateContainerResources(obj, fn, api.AddResourceList, "spec", "containers") if err != nil { return nil, err @@ -52,9 +52,9 @@ func (r Pod) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceL if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: containers, - api.PodRoleInit: initContainer, + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: containers, Replicas: 1}, + api.PodRoleInit: {Resource: initContainer, Replicas: 1}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/core/v1/rc.go b/vendor/kmodules.xyz/resource-metrics/core/v1/rc.go index 444847dc1..5c1720bae 100644 --- a/vendor/kmodules.xyz/resource-metrics/core/v1/rc.go +++ b/vendor/kmodules.xyz/resource-metrics/core/v1/rc.go @@ -52,8 +52,8 @@ func (_ ReplicationController) roleReplicasFn(obj map[string]interface{}) (api.R return api.ReplicaList{api.PodRoleDefault: replicas}, nil } -func (r ReplicationController) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r ReplicationController) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { rr, err := r.roleReplicasFn(obj) if err != nil { return nil, err @@ -68,9 +68,9 @@ func (r ReplicationController) roleResourceFn(fn func(rr core.ResourceRequiremen if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleInit: api.MulResourceList(initContainers, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleInit: {Resource: initContainers, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kafka.kubedb.com/v1alpha1/connectcluster.go b/vendor/kmodules.xyz/resource-metrics/kafka.kubedb.com/v1alpha1/connectcluster.go index 7198bd27e..56f2515c7 100644 --- a/vendor/kmodules.xyz/resource-metrics/kafka.kubedb.com/v1alpha1/connectcluster.go +++ b/vendor/kmodules.xyz/resource-metrics/kafka.kubedb.com/v1alpha1/connectcluster.go @@ -74,8 +74,8 @@ func (r ConnectCluster) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r ConnectCluster) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r ConnectCluster) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -84,9 +84,9 @@ func (r ConnectCluster) roleResourceFn(fn func(rr core.ResourceRequirements) cor if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/constants.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/constants.go new file mode 100644 index 000000000..978866aea --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/constants.go @@ -0,0 +1,43 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +const ( + DBModeEnsemble = "Ensemble" + DBModeCluster = "Cluster" + DBModeSharded = "Sharded" + DBModeStandalone = "Standalone" + DBModeReplicaSet = "ReplicaSet" + DBModeDedicated = "Dedicated" + DBModeCombined = "Combined" +) + +const ( + ElasticsearchContainerName = "elasticsearch" + MongoDBContainerName = "mongodb" + MySQLContainerName = "mysql" + PerconaXtraDBContainerName = "perconaxtradb" + MariaDBContainerName = "mariadb" + PostgresContainerName = "postgres" + ProxySQLContainerName = "proxysql" + RedisContainerName = "redis" + PgBouncerContainerName = "pgbouncer" + KafkaContainerName = "kafka" + MemcachedContainerName = "memcached" + RedisSentinelContainerName = "redissentinel" + MySQLRouterContainerName = "mysql-router" +) diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/elasticsearch.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/elasticsearch.go new file mode 100644 index 000000000..bdf2fc24e --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/elasticsearch.go @@ -0,0 +1,173 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + "reflect" + + "kmodules.xyz/resource-metrics/api" + + "gomodules.xyz/pointer" + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "Elasticsearch", + }, Elasticsearch{}.ResourceCalculator()) +} + +type Elasticsearch struct{} + +func (r Elasticsearch) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleMaster, api.PodRoleIngest, api.PodRoleData, api.PodRoleDataContent, api.PodRoleDataCold, api.PodRoleDataHot, api.PodRoleDataWarm, api.PodRoleDataFrozen, api.PodRoleML, api.PodRoleTransform, api.PodRoleCoordinating}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleMaster, api.PodRoleIngest, api.PodRoleData, api.PodRoleDataContent, api.PodRoleDataCold, api.PodRoleDataHot, api.PodRoleDataWarm, api.PodRoleDataFrozen, api.PodRoleML, api.PodRoleTransform, api.PodRoleCoordinating, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r Elasticsearch) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + result := api.ReplicaList{} + + topology, found, err := unstructured.NestedMap(obj, "spec", "topology") + if err != nil { + return nil, err + } + if found && topology != nil { + for role, roleSpec := range topology { + roleReplicas, found, err := unstructured.NestedInt64(roleSpec.(map[string]interface{}), "replicas") + if err != nil { + return nil, err + } + if found { + result[api.PodRole(role)] = roleReplicas + } + } + } else { + // Combined mode + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + result[api.PodRoleDefault] = 1 + } else { + result[api.PodRoleDefault] = replicas + } + } + return result, nil +} + +func (r Elasticsearch) modeFn(obj map[string]interface{}) (string, error) { + topology, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "topology") + if err != nil { + return "", err + } + if found && !reflect.ValueOf(topology).IsNil() { + return DBModeDedicated, nil + } + return DBModeCombined, nil +} + +func (r Elasticsearch) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "enableSSL") + return found, err +} + +func (r Elasticsearch) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + + topology, found, err := unstructured.NestedMap(obj, "spec", "topology") + if err != nil { + return nil, err + } + if found && topology != nil { + var replicas int64 = 0 + result := map[api.PodRole]api.PodInfo{} + + for role, roleSpec := range topology { + rolePerReplicaResources, roleReplicas, err := ElasticsearchNodeResources(roleSpec.(map[string]interface{}), fn) + if err != nil { + return nil, err + } + replicas += roleReplicas + result[api.PodRole(role)] = api.PodInfo{Resource: rolePerReplicaResources, Replicas: roleReplicas} + } + + result[api.PodRoleExporter] = api.PodInfo{Resource: exporter, Replicas: replicas} + return result, nil + } + + // Elasticsearch Combined + container, replicas, err := api.AppNodeResourcesV2(obj, fn, ElasticsearchContainerName, "spec") + if err != nil { + return nil, err + } + + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} + +type ElasticsearchNode struct { + Replicas *int64 `json:"replicas,omitempty"` + Resources core.ResourceRequirements `json:"resources,omitempty"` + Storage core.PersistentVolumeClaimSpec `json:"storage,omitempty"` +} + +func ElasticsearchNodeResources( + obj map[string]interface{}, + fn func(rr core.ResourceRequirements) core.ResourceList, + fields ...string, +) (core.ResourceList, int64, error) { + val, found, err := unstructured.NestedFieldNoCopy(obj, fields...) + if !found || err != nil { + return nil, 0, err + } + + var node ElasticsearchNode + err = runtime.DefaultUnstructuredConverter.FromUnstructured(val.(map[string]interface{}), &node) + if err != nil { + return nil, 0, fmt.Errorf("failed to parse node %#v: %w", node, err) + } + + if node.Replicas == nil { + node.Replicas = pointer.Int64P(1) + } + rr := fn(node.Resources) + sr := fn(api.ToResourceRequirements(node.Storage.Resources)) + rr[core.ResourceStorage] = *sr.Storage() + + return rr, *node.Replicas, nil +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/kafka.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/kafka.go new file mode 100644 index 000000000..09693f5d3 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/kafka.go @@ -0,0 +1,140 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + "reflect" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "Kafka", + }, Kafka{}.ResourceCalculator()) +} + +type Kafka struct{} + +func (r Kafka) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleBroker, api.PodRoleController, api.PodRoleCombined}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleBroker, api.PodRoleController, api.PodRoleCombined, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r Kafka) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + result := api.ReplicaList{} + + topology, found, err := unstructured.NestedMap(obj, "spec", "topology") + if err != nil { + return nil, err + } + if found && topology != nil { + // dedicated topology mode + for role, roleSpec := range topology { + roleReplicas, found, err := unstructured.NestedInt64(roleSpec.(map[string]interface{}), "replicas") + if err != nil { + return nil, err + } + if found { + result[api.PodRole(role)] = roleReplicas + } + } + } else { + // Combined mode + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + result[api.PodRoleDefault] = 1 + } else { + result[api.PodRoleDefault] = replicas + } + } + return result, nil +} + +func (r Kafka) modeFn(obj map[string]interface{}) (string, error) { + topology, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "topology") + if err != nil { + return "", err + } + if found && !reflect.ValueOf(topology).IsNil() { + return DBModeDedicated, nil + } + return DBModeCombined, nil +} + +func (r Kafka) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "enableSSL") + return found, err +} + +func (r Kafka) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + + topology, found, err := unstructured.NestedMap(obj, "spec", "topology") + if err != nil { + return nil, err + } + if found && topology != nil { + var replicas int64 = 0 + result := map[api.PodRole]api.PodInfo{} + + for role := range topology { + rolePerReplicaResources, roleReplicas, err := api.AppNodeResourcesV2(topology, fn, KafkaContainerName, role) + if err != nil { + return nil, err + } + replicas += roleReplicas + result[api.PodRole(role)] = api.PodInfo{Resource: rolePerReplicaResources, Replicas: roleReplicas} + } + + result[api.PodRoleExporter] = api.PodInfo{Resource: exporter, Replicas: replicas} + return result, nil + } + + // Kafka Combined + container, replicas, err := api.AppNodeResourcesV2(obj, fn, KafkaContainerName, "spec") + if err != nil { + return nil, err + } + + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mariadb.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mariadb.go new file mode 100644 index 000000000..2b8a0104d --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mariadb.go @@ -0,0 +1,94 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "MariaDB", + }, MariaDB{}.ResourceCalculator()) +} + +type MariaDB struct{} + +func (r MariaDB) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r MariaDB) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: replicas}, nil +} + +func (r MariaDB) modeFn(obj map[string]interface{}) (string, error) { + replicas, _, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return "", err + } + if replicas > 1 { + return DBModeCluster, nil + } + return DBModeStandalone, nil +} + +func (r MariaDB) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r MariaDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + container, replicas, err := api.AppNodeResourcesV2(obj, fn, MariaDBContainerName, "spec") + if err != nil { + return nil, err + } + + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/memcached.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/memcached.go new file mode 100644 index 000000000..abdc021d8 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/memcached.go @@ -0,0 +1,94 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "Memcached", + }, Memcached{}.ResourceCalculator()) +} + +type Memcached struct{} + +func (r Memcached) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r Memcached) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: replicas}, nil +} + +func (r Memcached) modeFn(obj map[string]interface{}) (string, error) { + replicas, _, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return "", err + } + if replicas > 1 { + return DBModeCluster, nil + } + return DBModeStandalone, nil +} + +func (r Memcached) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r Memcached) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + container, replicas, err := api.AppNodeResourcesV2(obj, fn, MemcachedContainerName, "spec") + if err != nil { + return nil, err + } + + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mongodb.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mongodb.go new file mode 100644 index 000000000..49804a5d7 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mongodb.go @@ -0,0 +1,171 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "MongoDB", + }, MongoDB{}.ResourceCalculator()) +} + +type MongoDB struct{} + +func (r MongoDB) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleTotalShard, api.PodRoleConfigServer, api.PodRoleMongos}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleTotalShard, api.PodRoleConfigServer, api.PodRoleMongos, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r MongoDB) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + // Sharded MongoDB cluster + shardTopology, found, err := unstructured.NestedMap(obj, "spec", "shardTopology") + if err != nil { + return nil, err + } + if found && shardTopology != nil { + shards, _, err := unstructured.NestedInt64(shardTopology, "shard", "shards") + if err != nil { + return nil, err + } + shardReplicas, _, err := unstructured.NestedInt64(shardTopology, "shard", "replicas") + if err != nil { + return nil, err + } + configServerReplicas, _, err := unstructured.NestedInt64(shardTopology, "configServer", "replicas") + if err != nil { + return nil, err + } + mongosReplicas, _, err := unstructured.NestedInt64(shardTopology, "mongos", "replicas") + if err != nil { + return nil, err + } + return api.ReplicaList{ + api.PodRoleTotalShard: shards * shardReplicas, + api.PodRoleShard: shards, + api.PodRoleReplicasPerShard: shardReplicas, + api.PodRoleConfigServer: configServerReplicas, + api.PodRoleMongos: mongosReplicas, + }, nil + } + + // MongoDB ReplicaSet or Standalone + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: replicas}, nil +} + +func (r MongoDB) modeFn(obj map[string]interface{}) (string, error) { + shards, found, err := unstructured.NestedMap(obj, "spec", "shardTopology") + if err != nil { + return "", err + } + if found && shards != nil { + return DBModeSharded, nil + } + rs, found, err := unstructured.NestedMap(obj, "spec", "replicaSet") + if err != nil { + return "", err + } + if found && rs != nil { + return DBModeReplicaSet, nil + } + return DBModeStandalone, nil +} + +func (r MongoDB) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r MongoDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + + // Sharded MongoDB + shardTopology, found, err := unstructured.NestedMap(obj, "spec", "shardTopology") + if err != nil { + return nil, err + } + if found && shardTopology != nil { + // Shard nodes resources + shards, _, err := unstructured.NestedInt64(shardTopology, "shard", "shards") + if err != nil { + return nil, err + } + shard, shardReplicas, err := api.AppNodeResourcesV2(shardTopology, fn, MongoDBContainerName, "shard") + if err != nil { + return nil, err + } + + // ConfigServer nodes resources + configServer, configServerReplicas, err := api.AppNodeResourcesV2(shardTopology, fn, MongoDBContainerName, "configServer") + if err != nil { + return nil, err + } + + // Mongos node resources + mongos, mongosReplicas, err := api.AppNodeResourcesV2(shardTopology, fn, MongoDBContainerName, "mongos") + if err != nil { + return nil, err + } + + return map[api.PodRole]api.PodInfo{ + api.PodRoleTotalShard: {Resource: shard, Replicas: shards * shardReplicas}, + api.PodRoleConfigServer: {Resource: configServer, Replicas: configServerReplicas}, + api.PodRoleMongos: {Resource: mongos, Replicas: mongosReplicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: shards*shardReplicas + configServerReplicas + mongosReplicas}, + }, nil + } + + // MongoDB ReplicaSet or Standalone + container, replicas, err := api.AppNodeResourcesV2(obj, fn, MongoDBContainerName, "spec") + if err != nil { + return nil, err + } + + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mysql.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mysql.go new file mode 100644 index 000000000..c43953c52 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/mysql.go @@ -0,0 +1,132 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "MySQL", + }, MySQL{}.ResourceCalculator()) +} + +type MySQL struct{} + +func (r MySQL) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleRouter}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter, api.PodRoleRouter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r MySQL) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + result := api.ReplicaList{} + + // Standalone or GroupReplication Mode + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + result[api.PodRoleDefault] = 1 + } else { + result[api.PodRoleDefault] = replicas + } + + // InnoDB Router + mode, found, err := unstructured.NestedString(obj, "spec", "topology", "mode") + if err != nil { + return nil, err + } + if found && mode == "InnoDBCluster" { + replicas, found, err := unstructured.NestedInt64(obj, "spec", "topology", "innoDBCluster", "router", "replicas") + if err != nil { + return nil, err + } + if !found { + result[api.PodRoleRouter] = 1 + } else { + result[api.PodRoleRouter] = replicas + } + } + + return result, nil +} + +func (r MySQL) modeFn(obj map[string]interface{}) (string, error) { + mode, found, err := unstructured.NestedString(obj, "spec", "topology", "mode") + if err != nil { + return "", err + } + if found { + return mode, nil + } + return DBModeStandalone, nil +} + +func (r MySQL) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r MySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + container, replicas, err := api.AppNodeResourcesV2(obj, fn, MySQLContainerName, "spec") + if err != nil { + return nil, err + } + + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + + result := map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + } + + // InnoDB Router + mode, found, err := unstructured.NestedString(obj, "spec", "topology", "mode") + if err != nil { + return nil, err + } + if found && mode == "InnoDBCluster" { + router, replicas, err := api.AppNodeResourcesV2(obj, fn, MySQLRouterContainerName, "spec", "topology", "innoDBCluster", "router") + if err != nil { + return nil, err + } + result[api.PodRoleRouter] = api.PodInfo{Resource: router, Replicas: replicas} + } + return result, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/perconaxtradb.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/perconaxtradb.go new file mode 100644 index 000000000..9bd6f2072 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/perconaxtradb.go @@ -0,0 +1,94 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "PerconaXtraDB", + }, PerconaXtraDB{}.ResourceCalculator()) +} + +type PerconaXtraDB struct{} + +func (r PerconaXtraDB) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r PerconaXtraDB) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: replicas}, nil +} + +func (r PerconaXtraDB) modeFn(obj map[string]interface{}) (string, error) { + replicas, _, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return "", err + } + if replicas > 1 { + return DBModeCluster, nil + } + return DBModeStandalone, nil +} + +func (r PerconaXtraDB) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r PerconaXtraDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + container, replicas, err := api.AppNodeResourcesV2(obj, fn, PerconaXtraDBContainerName, "spec") + if err != nil { + return nil, err + } + + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/pgbouncer.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/pgbouncer.go new file mode 100644 index 000000000..ca53c2f82 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/pgbouncer.go @@ -0,0 +1,94 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "PgBouncer", + }, PgBouncer{}.ResourceCalculator()) +} + +type PgBouncer struct{} + +func (r PgBouncer) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r PgBouncer) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: replicas}, nil +} + +func (r PgBouncer) modeFn(obj map[string]interface{}) (string, error) { + replicas, _, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return "", err + } + if replicas > 1 { + return DBModeCluster, nil + } + return DBModeStandalone, nil +} + +func (r PgBouncer) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r PgBouncer) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + container, replicas, err := api.AppNodeResourcesV2(obj, fn, PgBouncerContainerName, "spec") + if err != nil { + return nil, err + } + + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/postgres.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/postgres.go new file mode 100644 index 000000000..664883d30 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/postgres.go @@ -0,0 +1,95 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "Postgres", + }, Postgres{}.ResourceCalculator()) +} + +type Postgres struct{} + +func (r Postgres) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r Postgres) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + v, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: v}, nil +} + +func (r Postgres) modeFn(obj map[string]interface{}) (string, error) { + mode, found, err := unstructured.NestedString(obj, "spec", "mode") + if err == nil && found { + return mode, nil + } + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err == nil && found && replicas > 1 { + return DBModeCluster, nil + } + return DBModeStandalone, nil +} + +func (r Postgres) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r Postgres) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + container, replicas, err := api.AppNodeResourcesV2(obj, fn, PostgresContainerName, "spec") + if err != nil { + return nil, err + } + + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/proxysql.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/proxysql.go new file mode 100644 index 000000000..12b635120 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/proxysql.go @@ -0,0 +1,94 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "ProxySQL", + }, ProxySQL{}.ResourceCalculator()) +} + +type ProxySQL struct{} + +func (r ProxySQL) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r ProxySQL) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: replicas}, nil +} + +func (r ProxySQL) modeFn(obj map[string]interface{}) (string, error) { + replicas, _, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return "", err + } + if replicas > 1 { + return DBModeCluster, nil + } + return DBModeStandalone, nil +} + +func (r ProxySQL) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r ProxySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + container, replicas, err := api.AppNodeResourcesV2(obj, fn, ProxySQLContainerName, "spec") + if err != nil { + return nil, err + } + + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/redis.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/redis.go new file mode 100644 index 000000000..807830faa --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/redis.go @@ -0,0 +1,137 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "Redis", + }, Redis{}.ResourceCalculator()) +} + +type Redis struct{} + +func (r Redis) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + UsesTLSFn: r.usesTLSFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r Redis) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + mode, found, err := unstructured.NestedString(obj, "spec", "mode") + if err != nil { + return nil, err + } + if found && mode == DBModeCluster { + shards, _, err := unstructured.NestedInt64(obj, "spec", "cluster", "master") + if err != nil { + return nil, err + } + shardReplicas, _, err := unstructured.NestedInt64(obj, "spec", "cluster", "replicas") + if err != nil { + return nil, err + } + return api.ReplicaList{ + api.PodRoleTotalShard: shards * shardReplicas, + api.PodRoleDefault: shards * shardReplicas, + api.PodRoleShard: shards, + api.PodRoleReplicasPerShard: shardReplicas, + }, nil + } + + // Standalone or sentinel + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: replicas}, nil +} + +func (r Redis) modeFn(obj map[string]interface{}) (string, error) { + mode, found, err := unstructured.NestedString(obj, "spec", "mode") + if err != nil { + return "", err + } + if found { + return mode, nil + } + return DBModeStandalone, nil +} + +func (r Redis) usesTLSFn(obj map[string]interface{}) (bool, error) { + _, found, err := unstructured.NestedFieldNoCopy(obj, "spec", "tls") + return found, err +} + +func (r Redis) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + + // Redis Sentinel or Standalone + container, replicas, err := api.AppNodeResourcesV2(obj, fn, RedisContainerName, "spec") + if err != nil { + return nil, err + } + + mode, found, err := unstructured.NestedString(obj, "spec", "mode") + if err != nil { + return nil, err + } + if found && mode == DBModeCluster { + shards, _, err := unstructured.NestedInt64(obj, "spec", "cluster", "shards") + if err != nil { + return nil, err + } + shardReplicas, _, err := unstructured.NestedInt64(obj, "spec", "cluster", "replicas") + if err != nil { + return nil, err + } + // If spec.cluster.replicas = x + // That means in each shard there are (x+1) redis replicas + shardReplicas += 1 + replicas = shards * shardReplicas + } + + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/redissentinel.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/redissentinel.go new file mode 100644 index 000000000..a12c97336 --- /dev/null +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1/redissentinel.go @@ -0,0 +1,82 @@ +/* +Copyright AppsCode Inc. and Contributors + +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. +*/ + +package v1 + +import ( + "fmt" + + "kmodules.xyz/resource-metrics/api" + + core "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func init() { + api.Register(schema.GroupVersionKind{ + Group: "kubedb.com", + Version: "v1", + Kind: "RedisSentinel", + }, RedisSentinel{}.ResourceCalculator()) +} + +type RedisSentinel struct{} + +func (r RedisSentinel) ResourceCalculator() api.ResourceCalculator { + return &api.ResourceCalculatorFuncs{ + AppRoles: []api.PodRole{api.PodRoleDefault}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + RoleReplicasFn: r.roleReplicasFn, + ModeFn: r.modeFn, + RoleResourceLimitsFn: r.roleResourceFn(api.ResourceLimits), + RoleResourceRequestsFn: r.roleResourceFn(api.ResourceRequests), + } +} + +func (r RedisSentinel) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error) { + replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") + if err != nil { + return nil, fmt.Errorf("failed to read spec.replicas %v: %w", obj, err) + } + if !found { + return api.ReplicaList{api.PodRoleDefault: 1}, nil + } + return api.ReplicaList{api.PodRoleDefault: replicas}, nil +} + +func (r RedisSentinel) modeFn(obj map[string]interface{}) (string, error) { + return DBModeCluster, nil +} + +func (r RedisSentinel) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") + if err != nil { + return nil, err + } + + container, replicas, err := api.AppNodeResourcesV2(obj, fn, RedisSentinelContainerName, "spec") + if err != nil { + return nil, err + } + + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil + } +} diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/druid.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/druid.go index 4b0c9be39..182ce50c6 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/druid.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/druid.go @@ -39,8 +39,8 @@ type Druid struct{} func (r Druid) ResourceCalculator() api.ResourceCalculator { return &api.ResourceCalculatorFuncs{ - AppRoles: []api.PodRole{api.PodRoleDefault}, - RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + AppRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleCoordinators, api.PodRoleBrokers, api.PodRoleOverlords, api.PodRoleMiddleManagers, api.PodRoleHistoricals, api.PodRoleRouters}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleCoordinators, api.PodRoleBrokers, api.PodRoleOverlords, api.PodRoleMiddleManagers, api.PodRoleHistoricals, api.PodRoleRouters, api.PodRoleExporter}, RoleReplicasFn: r.roleReplicasFn, ModeFn: r.modeFn, UsesTLSFn: r.usesTLSFn, @@ -58,7 +58,6 @@ func (r Druid) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, erro } if found && topology != nil { - var replicas int64 = 0 for role, roleSpec := range topology { roleReplicas, found, err := unstructured.NestedInt64(roleSpec.(map[string]interface{}), "replicas") if err != nil { @@ -66,10 +65,8 @@ func (r Druid) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, erro } if found { result[api.PodRole(role)] = roleReplicas - replicas += roleReplicas } } - result[api.PodRoleDefault] = replicas } else { // Combined mode replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") @@ -82,7 +79,6 @@ func (r Druid) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, erro result[api.PodRoleDefault] = replicas } } - return result, nil } @@ -102,8 +98,8 @@ func (r Druid) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Druid) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Druid) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -113,10 +109,9 @@ func (r Druid) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resourc if err != nil { return nil, err } + result := map[api.PodRole]api.PodInfo{} if found && topology != nil { var replicas int64 = 0 - var totalResources core.ResourceList - result := map[api.PodRole]core.ResourceList{} for role, roleSpec := range topology { rolePerReplicaResources, roleReplicas, err := api.AppNodeResourcesV2(roleSpec.(map[string]interface{}), fn, DruidContainerName) @@ -124,16 +119,28 @@ func (r Druid) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resourc return nil, err } - roleResources := api.MulResourceList(rolePerReplicaResources, roleReplicas) - result[api.PodRole(role)] = roleResources - totalResources = api.AddResourceList(totalResources, roleResources) + result[api.PodRole(role)] = api.PodInfo{ + Resource: rolePerReplicaResources, + Replicas: roleReplicas, + } + + replicas += roleReplicas } - result[api.PodRoleDefault] = totalResources - result[api.PodRoleExporter] = api.MulResourceList(exporter, replicas) + result[api.PodRoleExporter] = api.PodInfo{ + Resource: exporter, + Replicas: replicas, + } return result, nil } + container, replicas, err := api.AppNodeResourcesV2(obj, fn, DruidContainerName, "spec") + if err != nil { + return nil, err + } - return nil, nil + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, + }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/elasticsearch.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/elasticsearch.go index 323618974..4bbaa40a0 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/elasticsearch.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/elasticsearch.go @@ -41,8 +41,8 @@ type Elasticsearch struct{} func (r Elasticsearch) ResourceCalculator() api.ResourceCalculator { return &api.ResourceCalculatorFuncs{ - AppRoles: []api.PodRole{api.PodRoleDefault}, - RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + AppRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleMaster, api.PodRoleIngest, api.PodRoleData, api.PodRoleDataContent, api.PodRoleDataCold, api.PodRoleDataHot, api.PodRoleDataWarm, api.PodRoleDataFrozen, api.PodRoleML, api.PodRoleTransform, api.PodRoleCoordinating}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleMaster, api.PodRoleIngest, api.PodRoleData, api.PodRoleDataContent, api.PodRoleDataCold, api.PodRoleDataHot, api.PodRoleDataWarm, api.PodRoleDataFrozen, api.PodRoleML, api.PodRoleTransform, api.PodRoleCoordinating, api.PodRoleExporter}, RoleReplicasFn: r.roleReplicasFn, ModeFn: r.modeFn, UsesTLSFn: r.usesTLSFn, @@ -59,7 +59,6 @@ func (r Elasticsearch) roleReplicasFn(obj map[string]interface{}) (api.ReplicaLi return nil, err } if found && topology != nil { - var replicas int64 = 0 for role, roleSpec := range topology { roleReplicas, found, err := unstructured.NestedInt64(roleSpec.(map[string]interface{}), "replicas") if err != nil { @@ -67,10 +66,8 @@ func (r Elasticsearch) roleReplicasFn(obj map[string]interface{}) (api.ReplicaLi } if found { result[api.PodRole(role)] = roleReplicas - replicas += roleReplicas } } - result[api.PodRoleDefault] = replicas } else { // Combined mode replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") @@ -102,8 +99,8 @@ func (r Elasticsearch) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Elasticsearch) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Elasticsearch) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -115,22 +112,18 @@ func (r Elasticsearch) roleResourceFn(fn func(rr core.ResourceRequirements) core } if found && topology != nil { var replicas int64 = 0 - var totalResources core.ResourceList - result := map[api.PodRole]core.ResourceList{} + result := map[api.PodRole]api.PodInfo{} for role, roleSpec := range topology { rolePerReplicaResources, roleReplicas, err := ElasticsearchNodeResources(roleSpec.(map[string]interface{}), fn) if err != nil { return nil, err } - - roleResources := api.MulResourceList(rolePerReplicaResources, roleReplicas) - result[api.PodRole(role)] = roleResources - totalResources = api.AddResourceList(totalResources, roleResources) + replicas += roleReplicas + result[api.PodRole(role)] = api.PodInfo{Resource: rolePerReplicaResources, Replicas: roleReplicas} } - result[api.PodRoleDefault] = totalResources - result[api.PodRoleExporter] = api.MulResourceList(exporter, replicas) + result[api.PodRoleExporter] = api.PodInfo{Resource: exporter, Replicas: replicas} return result, nil } @@ -140,9 +133,9 @@ func (r Elasticsearch) roleResourceFn(fn func(rr core.ResourceRequirements) core return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/ferretdb.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/ferretdb.go index c4f877ed4..a3c35548f 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/ferretdb.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/ferretdb.go @@ -75,8 +75,8 @@ func (r FerretDB) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r FerretDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r FerretDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResourcesV2(obj, fn, FerretDBContainerName, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (r FerretDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.Reso if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/kafka.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/kafka.go index caa347c7a..cf8aadecd 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/kafka.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/kafka.go @@ -41,8 +41,8 @@ type Kafka struct{} func (r Kafka) ResourceCalculator() api.ResourceCalculator { return &api.ResourceCalculatorFuncs{ - AppRoles: []api.PodRole{api.PodRoleDefault}, - RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + AppRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleBroker, api.PodRoleController, api.PodRoleCombined}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleBroker, api.PodRoleController, api.PodRoleCombined, api.PodRoleExporter}, RoleReplicasFn: r.roleReplicasFn, ModeFn: r.modeFn, UsesTLSFn: r.usesTLSFn, @@ -60,7 +60,6 @@ func (r Kafka) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, erro } if found && topology != nil { // dedicated topology mode - var replicas int64 = 0 for role, roleSpec := range topology { roleReplicas, found, err := unstructured.NestedInt64(roleSpec.(map[string]interface{}), "replicas") if err != nil { @@ -68,10 +67,8 @@ func (r Kafka) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, erro } if found { result[api.PodRole(role)] = roleReplicas - replicas += roleReplicas } } - result[api.PodRoleDefault] = replicas } else { // Combined mode replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") @@ -103,8 +100,8 @@ func (r Kafka) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Kafka) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Kafka) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -116,22 +113,18 @@ func (r Kafka) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resourc } if found && topology != nil { var replicas int64 = 0 - var totalResources core.ResourceList - result := map[api.PodRole]core.ResourceList{} + result := map[api.PodRole]api.PodInfo{} for role, roleSpec := range topology { rolePerReplicaResources, roleReplicas, err := KafkaNodeResources(roleSpec.(map[string]interface{}), fn) if err != nil { return nil, err } - - roleResources := api.MulResourceList(rolePerReplicaResources, roleReplicas) - result[api.PodRole(role)] = roleResources - totalResources = api.AddResourceList(totalResources, roleResources) + replicas += roleReplicas + result[api.PodRole(role)] = api.PodInfo{Resource: rolePerReplicaResources, Replicas: roleReplicas} } - result[api.PodRoleDefault] = totalResources - result[api.PodRoleExporter] = api.MulResourceList(exporter, replicas) + result[api.PodRoleExporter] = api.PodInfo{Resource: exporter, Replicas: replicas} return result, nil } @@ -141,9 +134,9 @@ func (r Kafka) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resourc return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mariadb.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mariadb.go index 7095e5ac2..0e3a6cef3 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mariadb.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mariadb.go @@ -75,8 +75,8 @@ func (r MariaDB) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r MariaDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r MariaDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResources(obj, fn, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (r MariaDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resou if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/memcached.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/memcached.go index 501569d3b..a0156ffc9 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/memcached.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/memcached.go @@ -75,8 +75,8 @@ func (r Memcached) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Memcached) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Memcached) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResources(obj, fn, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (r Memcached) roleResourceFn(fn func(rr core.ResourceRequirements) core.Res if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mongodb.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mongodb.go index cbac3b80f..f7789b045 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mongodb.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mongodb.go @@ -114,8 +114,8 @@ func (r MongoDB) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r MongoDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r MongoDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -149,11 +149,11 @@ func (r MongoDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resou return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleTotalShard: api.MulResourceList(shard, shards*shardReplicas), - api.PodRoleConfigServer: api.MulResourceList(configServer, configServerReplicas), - api.PodRoleMongos: api.MulResourceList(mongos, mongosReplicas), - api.PodRoleExporter: api.MulResourceList(exporter, shards*shardReplicas+configServerReplicas+mongosReplicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleTotalShard: {Resource: shard, Replicas: shards * shardReplicas}, + api.PodRoleConfigServer: {Resource: configServer, Replicas: configServerReplicas}, + api.PodRoleMongos: {Resource: mongos, Replicas: mongosReplicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: shards*shardReplicas + configServerReplicas + mongosReplicas}, }, nil } @@ -163,9 +163,9 @@ func (r MongoDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resou return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mysql.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mysql.go index c2cb55e9b..afea45381 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mysql.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/mysql.go @@ -98,8 +98,8 @@ func (r MySQL) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r MySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r MySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResources(obj, fn, "spec") if err != nil { return nil, err @@ -110,9 +110,9 @@ func (r MySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resourc return nil, err } - result := map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + result := map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, } // InnoDB Router @@ -125,7 +125,7 @@ func (r MySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resourc if err != nil { return nil, err } - result[api.PodRoleRouter] = api.MulResourceList(router, replicas) + result[api.PodRoleRouter] = api.PodInfo{Resource: router, Replicas: replicas} } return result, nil } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/perconaxtradb.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/perconaxtradb.go index 476c67358..b5d0127d0 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/perconaxtradb.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/perconaxtradb.go @@ -75,8 +75,8 @@ func (r PerconaXtraDB) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r PerconaXtraDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r PerconaXtraDB) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResources(obj, fn, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (r PerconaXtraDB) roleResourceFn(fn func(rr core.ResourceRequirements) core if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/pgbouncer.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/pgbouncer.go index 0d8b5b11b..0b1428b37 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/pgbouncer.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/pgbouncer.go @@ -75,8 +75,8 @@ func (r PgBouncer) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r PgBouncer) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r PgBouncer) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResources(obj, fn, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (r PgBouncer) roleResourceFn(fn func(rr core.ResourceRequirements) core.Res if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/pgpool.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/pgpool.go index e70473fed..3fc5aa776 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/pgpool.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/pgpool.go @@ -75,8 +75,8 @@ func (r Pgpool) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Pgpool) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Pgpool) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResourcesV2(obj, fn, PgpoolContainerName, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (r Pgpool) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resour if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/postgres.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/postgres.go index 8cc498512..dad3de545 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/postgres.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/postgres.go @@ -76,8 +76,8 @@ func (r Postgres) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Postgres) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Postgres) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResources(obj, fn, "spec") if err != nil { return nil, err @@ -87,9 +87,9 @@ func (r Postgres) roleResourceFn(fn func(rr core.ResourceRequirements) core.Reso if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/proxysql.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/proxysql.go index c8f9c2d39..e554a1a8c 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/proxysql.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/proxysql.go @@ -75,8 +75,8 @@ func (r ProxySQL) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r ProxySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r ProxySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResources(obj, fn, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (r ProxySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.Reso if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/rabbitmq.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/rabbitmq.go index 07cfcb32f..59bc7099b 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/rabbitmq.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/rabbitmq.go @@ -75,8 +75,8 @@ func (r RabbitMQ) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r RabbitMQ) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r RabbitMQ) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResourcesV2(obj, fn, RabbitMQContainerName, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (r RabbitMQ) roleResourceFn(fn func(rr core.ResourceRequirements) core.Reso if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/redis.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/redis.go index 6135e1b3a..258c88059 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/redis.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/redis.go @@ -97,8 +97,8 @@ func (r Redis) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Redis) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Redis) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -129,9 +129,9 @@ func (r Redis) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resourc replicas = shards * shardReplicas } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/redissentinel.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/redissentinel.go index e12d64151..4bda593cb 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/redissentinel.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/redissentinel.go @@ -62,8 +62,8 @@ func (r RedisSentinel) modeFn(obj map[string]interface{}) (string, error) { return DBModeCluster, nil } -func (r RedisSentinel) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r RedisSentinel) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -74,9 +74,9 @@ func (r RedisSentinel) roleResourceFn(fn func(rr core.ResourceRequirements) core return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/singlestore.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/singlestore.go index 0e71f7ba6..a456cb220 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/singlestore.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/singlestore.go @@ -100,8 +100,8 @@ func (r Singlestore) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Singlestore) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Singlestore) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -122,10 +122,10 @@ func (r Singlestore) roleResourceFn(fn func(rr core.ResourceRequirements) core.R return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleAggregator: api.MulResourceList(aggregator, aggregatorReplicas), - api.PodRoleLeaf: api.MulResourceList(leaf, leafReplicas), - api.PodRoleExporter: api.MulResourceList(exporter, aggregatorReplicas+leafReplicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleAggregator: {Resource: aggregator, Replicas: aggregatorReplicas}, + api.PodRoleLeaf: {Resource: leaf, Replicas: leafReplicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: aggregatorReplicas + leafReplicas}, }, nil } @@ -134,9 +134,9 @@ func (r Singlestore) roleResourceFn(fn func(rr core.ResourceRequirements) core.R return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/solr.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/solr.go index 09fa1f93f..16b487151 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/solr.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/solr.go @@ -39,8 +39,8 @@ type Solr struct{} func (r Solr) ResourceCalculator() api.ResourceCalculator { return &api.ResourceCalculatorFuncs{ - AppRoles: []api.PodRole{api.PodRoleDefault}, - RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleExporter}, + AppRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleCoordinator, api.PodRoleOverseer, api.PodRoleData}, + RuntimeRoles: []api.PodRole{api.PodRoleDefault, api.PodRoleCoordinator, api.PodRoleOverseer, api.PodRoleData, api.PodRoleExporter}, RoleReplicasFn: r.roleReplicasFn, ModeFn: r.modeFn, UsesTLSFn: r.usesTLSFn, @@ -58,7 +58,6 @@ func (r Solr) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error } if found && topology != nil { - var replicas int64 = 0 for role, roleSpec := range topology { roleReplicas, found, err := unstructured.NestedInt64(roleSpec.(map[string]interface{}), "replicas") if err != nil { @@ -66,13 +65,8 @@ func (r Solr) roleReplicasFn(obj map[string]interface{}) (api.ReplicaList, error } if found { result[api.PodRole(role)] = roleReplicas - replicas += roleReplicas - } else { - result[api.PodRole(role)] = 1 - replicas += 1 } } - result[api.PodRoleDefault] = replicas } else { // Combined mode replicas, found, err := unstructured.NestedInt64(obj, "spec", "replicas") @@ -105,8 +99,8 @@ func (r Solr) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r Solr) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r Solr) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -118,22 +112,18 @@ func (r Solr) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resource } if found && topology != nil { var replicas int64 = 0 - var totalResources core.ResourceList - result := map[api.PodRole]core.ResourceList{} + result := map[api.PodRole]api.PodInfo{} for role, roleSpec := range topology { rolePerReplicaResources, roleReplicas, err := api.AppNodeResourcesV2(roleSpec.(map[string]interface{}), fn, SolrContainerName) if err != nil { return nil, err } - - roleResources := api.MulResourceList(rolePerReplicaResources, roleReplicas) - result[api.PodRole(role)] = roleResources - totalResources = api.AddResourceList(totalResources, roleResources) + replicas += roleReplicas + result[api.PodRole(role)] = api.PodInfo{Resource: rolePerReplicaResources, Replicas: roleReplicas} } - result[api.PodRoleDefault] = totalResources - result[api.PodRoleExporter] = api.MulResourceList(exporter, replicas) + result[api.PodRoleExporter] = api.PodInfo{Resource: exporter, Replicas: replicas} return result, nil } @@ -143,9 +133,9 @@ func (r Solr) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resource return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/zookeeper.go b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/zookeeper.go index 98d2307ee..1d1dc4d5a 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/zookeeper.go +++ b/vendor/kmodules.xyz/resource-metrics/kubedb.com/v1alpha2/zookeeper.go @@ -75,8 +75,8 @@ func (z ZooKeeper) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (z ZooKeeper) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (z ZooKeeper) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { container, replicas, err := api.AppNodeResourcesV2(obj, fn, ZooKeeperContainerName, "spec") if err != nil { return nil, err @@ -86,9 +86,9 @@ func (z ZooKeeper) roleResourceFn(fn func(rr core.ResourceRequirements) core.Res if err != nil { return nil, err } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/kubevault.com/v1alpha2/vaultserver.go b/vendor/kmodules.xyz/resource-metrics/kubevault.com/v1alpha2/vaultserver.go index 13e2c2516..43dbf6130 100644 --- a/vendor/kmodules.xyz/resource-metrics/kubevault.com/v1alpha2/vaultserver.go +++ b/vendor/kmodules.xyz/resource-metrics/kubevault.com/v1alpha2/vaultserver.go @@ -68,8 +68,8 @@ func (r VaultServer) usesTLSFn(obj map[string]interface{}) (bool, error) { return found, err } -func (r VaultServer) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { - return func(obj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r VaultServer) roleResourceFn(fn func(rr core.ResourceRequirements) core.ResourceList) func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { + return func(obj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { exporter, err := api.ContainerResources(obj, fn, "spec", "monitor", "prometheus", "exporter") if err != nil { return nil, err @@ -88,9 +88,9 @@ func (r VaultServer) roleResourceFn(fn func(rr core.ResourceRequirements) core.R container[core.ResourceStorage] = raftBackend[core.ResourceStorage] } - return map[api.PodRole]core.ResourceList{ - api.PodRoleDefault: api.MulResourceList(container, replicas), - api.PodRoleExporter: api.MulResourceList(exporter, replicas), + return map[api.PodRole]api.PodInfo{ + api.PodRoleDefault: {Resource: container, Replicas: replicas}, + api.PodRoleExporter: {Resource: exporter, Replicas: replicas}, }, nil } } diff --git a/vendor/kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1/calculator.go b/vendor/kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1/calculator.go index 253cd9e86..9c5ee78f4 100644 --- a/vendor/kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1/calculator.go +++ b/vendor/kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1/calculator.go @@ -18,8 +18,6 @@ package v1alpha1 import ( "kmodules.xyz/resource-metrics/api" - - core "k8s.io/api/core/v1" ) type OpsResourceCalculator struct{} @@ -75,7 +73,7 @@ func (r OpsResourceCalculator) usesTLSFn(opsObj map[string]interface{}) (bool, e return c.UsesTLS(scaledObject) } -func (r OpsResourceCalculator) roleResourceLimitsFn(opsObj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r OpsResourceCalculator) roleResourceLimitsFn(opsObj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { scaledObject, err := GetScaledObject(opsObj) if err != nil { return nil, err @@ -85,10 +83,12 @@ func (r OpsResourceCalculator) roleResourceLimitsFn(opsObj map[string]interface{ if err != nil { return nil, err } - return c.RoleResourceLimits(scaledObject) + + dbLimitFunc := c.GetRoleResourceLimitsFn() + return dbLimitFunc(scaledObject) } -func (r OpsResourceCalculator) roleResourceRequestsFn(opsObj map[string]interface{}) (map[api.PodRole]core.ResourceList, error) { +func (r OpsResourceCalculator) roleResourceRequestsFn(opsObj map[string]interface{}) (map[api.PodRole]api.PodInfo, error) { scaledObject, err := GetScaledObject(opsObj) if err != nil { return nil, err @@ -98,5 +98,7 @@ func (r OpsResourceCalculator) roleResourceRequestsFn(opsObj map[string]interfac if err != nil { return nil, err } - return c.RoleResourceRequests(scaledObject) + + dbRequestFunc := c.GetRoleResourceRequestsFn() + return dbRequestFunc(scaledObject) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 9e476eaa9..b1ae63057 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -740,7 +740,7 @@ kmodules.xyz/go-containerregistry/name ## explicit; go 1.22.0 kmodules.xyz/offshoot-api/api/v1 kmodules.xyz/offshoot-api/api/v2 -# kmodules.xyz/resource-metrics v0.30.1 +# kmodules.xyz/resource-metrics v0.30.2-0.20240711131537-5e9d22977a2c ## explicit; go 1.22.1 kmodules.xyz/resource-metrics kmodules.xyz/resource-metrics/api @@ -749,6 +749,7 @@ kmodules.xyz/resource-metrics/batch/v1 kmodules.xyz/resource-metrics/batch/v1beta1 kmodules.xyz/resource-metrics/core/v1 kmodules.xyz/resource-metrics/kafka.kubedb.com/v1alpha1 +kmodules.xyz/resource-metrics/kubedb.com/v1 kmodules.xyz/resource-metrics/kubedb.com/v1alpha2 kmodules.xyz/resource-metrics/kubevault.com/v1alpha2 kmodules.xyz/resource-metrics/ops.kubedb.com/v1alpha1