This repository was archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
[Scalability] Enable Horizontal Pod Autoscaler (HPA) for Alcor deployment #679
Open
kevin-zhonghao
wants to merge
15
commits into
futurewei-cloud:master
Choose a base branch
from
kevin-zhonghao:k8s/hpa
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
24b9b76
commit message
kevin-zhonghao 08ec421
Merge branch 'master' of https://github.com/futurewei-cloud/alcor int…
kevin-zhonghao 598f3aa
Merge pull request #10 from futurewei-cloud/master
kevin-zhonghao 3f44da0
Merge pull request #11 from futurewei-cloud/master
kevin-zhonghao 72f9591
Merge pull request #12 from futurewei-cloud/master
kevin-zhonghao c26c1b2
Merge pull request #13 from futurewei-cloud/master
kevin-zhonghao ed7a10e
Merge pull request #14 from futurewei-cloud/master
kevin-zhonghao f4097e1
Merge pull request #15 from futurewei-cloud/master
kevin-zhonghao 1485704
update
kevin-zhonghao 29ea149
update
kevin-zhonghao 7e92e06
Merge pull request #16 from futurewei-cloud/master
kevin-zhonghao 2c5e59c
Merge branch 'new_master' of https://github.com/kevin-zhonghao/alcor …
kevin-zhonghao dabc518
update
kevin-zhonghao ff6d28c
Merge pull request #17 from futurewei-cloud/master
kevin-zhonghao 7420d5e
Merge branch 'new_master' of https://github.com/kevin-zhonghao/alcor …
kevin-zhonghao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| # Metrics Server has specific requirements for cluster and network configuration. These requirements aren't the default for all cluster distributions. Please ensure that your cluster distribution supports these requirements before using Metrics Server: | ||
|
|
||
| # 1. Metrics Server must be reachable from kube-apiserver by container IP address (or node IP if hostNetwork is enabled). | ||
|
|
||
| # 2. The kube-apiserver must enable an aggregation layer. | ||
|
|
||
| # 3. Nodes must have Webhook authentication and authorization enabled. | ||
|
|
||
| # 4. Kubelet certificate needs to be signed by cluster Certificate Authority (or disable certificate validation by passing --kubelet-insecure-tls to Metrics Server) | ||
|
|
||
| # 5. Container runtime must implement a container metrics RPCs (or have cAdvisor support) | ||
|
|
||
| # Please look at the link https://github.com/kubernetes-sigs/metrics-server#requirements for reference | ||
|
|
||
| # Latest Metrics Server release can be installed by running: | ||
| # kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| name: metrics-server | ||
| namespace: kube-system | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| rbac.authorization.k8s.io/aggregate-to-admin: "true" | ||
| rbac.authorization.k8s.io/aggregate-to-edit: "true" | ||
| rbac.authorization.k8s.io/aggregate-to-view: "true" | ||
| name: system:aggregated-metrics-reader | ||
| rules: | ||
| - apiGroups: | ||
| - metrics.k8s.io | ||
| resources: | ||
| - pods | ||
| - nodes | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| name: system:metrics-server | ||
| rules: | ||
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - pods | ||
| - nodes | ||
| - nodes/stats | ||
| - namespaces | ||
| - configmaps | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: RoleBinding | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| name: metrics-server-auth-reader | ||
| namespace: kube-system | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: Role | ||
| name: extension-apiserver-authentication-reader | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: metrics-server | ||
| namespace: kube-system | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| name: metrics-server:system:auth-delegator | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: system:auth-delegator | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: metrics-server | ||
| namespace: kube-system | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| name: system:metrics-server | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: system:metrics-server | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: metrics-server | ||
| namespace: kube-system | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| name: metrics-server | ||
| namespace: kube-system | ||
| spec: | ||
| ports: | ||
| - name: https | ||
| port: 443 | ||
| protocol: TCP | ||
| targetPort: https | ||
| selector: | ||
| k8s-app: metrics-server | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| name: metrics-server | ||
| namespace: kube-system | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| k8s-app: metrics-server | ||
| strategy: | ||
| rollingUpdate: | ||
| maxUnavailable: 0 | ||
| template: | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| spec: | ||
| containers: | ||
| - args: | ||
| - --cert-dir=/tmp | ||
| - --secure-port=443 | ||
| - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname | ||
| - --kubelet-use-node-status-port | ||
| - --metric-resolution=15s | ||
| image: k8s.gcr.io/metrics-server/metrics-server:v0.5.0 | ||
| imagePullPolicy: IfNotPresent | ||
| livenessProbe: | ||
| failureThreshold: 3 | ||
| httpGet: | ||
| path: /livez | ||
| port: https | ||
| scheme: HTTPS | ||
| periodSeconds: 10 | ||
| name: metrics-server | ||
| ports: | ||
| - containerPort: 443 | ||
| name: https | ||
| protocol: TCP | ||
| readinessProbe: | ||
| failureThreshold: 3 | ||
| httpGet: | ||
| path: /readyz | ||
| port: https | ||
| scheme: HTTPS | ||
| initialDelaySeconds: 20 | ||
| periodSeconds: 10 | ||
| resources: | ||
| requests: | ||
| cpu: 100m | ||
| memory: 200Mi | ||
| securityContext: | ||
| readOnlyRootFilesystem: true | ||
| runAsNonRoot: true | ||
| runAsUser: 1000 | ||
| volumeMounts: | ||
| - mountPath: /tmp | ||
| name: tmp-dir | ||
| nodeSelector: | ||
| kubernetes.io/os: linux | ||
| priorityClassName: system-cluster-critical | ||
| serviceAccountName: metrics-server | ||
| volumes: | ||
| - emptyDir: {} | ||
| name: tmp-dir | ||
| --- | ||
| apiVersion: apiregistration.k8s.io/v1 | ||
| kind: APIService | ||
| metadata: | ||
| labels: | ||
| k8s-app: metrics-server | ||
| name: v1beta1.metrics.k8s.io | ||
| spec: | ||
| group: metrics.k8s.io | ||
| groupPriorityMinimum: 100 | ||
| insecureSkipTLSVerify: true | ||
| service: | ||
| name: metrics-server | ||
| namespace: kube-system | ||
| version: v1beta1 | ||
| versionPriority: 100 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| apiVersion: autoscaling/v2beta1 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: subnetmanager-hpa | ||
| spec: | ||
| scaleTargetRef: | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| name: subnetmanager | ||
| # if minReplicas is less than Deployment replicas value, it may cause scale down | ||
| minReplicas: 5 | ||
| maxReplicas: 10 | ||
| metrics: | ||
| # Set the average usage rate of the cpu, scale up if it exceeds 50 | ||
| - type: Resource | ||
| resource: | ||
| name: cpu | ||
| target: | ||
| type: AverageUtilization | ||
| averageUtilization: 50 | ||
| # The average data volume per second reaches 1000 for scaling up | ||
| # - type: Pods | ||
| # pods: | ||
| # metric: | ||
| # name: packets-per-second | ||
| # target: | ||
| # type: AverageValue | ||
| # averageValue: 1k | ||
|
|
||
| # The value is derived from Ingress "main-route", scale up when the number of requests per second in Ingress reaches 2000 | ||
| # - type: Object | ||
| # object: | ||
| # metric: | ||
| # name: requests-per-second | ||
| # describedObject: | ||
| # apiVersion: networking.k8s.io/v1beta1 | ||
| # kind: Ingress | ||
| # name: main-route | ||
| # target: | ||
| # kind: Value | ||
| # value: 10k | ||
|
|
||
| # HPA's current status data | ||
| status: | ||
| observedGeneration: 1 | ||
| lastScaleTime: <some-time> | ||
| currentReplicas: 1 | ||
| desiredReplicas: 1 | ||
| currentMetrics: | ||
| - type: Resource | ||
| resource: | ||
| name: cpu | ||
| current: | ||
| averageUtilization: 0 | ||
| averageValue: 0 | ||
| # - type: Object | ||
| # object: | ||
| # metric: | ||
| # name: requests-per-second | ||
| # describedObject: | ||
| # apiVersion: networking.k8s.io/v1beta1 | ||
| # kind: Ingress | ||
| # name: main-route | ||
| # current: | ||
| # value: 10k |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| apiVersion: autoscaling/v2beta1 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: vpcmanager-hpa | ||
| spec: | ||
| scaleTargetRef: | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| name: vpcmanager | ||
| # if minReplicas is less than Deployment replicas value, it may cause scale down | ||
| minReplicas: 5 | ||
| maxReplicas: 10 | ||
| metrics: | ||
| # Set the average usage rate of the cpu, scale up if it exceeds 50 | ||
| - type: Resource | ||
| resource: | ||
| name: cpu | ||
| target: | ||
| type: AverageUtilization | ||
| averageUtilization: 50 | ||
| # The average data volume per second reaches 1000 for scaling up | ||
| # - type: Pods | ||
| # pods: | ||
| # metric: | ||
| # name: packets-per-second | ||
| # target: | ||
| # type: AverageValue | ||
| # averageValue: 1k | ||
|
|
||
| # The value is derived from Ingress "main-route", scale up when the number of requests per second in Ingress reaches 2000 | ||
| # - type: Object | ||
| # object: | ||
| # metric: | ||
| # name: requests-per-second | ||
| # describedObject: | ||
| # apiVersion: networking.k8s.io/v1beta1 | ||
| # kind: Ingress | ||
| # name: main-route | ||
| # target: | ||
| # kind: Value | ||
| # value: 10k | ||
|
|
||
| # HPA's current status data | ||
| status: | ||
| observedGeneration: 1 | ||
| lastScaleTime: <some-time> | ||
| currentReplicas: 1 | ||
| desiredReplicas: 1 | ||
| currentMetrics: | ||
| - type: Resource | ||
| resource: | ||
| name: cpu | ||
| current: | ||
| averageUtilization: 0 | ||
| averageValue: 0 | ||
| # - type: Object | ||
| # object: | ||
| # metric: | ||
| # name: requests-per-second | ||
| # describedObject: | ||
| # apiVersion: networking.k8s.io/v1beta1 | ||
| # kind: Ingress | ||
| # name: main-route | ||
| # current: | ||
| # value: 10k |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevin-zhonghao Kevin, where are those metrics stored? Is it possible to visualize those metrics somethere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xieus Metrics Server collects resource metrics from Kubelets and exposes them in Kubernetes apiserver through Metrics API for use by Horizontal Pod Autoscaler. It is not used to store any data, it is more likely an API to get current resource usage status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevin-zhonghao @xieus Is that similar to Elastic's Meatricbeat? https://www.elastic.co/blog/kubernetes-observability-tutorial-k8s-metrics-collection-and-analysis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cj-chung A little similar. In general, we don't use metrics-server as monitoring solution or as a source of monitoring solution metrics. Currently it is just used by HPA.