I tried using the Stackdriver container in the container to collect statistics about Nginx / Uwsgi in the same container. I had some conclusions that may not be as useful. Just for reference.
To create a stackdriver image, you can reference the docker file created by Keto. https://hub.docker.com/r/keto/stackdriver/~/dockerfile/
FROM centos:centos7 MAINTAINER Mikael Keto # add stackdriver repository RUN curl -o /etc/yum.repos.d/stackdriver.repo https://repo.stackdriver.com/stackdriver-el7.repo # install stackdriver RUN yum -y install initscripts stackdriver-agent && yum clean all RUN mkdir -p /var/lock/subsys; exit 0 ADD run.sh /run.sh RUN chmod 755 /run.sh CMD ["/run.sh"]
Run.sh looks like below
#!/usr/bin/env bash /opt/stackdriver/stack-config --write-gcm --no-start /etc/init.d/stackdriver-agent start while true; do sleep 60 agent_pid=$(cat /var/run/stackdriver-agent.pid 2>/dev/null) ps -p $agent_pid > /dev/null 2>&1 if [ $? != 0 ]; then echo "Stackdriver agent pid not found!" break; fi done
In the GKE / K8S deployment yaml file,
apiVersion: extensions/v1beta1 kind: Deployment ... - name: stackdriver-agent image: gcr.io/<project_id>/stackdriver-agent:<your_version> command: ['/run.sh']
In my test, I found
- It will report statistics based on [hostname] instead of [content_name].
- It will collect a lot of system statistics that make sense for the node, but since it is in the container, this is completely pointless.
Well, I hope to find some way to collect both the statistics of the boxes and the nodes that I need, but I have not found an easy way to do this. I did this using the Google Python API library, but it takes too much time.
Walter liu
source share