Merge pull request #60174 from hyperbolic2346/mwilson/metrics-server

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Adding metrics server

**What this PR does / why we need it**:
Adds support for the metrics server in the kubernetes-master charm. This allows the use of a horizontal pod autoscaler.
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #
https://github.com/juju-solutions/bundle-canonical-kubernetes/issues/484
**Special notes for your reviewer**:
Needs to go in after https://github.com/juju-solutions/cdk-addons/pull/28
**Release note**:

```release-note
kubernetes-master charm now supports metrics server for horizontal pod autoscaler.
```
This commit is contained in:
Kubernetes Submit Queue 2018-04-02 02:47:26 -07:00 committed by GitHub
commit 2550bab1e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -86,3 +86,8 @@ options:
description: | description: |
The storage backend for kube-apiserver persistence. Can be "etcd2", "etcd3", or The storage backend for kube-apiserver persistence. Can be "etcd2", "etcd3", or
"auto". Auto mode will select etcd3 on new installations, or etcd2 on upgrades. "auto". Auto mode will select etcd3 on new installations, or etcd2 on upgrades.
enable-metrics:
type: boolean
default: true
description: |
If true the metrics server for Kubernetes will be deployed onto the cluster.

View File

@ -640,12 +640,14 @@ def configure_cdk_addons():
remove_state('cdk-addons.configured') remove_state('cdk-addons.configured')
dbEnabled = str(hookenv.config('enable-dashboard-addons')).lower() dbEnabled = str(hookenv.config('enable-dashboard-addons')).lower()
dnsEnabled = str(hookenv.config('enable-kube-dns')).lower() dnsEnabled = str(hookenv.config('enable-kube-dns')).lower()
metricsEnabled = str(hookenv.config('enable-metrics')).lower()
args = [ args = [
'arch=' + arch(), 'arch=' + arch(),
'dns-ip=' + get_deprecated_dns_ip(), 'dns-ip=' + get_deprecated_dns_ip(),
'dns-domain=' + hookenv.config('dns_domain'), 'dns-domain=' + hookenv.config('dns_domain'),
'enable-dashboard=' + dbEnabled, 'enable-dashboard=' + dbEnabled,
'enable-kube-dns=' + dnsEnabled 'enable-kube-dns=' + dnsEnabled,
'enable-metrics=' + metricsEnabled
] ]
check_call(['snap', 'set', 'cdk-addons'] + args) check_call(['snap', 'set', 'cdk-addons'] + args)
if not addons_ready(): if not addons_ready():
@ -1183,6 +1185,18 @@ def configure_apiserver(etcd_connection_string, leader_etcd_version):
else: else:
api_opts['admission-control'] = ','.join(admission_control) api_opts['admission-control'] = ','.join(admission_control)
if get_version('kube-apiserver') > (1, 6) and \
hookenv.config('enable-metrics'):
api_opts['requestheader-client-ca-file'] = ca_cert_path
api_opts['requestheader-allowed-names'] = 'client'
api_opts['requestheader-extra-headers-prefix'] = 'X-Remote-Extra-'
api_opts['requestheader-group-headers'] = 'X-Remote-Group'
api_opts['requestheader-username-headers'] = 'X-Remote-User'
api_opts['proxy-client-cert-file'] = client_cert_path
api_opts['proxy-client-key-file'] = client_key_path
api_opts['enable-aggregator-routing'] = 'true'
api_opts['client-ca-file'] = ca_cert_path
configure_kubernetes_service('kube-apiserver', api_opts, 'api-extra-args') configure_kubernetes_service('kube-apiserver', api_opts, 'api-extra-args')
restart_apiserver() restart_apiserver()