Is it possible to set up Stackdriver Monitoring for Kubernetes on Google Compute Engine? - kubernetes

I'm running Kubernetes myself on Google Compute Engine (not Google Container Engine). Google Container Engine has built-in integration with Stackdriver Monitoring and I'm wondering if it's possible to set this up for a Kubernetes cluster on Google Compute Engine.
Specifically, I'd like to see more than just cpu, disk, etc. I want to see Kubernetes data like pod scheduling failures, pod counts, etc.

It is not possible to configure Stackdriver exactly the same way that it is done in GKE.
However, you can set ENABLE_CLUSTER_MONITORING to google in config-default.sh to enable Heapster and Google Cloud Monitoring.

Related

Google Cloud Kubernetes external autoscale

I need to create a custom autoscaler in Google Cloud Kubernetes Engine.
I develope a software that write time series data to a custom metric in Google Cloud Monitoring and I want that Kubernetes autoscaler uses this data to manage the number of replicas.
I read a lot of documentation but I have a lot of doubts:
Is mandatory to deploy the custom metrics stackdriver adapter? If yes, why?
Which is the difference between "target total value" and "target average value" and how they work?
I saw that is possible to create more than one metric, how autoscaler works with 2 or more metrics?

GKE is built by default in Anthos solution ? Getting Anthos Metrics

I have a cluster with 7 nodes and a lot of services, nodes, etc in the Google Cloud Platform. I'm trying to get some metrics with StackDriver Legacy, so in the Google Cloud Console -> StackDriver -> Metrics Explorer I have all the set of anthos metrics listed but when I try to create a chart based on that metrics it doesn't show the data, actually the only response that I get in the panel is no data is available for the selected time frame even changing the time frame and stuffs.
Is right to think that with anthos metrics I can retrieve information about my cronjobs, pods, services like failed initializations, jobs failures ? And if so, I can do it with StackDriver Legacy or I need to Update to StackDriver kubernetes Engine Monitoring ?
Anthos solution, includes what’s called GKE-on prem. I’d take a look at the instructions to use logging and monitoring on GKE-on prem. Stackdriver monitors GKE On-Prem clusters in a similar way as cloud-based GKE clusters.
However, there’s a note where they say that currently, Stackdriver only collects cluster logs and system component metrics. The full Kubernetes Monitoring experience will be available in a future release.
You can also check that you’ve met all the configuration requirements.

Deploy service dynamically according to load with Googl Kubernetes Engine

I'm currently working on an application deployed with Google Kubernetes Engine. I want to be able to change the behavior of a service if the load on my application reaches a certain point. The idea is to deploy a similar service which consumes less ressources so that my application can still work with a bigger load.
Is it possible with Google Kubernetes Engine ?
Yes it can be done with HPA and custom metrics in prometheus. We are using this setup to autoscale our deployments based on requests per minute.
Prometheus scrapes this metric from the application and prometheus adapter makes them available to kubernetes.
https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
https://github.com/DirectXMan12/k8s-prometheus-adapter

Is there a clean way to connect kubernetes with cloud autoscaling?

I would like to use kubernetes on any IaaS cloud (e.g. OpenStack, AWS, etc.) and have it scale up the pool of worker instances when it can no longer bin-pack new workload.
I hope there is a IaaS-independent integration/API to allow this. If not, an integration with a specific cloud is good too.
Kubernetes cluster autoscaler is what you are looking for. It works with multiple cloud providers including AWS

How to go about logging in GKE without using Stackdriver

We are unable to grab logs from our GKE cluster running containers if StackDriver is disabled on GCP. I understand that it is proxying stderr/stdout but it seems rather heavy handed to block these outputs when Stackdriver is disabled.
How does one get an ELF stack going on GKE without being billed for StackDriver aka disabling it entirely? or is it so much a part of GKE that this is not doable?
From the article linked on a similar question regarding GCP:
"Kubernetes doesn’t specify a logging agent, but two optional logging agents are packaged with the Kubernetes release: Stackdriver Logging for use with Google Cloud Platform, and Elasticsearch. You can find more information and instructions in the dedicated documents. Both use fluentd with custom configuration as an agent on the node." (https://kubernetes.io/docs/concepts/cluster-administration/logging/#exposing-logs-directly-from-the-application)
Perhaps our understanding of Stackdriver billing is wrong?
But we don't want to be billed for Stackdriver as the 150MB of logs outside of the GCP metrics is not going to be enough and we have some expertise in setting up ELF for logging that we'd like to use.
You can disable Stackdriver logging/monitoring on Kubernetes by editing your cluster, and setting "Stackdriver Logging" and "Stackdriver Monitoring" to disable.
I would still suggest sticking to GCP over AWS as you get the whole Kube as a service experience. Amazon's solution is still a little way off, and they are planning charging for the service in addition to the EC2 node prices (Last I heard).