Replace gke_container with k8s_container for stackdriver#528
Replace gke_container with k8s_container for stackdriver#528c24t merged 13 commits intocensus-instrumentation:masterfrom
Conversation
| from opencensus.common.monitored_resource import k8s_utils | ||
|
|
||
|
|
||
| class TestK8SUtils(unittest.TestCase): |
There was a problem hiding this comment.
These were moved from test_gcp_metadata_config.py. Note that instance_id label doesn't appear anymore.
| _K8S_ATTRIBUTES = { | ||
| # ProjectID is the identifier of the GCP project associated with this | ||
| # resource, such as "my-project". | ||
| 'project_id': 'project/project-id', |
There was a problem hiding this comment.
project-id and location aren't part of the K8S resource. For K8S container resource we have:
- k8s.io/cluster/name
- k8s.io/namespace/name
- k8s.io/pod/name
- k8s.io/container/name
See the latest Java implementation: https://github.com/census-instrumentation/opencensus-java/blob/master/contrib/resource_util/src/main/java/io/opencensus/contrib/resource/util/K8sContainerResource.java.
I'll update the specs in a minute.
| 1. 'gke_container' | ||
| - https://cloud.google.com/monitoring/api/resources#tag_gke_container | ||
| 1. 'k8s_container' | ||
| - https://cloud.google.com/monitoring/api/resources#tag_k8s_container |
There was a problem hiding this comment.
Those URLs (including the ones below) shouldn't point to Stackdriver documentation, since this is our core library (not exporters). Please update this to point to the specs.
There was a problem hiding this comment.
I dropped the whole comment since we link to the resource spec from the Resource docstring.
songy23
left a comment
There was a problem hiding this comment.
LGTM except one minor nit.
| POD_NAME_KEY = 'k8s.io/pod/name' | ||
|
|
||
| # Container name | ||
| CONTAINER_NAME_KEY = 'k8s.io/container' |
There was a problem hiding this comment.
This should be 'k8s.io/container/name': https://github.com/census-instrumentation/opencensus-specs/pull/235/files#diff-b965ed607d4cefb5c41b99223e8e0ac0R16.
This PR replaces the
gke_containermonitored resource type with the newk8s_containerfor stackdriver following the migration guide.It also moves the detection utils for kubernetes out of
gcp_metadata_configand into a new module. It still depends on GCP metadata, so it won't work on non-GKE kubernetes environments, but this does match the behavior of the other clients.See census-instrumentation/opencensus-java#1467 for the same change in the java client.
This PR fixes #510 and unblocks #515.
@songy23 @mayurkale22 there's a good chance I'm still missing something here, please take a look.