Merge pull request #9233 from johngmyers/update-hpa

Prune old metrics-server and update HPA docs
This commit is contained in:
Kubernetes Prow Robot 2020-06-17 05:22:39 -07:00 committed by GitHub
commit 7200889cf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 193 deletions

View File

@ -42,17 +42,11 @@ Compatibility matrix:
Metrics Server | Metrics API group/version | Supported Kubernetes version
---------------|---------------------------|-----------------------------
0.3.x | `metrics.k8s.io/v1beta1` | 1.8+
0.2.x | `metrics.k8s.io/v1beta1` | 1.8+
0.1.x | `metrics/v1alpha1` | 1.7
In order to deploy metrics-server in your cluster run the following command from
the top-level directory of this repository:
```console
# Kubernetes 1.7
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/kops/master/addons/metrics-server/v1.7.x.yaml
# Kubernetes 1.8+ <= 1.15
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/kops/master/addons/metrics-server/v1.8.x.yaml

View File

@ -3,11 +3,6 @@ metadata:
name: metrics-server
spec:
addons:
- version: 0.1.0
selector:
k8s-addon: metrics-server.addons.k8s.io
manifest: v1.7.x.yaml
kubernetesVersion: "<1.8.0"
- version: 0.3.6
selector:
k8s-addon: metrics-server.addons.k8s.io

View File

@ -1,95 +0,0 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: metrics-server
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
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/v1beta1
kind: RoleBinding
metadata:
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: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1alpha1.metrics
spec:
service:
name: metrics-server
namespace: kube-system
group: metrics
version: v1alpha1
insecureSkipTLSVerify: true
groupPriorityMinimum: 100
versionPriority: 100
---
apiVersion: v1
kind: Service
metadata:
name: metrics-server
namespace: kube-system
labels:
kubernetes.io/name: "Metrics-server"
spec:
selector:
k8s-app: metrics-server
ports:
- port: 443
protocol: TCP
targetPort: 443
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: metrics-server
namespace: kube-system
labels:
k8s-app: metrics-server
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
name: metrics-server
labels:
k8s-app: metrics-server
spec:
serviceAccountName: metrics-server
containers:
- name: metrics-server
image: k8s.gcr.io/metrics-server-amd64:v0.1.0
imagePullPolicy: Always
command:
- /metrics-server
- --source=kubernetes.summary_api:''
resources:
requests:
cpu: 20m
memory: 200Mi
limits:
cpu: 100m
memory: 500Mi

View File

@ -1,17 +1,16 @@
# Horizontal Pod Autoscaling
With Horizontal Pod Autoscaling, Kubernetes automatically scales the number of
pods in a replication controller, deployment or replica set based on observed
pods in a replication controller, deployment, or replica set based on observed
CPU utilization (or, with alpha support, on some other, application-provided
metrics).
The current stable version, which only includes support for CPU autoscaling, can
be found in the `autoscaling/v1` API version. The alpha version, which includes
support for scaling on memory and custom metrics, can be found in
`autoscaling/v2alpha1` in 1.7 and `autoscaling/v2beta1` 1.8 and 1.9.
`autoscaling/v2beta1` (and `autoscaling/v2beta2` in 1.12 and later).
Kops can assist in setting up HPA and recommends Kubernetes `1.7.x` to `1.9.x`
and Kops `>=1.7`. Relevant reading you will need to go through:
Kops can assist in setting up HPA. Relevant reading you will need to go through:
* [Extending the Kubernetes API with the aggregation layer][k8s-extend-api]
* [Configure The Aggregation Layer][k8s-aggregation-layer]
@ -35,102 +34,25 @@ Specifically:
* [x] `--horizontal-pod-autoscaler-use-rest-clients` should be true.
* [x] `--kubeconfig <path-to-kubeconfig>`
Ensure that you use **1.8.5 at minimum for Kubernetes 1.8.x** due to [a nasty
bug affecting the API aggregation layer][issue-1]. It was fixed in
[kubernetes/kubernetes#55259][pr-5].
## Cluster Configuration
### Support For Multiple Metrics
Enable API versions required to support scaling on cpu, memory and custom
metrics:
```yaml
# On K8s 1.7
spec:
kubeAPIServer:
runtimeConfig:
autoscaling/v2alpha1: "true"
```
```yaml
# On K8s 1.8 and 1.9
spec:
kubeAPIServer:
runtimeConfig:
autoscaling/v2beta1: "true"
```
If you've set the above configuration, your cluster is now ready for the
resource metrics API ([installation instruction here][k8s-metrics-server]). The
To enable the resource metrics API for scaling on CPU and memory, install metrics-server
([installation instruction here][k8s-metrics-server]). The
compatibility matrix is as follows:
Metrics Server | Metrics API group/version | Supported Kubernetes version
---------------|---------------------------|-----------------------------
0.3.x | `metrics.k8s.io/v1beta1` | 1.8+
0.2.x | `metrics.k8s.io/v1beta1` | 1.8+
0.1.x | `metrics/v1alpha1` | 1.7
### Support For Custom Metrics
Enable gathering custom metrics:
```yaml
spec:
kubelet:
enableCustomMetrics: true
```
Note that the deprecated and inactive option '--enable-custom-metrics' has been removed in Kubernetes 1.11 [#60699](https://github.com/kubernetes/kubernetes/pull/60699)
Enable the horizontal pod autoscaler REST client:
```yaml
spec:
kubeControllerManager:
horizontalPodAutoscalerUseRestClients: true
```
If you've set the above configuration, your cluster is now ready for the custom
metrics API. Register it via the API aggregation layer. If you're using
To enable the custom metrics API, register it via the API aggregation layer. If you're using
Prometheus, checkout the [custom metrics adapter for Prometheus][k8s-prometheus-custom-metrics-adapter].
## Implementation Details
These are the PRs that enable the required configuration:
* [kubernetes/kops#3679][pr-1] - sets `--requestheader-xxx` kube-apiserver flags
required to enable aggregation layer
```
--requestheader-client-ca-file=<path to aggregator CA cert>
--requestheader-allowed-names=aggregator
--requestheader-extra-headers-prefix=X-Remote-Extra-
--requestheader-group-headers=X-Remote-Group
--requestheader-username-headers=X-Remote-User
```
* [kubernetes/kops#3165][pr-2] - sets `--proxy-client-xxx` kube-apiserver flags
required to enable aggregation layer
```
--proxy-client-cert-file=<path to aggregator proxy cert>
--proxy-client-key-file=<path to aggregator proxy key>
```
* [kubernetes/kops#3939][pr-3] - add config option to set `--horizontal-pod-
autoscaler-use-rest-clients` kube-controller-manager flag required to enable
custom metrics
* [kubernetes/kops#1574][pr-4] - add config options to set `--enable-custom-
metrics` flag on master and node kubelets required to enable custom metrics
[k8s-aggregation-layer]: https://v1-9.docs.kubernetes.io/docs/tasks/access-kubernetes-api/configure-aggregation-layer/
[k8s-extend-api]: https://v1-9.docs.kubernetes.io/docs/concepts/api-extension/apiserver-aggregation/
[k8s-hpa]: https://v1-9.docs.kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
[k8s-aggregation-layer]: https://kubernetes.io/docs/tasks/access-kubernetes-api/configure-aggregation-layer/
[k8s-extend-api]: https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/
[k8s-hpa]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
[k8s-metrics-server]: https://github.com/kubernetes/kops/blob/master/addons/metrics-server/README.md
[k8s-prometheus-custom-metrics-adapter]: https://github.com/DirectXMan12/k8s-prometheus-adapter
[pr-1]: https://github.com/kubernetes/kops/pull/3679
[pr-2]: https://github.com/kubernetes/kops/pull/3165
[pr-3]: https://github.com/kubernetes/kops/pull/3939
[pr-4]: https://github.com/kubernetes/kops/pull/1574
[pr-5]: https://github.com/kubernetes/kubernetes/pull/55259
[issue-1]: https://github.com/kubernetes/kubernetes/issues/55022