The following sections explain how to manually install Stackdriver Kubernetes Monitoring in a new or existing existing cluster, and include some information about how Stackdriver Kubernetes Monitoring is implemented.
gcloud beta containerto create your cluster. Do not install Stackdriver support. Use Kubernetes 1.10.6 or 1.11.2 (or later, if available).
kubectlto configure Stackdriver Kubernetes Monitoring as shown below.
Create a cluster
Open a terminal window with the Cloud SDK and
kubectlinstalled. An easy way to do this is to use the Cloud Shell:
Go to the Kubernetes Clusters page for your project:
Click the Activate Cloud Shell icon at the top of the page.
Create your Kubernetes Engine cluster using the following
gcloudcommand. Do not install any logging or monitoring support:
gcloud beta container clusters create [CLUSTER_NAME] \ --zone=[ZONE] \ --project=[PROJECT_ID] \ --cluster-version=1.10 \ --no-enable-cloud-logging \ --no-enable-cloud-monitoring
For information on other flags and options you might want to use for your cluster, see Creating a Cluster.
Installing Kubernetes Monitoring
Connect to your cluster using the following command:
gcloud container clusters get-credentials [CLUSTER_ID] --zone [ZONE] --project [PROJECT_ID]
Configure Stackdriver Kubernetes Monitoring using the following commands:
kubectl apply -f https://raw.githubusercontent.com/Stackdriver/kubernetes-configs/stable/rbac-setup.yaml \ --as=admin --as-group=system:masters kubectl apply -f https://raw.githubusercontent.com/Stackdriver/kubernetes-configs/stable/agents.yaml
For more information about the configuration scripts above, see Configuration files on this page.
Validating your installation
To ensure that Stackdriver Kubernetes Monitoring is running correctly, wait a few minutes and then examine your cluster with the following command:
kubectl get pods --all-namespaces
You should see pods with the following names (among others):
stackdriver-logging-agent-...: the Stackdriver Logging agent.
heapster-...: the Monitoring agent.
stackdriver-metadata-agent-...: the Stackdriver metadata agent.
Removing manual installations
To uninstall a manual installation, run following command on your cluster:
kubectl delete namespace stackdriver-agents
This step is necessary before you go back to using the recommended managed support for Stackdriver Kubernetes Monitoring. For more information, see Upgrading an existing cluster.
To use Stackdriver Kubernetes Monitoring, see Observing Your System.
You can deploy your application software to your cluster as usual. For more information, see Overview of Deploying Workloads.
If you are familiar with the current Stackdriver support, then review the differences in Stackdriver Kubernetes Monitoring. For example, this release uses different monitored resource types for your Stackdriver logs, charts, metrics, and alerting policies.
The information in this section is optional.
Stackdriver Kubernetes Monitoring is implemented by three Stackdriver agents:
- The Stackdriver metadata agent (
stackdriver-metadata-agent-...) records the current set of nodes, containers, pods, etc.
- The Stackdriver Logging agent (
stackdriver-logging-agent-...) sends log entries to Stackdriver Logging.
- The Stackdriver Monitoring agent (
heapster...) sends metric data to Stackdriver Monitoring. This includes metrics from Prometheus.
The agents run in the one of two namespaces:
stackdriver-agents, when installed manually using the scripts on this page
kube-system, when installed by Kubernetes Engine console or when installed with
The following diagram shows how these agents are organized.
The configuration files used to install Stackdriver Kubernetes Monitoring are described below:
The agents are each given an RBAC ClusterRole that lets them list and watch all Kubernetes resources.
The Stackdriver metadata agent collects and transmits metadata for all resources inside of the Kubernetes cluster. The Stackdriver Logging agent collects and transmits log data from all Kubernetes resources. In Stackdriver Kubernetes Monitoring, the Stackdriver Monitoring agent is based on Heapster. It collects and transmits metric data from all Kubernetes resources.
Monitored resource types
Stackdriver labels each log entry and metric datum with a monitored resource that identifies the origin of the information. The resource types associated with Stackdriver Kubernetes Monitoring, for both monitoring and logging, are listed below:
- Kubernetes Container (
- Kubernetes Cluster (
- Kubernetes Node (
- Kubernetes Pod (
These types are not the same as those used by the former Stackdriver support. For a discussion of this incompatibility and how to migrate your existing cluster, see Migrating to Stackdriver Kubernetes Monitoring.