From 9e2b285213334a9aca8d9fd3bbbe225141754816 Mon Sep 17 00:00:00 2001 From: King'ori Maina Date: Mon, 5 Mar 2018 19:29:48 +0200 Subject: [PATCH 1/3] Add metrics-server addon Complements HPA documentation. --- addons/metrics-server/1.7/01_rbac.yml | 33 +++++++++ addons/metrics-server/1.7/02_apiservice.yml | 14 ++++ addons/metrics-server/1.7/03_app.yml | 48 ++++++++++++++ addons/metrics-server/1.8+/01_rbac.yml | 70 ++++++++++++++++++++ addons/metrics-server/1.8+/02_apiservice.yml | 14 ++++ addons/metrics-server/1.8+/03_app.yml | 48 ++++++++++++++ addons/metrics-server/README.md | 20 ++++++ 7 files changed, 247 insertions(+) create mode 100644 addons/metrics-server/1.7/01_rbac.yml create mode 100644 addons/metrics-server/1.7/02_apiservice.yml create mode 100644 addons/metrics-server/1.7/03_app.yml create mode 100644 addons/metrics-server/1.8+/01_rbac.yml create mode 100644 addons/metrics-server/1.8+/02_apiservice.yml create mode 100644 addons/metrics-server/1.8+/03_app.yml create mode 100644 addons/metrics-server/README.md diff --git a/addons/metrics-server/1.7/01_rbac.yml b/addons/metrics-server/1.7/01_rbac.yml new file mode 100644 index 0000000000000..a094591ceb452 --- /dev/null +++ b/addons/metrics-server/1.7/01_rbac.yml @@ -0,0 +1,33 @@ +--- +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 diff --git a/addons/metrics-server/1.7/02_apiservice.yml b/addons/metrics-server/1.7/02_apiservice.yml new file mode 100644 index 0000000000000..32b1b144c4eed --- /dev/null +++ b/addons/metrics-server/1.7/02_apiservice.yml @@ -0,0 +1,14 @@ +--- +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 diff --git a/addons/metrics-server/1.7/03_app.yml b/addons/metrics-server/1.7/03_app.yml new file mode 100644 index 0000000000000..3f11b4fd9648f --- /dev/null +++ b/addons/metrics-server/1.7/03_app.yml @@ -0,0 +1,48 @@ +--- +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: gcr.io/google_containers/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 diff --git a/addons/metrics-server/1.8+/01_rbac.yml b/addons/metrics-server/1.8+/01_rbac.yml new file mode 100644 index 0000000000000..8de34208ad450 --- /dev/null +++ b/addons/metrics-server/1.8+/01_rbac.yml @@ -0,0 +1,70 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +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/v1 +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: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: system:metrics-server +rules: + - apiGroups: + - "" + resources: + - pods + - nodes + - namespaces + verbs: + - get + - list + - watch + - apiGroups: + - "extensions" + resources: + - deployments + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + 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 diff --git a/addons/metrics-server/1.8+/02_apiservice.yml b/addons/metrics-server/1.8+/02_apiservice.yml new file mode 100644 index 0000000000000..08b0530d809fd --- /dev/null +++ b/addons/metrics-server/1.8+/02_apiservice.yml @@ -0,0 +1,14 @@ +--- +apiVersion: apiregistration.k8s.io/v1beta1 +kind: APIService +metadata: + name: v1beta1.metrics.k8s.io +spec: + service: + name: metrics-server + namespace: kube-system + group: metrics.k8s.io + version: v1beta1 + insecureSkipTLSVerify: true + groupPriorityMinimum: 100 + versionPriority: 100 diff --git a/addons/metrics-server/1.8+/03_app.yml b/addons/metrics-server/1.8+/03_app.yml new file mode 100644 index 0000000000000..088e7b5248243 --- /dev/null +++ b/addons/metrics-server/1.8+/03_app.yml @@ -0,0 +1,48 @@ +--- +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: apps/v1beta2 +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: gcr.io/google_containers/metrics-server-amd64:v0.2.1 + imagePullPolicy: Always + command: + - /metrics-server + - --source=kubernetes.summary_api:'' + resources: + requests: + cpu: 20m + memory: 200Mi + limits: + cpu: 100m + memory: 500Mi diff --git a/addons/metrics-server/README.md b/addons/metrics-server/README.md new file mode 100644 index 0000000000000..775a7e251b830 --- /dev/null +++ b/addons/metrics-server/README.md @@ -0,0 +1,20 @@ +# Kubernetes Metrics Server + +Compatibility matrix: + +Metrics Server | Metrics API group/version | Supported Kubernetes version +---------------|---------------------------|----------------------------- +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 addons/metrics-server/1.7/ + +# Kubernetes 1.8+ +$ kubectl apply -f addons/metrics-server/1.8+/ +``` From ae032eb0cc4cfde53fca95d7e50b757cc6ab99aa Mon Sep 17 00:00:00 2001 From: King'ori Maina Date: Tue, 6 Mar 2018 20:15:18 +0200 Subject: [PATCH 2/3] Prefer to use single files --- addons/metrics-server/1.7/01_rbac.yml | 33 ---------- addons/metrics-server/1.7/02_apiservice.yml | 14 ----- addons/metrics-server/1.8+/02_apiservice.yml | 14 ----- addons/metrics-server/1.8+/03_app.yml | 48 -------------- addons/metrics-server/README.md | 4 +- .../{1.7/03_app.yml => v1.7.x.yaml} | 47 ++++++++++++++ .../{1.8+/01_rbac.yml => v1.8.x.yaml} | 62 +++++++++++++++++++ 7 files changed, 111 insertions(+), 111 deletions(-) delete mode 100644 addons/metrics-server/1.7/01_rbac.yml delete mode 100644 addons/metrics-server/1.7/02_apiservice.yml delete mode 100644 addons/metrics-server/1.8+/02_apiservice.yml delete mode 100644 addons/metrics-server/1.8+/03_app.yml rename addons/metrics-server/{1.7/03_app.yml => v1.7.x.yaml} (50%) rename addons/metrics-server/{1.8+/01_rbac.yml => v1.8.x.yaml} (51%) diff --git a/addons/metrics-server/1.7/01_rbac.yml b/addons/metrics-server/1.7/01_rbac.yml deleted file mode 100644 index a094591ceb452..0000000000000 --- a/addons/metrics-server/1.7/01_rbac.yml +++ /dev/null @@ -1,33 +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 diff --git a/addons/metrics-server/1.7/02_apiservice.yml b/addons/metrics-server/1.7/02_apiservice.yml deleted file mode 100644 index 32b1b144c4eed..0000000000000 --- a/addons/metrics-server/1.7/02_apiservice.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -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 diff --git a/addons/metrics-server/1.8+/02_apiservice.yml b/addons/metrics-server/1.8+/02_apiservice.yml deleted file mode 100644 index 08b0530d809fd..0000000000000 --- a/addons/metrics-server/1.8+/02_apiservice.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -apiVersion: apiregistration.k8s.io/v1beta1 -kind: APIService -metadata: - name: v1beta1.metrics.k8s.io -spec: - service: - name: metrics-server - namespace: kube-system - group: metrics.k8s.io - version: v1beta1 - insecureSkipTLSVerify: true - groupPriorityMinimum: 100 - versionPriority: 100 diff --git a/addons/metrics-server/1.8+/03_app.yml b/addons/metrics-server/1.8+/03_app.yml deleted file mode 100644 index 088e7b5248243..0000000000000 --- a/addons/metrics-server/1.8+/03_app.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -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: apps/v1beta2 -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: gcr.io/google_containers/metrics-server-amd64:v0.2.1 - imagePullPolicy: Always - command: - - /metrics-server - - --source=kubernetes.summary_api:'' - resources: - requests: - cpu: 20m - memory: 200Mi - limits: - cpu: 100m - memory: 500Mi diff --git a/addons/metrics-server/README.md b/addons/metrics-server/README.md index 775a7e251b830..f7d3c841be5e4 100644 --- a/addons/metrics-server/README.md +++ b/addons/metrics-server/README.md @@ -13,8 +13,8 @@ the top-level directory of this repository: ```console # Kubernetes 1.7 -$ kubectl apply -f addons/metrics-server/1.7/ +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/kops/master/addons/metrics-server/v1.7.x.yaml # Kubernetes 1.8+ -$ kubectl apply -f addons/metrics-server/1.8+/ +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/kops/master/addons/metrics-server/v1.8.x.yaml ``` diff --git a/addons/metrics-server/1.7/03_app.yml b/addons/metrics-server/v1.7.x.yaml similarity index 50% rename from addons/metrics-server/1.7/03_app.yml rename to addons/metrics-server/v1.7.x.yaml index 3f11b4fd9648f..a9c5408ed0788 100644 --- a/addons/metrics-server/1.7/03_app.yml +++ b/addons/metrics-server/v1.7.x.yaml @@ -1,5 +1,52 @@ --- 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 diff --git a/addons/metrics-server/1.8+/01_rbac.yml b/addons/metrics-server/v1.8.x.yaml similarity index 51% rename from addons/metrics-server/1.8+/01_rbac.yml rename to addons/metrics-server/v1.8.x.yaml index 8de34208ad450..b4d2a4eefdbe1 100644 --- a/addons/metrics-server/1.8+/01_rbac.yml +++ b/addons/metrics-server/v1.8.x.yaml @@ -68,3 +68,65 @@ subjects: - kind: ServiceAccount name: metrics-server namespace: kube-system +--- +apiVersion: apiregistration.k8s.io/v1beta1 +kind: APIService +metadata: + name: v1beta1.metrics.k8s.io +spec: + service: + name: metrics-server + namespace: kube-system + group: metrics.k8s.io + version: v1beta1 + 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: apps/v1beta2 +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: gcr.io/google_containers/metrics-server-amd64:v0.2.1 + imagePullPolicy: Always + command: + - /metrics-server + - --source=kubernetes.summary_api:'' + resources: + requests: + cpu: 20m + memory: 200Mi + limits: + cpu: 100m + memory: 500Mi From d56a736cba6b9be88cedbeabe94ae081137c0590 Mon Sep 17 00:00:00 2001 From: King'ori Maina Date: Tue, 6 Mar 2018 20:17:27 +0200 Subject: [PATCH 3/3] Link to addon installation steps in HPA docs --- docs/horizontal_pod_autoscaling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/horizontal_pod_autoscaling.md b/docs/horizontal_pod_autoscaling.md index 88be0d50d87dc..2fb791e3fcced 100644 --- a/docs/horizontal_pod_autoscaling.md +++ b/docs/horizontal_pod_autoscaling.md @@ -121,7 +121,7 @@ These are the PRs that enable the required configuration: [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-metrics-server]: https://github.com/kubernetes-incubator/metrics-server#deployment +[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