This repository has been archived by the owner on Apr 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 205
Support the Kubernetes Metrics Server #319
Open
abcdabcd987
wants to merge
3
commits into
pires:master
Choose a base branch
from
abcdabcd987:metrics-server
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 all commits
Commits
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
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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,11 @@ | ||
export NODES=3 | ||
export MASTER_MEM=2048 | ||
export MASTER_CPUS=2 | ||
export NODE_MEM=4096 | ||
export NODE_CPUS=3 | ||
export USE_KUBE_UI=true | ||
export KUBERNETES_VERSION=1.12.1 | ||
export VAGRANT_USE_VAGRANT_TRIGGERS=false | ||
export AUTHORIZATION_MODE=AlwaysAllow | ||
# export AUTHORIZATION_MODE=RBAC | ||
export USE_METRICS_SERVER=true |
This file contains 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
This file contains 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
This file contains 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,12 @@ | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: system:aggregated-metrics-reader | ||
labels: | ||
rbac.authorization.k8s.io/aggregate-to-view: "true" | ||
rbac.authorization.k8s.io/aggregate-to-edit: "true" | ||
rbac.authorization.k8s.io/aggregate-to-admin: "true" | ||
rules: | ||
- apiGroups: ["metrics.k8s.io"] | ||
resources: ["pods"] | ||
verbs: ["get", "list", "watch"] |
This file contains 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,13 @@ | ||
--- | ||
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 |
This file contains 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,14 @@ | ||
--- | ||
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 |
This file contains 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,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 |
This file contains 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,37 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: metrics-server | ||
namespace: kube-system | ||
--- | ||
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 | ||
volumes: | ||
# mount in tmp so we can safely use from-scratch images and/or read-only containers | ||
- name: tmp-dir | ||
emptyDir: {} | ||
containers: | ||
- name: metrics-server | ||
image: k8s.gcr.io/metrics-server-amd64:v0.3.1 | ||
imagePullPolicy: Always | ||
volumeMounts: | ||
- name: tmp-dir | ||
mountPath: /tmp | ||
|
This file contains 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,15 @@ | ||
--- | ||
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 |
This file contains 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,38 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: system:metrics-server | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- nodes | ||
- nodes/stats | ||
- 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 |
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.
This is required for the Horizontal Pod Autoscaler to work.
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.
I would say agree because HPA is my motivation for adding this feature. The reason why I put it to false by default is that I haven't tested it in Windows nor RBAC (and I probably won't because I don't have this kind of setup).
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.
I'm sure @bmcstdio can help here, right Bruno?
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.
Definitely. However, it seems to me that this PR needs some love. I checked out this branch and ran the following command:
Turns out the Kubernetes API can never be reachable:
This does not happen in
USE_METRICS_SERVER
is set tofalse
.I also noticed high load on the system - far higher than usual. While I am not sure, part of what the root cause for this may be the fact that the following flag is not being defined:
https://kubernetes.io/docs/tasks/access-kubernetes-api/configure-aggregation-layer/#enable-apiserver-flags
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.
Yeah, definitely need more tests. I only tested it on macOS. Also, good catch on
--enable-aggregator-routing=true
.