Skip to content

add documentation for multi-project metrics#213

Open
astropuffin wants to merge 1 commit intoGoogleCloudPlatform:masterfrom
dronedeploy:stackdriver-adapter-multi-project-documentation
Open

add documentation for multi-project metrics#213
astropuffin wants to merge 1 commit intoGoogleCloudPlatform:masterfrom
dronedeploy:stackdriver-adapter-multi-project-documentation

Conversation

@astropuffin
Copy link
Contributor

documentation for #212

which addresses #205

@astropuffin astropuffin changed the title add documentation add documentation for multi-project metrics Oct 8, 2018
@kawych kawych self-assigned this Oct 12, 2018
@kawych kawych self-requested a review October 12, 2018 09:30
@loburm
Copy link
Member

loburm commented Dec 6, 2018

@kawych do you have any comments?

1. Grant the default service account for your project access to `roles/monitoring.viewer` in
your other project.

1. Create your GKE cluster with a service account, and grant the service account access to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Create your GKE cluster with a service account, and grant the service account access to
1. Create your GKE cluster with a custom service account, and grant the service account access to

`roles/monitoring.viewer` in your other project

1. (Recommended) Create a service a service account for the stackdriver-adapter, and mount
the credentials into the pod. This is the method this example implements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the credentials into the pod. This is the method this example implements.
the credentials into the pod. This is the method explained in this example.

## Create a service account with credentials

For this example, you will need to create a service account. See [Creating a service account](https://cloud.google.com/iam/docs/creating-managing-service-accounts)
for how to do that.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for how to do that.
for instructions.

for how to do that.


Next, you will need to create a key for that services account. See [Creating service account keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-console) for how to do that.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Next, you will need to create a key for that services account. See [Creating service account keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-console) for how to do that.
Next, you will need to create a key for that services account. See [Creating service account keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-console) for instructions.

Next, you will need to create a key for that services account. See [Creating service account keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-console) for how to do that.


Copy the key to this directory. The filename should be `key.json`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Copy the key to this directory. The filename should be `key.json`
Copy the key to your current directory. The filename should be `key.json`

Copy the key to this directory. The filename should be `key.json`


Add `roles/monitoring.viewer` to your service account in all projects that you want it to grab metrics from.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run the following command:

```
kubectl apply -f modified-adapter.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a link using raw github content instead of assuming that user has cloned this repo? Something like: https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/examples/cross-project-metrics/adapter.yaml

There are several places where cross project autoscaling can get stuck, so when troubleshooting
make sure to check them one by one.

1. Check that your service account has the right permissions. It needs `roles/monitoring.viewer`
Copy link
Member

@kawych kawych Dec 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Check that your service account has the right permissions. It needs `roles/monitoring.viewer`
1. Check that your service account has the right permissions on the IAM page of **your other project**. It needs `roles/monitoring.viewer`

curl http://localhost:8001/apis/custom.metrics.k8s.io/v1beta1/namespaces/<namespace-name>/pods/*/<metric-name>
```

This should return a MetricValueList object. If you get a 404, the metric timeseries is not available from
Copy link
Member

@kawych kawych Dec 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two different cases here:

  1. You get 404 - this usually means that the metric descriptor for <metric-name> doesn't exist for specified project (e.g. or project is incorrect).
  2. You get [] (empty list) - this means that the metric is correct, but no timeseries were found. This may also be caused by several things, for example:
  • <namespace-name> is incorrect
  • <metric-name> wasn't exporter recently, e.g. deployment-to-be-scaled.yml was not deployed

Also, note that this url will look for metric for your current project. To check for metrics from different project, add suffix "?labelSelector=resource.labels.project_id=<my-other-project>"

```
And check the available metrics
```
curl http://localhost:8001/apis/custom.metrics.k8s.io/v1beta1/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this won't work. This returns metrics from your current project, while the requested metric can be specified only for the other project. It may still make sense to check that for predefined metrics (non-custom metrics) that should exist for all projects, such as pubsub metrics used here.

@@ -0,0 +1,51 @@
apiVersion: extensions/v1beta1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to include a comment at the top to explain that it is modified by mounting service account credentials.

Copy link
Member

@kawych kawych left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Added few commits, after these changes I think we're good to go

@kawych
Copy link
Member

kawych commented Dec 28, 2018

Sorry for delay with this review. FYI, I'm starting the release of this feature.

@sjoeboo
Copy link

sjoeboo commented Feb 15, 2019

Any updates on releasing this feature?

@kawych
Copy link
Member

kawych commented Feb 20, 2019

I've started the release, but it got stuck in review, sorry for delay.

@juli4n juli4n added the custom-metrics-stackdriver-adapter Issues for custom-metrics-stackdriver-adapter label Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes custom-metrics-stackdriver-adapter Issues for custom-metrics-stackdriver-adapter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants