Skip to content

Commit

Permalink
Metrics "Sidecar" (scraping container) support (#3504)
Browse files Browse the repository at this point in the history
* rebasing to master

* rebase fixes

* update npm deps

* fix tests

* first deployment script, just using head for now.

* remove dev artifacts

* golint fix

* more govet fixes.

* review nits. force goos to be linux. updated head deployment yaml

* fix url

* addressing nits

* point to the correct endpoint

* add deployment script for local testing

* remove uncalled code

* move/update local deployment
  • Loading branch information
jeefy authored and k8s-ci-robot committed Jun 17, 2019
1 parent 708e606 commit 5c5c736
Show file tree
Hide file tree
Showing 18 changed files with 1,648 additions and 16 deletions.
101 changes: 91 additions & 10 deletions aio/deploy/recommended/kubernetes-dashboard-head.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ metadata:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: kubernetes-dashboard-minimal-head
name: kubernetes-dashboard-head-minimal
namespace: kube-system
rules:
# Allow Dashboard to create 'kubernetes-dashboard-key-holder' secret.
Expand All @@ -77,32 +77,56 @@ rules:
# Allow Dashboard to get metrics from heapster.
- apiGroups: [""]
resources: ["services"]
resourceNames: ["heapster"]
resourceNames: ["heapster", "dashboard-metrics-scraper"]
verbs: ["proxy"]
- apiGroups: [""]
resources: ["services/proxy"]
resourceNames: ["heapster", "http:heapster:", "https:heapster:"]
resourceNames: ["heapster", "http:heapster:", "https:heapster:", "dashboard-metrics-scraper", "http:dashboard-metrics-scraper"]
verbs: ["get"]
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: kubernetes-dashboard-head-minimal
namespace: kube-system
rules:
# Allow Metrics Scraper to get metrics from the Metrics server
- apiGroups: ["metrics.k8s.io"]
resources: ["pods", "nodes"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: kubernetes-dashboard-minimal-head
name: kubernetes-dashboard-head-minimal
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: kubernetes-dashboard-minimal-head
name: kubernetes-dashboard-head-minimal
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard-head
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard-head-minimal
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kubernetes-dashboard-head-minimal
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard-head
namespace: kube-system

---
# ------------------- Dashboard Deployment ------------------- #

kind: Deployment
apiVersion: apps/v1beta2
apiVersion: apps/v1
metadata:
labels:
k8s-app: kubernetes-dashboard-head
Expand All @@ -122,7 +146,6 @@ spec:
containers:
- name: kubernetes-dashboard-head
image: kubernetesdashboarddev/kubernetes-dashboard-amd64:head
# Image is tagged and updated with :head, so always pull it.
imagePullPolicy: Always
ports:
- containerPort: 8443
Expand Down Expand Up @@ -170,7 +193,65 @@ metadata:
namespace: kube-system
spec:
ports:
- port: 443
targetPort: 8443
- port: 443
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard-head


---
# ------------------- Metrics Scraper Deployment ------------------- #

kind: Deployment
apiVersion: apps/v1
metadata:
labels:
k8s-app: kubernetes-metrics-scraper-head
name: kubernetes-metrics-scraper-head
namespace: kube-system
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: kubernetes-metrics-scraper-head
template:
metadata:
labels:
k8s-app: kubernetes-metrics-scraper-head
spec:
containers:
- name: kubernetes-metrics-scraper-head
image: kubernetesdashboarddev/dashboard-metrics-sidecar:latest
ports:
- containerPort: 8000
protocol: TCP
livenessProbe:
httpGet:
scheme: HTTP
path: /
port: 8000
initialDelaySeconds: 30
timeoutSeconds: 30
serviceAccountName: kubernetes-dashboard-head
# Comment the following tolerations if Dashboard must not be deployed on master
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule

---
# ------------------- Metrics Scraper Service ------------------- #

kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-metrics-scraper-head
name: dashboard-metrics-scraper
namespace: kube-system
spec:
ports:
- port: 8000
targetPort: 8000
selector:
k8s-app: kubernetes-metrics-scraper-head
1 change: 1 addition & 0 deletions aio/gulp/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function backendProd(outputBinaryPathsAndArchs) {
// Disable cgo package. Required to run on scratch docker image.
CGO_ENABLED: '0',
GOARCH: arch,
GOOS: 'linux',
});
};
};
Expand Down
13 changes: 12 additions & 1 deletion aio/gulp/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,24 @@ export default {
* dashboard defaults to INFO, publishing sanitized logs to STDOUT
*/
apiLogLevel: gulpUtil.env.apiLogLevel !== undefined ? gulpUtil.env.apiLogLevel : '',
/**
* Setting for metrics provider. Defaults to sidecar.
*/
metricsProvider: gulpUtil.env.metricsProvider !== undefined ? gulpUtil.env.metricsProvider : 'sidecar',
/**
* Address for the Heapster API server. If blank, the dashboard
* will attempt to connect to Heapster via a service proxy.
*/
heapsterServerHost: gulpUtil.env.heapsterServerHost !== undefined ?
gulpUtil.env.heapsterServerHost :
'',
'http://localhost:8001',
/**
* Address for the Sidecar API server. If blank, the dashboard
* will attempt to connect to Sidecar via a service proxy.
*/
sidecarServerHost: gulpUtil.env.sidecarServerHost !== undefined ?
gulpUtil.env.sidecarServerHost :
'http://localhost:8000',
/**
* File containing the default x509 Certificate for HTTPS.
*/
Expand Down
2 changes: 1 addition & 1 deletion aio/gulp/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let runningBackendProcess = null;
*/
function getBackendArgs() {
let args = [
`--heapster-host=${conf.backend.heapsterServerHost}`,
`--sidecar-host=${conf.backend.sidecarServerHost}`,
`--tls-cert-file=${conf.backend.tlsCert}`,
`--tls-key-file=${conf.backend.tlsKey}`,
`--auto-generate-certificates=${conf.backend.autoGenerateCerts}`,
Expand Down
Loading

0 comments on commit 5c5c736

Please sign in to comment.