Skip to content

Conversation

hitomitak
Copy link
Contributor

This PR adds a function to get ip address in K8S environment for metrics crawler.
The detail information about metrics crawler is described at issue #196

IP address is not assigned to each docker and it is not included in docker inspect information (c.get_container_ip()) in k8s. So we pass IP address to the crawler by env variable (KUBE_POD_INFO) .

Signed-off-by: Hitomi Takahashi [email protected]

@codecov-io
Copy link

codecov-io commented Sep 15, 2017

Codecov Report

Merging #335 into master will increase coverage by 0.21%.
The diff coverage is 98.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #335      +/-   ##
==========================================
+ Coverage   88.48%   88.69%   +0.21%     
==========================================
  Files         117      117              
  Lines        4742     4867     +125     
==========================================
+ Hits         4196     4317     +121     
- Misses        546      550       +4
Impacted Files Coverage Δ
...ns/applications/apache/apache_container_crawler.py 100% <100%> (ø) ⬆️
...ns/applications/tomcat/tomcat_container_crawler.py 100% <100%> (ø) ⬆️
...gins/applications/nginx/nginx_container_crawler.py 100% <100%> (ø) ⬆️
.../plugins/applications/db2/db2_container_crawler.py 100% <100%> (ø) ⬆️
.../applications/liberty/liberty_container_crawler.py 100% <100%> (ø) ⬆️
...gins/applications/redis/redis_container_crawler.py 92.72% <89.74%> (-7.28%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ccb5e14...44d752a. Read the comment docs.

@sahilsuneja1
Copy link
Contributor

sahilsuneja1 commented Sep 15, 2017

@tatsuhirochiba: Looks good. Can you please clarify the following:

  1. 'IP address is not assigned to each docker container'- Why does this happen?
  2. Is KUBE_POD_INFO a standard env var?
  3. Would the alternative of getting ip addresses from inside the container work (as in os_container_crawler)?

@tatsuhirochiba
Copy link
Contributor

For 1: At first, ip address is hidden from app container's docker inspect and some meaningful information are shown in pause container's docker inspect, so I was thinking about the following approaches.

a) preparing pod crawling mode (issued at #246)
b) preparing k8s client inside crawler
c) passing endpoint info via env and handling it within each container crawler plugin

option c) can minimize code change than option a) and b).

For 2: KUBE_POD_INFO is not standard env var. It is just defined for app metrics crawler plugins.

For 3: Thanks for nice info, I did not check some useful util code (os_utils.py and namespace.py). We can retrieve ip address with similar approach. I just confirmed that I can get ip with nsenter command in terminal.

We just try to use these utility code inside app metrics crawling plugin.

@sahilsuneja1
Copy link
Contributor

Thanks for the clarifications @tatsuhirochiba!
Should we merge the current KUBE_POD_INFO version, or will you be creating an nsenter version? Your choice, really. We can even revisit Options 'a' and 'b' if you like.

@tatsuhirochiba
Copy link
Contributor

@hitomitak will make nsenter version and then revise this PR, so we do not need to merge current KUBE_POD_INFO version, thanks!

@sahilsuneja1
Copy link
Contributor

I'm sorry @hitomitak and @tatsuhirochiba. I just realized I did not tag the right person in my original comment and ended up following up with the wrong committer! :)

@hitomitak hitomitak force-pushed the metrics_k8s branch 2 times, most recently from b30859c to 0959ee5 Compare September 29, 2017 13:56
Signed-off-by: hitomitak <[email protected]>
@hitomitak
Copy link
Contributor Author

Thank you for the nice advice @sahilsuneja1
I modified the code to use run_as_another_namespace function.

@sahilsuneja1
Copy link
Contributor

Thanks @hitomitak !

@sahilsuneja1 sahilsuneja1 merged commit 6d5991e into cloudviz:master Oct 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants