Monitor cloud costs and create budgets at scale

Monitoring and controlling costs effectively is important, especially as you scale your business in the cloud. As the number of teams, applications, and environments running in your cloud deployment expands, it becomes crucial that you provide granular transparency, accountability, and controls to various parts of your organization that incur cloud costs. When you’re using Google Cloud, our budgets and alerts features are a powerful part of your cost monitoring toolkit, letting you set your target spending and notify key stakeholders if you’re getting off track. We’re dedicated to making it even easier for you to monitor and control your costs at scale so that you can achieve greater predictability, and we’ve recently released several enhancements that help you do just that.With the beta release of the Budget API, you can view, create, and manage budgets programmatically at scale. This is especially important if you’re creating a large number of budgets across your organization. For example, you can integrate the Budget API into your deployment manager, like Terraform, to programmatically create a budget for each new project as it’s created in your organization.We have also added more granular budget filters to make it easier for you to monitor specific slices of your costs across groups of projects and services. For example, an analytics manager can now create a budget to monitor BigQuery spending for the three projects her team uses for business intelligence and building predictive models, as shown here:Once you’ve created a budget, you can also set up cost forecast alerts to proactively receive notifications when you’re projected to exceed your budget for the month and may need to take action. For example, if you set a cost forecast alert threshold to 120% of your monthly budget, then you will receive notifications when you are expected to exceed your budget by more than 20%, like this:How customers are monitoring costs at scale Customers are already seeing the benefits of these new features, like global water, waste, and energy company Veolia. “At Veolia, we automatically create budgets for new projects using the Google Cloud Budget API as a step in our cloud provisioning workflow in ServiceNow.” says Antoine Castex, product manager at Veolia. “By creating a budget for each project, we are able to closely monitor our costs and take action when needed to prevent budget overruns. This empowers application developers at Veolia focus on what they do best—build amazing products that help make the world more sustainable.” Get started with new cost management featuresWith the new Budget API, granular budget filters, and cost forecast alerts, you can proactively monitor costs across your cloud environment, however you organize your business. Get started by visiting the Budgets and Alerts page in the Cloud Console or by trying out the new Budget API. See the Budget API user guide for more details.To learn more about budget alerts and Google Cloud cost management tools, check out the following resources:Documentation: Budget APIDocumentation: Set budget alertsHands-on training: Understanding your GCP costsHands-on training: Optimizing your GCP costs What’s new: Billing release notes
Quelle: Google Cloud Platform

Azure Container Registry: preview of repository-scoped permissions

The Azure Container Registry (ACR) team is rolling out the preview of repository scoped role-based access control (RBAC) permissions, our top-voted item on UserVoice. In this release, we have a command-line interface (CLI) experience for you to try and provide feedback.

ACR already supports several authentication options using identities that have role-based access to an entire registry. However, for multi-team scenarios, you might want to consolidate multiple teams into a single registry, limiting each team’s access to their specific repositories. Repository scoped RBAC now enables this functionality.

Here are some of the scenarios where repository scoped permissions might come in handy:

Limit repository access to specific user groups within your organization. For example, provide write access to developers who build images that target specific repositories, and read access to teams that deploy from those repositories.

Provide millions of IoT devices with individual access to pull images from specific repositories.

Provide an external organization with permissions to specific repositories.

In this release, we have introduced tokens as a mechanism to implement repository scoped RBAC permissions. A token is a credential used to authenticate with the registry. It can be backed by username and password or Azure Active Directory(AAD) objects like Azure Active Directory users, service principals, and managed identities. For this release, we have provided tokens backed by username and password. Future releases will support tokens backed by Azure Active Directory objects like Azure Active Directory users, service principals, and managed identities. See Figure 1.

*Support for Azure Active Directory (AAD) backed token will be available in a future release.

Figure 1

Figure 2 below describes the relationship between tokens and scope-maps.

A token is a credential used to authenticate with the registry. It has a permitted set of actions which are scoped to one or more repositories. Once you have generated a token, you can use it to authenticate with your registry. You can do a docker login using the following command:

docker login –username mytoken –password-stdin myregistry.azurecr.io.

A scope map is a registry object that groups repository permissions you apply to a token. It provides a graph of access to one or more repositories. You can apply scoped repository permissions to a token or reapply them to other tokens. If you don't apply a scope map when creating a token, a scope map is automatically created for you, to save the permission settings.

A scope map helps you configure multiple users with identical access to a set of repositories.

Figure 2

As customers use containers and other artifacts for their IoT deployment, the number of devices can grow into the millions. In order to support the scale of IoT, Azure Container Registry has implemented repository based RBAC, using tokens (figure 3). Tokens are not a replacement for service principals or managed identities. You can add tokens as an additional option providing scalability of IoT deployment scenarios.

This article shows how to create a token with permissions restricted to a specific repository within a registry. With the introduction of token-based repository permissions, you can now provide users or services with scoped and time-limited access to repositories without requiring an Azure Active Directory identity. In the future, we will support tokens backed by Azure Active Directory objects. Check out this new feature and let us know your feedback on GitHub.

Figure 3

Availability and feedback

Azure CLI experience is now in preview. As always, we love to hear your feedback on existing features as well as ideas for our product roadmap.

Roadmap: For visibility into our planned work.

UserVoice: To vote for existing requests or create a new request.

Issues: To view existing bugs and issues, or log new ones.

ACR documents: For ACR tutorials and documentation.
Quelle: Azure

What We Announced Today and Why it Matters

The post What We Announced Today and Why it Matters appeared first on Mirantis | Pure Play Open Cloud.
Today we announced that we have acquired the Docker Enterprise platform business from Docker, Inc. including its industry leading Docker Enterprise and 750 customers.

Why Docker Enterprise, and Why Now?

Docker led the container revolution and changed the world towards a better way to build, share and run software. No infrastructure company has had a bigger impact on developers in the last decade.

Docker Enterprise is the only independent container platform that enables developers to seamlessly build, share and safely run their applications anywhere – from public cloud, to hybrid cloud to the edge.  One-third of Fortune 100 and one-fifth of Global 500 companies use Docker Enterprise. Two years ago Docker Enterprise started to ship Kubernetes as part of its Universal Control Plane and many of its customers are using it today or plan to use it in the near future.

This acquisition will accelerate Mirantis’ vision to deliver Kubernetes-as-a-Service with a consistent experience for developers on any cloud and on-prem infrastructure. 

Why Mirantis?

Mirantis has always brought strategic flexibility to companies moving to cloud. Our Kubernetes technology joined with Docker Enterprise brings even greater simplicity and choice to enterprises with a cloud-first mandate.

By basing the combined technology on flexible infrastructure and open standards like Kubernetes for full application portability, along with our expertise in providing market-leading enterprise support for open source software, Mirantis is a compelling alternative to lock-in platforms like VMware and Red Hat.

As enterprises continue to accelerate moving to hybrid and multi-cloud architectures, they want to avoid cloud lock-in and cloud sprawl. Selecting a container platform based on open standards allows enterprises to retain the strategic flexibility needed to run applications wherever needed. 

What Exactly Is Mirantis Acquiring?

Mirantis is acquiring Docker’s Enterprise business including products, technology, IP, and customer and partner relationships and will onboard former Docker Enterprise employees to continue to provide Docker Enterprise users a world-class customer experience.

The Docker Enterprise platform technology and associated IP: Docker Enterprise Engine, Docker Trusted Registry, Docker Unified Control Plane, Docker CLI 
All Docker Enterprise customers and contracts 
Strategic technology alliances and partner programs

What is Mirantis adding to Docker’s Enterprise business?

Its K8s-as-a-Service technology and expertise 
A shared product vision to deliver a consistent developer experience on any infrastructure, powered by K8s
A sound financial foundation with a proven track record of long-term success
Ongoing commitment to open source development and open standards 
The Mirantis as-a-service model for a simpler customer experience with greater economic value

Where Do We Go From Here?

Mirantis will assume the Docker Enterprise customer contracts. As the leader in enterprise support and managed services for open cloud infrastructure, Mirantis will work with customers on an ongoing basis to ensure continuity in support and services.

What About Docker Swarm?

The primary orchestrator going forward is Kubernetes. Mirantis is committed to providing an excellent experience to all Docker Enterprise platform customers and currently expects to support Swarm for at least two years, depending on customer input into the roadmap. Mirantis is also evaluating options for making the transition to Kubernetes easier for Swarm users.

Where You Can Learn More About Today’s News

Mirantis will be hosting a webinar on November 21, where we will be available to answer additional questions about the news and our vision for the future. Register here for the webinar.

If you’re a Docker Enterprise customer, an FAQ is available to answer your basic questions and provide a few ways to reach out to Mirantis. Of course, we will also reach out to you in the near term and ensure that your transition experience is seamless and positive.

We’re happy to note that this acquisition will enable Docker, Inc. to focus on advancing developers’ workflows when assembling, sharing and deploying modern applications. We see significant opportunities to collaborate with Docker, Inc. as both companies accelerate the move to containers and Kubernetes.
The post What We Announced Today and Why it Matters appeared first on Mirantis | Pure Play Open Cloud.
Quelle: Mirantis

Mirantis Acquires Docker Enterprise Platform Business

The post Mirantis Acquires Docker Enterprise Platform Business appeared first on Mirantis | Pure Play Open Cloud.
Industry-leading Docker Enterprise container platform complements existing Kubernetes technology from Mirantis

Campbell, Calif – November 13, 2019 – Mirantis, the open cloud company, announced today its acquisition of Docker’s Enterprise Platform business. Its industry leading container platform, employees and hundreds of enterprise customers will accelerate Mirantis’ goal to deliver Kubernetes-as-a-Service with a consistent experience for developers on any cloud and on-prem infrastructure. Terms of the deal are confidential.

Docker Enterprise is the only platform that enables developers to seamlessly build, share and safely run any applications anywhere – from public cloud to hybrid cloud to the edge. One third of Fortune 100 companies use Docker Enterprise as their high-velocity innovation platform.

Mirantis and the newly acquired Docker Enterprise team will continue to develop and support the Docker Enterprise platform and add new capabilities that enterprise clients expect:

A zero touch, as-a-service experience to eliminate the administration, integration and operation burden for customers 
Mirantis Kubernetes and related cloud-native technologies 
A proven enterprise business model with a strong financial foundation  

“The Mirantis Kubernetes technology joined with the Docker Enterprise Container Platform brings simplicity and choice to enterprises moving to the cloud. Delivered as a service, it’s the easiest and fastest path to the cloud for new and existing applications,” said Adrian Ionel, CEO and co-founder at Mirantis. “The Docker Enterprise employees are among the most talented cloud native experts in the world and can be immensely proud of what they achieved. We’re very grateful for the opportunity to create an exciting future together and welcome the Docker Enterprise team, customers, partners, and community.”

Commitment to open source and collaboration with Docker, Inc.

Mirantis and Docker will work together on core upstream technology, contributing to open source development. In addition, Mirantis and Docker will continue to ensure integration between their products with Docker focused on Docker Desktop and Docker Hub and Mirantis on the Docker Enterprise container platform.

According to Gartner, “cloud computing continues to be the platform for innovation that the digital business demands. Cloud has become the foundation that enables businesses to transform, differentiate and gain a competitive advantage. In 2020, infrastructure, applications and data will continue to proliferate everywhere, forcing organizations to extend their hybrid and multi cloud strategies to the edge.” As enterprises continue their cloud adoption, they want to avoid expensive operations, developer roadblocks and cloud lock-in. A container platform based on open standards gives enterprises the strategic flexibility needed to run applications wherever they need.

Mirantis has made significant investments in Kubernetes which will flow into the Docker Enterprise platform and benefit all of its customers. Kubernetes has become the defacto container orchestrator with an active, vibrant community, and Mirantis will combine its Kubernetes technology with Docker Enterprise to fuel the next wave of cloud-native innovation for enterprises.

Additional Resources

Mirantis will host a webinar on Thursday, November 21, 2019 at 9:00 a.m. PT to discuss its vision for combining Docker Enterprise with Mirantis. Register here: https://info.mirantis.com/mirantis-product-update
Read the blog post by Adrian Ionel: https://www.mirantis.com/blog/mirantis-acquires-docker-enterprise-platform-business/

About Mirantis
Mirantis helps enterprises move to the cloud on their terms, delivering a true cloud experience on any infrastructure, powered by Kubernetes. The company uses a unique as-a-service model empowering developers to build, share and run their applications anywhere – from public to hybrid cloud and to the edge. Mirantis serves many of the world’s leading enterprises, including Adobe, Cox Communications, DocuSign, Reliance Jio, STC, Vodafone, and Volkswagen. Learn more at www.mirantis.com.

 

###

 

Media Contact

Joseph Eckert for Mirantis

jeckertflak@gmail.com

 

12020 Planning Guide for Cloud Computing, Gartner, October 2019

 The post Mirantis Acquires Docker Enterprise Platform Business appeared first on Mirantis | Pure Play Open Cloud.
Quelle: Mirantis

Federated Prometheus with Thanos Receive

OpenShift Container Platform 4 comes with a Prometheus monitoring stack preconfigured. This stack is in charge of getting cluster metrics to ensure everything is working seamlessly, so cool, isn’t it?
But what happens if we have more than one OpenShift cluster and we want to consume those metrics from a single tool, let me introduce you to Thanos.
In the words of its creators, Thanos is a set of components that can be composed into a highly available metrics system with unlimited storage capacity, which can be added seamlessly on top of existing Prometheus deployments.

NOTE: Prometheus instances and Thanos components deployed by prometheus-operator don’t have Red Hat commercial support yet, they are supported by the community.
NOTE: Prometheus remote_write is an experimental feature.

Architecture
In this blog post we are going to go through the deployment and configuration of multiple Prometheus instances, for such task we are going to use the Prometheus Operator available in the in-cluster Operator Marketplace.
We will have two OpenShift 4 clusters, each cluster comes with a pre-configured Prometheus instance managed by the OpenShift Cluster Monitoring Operator, those Prometheus instances are already scraping out our clusters.
Since we cannot modify the configuration for the existing Prometheus instances managed by the Cluster Monitoring Operator yet (We will be able to modify some properties in OCP 4.2), we will deploy new instances using the Prometheus Operator. Also, we don’t want to configure the new Prometheus instances to scrape out the exact same cluster data, instead we will configure the new instances to get the cluster metrics from the managed Prometheus instances using Prometheus Federation.

Prometheus will be configured to send all metrics to the Thanos Receive using remote_write.
Thanos Receive receives the metrics sent by the different Prometheus instances and persist them into the S3 Storage.
Thanos Store Gateway will be deployed so we can query persisted data on the S3 Storage.
Thanos Querier will be deployed, the Querier will answer user’s queries getting the required information from the Thanos Receiver and from the S3 Storage through the Thanos Store Gateway if needed.

Below a diagram depicting the architecture:

NOTE: Steps below assume you have valid credentials to connect to your clusters using oc tooling. We will refer to cluster1 as west2 context, cluster2 as east1 context and cluster3 as east2. Take a look at this video to know how to flatten your config files.

Deploying Thanos Store Gateway
The Store Gateway will be deployed only in one of the clusters, in this scenario we’re deploying it in Cluster3 (east2).
We want our metrics to persist indefinitely as well, an S3 Bucket is required for that. We will use AWS S3 for storing the persisted Prometheus data, you can find the required steps to create an AWS S3 Bucket here.
We need a secret that stores the S3 configuration (and credentials) for the Store Gateway to connect to AWS S3.
Download the file store-s3-secret.yaml and modify the credentials accordingly.
oc –context east2 create namespace thanos
oc –context east2 -n thanos create secret generic store-s3-credentials –from-file=store-s3-secret.yaml

At the moment of this writing the Thanos Store Gateway requires of anyuid for work on OCP 4, we are going to create a service account with such privileges:
oc –context east2 -n thanos create serviceaccount thanos-store-gateway
oc –context east2 -n thanos adm policy add-scc-to-user anyuid -z thanos-store-gateway

Download the file store-gateway.yaml containing the required definitions for deploying the Store Gateway.
oc –context east2 -n thanos create -f store-gateway.yaml

After a few seconds we should see the Store Gateway pod up and running:
oc –context east2 -n thanos get pods -l “app=thanos-store-gateway”
NAME READY STATUS RESTARTS AGE
thanos-store-gateway-0 1/1 Running 0 2m18s

Deploying Thanos Receive
Thanos Receive will be deployed only in one of the clusters, in this scenario we’re deploying it in Cluster3 (east2).
Thanos Receive requires a secret that stores the S3 configuration (and credentials) in order to persist data into S3, we are going to re-utilize the credentials created for the Store Gateway.
Our Thanos Receive instance will require clients to provide a Bearer Token in order to authenticate and be able to send metrics, we are going to deploy an OAuth Proxy in front of the Thanos Receive for providing such service.
We need to generate a session secret as well as annotate the ServiceAccount that will run the pods indicating which OpenShift Route will redirect to the oauth proxy.
oc –context east2 -n thanos create serviceaccount thanos-receive
oc –context east2 -n thanos create secret generic thanos-receive-proxy –from-literal=session_secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c43)
oc –context east2 -n thanos annotate serviceaccount thanos-receive serviceaccounts.openshift.io/oauth-redirectreference.thanos-receive='{“kind”:”OAuthRedirectReference”,”apiVersion”:”v1″,”reference”:{“kind”:”Route”,”name”:”thanos-receive”}}’

On top of that using delegating authentication and authorization requires a cluster role system:auth-delegator to be assigned to the service account the oauth_proxy is running under, so we are going to add this role to the service account we just created:
oc –context east2 -n thanos adm policy add-cluster-role-to-user system:auth-delegator -z thanos-receive

Download the file thanos-receive.yaml containing the required definitions for deploying the Thanos Receive.
oc –context east2 -n thanos create -f thanos-receive.yaml

After a few seconds we should see the Thanos Receive pod up and running:
oc –context east2 -n thanos get pods -l “app=thanos-receive”
NAME READY STATUS RESTARTS AGE
thanos-receive-0 2/2 Running 0 112s

Now we can publish our Thanos receive instance using an OpenShift Route:
oc –context east2 -n thanos create route reencrypt thanos-receive –service=thanos-receive –port=web-proxy –insecure-policy=Redirect

Create ServiceAccounts for sending metrics
Since our Thanos Receive instance requires clients to provide a Bearer Token in order to authenticate and be able to send metrics, we need to create two ServiceAccounts (one per cluster) and give them the proper rights so they can authenticate against the oauth-proxy.
In our case we have configured the oauth-proxy to authenticate any account that have access to the thanos namespace in the cluster where it’s running (east2):
-openshift-delegate-urls={“/”:{“resource”:”namespaces”,”resourceName”:”thanos”,”namespace”:”thanos”,”verb”:”get”}}

So it will be enough creating the ServiceAccounts in the namespace and granting view Role to them:
oc –context east2 -n thanos create serviceaccount west2-metrics
oc –context east2 -n thanos adm policy add-role-to-user view -z west2-metrics
oc –context east2 -n thanos create serviceaccount east1-metrics
oc –context east2 -n thanos adm policy add-role-to-user view -z east1-metrics

Deploying Prometheus instances using the Prometheus Operator
First things first, we need to deploy a new Prometheus instance into each cluster, we are going to use the Prometheus operator for such task, so let’s start by deploying the operator.
We will deploy the operator on west2 and east1 clusters.
Deploying the Prometheus Operator into a new Namespace
A new namespace where the Operator and the Prometheus instances will be deployed needs to be created.

Once logged in the OpenShift Console, on the left menu go to Home -> Projects and click on Create Project:

Fill in the required information, we’ve used thanos as our namespace name:

Now we are ready to deploy the Prometheus Operator, we’re going to use the in-cluster Operator Marketplace for that matter.

On the left menu go to Catalog -> OperatorHub:

From the list of Operators, choose Prometheus Operator:

Accept the Community Operator supportability warning (if prompted):

Install the Operator clicking on Install:

Create the subscription to the operator:

After a few seconds you should see the the operator installed.

NOTE: Above steps have to be performed in both clusters

Deploying Prometheus Instance
At this point we should have the Prometheus Operator already running on our namespace, which means we can start the deployment of our Prometheus instances leveraging it.
Configuring Serving CA to Connect to Cluster Managed Prometheus
Our Prometheus instance needs to connect to the Cluster Managed Prometheus instance in order to gather the cluster-related metrics, this connection uses TLS, so we will use the Serving CA to validate the Targets endpoints (Cluster Managed Prometheus).
The Serving CA is located in the openshift-monitoring namespace, we will create a copy into our namespace so we can use it in our Prometheus instances:
oc –context west2 -n openshift-monitoring get configmap serving-certs-ca-bundle –export -o yaml | oc –context west2 -n thanos apply -f –
oc –context east1 -n openshift-monitoring get configmap serving-certs-ca-bundle –export -o yaml | oc –context east1 -n thanos apply -f –

Configuring Required Cluster Role for Prometheus
We are going to use Service Monitors to discover Cluster Managed Prometheus instances and connect to them, in order to do so we need to grant specific privileges to the ServiceAccount that runs our Prometheus instances.
As you may know, the Cluster Managed Prometheus instances include the oauth proxy to perform authentication and authorization, in order to be able to authenticate we need a ServiceAccount that can GET all namespaces in the cluster. The token for this ServiceAccount will be used as Bearer Token to authenticate our connections to the Cluster Managed Prometheus instances.
Download cluster-role.yaml file containing the required ClusterRole and ClusterRoleBinding.
Now we are ready to create the ClusterRole and ClusterRoleBinding in both clusters:
oc –context west2 -n thanos create -f cluster-role.yaml
oc –context east1 -n thanos create -f cluster-role.yaml

Configuring Authentication for Thanos Receive
We need to create a secret containing the bearer token for the ServiceAccount we created before and that will grant access to the Thanos Receive, this secret will be mounted in the
Prometheus pod so it can be used to authenticate against the Thanos Receive:
oc –context west2 -n thanos create secret generic metrics-bearer-token –from-literal=metrics_bearer_token=$(oc –context east2 -n thanos serviceaccounts get-token west2-metrics)
oc –context east1 -n thanos create secret generic metrics-bearer-token –from-literal=metrics_bearer_token=$(oc –context east2 -n thanos serviceaccounts get-token east1-metrics)

Deploying Prometheus Instance
In order to deploy the Prometheus instance, we need to create a Prometheus object. On top of that two ServiceMonitors will be created. The ServiceMonitors have the required configuration for scraping the /federate endpoint from the Cluster Managed Prometheus instances. We will use openshift-oauth-proxy to protect our Prometheus instances so unauthenticated users cannot see our metrics.
As we want to protect our Prometheus instances using oauth-proxy we need to generate a session secret as well as annotate the ServiceAccount that will run the pods indicating which OpenShift Route will redirect to the oauth proxy.
oc –context west2 -n thanos create secret generic prometheus-k8s-proxy –from-literal=session_secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c43)
oc –context east1 -n thanos create secret generic prometheus-k8s-proxy –from-literal=session_secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c43)

oc –context west2 -n thanos annotate serviceaccount prometheus-k8s serviceaccounts.openshift.io/oauth-redirectreference.prometheus-k8s='{“kind”:”OAuthRedirectReference”,”apiVersion”:”v1″,”reference”:{“kind”:”Route”,”name”:”federated-prometheus”}}’
oc –context east1 -n thanos annotate serviceaccount prometheus-k8s serviceaccounts.openshift.io/oauth-redirectreference.prometheus-k8s='{“kind”:”OAuthRedirectReference”,”apiVersion”:”v1″,”reference”:{“kind”:”Route”,”name”:”federated-prometheus”}}’

Download the following files:

prometheus-thanos-receive.yaml
service-monitor-west2.yaml
service-monitor-east1.yaml

First, we will create the Prometheus instances and the required ServiceMonitor for scraping the Cluster Managed Prometheus instance on west2, then we will do the same for east1.
We need to modify the prometheus-thanos-receive.yaml in order to configure the remote_write url where Thanos Receive is listening:
THANOS_RECEIVE_HOSTNAME=$(oc –context east2 -n thanos get route thanos-receive -o jsonpath='{.status.ingress[*].host}’)
sed -i.orig “s/<THANOS_RECEIVE_HOSTNAME>/${THANOS_RECEIVE_HOSTNAME}/g” prometheus-thanos-receive.yaml

oc –context west2 -n thanos create -f prometheus-thanos-receive.yaml
oc –context west2 -n thanos create -f service-monitor-west2.yaml
oc –context east1 -n thanos create -f prometheus-thanos-receive.yaml
oc –context east1 -n thanos create -f service-monitor-east1.yaml

ServiceMonitor Notes
The Prometheus Operator introduces additional resources in Kubernetes, one of these resources are the ServiceMonitors. A ServiceMonitor describes the set of targets to be monitored by Prometheus. You can learn more about that here
You can see the following properties used in the ServiceMonitors we created above:

honorLabels: true -> We want to keep the labels from the Cluster Managed Prometheus instance
– ‘{__name__=~”.+”}’ -> We want to get all the metrics found on /federate endpoint
scheme: https -> The Cluster Managed Prometheus instance is configured to use TLS, so we need to use https port for connecting to it
bearerTokenFile: <omitted> -> In order to authenticate through the oauth proxy we need to send a token from a SA that can GET all namespaces
caFile: <omitted> -> We will use this CA to validate Prometheus Targets certificates
serverName: <omitted> -> This is the Server Name we expect targets to report back
namespaceSelector + selector -> We will apply use this selectors to get pods running on openshift-monitoring namespace that have the label prometheus: k8s

After a few seconds we should see our Prometheus instances running on both clusters:
oc –context west2 -n thanos get pods -l “prometheus=federated-prometheus”
NAME READY STATUS RESTARTS AGE
prometheus-federated-prometheus-0 4/4 Running 1 104s
prometheus-federated-prometheus-1 4/4 Running 1 104s

oc –context east1 -n thanos get pods -l “prometheus=federated-prometheus”
NAME READY STATUS RESTARTS AGE
prometheus-federated-prometheus-0 4/4 Running 1 53s
prometheus-federated-prometheus-1 4/4 Running 1 53s

Now we can publish our prometheus instances using an OpenShift Route:
oc –context west2 -n thanos create route reencrypt federated-prometheus –service=prometheus-k8s –port=web-proxy –insecure-policy=Redirect
oc –context east1 -n thanos create route reencrypt federated-prometheus –service=prometheus-k8s –port=web-proxy –insecure-policy=Redirect

Deploying Custom Application
Our Prometheus instance is getting the cluster metrics from the Cluster Monitoring managed Prometheus, now we are going to deploy a custom application and get metrics from this application as well, so you can see the potential benefits from this solution.
The custom application exports some Prometheus metrics that we want to gather, we’re going to define a ServiceMonitor to get the following metrics:

total_reserverd_words – Number of words reversed by our application
endpoints_accesed{endpoint} – Number of requests on a given endpoint

Deploying the application to both clusters
Download the file reversewords.yaml
oc –context west2 create namespace reverse-words-app
oc –context west2 -n reverse-words-app create -f reversewords.yaml
oc –context east1 create namespace reverse-words-app
oc –context east1 -n reverse-words-app create -f reversewords.yaml

After a few seconds we should see the Reverse Words pod up and running:
oc –context west2 -n reverse-words-app get pods -l “app=reverse-words”
NAME READY STATUS RESTARTS AGE
reverse-words-cb5b44bdb-hvg88 1/1 Running 0 95s

oc –context east1 -n reverse-words-app get pods -l “app=reverse-words”
NAME READY STATUS RESTARTS AGE
reverse-words-cb5b44bdb-zxlr6 1/1 Running 0 60s

Let’s go ahead and expose our application:
oc –context west2 -n reverse-words-app create route edge reverse-words –service=reverse-words –port=http –insecure-policy=Redirect
oc –context east1 -n reverse-words-app create route edge reverse-words –service=reverse-words –port=http –insecure-policy=Redirect

If we query the metrics for our application, we will get something like this:
curl -ks https://reverse-words-reverse-words-app.apps.west-2.sysdeseng.com/metrics | grep total_reversed_words | grep -v ^#
total_reversed_words 0

Let’s send some words and see how the metric increases:
curl -ks https://reverse-words-reverse-words-app.apps.west-2.sysdeseng.com/ -X POST -d ‘{“word”: “PALC”}’
{“reverse_word”:”CLAP”}

curl -ks https://reverse-words-reverse-words-app.apps.west-2.sysdeseng.com/metrics | grep total_reversed_words | grep -v ^#
total_reversed_words 1

In order to get this metrics into Prometheus, we need a ServiceMonitor that scrapes the metrics endpoint from our application.
Download the following files:

service-monitor-reversewords-west2.yaml
service-monitor-reversewords-east1.yaml

And create the ServiceMonitors:
oc –context west2 -n thanos create -f service-monitor-reversewords-west2.yaml
oc –context east1 -n thanos create -f service-monitor-reversewords-east1.yaml

After a few moments we should see a new Target within our Prometheus instance:

Deploying Thanos Querier
At this point we have:

Thanos Receive listening for metrics and persisting data to AWS S3
Thanos Store Gateway configured to get persisted data from AWS S3
Prometheus instances deployed on both clusters gathering cluster and custom app metrics and sending metrics to Thanos Receive

We can now go ahead and deploy the Thanos Querier which will provide an unified WebUi for getting metrics for all our clusters.
The Thanos Querier connects to Thanos Receive and Thanos Store Gateway instances over GRPC, we are going to use standard OpenShift services for providing such connectivity since
all components are running in the same cluster.
As we already did with Prometheus instances, we are going to protect the Thanos Querier WebUI with the openshift-oauth-proxy, so first of all a session secret has to be created:
oc –context east2 -n thanos create secret generic thanos-querier-proxy –from-literal=session_secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c43)

Download the thanos-querier-thanos-receive.yaml.

NOTE: Port http/9090 is needed in the service until Grafana allows to connect to datasources using serviceaccounts bearer tokens so we can connect through the oauth-proxy

oc –context east2 -n thanos create serviceaccount thanos-querier
oc –context east2 -n thanos create -f thanos-querier-thanos-receive.yaml

After a few seconds we should see the Querier pod up and running:
oc –context east2 -n thanos get pods -l “app=thanos-querier”
NAME READY STATUS RESTARTS AGE
thanos-querier-5f7cc544c-p9mn2 2/2 Running 0 2m43s

Annotate the SA with the route name so oauth proxy handles the authentication:
oc –context east2 -n thanos annotate serviceaccount thanos-querier serviceaccounts.openshift.io/oauth-redirectreference.thanos-querier='{“kind”:”OAuthRedirectReference”,”apiVersion”:”v1″,”reference”:{“kind”:”Route”,”name”:”thanos-querier”}}’

Time to expose the Thanos Querier WebUI:
oc –context east2 -n thanos create route reencrypt thanos-querier –service=thanos-querier –port=web-proxy –insecure-policy=Redirect

If we go now to the Thanos Querier WebUI we should see two stores:

Receive: East2 Thanos Receive
Store Gateway: S3 Bucket

Grafana
Now that we have Prometheus and Thanos components deployed, we are going to deploy Grafana.
Grafana will use Thanos Querier as Prometheus datasource and will enable the creation of graphs from aggregated metrics from all your clusters.
We have prepared a small demo with example dashboards for you to get a sneak peek of what can be done.
Deploying Grafana
As we did before with Prometheus and Thanos Querier, we want to protect Grafana access with openshift-oauth-proxy, so let’s start by creating a session secret:
oc –context east2 -n thanos create secret generic grafana-proxy –from-literal=session_secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c43)

Annotate the SA with the route name so oauth proxy handles the authentication:
oc –context east2 -n thanos create serviceaccount grafana
oc –context east2 -n thanos annotate serviceaccount grafana serviceaccounts.openshift.io/oauth-redirectreference.grafana='{“kind”:”OAuthRedirectReference”,”apiVersion”:”v1″,”reference”:{“kind”:”Route”,”name”:”grafana”}}’

Download the following files:

grafana.ini
prometheus.json
grafana-dashboards.yaml
reversewords-dashboard.yaml
clusters-dashboard.yaml
grafana.yaml

oc –context east2 -n thanos create secret generic grafana-config –from-file=grafana.ini
oc –context east2 -n thanos create secret generic grafana-datasources –from-file=prometheus.yaml=prometheus.json
oc –context east2 -n thanos create -f reversewords-dashboard.yaml
oc –context east2 -n thanos create -f grafana-dashboards.yaml
oc –context east2 -n thanos create -f clusters-dashboard.yaml
oc –context east2 -n thanos create -f grafana.yaml

Now we can expose the Grafana WebUI using an OpenShift Route:
oc –context east2 -n thanos create route reencrypt grafana –service=grafana –port=web-proxy –insecure-policy=Redirect

Once logged we should see two demo dashboards available for us to use:

The OCP Cluster Dashboard has a cluster selector so we can select which cluster we want to get the metrics from.
Metrics from east-1

Metrics from west-2

We can have aggregated metrics as well, example below.
Metrics from reversed words

Next Steps

Configure a Thanos Receiver Hashring

The post Federated Prometheus with Thanos Receive appeared first on Red Hat OpenShift Blog.
Quelle: OpenShift