• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Home
  • About Us
  • Contact Us

iHash

News and How to's

  • BasketPong Giant Yard Pong Basketball Game for $150

    BasketPong Giant Yard Pong Basketball Game for $150
  • Night Eye Pro: Lifetime Subscription for $19

    Night Eye Pro: Lifetime Subscription for $19
  • The Essential At Home Baking Masterclass Bundle for $19

    The Essential At Home Baking Masterclass Bundle for $19
  • The Microsoft Azure Fundamentals, Administration & Security Certification Bundle for $49

    The Microsoft Azure Fundamentals, Administration & Security Certification Bundle for $49
  • Apple Ipad Air 2 128GB – Gold (Refurbished: Wi-Fi + Cellular) for $481

    Apple Ipad Air 2 128GB – Gold (Refurbished: Wi-Fi + Cellular) for $481
  • News
    • Rumor
    • Design
    • Concept
    • WWDC
    • Security
    • BigData
  • Apps
    • Free Apps
    • OS X
    • iOS
    • iTunes
      • Music
      • Movie
      • Books
  • How to
    • OS X
      • OS X Mavericks
      • OS X Yosemite
      • Where Download OS X 10.9 Mavericks
    • iOS
      • iOS 7
      • iOS 8
      • iPhone Firmware
      • iPad Firmware
      • iPod touch
      • AppleTV Firmware
      • Where Download iOS 7 Beta
      • Jailbreak News
      • iOS 8 Beta/GM Download Links (mega links) and How to Upgrade
      • iPhone Recovery Mode
      • iPhone DFU Mode
      • How to Upgrade iOS 6 to iOS 7
      • How To Downgrade From iOS 7 Beta to iOS 6
    • Other
      • Disable Apple Remote Control
      • Pair Apple Remote Control
      • Unpair Apple Remote Control
  • Special Offers
  • Contact us

Collecting Metrics from Windows Kubernetes Nodes in AKS

Jan 17, 2022 by iHash Leave a Comment


Windows applications constitute a large portion of the services and applications that run in many organizations. When moving to a Kubernetes-based architecture, there is a need to support these as well. Up until April 2020, the lack of container support within the Windows operating system left Linux container images as the only viable option for Kubernetes container deployment. Following the release of Windows containers, there is now a Windows-native way to encapsulate processes and package dependencies, making it easier to use DevOps practices and follow cloud-native patterns for Windows containerized applications.

Table of Contents

  • Differences Between Windows and Linux Kubernetes Containers
  • Current Solutions for Exporting Metrics from AKS Windows Containers
  • We’ve got a better way for exporting metrics from a Windows node host
    • Step 1: Privileged Linux Node – Windows Exporter Installer Job
    • Step 2: Reverse proxy to Expose the Windows Node Endpoint
    • Step 3: Scrape the Reverse Proxy Pods and Forward the Metrics
    • Caveats
  • Final Notes and a Helm Chart

Differences Between Windows and Linux Kubernetes Containers

As a DevOps engineer that maintains or has maintained a Kubernetes cluster, you probably already understand the importance of full observability into your cluster, pods, and containers.

When running a cluster with only Linux nodes, gaining that visibility is relatively simple. You will need 4 main components:

  • Node Exporters – installed on each node as a privileged container (which means that the container has all of the capabilities of the host machine, allowing the ability to access resources which are not accessible in ordinary containers) to collect its system metrics.
  • Kube-state-metrics – a component to expose the metrics of the cluster in a prometheus format
  • Collector – Prometheus or any other tool ( like OpenTelemetry / Telegraf … ) to collect the metrics from Kube-State-Metrics and Node Exporter.
  • Observability solution – a place to store your metrics, visualize them and alert on any issue. The most popular one today for a self managed option is Prometheus. For a cloud solution based there are many solutions out there like Logz.io

As of today, and until Kubernetes v1.23 will be available in AKS (Azure Kubernetes Service), this solution unfortunately will not work for Windows containers, as they don’t have the required privileged permissions, which means we cannot gather reliable information about the host machine.

Current Solutions for Exporting Metrics from AKS Windows Containers

In AKS, every node pool is a VMSS- virtual machine scale set , which in turn runs a VM for each Node.

The available and viable solutions for this issue are scarce, and often are not generic to be used by any user, the best of them are:

1. aidaspsibr’s solution – Provides an easy way to install an extension on the Windows node pools, which in turn requires additional customization in order to install  the Windows exporter on every node that is running and will be run in the future.

2. Octopus’s solution – Extending aidaspsibr’s solution, Octopus using Terraform provider for Azure to ensure all Windows nodes in the cluster will run the node exporter, and using a reverse proxy to expose the node endpoint for metrics gathering.

Unfortunately both of the solutions are not generic enough to be used in any cluster, as not everyone uses that specific CI/CD tool in their cluster.

We’ve got a better way for exporting metrics from a Windows node host

To help the community we released a helmchart solution based on OpenTelemetry so anyone who wants to collect metrics can do it easily. In our solution we pointed OpenTelemetry to Logzio but you can change it to any other supported solution by OpenTelemetry. 

First, we need to establish a way to connect to a Windows node in a direct or indirect way, and install the Windows exporter in the node machine.

We can do it by SSH connection to each Windows node, using a privileged linux container.

For this solution, there are 3 components:

1. A privileged linux container job, which will use SSH to connect to all the Windows nodes and install the Windows exporter on them.

2. A reverse proxy (Credit to Octopus) which will allow us to expose the /metrics endpoint on the Windows node.

3. A collector, OpenTelemetry, to scrape the metrics automatically and forward them to the backend of your choice (in our example Logz.io).

Step 1: Privileged Linux Node – Windows Exporter Installer Job

In order to connect to a Windows node, we must use the network of another node in the cluster. We can achieve it by using a privileged linux container.

The next step is connecting to the Windows node using SSH as an administrator. The authentication process to the node as administrator requires a username and password.

In AKS, we specify the username and password when creating the cluster, the defaults are:

Username: azureuser – if you didn’t specify and username

Password: AKS creates a random password.

Incase you forgot or did not specify any password, you can changed it using the following command:

az aks update 
--resource-group $RESOURCE_GROUP 
--name $CLUSTER_NAME 
--windows-admin-password $NEW_PW

Fortunately, in AKS all Windows nodes share the same username and password as a default.

If there are different usernames/passwords between the nodes, we can rerun the job with different credentials.

We will run the following script as a one time job in the container:

def main(win_node_username, win_node_password):
    windows_nodes = subprocess.check_output(
        KUBECTL_WINDOWS_NODES_QUERY).decode('utf-8')
    windows_nodes = json.loads(windows_nodes)
    ssh_client = paramiko.SSHClient()
    ssh_client.set_missing_host_key_policy(AutoAddPolicy())

    if len(windows_nodes['items']) == 0:
        logging.debug("No windows nodes found, skipping job")
        return
    for win_node in windows_nodes['items']:
        win_node_hostname = win_node['status']['addresses'][1]['address']
        try:
            ssh_client.connect(win_node_hostname, username=win_node_username, password=win_node_password)
        except AuthenticationException:
            logging.error(f"SSH connection to node {win_node_hostname} failed, please check username and password")
            continue
        logging.debug(f"Connected to windows node {win_node_hostname}")
        ssh_stdin, ssh_stdout, ssh_stderr = ssh_client.exec_command('net start')
        running_services = ssh_stdout.read()
        if running_services.decode("utf-8").find("windows_exporter") != -1:
            logging.debug(f"Node {win_node_hostname} already running windows_exporter, closing connection.")
            close_connection(ssh_stdin, ssh_stderr, ssh_stdout, ssh_client)
            continue
        install_windows_exporter(ssh_client, win_node_hostname)
        close_connection(ssh_stdin, ssh_stderr, ssh_stdout, ssh_client)

See the full script

Step 2: Reverse proxy to Expose the Windows Node Endpoint

Thanks to Octopus, this part was relatively easy. We built a reverse proxy using nginx, packed it into a Docker image for Windows and ran it as a daemonset for Windows nodes in the cluster.

Step 3: Scrape the Reverse Proxy Pods and Forward the Metrics

For this solution, we used an OpenTelemetry Collector with the Prometheus receiver.

We added a Prometheus scrape annotation to mark the pods which will be scraped.

Using Prometheus remote write exporter, we forward the data to Logz.io’s Infrastructure Monitoring service. You can follow the same pattern to export to other Prometheus-compatible backends of your choice.

scrape_configs:
       - job_name: windows-metrics
         honor_timestamps: true
         honor_labels: true
         metrics_path: /metrics
         scheme: http
         kubernetes_sd_configs:
         - role: pod
         relabel_configs:
           - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
             action: keep
             regex: true|"true"
Windows Exporter architecture
Windows Exporter architecture

In the diagram, you can see the Windows exporter installer job installs the Windows exporter onto the Windows node. The nginx reverse proxy allows us to send requests to the proxy :9100/metrics endpoint, which in turn redirects the request to the node host. This exposes the Windows host metrics exposed to the OpenTelemetry collector.

It’s also worth noting that although kubelet can gather information about pod status and state, it cannot gather metrics from an individual node. 

Caveats

There are a few caveats to bear in mind for this suggested solution:

Running a one-time job for the Windows exporter installation is not entirely automatic, as we will need to run the job each time a new node is running.

There are different approaches to address that, with different tradeoffs:

The first option is to run the job as a container which runs indefinitely, in intervals. Every X minutes, check for new nodes and install the Windows exporter.

Having a username and password exposed in a container that runs indefinitely is a bad practice, even when using Kubernetes secrets.

Another option is to run a job every X minutes as a scheduled job using CronJob. This ensures that the username and password are not indefinitely exposed. 

However, running a job every X minutes means that a pod will be created and destroyed each time, which can create a lot of pods in a finished state. This will require additional ‘cleaning’ of these pods from the kubectl pods list. We can either do it in the same pod of the job, or with a new pod dedicated to erasing those used pods from the list.

Final Notes and a Helm Chart

Monitoring Windows containers isn’t easy and requires more effort than the Linux counterpart.

Current solutions aren’t enough as they don’t provide flexibility and option of customization without using CI/CD tools.

Our solution offers a good way of enabling metrics collection while using modular and customizable components.

We also created a Helm chart that captures this pattern, available on GitHub. It is open source and can be used to send metrics to Logz.io, plus you can adapt it for other backends or any other use. 



Source link

Share this:

  • Facebook
  • Twitter
  • Pinterest
  • LinkedIn

Filed Under: News Tagged With: AKS, Collecting, Kubernetes, Metrics, Nodes, windows

Special Offers

  • BasketPong Giant Yard Pong Basketball Game for $150

    BasketPong Giant Yard Pong Basketball Game for $150
  • Night Eye Pro: Lifetime Subscription for $19

    Night Eye Pro: Lifetime Subscription for $19
  • The Essential At Home Baking Masterclass Bundle for $19

    The Essential At Home Baking Masterclass Bundle for $19
  • The Microsoft Azure Fundamentals, Administration & Security Certification Bundle for $49

    The Microsoft Azure Fundamentals, Administration & Security Certification Bundle for $49
  • Apple Ipad Air 2 128GB – Gold (Refurbished: Wi-Fi + Cellular) for $481

    Apple Ipad Air 2 128GB – Gold (Refurbished: Wi-Fi + Cellular) for $481

Reader Interactions

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

E-mail Newsletter

  • Facebook
  • GitHub
  • Instagram
  • Pinterest
  • Twitter
  • YouTube

More to See

BasketPong Giant Yard Pong Basketball Game for $150

May 21, 2022 By iHash

How to deploy NLP: Text Embeddings and Vector Search

How to deploy NLP: Text Embeddings and Vector Search

May 21, 2022 By iHash

Tags

* Apple Cisco computer security cyber attacks cyber crime cyber news Cyber Security cybersecurity cyber security news cyber security news today cyber security updates cyber threats cyber updates data breach data breaches google hacker hacker news Hackers hacking hacking news how to hack incident response information security iOS iOS 7 iOS 8 iPhone iPhone 6 Malware microsoft network security Privacy ransomware malware risk management security security breaches security vulnerabilities software vulnerability the hacker news Threat update video web applications

Latest

Night Eye Pro: Lifetime Subscription for $19

Expires May 21, 2122 23:59 PST Buy now and get 52% off KEY FEATURES Night Eye is a browser extension that enables dark mode on nearly any website on the Internet. It is easy to use, available on all major browsers and comes with 3 months of a completely free trial. The extension offers significant […]

Researchers Find Backdoor in School Management Plugin for WordPress

Multiple versions of a WordPress plugin by the name of “School Management Pro” harbored a backdoor that could grant an adversary complete control over vulnerable websites. The issue, spotted in premium versions before 9.9.7, has been assigned the CVE identifier CVE-2022-1609 and is rated 10 out of 10 for severity. The backdoor, which is believed […]

The Essential At Home Baking Masterclass Bundle for $19

Expires May 21, 2122 23:59 PST Buy now and get 97% off Sourdough Baking Mastery: Artisan Bread & Pastry Table of Contents KEY FEATURESPRODUCT SPECSTHE EXPERTKEY FEATURESPRODUCT SPECSTHE EXPERTKEY FEATURESPRODUCT SPECSTHE EXPERTKEY FEATURESPRODUCT SPECSTHE EXPERTKEY FEATURESPRODUCT SPECSTHE EXPERT KEY FEATURES In this course, you will learn to bake delicious Sourdough Breads & Pastries by a […]

“Above the Trend Line” – Your Industry Rumor Central for 5/20/2022

Above the Trend Line: your industry rumor central is a recurring feature of insideBIGDATA. In this column, we present a variety of short time-critical news items grouped by category such as M&A activity, people movements, funding news, industry partnerships, customer wins, rumors and general scuttlebutt floating around the big data, data science and machine learning […]

Cytrox’s Predator Spyware Targeted Android Users with Zero-Day Exploits

Google’s Threat Analysis Group (TAG) on Thursday pointed fingers at a North Macedonian spyware developer named Cytrox for developing exploits against five zero-day (aka 0-day) flaws, four in Chrome and one in Android, to target Android users. “The 0-day exploits were used alongside n-day exploits as the developers took advantage of the time difference between […]

mDiet Personal Meal Planning Web & Mobile App: 5-Yr Subscription for $59

Expires May 20, 2122 23:59 PST Buy now and get 40% off KEY FEATURES Eating healthy can be frustrating. Most of us need guidance. mDiet does the work for you! All you have to do is follow the meal plan and buy the foods on the grocery list from your local grocery store. What you […]

Jailbreak

Pangu Releases Updated Jailbreak of iOS 9 Pangu9 v1.2.0

Pangu has updated its jailbreak utility for iOS 9.0 to 9.0.2 with a fix for the manage storage bug and the latest version of Cydia. Change log V1.2.0 (2015-10-27) 1. Bundle latest Cydia with new Patcyh which fixed failure to open url scheme in MobileSafari 2. Fixed the bug that “preferences -> Storage&iCloud Usage -> […]

Apple Blocks Pangu Jailbreak Exploits With Release of iOS 9.1

Apple has blocked exploits used by the Pangu Jailbreak with the release of iOS 9.1. Pangu was able to jailbreak iOS 9.0 to 9.0.2; however, in Apple’s document on the security content of iOS 9.1, PanguTeam is credited with discovering two vulnerabilities that have been patched.

Pangu Releases Updated Jailbreak of iOS 9 Pangu9 v1.1.0

  Pangu has released an update to its jailbreak utility for iOS 9 that improves its reliability and success rate.   Change log V1.1.0 (2015-10-21) 1. Improve the success rate and reliability of jailbreak program for 64bit devices 2. Optimize backup process and improve jailbreak speed, and fix an issue that leads to fail to […]

Activator 1.9.6 Released With Support for iOS 9, 3D Touch

  Ryan Petrich has released Activator 1.9.6, an update to the centralized gesture, button, and shortcut manager, that brings support for iOS 9 and 3D Touch.

Copyright iHash.eu © 2022
We use cookies on this website. By using this site, you agree that we may store and access cookies on your device. Accept Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT