Kubernetes Engine is a cloud computing platform that helps you run your containers in production with high availability, automation, and ease of use. The platform is built on Google’s experience running containers at scale, and offers the security, reliability, and portability of the Google Cloud Platform. In this article we will look at some tools that help you monitor the performance of your Kubernetes cluster using the kubernetes engine monitoring features. By using these features you can monitor your cluster’s health and be notified when there are any issues with your application or system components, including nodes, pods and replication controllers.

What is Kubernetes Engine?

Kubernetes Engine is Google’s hosted platform for deploying containerized applications using Kubernetes. It gives you access to a managed cluster of virtual machines that are preconfigured with Kubernetes. When you’re ready, you can easily scale up your cluster by simply telling Google Compute Engine to add more virtual machines. And when your application needs more capacity, Compute Engine will automatically provision new VMs as needed. With just a few clicks in GCP Console, your app will have access to multiple VM instances running on-demand in parallel across multiple zones for high availability.

Installing GKE on Google Cloud Platform

Google Cloud Platform is a managed cloud computing platform that makes it easier to deploy applications without having to maintain servers. This allows developers to focus on building applications rather than infrastructure. The latest version of GCP is known as Google Kubernetes Engine, or GKE for short. It’s an extension of Google Compute Engine (GCE), which allows you to run virtual machines in Google’s data centers. One of its biggest advantages over other platforms is that containers are natively supported by GCP; if you want to use containers, then there’s no need to rent a separate server or additional software—you can just upload your container image and use it in GKE!

Accessing the terminal on GKE

To use all of GKE’s features, you’ll need to be able to access a Linux-like terminal (GCP calls them shells). You can access these either via SSH or a tool called Cloud Shell. Both methods offer different levels of integration with Google Cloud products. In order to create an instance group for your services, for example, you’ll need direct shell access on at least one node in that group. In our experience both methods work well but each has its own benefits. If you prefer to work directly from your computer—or if you want access from anywhere—then SSH is a good choice. If you find yourself frequently switching between multiple tasks on your laptop then Cloud Shell might make more sense for you. Note: These instructions show how to set up and run an nginx web server on Kubernetes Engine using our open source repository k8s-ingress-nginx . Instructions for running other applications will vary slightly depending on which service or application they are designed around but most follow a similar process.

Updating the current version of Kubernetes Engine

After we update an existing version of Kubernetes Engine, we’ll need to monitor it to make sure all clusters are in a healthy state. This will ensure that your apps keep running if new versions of Kubernetes Engine introduce incompatibilities with your cluster configuration files or custom kubectl scripts. You can also use dashboards to get a quick overview of resource usage across all active clusters in your project or take a deep dive into individual clusters by querying your GCP logs for important events such as pods failing to launch or nodes going down. With these tools at our disposal, we’ll be able to quickly fix problems with updated versions of Kubernetes Engine.

Enabling cluster autoscaler to scale out or in based on load

When writing a containerized application, particularly in a microservices style, adding new instances to your cluster is typically a manual process. With Autoscaler (as with Horizontal Pod Autoscaler ), you can set up an autoscaler that will automatically add or remove instances from your cluster as load increases or decreases in order to meet your desired target. You can set up multiple autoscalers; if two or more disagree on how many nodes should be running at any given time, they can cancel each other out and no action will be taken. If there are multiple desired states (for example, if you want 10 pods on average but 100 when some condition is met), consider using Deployment-Level Auto Scaling .

Monitoring CPU usage of each pod running in your cluster

Kubernetes will measure and report CPU usage of each pod running in your cluster. If you’re using Google Cloud Platform (GCP), then all you need to do is provide kubectl with a public SSH key to access your GCE instances, or disable authentication entirely for easy testing. With either method, once kubectl can run commands against GCE instances, you just have to run: gcloud compute instances list . Once that’s complete, kubectl will report CPU usage on all your running pods.

Monitoring Memory usage per node using kubectl top nodes

If you are on a large cluster with 30,000 pods, you can no longer use CPU/Mem to distinguish between busy pods/nodes. Ex. why does a memory hungry pod only show up on one node but not others? If you have high density of containers (30-40k pods), you’ll start to see more NodeInUse errors; This will be due to high density causing resource contention which results in unavailability of nodes. It is useful to look at memory metrics from your Kubernetes Nodes & Pods so that you can understand problems like these better.

Checking Dashboard status & downloading logs using kubectl logs command.

Running a service on any Kubernetes Engine cluster is only part of your total responsibility. Monitoring its status, logging, managing versions and upgrades are also key components in delivering high quality services. Let’s review some examples. For many of you, getting logs out of Kubernetes may be a common task. But what about getting logs from an individual container in your pod? Or pulling logs for a container that’s no longer running? Let’s take a look at some examples using kubectl . The primary method for retrieving log data from a Kubernetes Engine cluster is through kubectl get … . We can then use other commands to filter down to containers we want to inspect further.

Replication controllers, pods & services

In order to monitor your clusters resources, you’ll need a way to collect metrics from all of your objects. Luckily for us, Kubernetes has multiple ways to do just that. For replication controllers, pods and services you can use kubectl get commands with labels specified using -o wide output flag (see more here). This will list an object with its CPU/memory usage as well as other important information like its current state (running or pending) etc… Remember that when specifying kubectl commands make sure to add -n kube-system so that you are only querying objects in Kubernetes cluster namespace instead of localhost if you plan on using these scripts yourself.

Managing Jobs across clusters, namespaces & projects using Cron jobs

Kubernetes’ CronJob controller has been around for a while now, but chances are good that you haven’t taken full advantage of it. Don’t worry if that sounds familiar; we still have some tips to help you get your cron jobs running smoothly in Kubernetes. First, let’s refresh on what CronJobs are for. Imagine you have a set of containerized tasks that need to be run periodically or at certain times.

Monitoring K8s services like Deployment, Statefulset & Job using InfluxDB, Grafana dashboards. Also displaying graphs via Kibana dashboard.

Google Cloud platform has different offerings for container management. One of them is Kubernetes Engine that allows you to easily deploy, manage, monitor and troubleshoot your k8s cluster. In my experience you can’t just rely on logs or simple stats about CPU usage etc. You need more advanced tooling for an efficient DevOps-like workflow. Monitoring K8s services like Deployment, Statefulset & Job using InfluxDB, Grafana dashboards. Also displaying graphs via Kibana dashboard.: Google Cloud platform has different offerings for container management. One of them is Kubernetes Engine that allows you to easily deploy, manage, monitor and troubleshoot your k8s cluster.


We’d love to keep you updated with our latest blog and webinars 😎

Categories: CloudGCP


Leave a Reply

Avatar placeholder