gocrane/crane

How to configure the CRD workload to use recommended features

Closed this issue · 2 comments

Describe the feature

K8s version v1.20.8
crane version v0.11.0

Submit the following configuration in the cluster:

apiVersion: analysis.crane.io/v1alpha1
kind: RecommendationRule
metadata:
  name: workloads-rule
  labels:
    analysis.crane.io/recommendation-rule-preinstall: "true"
spec:
  runInterval: 24h                            
  resourceSelectors:                         
    - kind: StatefulSet
      apiVersion: apps/v1
    - kind: Rollout    #CRD
      apiVersion: argoproj.io/v1alpha1
  namespaceSelector:
    any: true                               
  recommenders:                            
    - name: Replicas
    - name: Resource

I hope to recommend Rollout resources just like StatefulSet, check the crane log and the following information appears:

E0105 18:06:04.327485       1 manager.go:138] RecommendationRule(workloads-rule) Target(demo-project/rollouts-demo): recommender "Resource" failed at filter phase: recommender  is failed at filter, your kubernetes resource is not supported for recommender
I0105 18:06:04.327622       1 manager.go:133] RecommendationRule(workloads-rule) Target(demo-project/rollouts-demo): start to run recommender "Replicas".
E0105 18:06:04.327634       1 manager.go:138] RecommendationRule(workloads-rule) Target(demo-project/rollouts-demo): recommender "Replicas" failed at filter phase: recommender  is failed at filter, your kubernetes resource is not supported for recommender
I0105 18:06:04.327834       1 manager.go:133] RecommendationRule(workloads-rule) Target(default/nginx-rollout): start to run recommender "Resource".

Recommended values that are not available in the crane console:
image

How to solve this problem ?

wu0407 commented

Please check if the configmap named "recommendation-configuration" is correctly configured.

apiVersion: v1
kind: ConfigMap
metadata:
name: recommendation-configuration
namespace: crane-system
data:
config.yaml: |-
apiVersion: analysis.crane.io/v1alpha1
kind: RecommendationConfiguration
recommenders:
- name: Replicas
acceptedResources:
- kind: Deployment
apiVersion: apps/v1
- kind: StatefulSet
apiVersion: apps/v1
- name: Resource
acceptedResources:
- kind: Deployment
apiVersion: apps/v1
- kind: StatefulSet
apiVersion: apps/v1
- name: IdleNode
acceptedResources:
- kind: Node
apiVersion: v1
- name: Volume
acceptedResources:
- kind: PersistentVolume
apiVersion: v1
- name: Service
acceptedResources:
- kind: Service
apiVersion: v1
---

Please check if the configmap named "recommendation-configuration" is correctly configured.

apiVersion: v1
kind: ConfigMap
metadata:
name: recommendation-configuration
namespace: crane-system
data:
config.yaml: |-
apiVersion: analysis.crane.io/v1alpha1
kind: RecommendationConfiguration
recommenders:
- name: Replicas
acceptedResources:
- kind: Deployment
apiVersion: apps/v1
- kind: StatefulSet
apiVersion: apps/v1
- name: Resource
acceptedResources:
- kind: Deployment
apiVersion: apps/v1
- kind: StatefulSet
apiVersion: apps/v1
- name: IdleNode
acceptedResources:
- kind: Node
apiVersion: v1
- name: Volume
acceptedResources:
- kind: PersistentVolume
apiVersion: v1
- name: Service
acceptedResources:
- kind: Service
apiVersion: v1
---

Thank you. It has been solved. Add resources based on this configuration.