Add autoscaler - Metrics might not be configured by your cluster administrator - Metrics components already installed .
I deployed one mysql image to my openshift infrastructure ("fap" namespace). When I access the Web Console >"fap" Project > Deployment > and try to "Add autoscaler", I got the message "Metrics might not be configured by your cluster administrator. Metrics are required for autoscaling." But previously, I installed the Metrics components with success as you can see below.
What else do I have to do?
$ oc login -u system:admin
Logged into "https://10.8.7.213:8443" as "system:admin" using existing credentials.
You have access to the following projects and can switch between them with 'oc project <projectname>':
default
* fap
kube-system
my-project
openshift
openshift-infra
Using project "fap".
$ oc get pods
NAME READY STATUS RESTARTS AGE
mysql-55-rhel7-1-dt1uq 1/1 Running 0 16m
$ oc status
In project fap on server https://10.8.7.213:8443
svc/mysql-55-rhel7 - 172.30.116.100:3306
dc/mysql-55-rhel7 deploys istag/mysql-55-rhel7:latest
deployment #1 deployed 16 minutes ago - 1 pod
1 warning identified, use 'oc status -v' to see details.
$ oc project openshift-infra
Now using project "openshift-infra" on server "https://10.8.7.213:8443".
$ oc get pods
NAME READY STATUS RESTARTS AGE
hawkular-cassandra-1-p766c 1/1 Running 0 3h
hawkular-metrics-pkc0q 1/1 Running 0 3h
heapster-d5yfy 1/1 Running 0 3h
hello-openshift 1/1 Running 0 1h
metrics-deployer-z8cwd 0/1 Completed 0 3h
openshift-router-1-g0edv 1/1 Running 1 3h
Version
$ oc version oc v1.3.0-alpha.3+1148c68 kubernetes v1.3.0+507d3a7 features: Basic-Auth GSSAPI Kerberos SPNEGO
Server https://10.8.7.213:8443 openshift v1.3.0-alpha.3+1148c68 kubernetes v1.3.0+507d3a7
Are you able to see metrics in the console? Just wondering if the metrics components are properly running or not.
Can you also try and see if you can access the Heapster endpoint via the proxy? It should be accessible via something like:
curl -k -H "Authorization: Bearer $CLUSTER_ADMIN_TOKEN" -X GET https://$MASTER_URL:8443/api/v1/proxy/namespace/openshift-infra/services/https:heapster:/api/
@mwringe My pods doesn't have metrics options avaliable in the web console.
$ curl --insecure -H "Authorization: Bearer XXXXXXXXXXXXXXXXX" -X GET https://10.8.7.213:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/metrics Unauthorized
$ oc project openshift-infra Now using project "openshift-infra" on server "https://10.8.7.213:8443".
$ oc get pods NAME READY STATUS RESTARTS AGE hawkular-cassandra-1-p766c 1/1 Running 0 22h hawkular-metrics-pkc0q 1/1 Running 0 22h heapster-d5yfy 1/1 Running 0 22h hello-openshift 1/1 Running 0 20h metrics-deployer-z8cwd 0/1 Completed 0 22h openshift-router-1-g0edv 1/1 Running 1 23h
@Shyckymn ah, ok, I guess you may not have set the METRICS_URL parameter in the master-config.yaml file. That would explain why the metric tabs are not showing up, this wont affect heapster though.
When you get the unauthorized error trying to access the Heapster api, are you using a token from a cluster-admin or from some other component? I believe its only the cluster admin and hpa sa which can access that endpoint.
If not, did you make any changes to the Heapster configuration when deploying the metric components? Such as changing the secrets for who can access the Heapster api?
Hi @mwringe !
I didn't make any changes to the Heapster configuration. I followed the instructions from this link: https://docs.openshift.org/latest/install_config/cluster_metrics.html
I just forgot to change the master-config.yaml file. Right now, I have the following configuration: $ cat /openshift.local.config/master/master-config.yaml admissionConfig: (...) masterPublicURL: https://10.8.7.213:8443 metricsPublicURL: "https://10.8.7.213:8443/hawkular/metrics" publicURL: https://10.8.7.213:8443/console/
After restart my openshift container, I don't see any changes. My pod still doesn't have the metrics tab.
$ oc projects
You have access to the following projects and can switch between them with 'oc project
default
fap
kube-system
my-project - My Project
openshift
- openshift-infra
Using project "openshift-infra" on server "https://10.8.7.213:8443".
$ oc status In project openshift-infra on server https://10.8.7.213:8443
svc/hawkular-cassandra - 172.30.246.186 ports 9042->cql-port, 9160->thift-port, 7000->tcp-port, 7001->ssl-port rc/hawkular-cassandra-1 runs openshift/origin-metrics-cassandra:latest rc/hawkular-cassandra-1 created 23 hours ago - 1 pod
svc/hawkular-cassandra-nodes (headless) ports 9042, 9160, 7000, 7001 rc/hawkular-cassandra-1 runs openshift/origin-metrics-cassandra:latest rc/hawkular-cassandra-1 created 23 hours ago - 1 pod
https://pxl0docker001 (reencrypt) to pod port https-endpoint (svc/hawkular-metrics) rc/hawkular-metrics runs openshift/origin-metrics-hawkular-metrics:latest rc/hawkular-metrics created 23 hours ago - 1 pod
svc/heapster - 172.30.239.13:80 -> http-endpoint rc/heapster runs openshift/origin-metrics-heapster:latest rc/heapster created 23 hours ago - 1 pod
svc/openshift-router - 172.30.67.12 ports 80, 443, 1936 dc/openshift-router deploys docker.io/openshift/origin-haproxy-router:v1.3.0-alpha.3 deployment #1 deployed 24 hours ago - 1 pod
pod/hello-openshift runs openshift/hello-openshift
I'm using system:admin account. How can I get it's token to test the Heapster API access directly?
$ curl -X GET https://pxl0docker001/hawkular/metrics/status --insecure {"MetricsService":"STARTED","Implementation-Version":"0.18.3.Final","Built-From-Git-SHA1":"38ea6c2a1e33ed1024684084812ad2ad5730fb76"}
But still without metrics tab...
You should see the metric tabs appear in the console if the metricsPublicURL is set. In your browser, can you directly access https://10.8.7.213:8443/hawkular/metrics ? or should it be https://pxl0docker001/hawkular/metrics like in your previous curl command?
I have just tried this out, and I can access the Heapster API endpoint using the token from a cluster-admin user:
curl -k -H "Authorization: Bearer
oc whoami -t" -X GET https://localhost:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/metrics
If you cannot access that endpoint using the token from user with cluster-admin privileges, then something is wrong with the policy setup. Does running oadm policy reconcile-cluster-roles help?
@mwringe, when I try to access https://10.8.7.213:8443/hawkular/metrics, I got the following:
$ oc login -u system:admin Logged into "https://10.8.7.213:8443" as "system:admin" using existing credentials.
You have access to the following projects and can switch between them with 'oc project
default
fap
kube-system
my-project
openshift
- openshift-infra
Using project "openshift-infra".
Trying to access https://10.8.7.213:8443/hawkular/metrics:
{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Failure", "message": "User "system:anonymous" cannot "get" on "/hawkular/metrics"", "reason": "Forbidden", "details": {}, "code": 403
}
$ oc whoami -t error: no token is currently in use for this session
So, I think that the system:admin account cannot get tokens, right?
The same issue occurs with user "fap":
$ oc login Authentication required for https://10.8.7.213:8443 (openshift) Username: fap Password: Login successful.
You have one project on this server: "fap"
Using project "fap".
$curl -k -H "Authorization: Bearer oc whoami -t" -X GET https://pxl0docker001:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/metrics
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "User "fap" cannot "proxy" "services" with name "https:heapster:" in project "openshift-infra"",
"reason": "Forbidden",
"details": {
"name": "https:heapster:",
"kind": "services"
},
"code": 403
}
How can I give cluster-admin roles to my "fap" user?
Ooops, I got it:
$ oadm policy add-cluster-role-to-user cluster-admin fap
$ curl -k -H "Authorization: Bearer oc whoami -t" -X GET https://pxl0docker001:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/metrics
[
"memory/usage",
"cpu/request",
"cpu/limit",
"memory/request",
"memory/limit",
"cpu/usage_rate"
I will restart my openshift container to see what happens now...
@mwringe, I'm getting crazy! :-) After restart, the web console still doesn't show metrics tab in any container... Is there any command line or logfiles that we should analyse?
$ oc get all
NAME REVISION DESIRED CURRENT TRIGGERED BY
dc/openshift-router 1 1 1 config
NAME DESIRED CURRENT AGE
rc/hawkular-cassandra-1 1 1 1d
rc/hawkular-metrics 1 1 1d
rc/heapster 1 1 1d
rc/openshift-router-1 1 1 1d
NAME HOST/PORT PATH SERVICE TERMINATION LABELS
routes/hawkular-metrics pxl0docker001 hawkular-metrics:https-endpoint reencrypt metrics-infra=hawkular-metrics,name=hawkular-metrics
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/hawkular-cassandra 172.30.246.186
$ curl -k -H "Authorization: Bearer oc whoami -t" -X GET https://pxl0docker001:8443/api/v1/proxy/namespaces/openshift-infra/services/https:heapster:/api/v1/model/metrics
[
"cpu/usage_rate",
"cpu/request",
"cpu/limit",
"memory/request",
"memory/limit",
"memory/usage"
]
Are you sure you are looking at the right areas in the console?
Can you open the monitoring page and then expand one of the components to see the graphs? https://${MASTER_URL}:8443/console/project/openshift-infra/monitoring
There are few places where the metrics are available in the console, but the monitoring one is probably the quickest one to check.
@mwringe Yeah, I think so... I'll attach some screen captures...
From the monitoring page, please click the ">" button so that it opens up something beneath that, in that area you should see graphs (or at least a warning message)
From the third screenshot, that one should have the 'metrics' tag available there. The only time I have not seen the metric tab show up there is when the metricsPublicURL is not set (or its property value has a spelling mistake in it, such as MetricsPublicURL or metricPublicURL)
Nothing beneath the ">" button.
I haven't found any metrics tag available from the third screenshot...
Can you please double check the metricsPublicURL value in your master-config.yaml? And that you are also picking up that master-config.yaml file and not another one. Please also make sure that you have restarted it after making this change.
I've restarted my openshift container and also the k8s containers.
The results from my openshift container:
Are you sure that is the master-config.yaml file which is used to start the OpenShift cluster?
Eg it should be started with something like openshift start --node-config=openshift.local.config/node-mynode/node-config.yaml --master-config=openshift.local.config/master/master-config.yaml
When you start the OpenShift instance, do you see something like the following in the logs (it should be within the first few messages in the logs):
start_master.go:272] Warning: assetConfig.metricsPublicURL: Invalid value: "": required to view cluster metrics in the console, master start will continue.
I cannot reproduce this locally, and as long at the metricsPublicURL is set you should be seeing the metrics tab in the console. If you still cannot get this to function, we should get this issue assigned to the console team.
@mwringe I'm launching the server in a Docker container, using the following command:
sudo docker run -d --name "origin" \
--privileged --pid=host --net=host \
-v /:/rootfs:ro -v /var/run:/var/run:rw -v /sys:/sys -v /var/lib/docker:/var/lib/docker:rw \
-v /var/lib/origin/openshift.local.volumes:/var/lib/origin/openshift.local.volumes \
openshift/origin start
My container logfile doesn't have any entry with the "start_master" or "metricsPublicURL" strings.
Do you know if is possible to have the metrics working for a openshift container or should I have to install by "Method 2: Downloading the Binary" from the instructions in https://docs.openshift.org/latest/getting_started/administrators.html?
@Shyckymn running it in an OpenShift container is fine, that should not cause any problems.
@spadgett Any idea why the metrics tab wouldn't be showing up when the metricsPublicURL is set in master-config.yaml?
@Shyckymn A few things to check:
- Is
metricsPublicURLinside theassetConfigstanza in master-config.yaml? It must be underassetConfig. (Also make sure you've restarted the server after editing master config.) - Do you see any certificate warnings when you open https://10.8.7.213:8443/hawkular/metrics in the browser? If so, you'd need to accept the certificate and reload the web console.
If neither of these is the problems, you should try opening dev tools in Chrome (or Firefox), refreshing the page, and looking at the network tab.
- If you type in "metrics" as a filter, do you see any requests? Are they failing?
- If you type in "config.js" as a filter and click on the request, do you see a
metricsURLset in the response tab?
https://developer.chrome.com/devtools
Even if the certificate is not accepted, the metric tab for pods should still show up though, right? Its always worked this way for me.