<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Max Espinoza</title>
    <description>The latest articles on DEV Community by Max Espinoza (@maxineer).</description>
    <link>https://dev.to/maxineer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F614322%2F13aa6f86-736d-435e-a3e4-59855b3dd620.jpg</url>
      <title>DEV Community: Max Espinoza</title>
      <link>https://dev.to/maxineer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/maxineer"/>
    <language>en</language>
    <item>
      <title>Cloud Cost Pondering Part 1</title>
      <dc:creator>Max Espinoza</dc:creator>
      <pubDate>Fri, 05 Sep 2025 00:53:35 +0000</pubDate>
      <link>https://dev.to/maxineer/cloud-cost-pondering-part-1-16mi</link>
      <guid>https://dev.to/maxineer/cloud-cost-pondering-part-1-16mi</guid>
      <description>&lt;p&gt;It's been a while since I've posted here. I've been meaning to use this space to pose questions to myself and anyone else reading. This is meant to be a series of posts as I learn a more about GCP billing so if you know of any interesting resources, please do share!&lt;/p&gt;

&lt;p&gt;I've been doing cost comparisons between providers. I'm familiar with one of the major providers' billing pages, but I'm still new when it comes to GCP. That said, GCP provides a handy &lt;a href="https://cloud.google.com/products/calculator" rel="noopener noreferrer"&gt;Price Calculator&lt;/a&gt; to assist in getting a rough estimate. Almost all cloud vendors have some version of a price calculator. One thing I never asked myself until recently was: how &lt;em&gt;accurate&lt;/em&gt; are these price calculators, especially those that do some behind-the-scenes math, like the &lt;a href="https://cloud.google.com/products/calculator?dl=CjhDaVJsWVRSaU9UVmxNQzFsWW1abExUUm1NakV0T0ROaFpDMWlORFZtT1RBMk5XTXhObVVRQVE9PRAcGiRDMUI2RTFCQi0yQjJFLTRBRkEtODk5Mi02MDk2NzQzN0I0Rjc" rel="noopener noreferrer"&gt;Cloud Run calculator&lt;/a&gt; based on 'Traffic Shape'? And how should one best use these calculators before making large financial commitments?&lt;/p&gt;

&lt;p&gt;I imagine there's already a wealth of material out there, including &lt;a href="https://www.lastweekinaws.com/podcast/screaming-in-the-cloud/" rel="noopener noreferrer"&gt;podcasts&lt;/a&gt; about this sort of thing. This series of posts isn't meant to add to the body of knowledge out there, but I hope it can help others sift through the material and get to the heart of these two questions&lt;sup id="fnref1"&gt;1&lt;/sup&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How accurate are the online price calculators published by the big cloud vendors?&lt;/li&gt;
&lt;li&gt;What is the best way to estimate cloud costs using these calculators?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cover art generated with &lt;a href="https://perchance.org/ai-text-to-image-generator" rel="noopener noreferrer"&gt;perchance&lt;/a&gt;.&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;That or at the very least be fodder for latest LLMs. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>gcp</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Istio Authentication &amp; Authorization</title>
      <dc:creator>Max Espinoza</dc:creator>
      <pubDate>Fri, 16 Jul 2021 18:27:55 +0000</pubDate>
      <link>https://dev.to/maxineer/istio-authentication-authorization-35ji</link>
      <guid>https://dev.to/maxineer/istio-authentication-authorization-35ji</guid>
      <description>&lt;h1&gt;
  
  
  Istio Authorization Policies
&lt;/h1&gt;

&lt;p&gt;I recently had to debug Istio authorization policies and I learned what a pain it can be understand how and when policies are applied to protect service on your mesh. This post is my attempt to explain the important bits of how to set this up. &lt;/p&gt;

&lt;p&gt;With that said, checkout the &lt;a href="https://istio.io/latest/docs/reference/config/security/authorization-policy/" rel="noopener noreferrer"&gt;Istio official docs&lt;/a&gt; for more detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Istio
&lt;/h3&gt;

&lt;p&gt;Istio is one of the leading service mesh implementations out there. It's used by a lot of companies to manage the growing overhead of having services running on Kubernetes. This is especially true when dealing with microservice architectures, which yield dozens (if not hundreds) services which need to talk to each other securely and reliably. &lt;/p&gt;

&lt;p&gt;Using a service mesh, like Istio, handles a lot of this complexity for you. For example app developers do not need implement the following features and can instead use what's configurable in the mesh:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mTLS between services (encrypted both ways)&lt;/li&gt;
&lt;li&gt;telemetry (common network metrics exposed for Prometheus)&lt;/li&gt;
&lt;li&gt;rate limiting &amp;amp; fault tolerance&lt;/li&gt;
&lt;li&gt;authentication (proving &lt;strong&gt;who&lt;/strong&gt; you are)&lt;/li&gt;
&lt;li&gt;authorization (can &lt;strong&gt;you&lt;/strong&gt; do &lt;strong&gt;that&lt;/strong&gt;?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is more the service mesh can do for your, but we're going to focus on the last two in this post. &lt;/p&gt;

&lt;h3&gt;
  
  
  The JWT
&lt;/h3&gt;

&lt;p&gt;(&lt;em&gt;pronounced 'jot'&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;Authentication is proving who are you. Using Istio, you can request clients calling services on the mesh prove who they are using JWTs (&lt;a href="https://jwt.io/introduction" rel="noopener noreferrer"&gt;Javascript Web Token&lt;/a&gt;). This functionality is configured with a &lt;a href="https://istio.io/latest/docs/reference/config/security/request_authentication/" rel="noopener noreferrer"&gt;RequestAuthenication&lt;/a&gt; CRD (Custom Resource Definition). Once this functionality is configured you can use &lt;a href="https://istio.io/latest/docs/reference/config/security/authorization-policy/" rel="noopener noreferrer"&gt;AuthorizationPolicies&lt;/a&gt; CRDs to enforce RBAC based on provided JWTs.&lt;/p&gt;

&lt;p&gt;But to that, you need to understand what the JWT is, and how it's used in conjunction with Istio to enforce RBAC for services.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfzg6v1c2d07iux7o1vo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfzg6v1c2d07iux7o1vo.png" alt="image-20210709173717855" width="800" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Above: Anatomy of a JWT&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The JWT is the standard token used in &lt;a href="https://openid.net/connect/" rel="noopener noreferrer"&gt;OpenIDConnect&lt;/a&gt; (OIDC) spec, and widely used as result. It has three pieces to it, the header, &lt;strong&gt;payload&lt;/strong&gt;, and signature. We are focused on the payload. Within the JSON payload one can put data (note: keys in the payload are called &lt;strong&gt;claims&lt;/strong&gt;). That said, there are certain keys (claims) that are reserved by the JWT spec. Non-reserved claims are called custom claims, of which the OIDC spec &lt;a href="https://auth0.com/docs/scopes/openid-connect-scopes" rel="noopener noreferrer"&gt;defines a handful of&lt;/a&gt;. These claims are often grouped into scopes. Where a scopes can be thought of as groupings of related permissions. Again, unsurprisingly the OIDC specifies certain scopes.&lt;/p&gt;

&lt;h4&gt;
  
  
  Now why does this matter?
&lt;/h4&gt;

&lt;p&gt;Because, having a JWT can act as proof of who you are, and claims within the JWT capture what you are allowed to do. Clients usually obtain a JWT by requesting one from a JWT issuer along with some credentials to prove identity (user/pass/2FA). The JWT is then usually provided by the client to the app in the &lt;code&gt;Authorization: Bearer &amp;lt;token&amp;gt;&lt;/code&gt; request header. There's a whole slew of tooling around doing this "handshake", from both client and server-side (Istio included). The neat thing about using a service mesh is that Istio can handle this interaction transparently to services. You only need configure the &lt;code&gt;RequestAuthenication&lt;/code&gt; and &lt;code&gt;AuthorizationPolicy&lt;/code&gt; objects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4mi7v4b401jq8ok4v8c0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4mi7v4b401jq8ok4v8c0.png" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Above: JWT 'handshake'&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;RequestAuthentication&lt;/code&gt; Object
&lt;/h2&gt;

&lt;p&gt;In the &lt;code&gt;RequestAuthentication&lt;/code&gt; object you can specify which workloads require a JWT from which trusted issuers. Note you need to provide &lt;code&gt;jwksUri&lt;/code&gt; so that Istio knows where to grab the certs used in the validation of the tokens (aka the &lt;a href="https://auth0.com/docs/tokens/json-web-tokens/json-web-key-sets" rel="noopener noreferrer"&gt;JSON Web Key Set&lt;/a&gt;). Your issuer will have an endpoint for this (sometimes linked from the &lt;code&gt;well-known&lt;/code&gt; endpoint ).&lt;/p&gt;

&lt;h3&gt;
  
  
  Example Request Authentication
&lt;/h3&gt;

&lt;p&gt;In this example, we want our service &lt;code&gt;httpbin&lt;/code&gt; in the foo &lt;code&gt;namespace&lt;/code&gt; to require a valid JWT issues from google.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;security.istio.io/v1beta1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;RequestAuthentication&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;foo-req-auth&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;foo&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;httpbin&lt;/span&gt;
  &lt;span class="na"&gt;jwtRules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;issuer&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://accounts.google.com"&lt;/span&gt; &lt;span class="c1"&gt;# Whose JWTs do you trust?&lt;/span&gt;
    &lt;span class="na"&gt;jwksUri&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://www.googleapis.com/oauth2/v3/certs"&lt;/span&gt; &lt;span class="c1"&gt;# Certs to verify JWTs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This alone does not however enforce that others cannot hit your endpoint publicly. You need to this this in with Authorization Policies.&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;AuthorizationPolicy&lt;/code&gt; Object
&lt;/h2&gt;

&lt;p&gt;Now here is the meat of what you will be configuring when using Istio enforce RBAC for your services. I won't go in depth here (there is a lot you can do) but I will briefly touch on the .&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;There are 3 kind of authorization policies:

&lt;ol&gt;
&lt;li&gt;allow policies&lt;/li&gt;
&lt;li&gt;deny policies&lt;/li&gt;
&lt;li&gt;custom policies&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;There is an ordering in how access is determined with these three policies&lt;/li&gt;

&lt;li&gt;These policies have &lt;code&gt;rules&lt;/code&gt;, which define if certain criteria is met, what level of access is allowed.&lt;/li&gt;

&lt;/ol&gt;

&lt;h4&gt;
  
  
  Example Authorization Policy
&lt;/h4&gt;

&lt;p&gt;In this example, we allow access to our service &lt;code&gt;httpbin&lt;/code&gt; in namespace &lt;code&gt;foo&lt;/code&gt; from any JWT (regardless of the principle) to use the &lt;code&gt;GET&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;security.istio.io/v1beta1"&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AuthorizationPolicy"&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;allow-reads"&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;foo&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;httpbin&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;principals&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;*"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;to&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;operation&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;methods&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GET"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example tying together claims with Authorization Policies
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;🚧 I will fill out this section soon. I working on more examples and diagrams to tie these concepts together!&lt;br&gt;
I highly recommend reading &lt;a href="https://www.istiobyexample.dev/authorization" rel="noopener noreferrer"&gt;Istio By Example&lt;/a&gt;  for more info!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Access Flow with Auth Policies
&lt;/h2&gt;

&lt;p&gt;There is some logic behind how authorization is determined given defined &lt;code&gt;AuthorizationPolicies&lt;/code&gt;. Below is the flow as taken directly from the Istio documentation.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;1 - If there are any CUSTOM policies that match the request, evaluate and deny the request if the evaluation result is deny.&lt;br&gt;
2 - If there are any DENY policies that match the request, deny the request.&lt;br&gt;
3 - If there are no ALLOW policies for the workload, allow the request.&lt;br&gt;
4 - If any of the ALLOW policies match the request, allow the request.&lt;br&gt;
5 - Deny the request.&lt;br&gt;
&lt;a href="https://istio.io/latest/docs/reference/config/security/authorization-policy/" rel="noopener noreferrer"&gt;source&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That said, as a visual learner, I need something tangible to keep this model in my head. So I think model the auth flow a person in a cooperate lobby trying to get enter an office. &lt;/p&gt;

&lt;p&gt;In this analogy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the Custom auth policies can be thought of C-level execs

&lt;ul&gt;
&lt;li&gt;They can decided many things, including if your allowed in or not!&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;the Deny policies can be thought of a office security

&lt;ul&gt;
&lt;li&gt;They are on the look out for features, if you catch their eye they will kick out&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;the Allow policies can thought of as employees of the office your are visiting

&lt;ul&gt;
&lt;li&gt;They can swipe you into the office if they happen to be expecting you&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnq6q6p515efq4dx2vxa2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnq6q6p515efq4dx2vxa2.png" width="800" height="260"&gt;&lt;/a&gt;&lt;br&gt;
Above: You enter the lobby and you notice the custom policies. If they are expecting (match) you, they will decide if you should be allowed in the office or not. They make the first call in regards to access.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2tib1zw3xckepbyirxzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2tib1zw3xckepbyirxzc.png" width="800" height="268"&gt;&lt;/a&gt;&lt;br&gt;
Above: Here, the execs are not expecting you, you're barely noticed by them. But if you catch the eye (match) one of the deny policies, they will escort you out. So try not to look suspicious!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9q9ngyu7hjj7au0m1v62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9q9ngyu7hjj7au0m1v62.png" width="800" height="312"&gt;&lt;/a&gt;&lt;br&gt;
Above:  In this case, no one wants you out and there are no Allow policies defined.  It's assumed you are allowed to enter the office&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feh2yvswpoq3ycfpiuhhw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feh2yvswpoq3ycfpiuhhw.png" width="800" height="316"&gt;&lt;/a&gt;&lt;br&gt;
Above: But, if any Allow policies are defined, you're going to need to have one of them expecting you (match) to allow you into the office.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmzzq4u2zol5ehsgdkc7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmzzq4u2zol5ehsgdkc7m.png" width="800" height="355"&gt;&lt;/a&gt;&lt;br&gt;
Above: If no one is expecting you, but no one kicks you out explicitly, you are not allowed linger in the lobby. You will be kicked out.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Summary
&lt;/h2&gt;

&lt;p&gt;Using Istio you are just a few configuration files away from handling auth for your services. While the configuration of these files might be a little obtuse, thinking about how they fit and how they get applied shouldn't have to be!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frmurotu1jthc868k799p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frmurotu1jthc868k799p.png" width="800" height="442"&gt;&lt;/a&gt;&lt;br&gt;
Above: The main actors in this play and the steps that happen. Note in step 5, that we apply the flow discussed earlier in this post.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>cloud</category>
      <category>security</category>
      <category>envoy</category>
    </item>
    <item>
      <title>Rancher, Prometheus, and Alert Manager in 5 minutes</title>
      <dc:creator>Max Espinoza</dc:creator>
      <pubDate>Thu, 29 Apr 2021 18:05:34 +0000</pubDate>
      <link>https://dev.to/maxineer/rancher-prometheus-and-alert-manager-in-5-minutes-2no6</link>
      <guid>https://dev.to/maxineer/rancher-prometheus-and-alert-manager-in-5-minutes-2no6</guid>
      <description>&lt;p&gt;I recently had take a look at how to setup monitoring and alerting for a Kubernetes cluster. I knew that Rancher offered monitoring that via Prometheus and Alert Manager, but never had the chance to sit down do its. &lt;/p&gt;

&lt;p&gt;This is my attempt to explain the important bits to anyone looking to implement monitoring and alerting (without just throwing the docs back at you). &lt;/p&gt;

&lt;p&gt;First,  let's talk about the main players. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Tooling  Chain
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Prometheus
&lt;/h4&gt;

&lt;p&gt;Simply put Prometheus can be thought of as a cronjob with a database.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It will scrape endpoints for metrics at set intervals of time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It will run queries against itself and save those results for later use at set intervals of time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Alert Manager
&lt;/h4&gt;

&lt;p&gt;Alert Manager is a &lt;em&gt;watcher&lt;/em&gt; of Prometheus alerts and a &lt;em&gt;notifer&lt;/em&gt; with support for tools like xMatters, Slack, PagerDuty, Etc.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It will look at alerts and notify based on how you configure it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can slience triggered alerts for periods of time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For more advance use cases you can de-duplicate alerts from multiple sources&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Rancher
&lt;/h4&gt;

&lt;p&gt;It's what Ubuntu is to Linux. For this post, you can think of it as the thing that has already installed Alert Manager and Prometheus on your cluster. Also, it's got a nice UI for you configure those tools without writing the underlying Kubernetes CRDs.&lt;/p&gt;

&lt;p&gt;What's neat about Rancher is that when &lt;a href="https://rancher.com/docs/rancher/v2.x/en/monitoring-alerting/v2.5/" rel="noopener noreferrer"&gt;monitoring is enabled&lt;/a&gt;, then Prometheus is already scraping your cluster for a wide variety of metrics you can set notifications on. However, if you are not using Rancher then be sure configure Prometheus to scrape targets for the metrics you'd like to notify on. I won't talk about this here, but a Google search will turn out a lot of resources on how configure Prometheus targets.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Potentially unfamiliar terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Scraping: Polling and collecting data exposed at endpoint&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Targets: The endpoints Prometheus is scraping&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CRD: Custom Resource Definitions -- Custom Kuberenetes API Objects that is used to configure something on the cluster&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Prometheus hands-off alerting
&lt;/h2&gt;

&lt;p&gt;Prometheus offers alerting, in much the same way that books offer knowledge. It's there but it's on you read and act on it. As mentioned before Prometheus can be configured to query against itself (at set intervals of time) and record those results. Now, that's as far as Prometheus goes in regards to alerting. It's just making notes of what alerts were triggered.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9i556ycxty6acboepvn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9i556ycxty6acboepvn.png" width="800" height="645"&gt;&lt;/a&gt;&lt;br&gt;
Above: How Prometheus operates glossing over some details&lt;/p&gt;

&lt;p&gt;How exactly do you tell Prometheus what to make note of then?  &lt;strong&gt;PrometheusRules&lt;/strong&gt;, that's how. PrometheusRules are the CRD that hold the logic of what [with Alert Manager's help] to alert on. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvpjogpzarrremudb8grq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvpjogpzarrremudb8grq.png" width="800" height="418"&gt;&lt;/a&gt;&lt;br&gt;
Above: Basic pieces of PrometheusRule.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ApiAppPodCrashing&lt;/span&gt;
&lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Container {{ $labels.container }} in pod {{ $labels.pod }} in {{$labels.namespace}} is crashing perpetually.&lt;/span&gt;
  &lt;span class="na"&gt;recipient&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Infrastructure Team&lt;/span&gt;
&lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sum by(namespace) (kube_pod_container_status_last_terminated_reason{reason="CrashLoopBackoff", namespace!~"cattle-.*system|fleet-system|node-logging|cis-operator-system|ingress-nginx|kube-system"}) &amp;gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;
&lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;0s&lt;/span&gt;
&lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;priority&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;critical&lt;/span&gt;
  &lt;span class="na"&gt;team&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;infra&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above: More detailed view of the alert YAML with a PromQL expression to app crashing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Alert Manager doing the actual alerting
&lt;/h2&gt;

&lt;p&gt;Alert Manager is the tooling that reads Promethus recorded alerts and pushes those alerts to other notification tools like Slack/xMatters.&lt;/p&gt;

&lt;p&gt;What you need to know about Alert Manager is that it's configuration is done through creation of &lt;strong&gt;Routes&lt;/strong&gt; and &lt;strong&gt;Receivers&lt;/strong&gt;. Receivers can be thought of as endpoints to send alerts to. These can be slack rooms, xMatters integration, and a bunch more. Routes house the logic of "&lt;em&gt;if you see an alert with these properties, then send these alert records to these recievers&lt;/em&gt;."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0dfw1rtkd63nzn6z6o0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0dfw1rtkd63nzn6z6o0.png" width="800" height="350"&gt;&lt;/a&gt;&lt;br&gt;
Above: How routes, receivers, and alerts relate to one another&lt;/p&gt;

&lt;p&gt;Whats important to note here is that we can use &lt;strong&gt;labels&lt;/strong&gt; to route the alerts to different places. In our setup, we use this to route alerts to various slack rooms (depending on app) and to trigger xMatters notifications on &lt;code&gt;priority: critical&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration all the way down
&lt;/h2&gt;

&lt;p&gt;Monitoring and alerting is configuration files all the way down. These are the configurations you'd likely be working with.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa0o4q379zacyrf8mqzhe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa0o4q379zacyrf8mqzhe.png" width="800" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is more than one way to actually update/create these configurations. You can directly apply the PrometheusRule CRDs to the cluster and use the &lt;a href="https://prometheus.io/docs/alerting/latest/configuration/" rel="noopener noreferrer"&gt;Alert Manager CLI&lt;/a&gt; to make the Routes/Receivers. But if you have Rancher, life gets a lot easier.&lt;/p&gt;

&lt;p&gt;If you go the Cluster Explorer &amp;gt; Monitoring tab you'll find these configuration can all be setup from within the Rancher UI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0b6s8geip1j3ry4v5vby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0b6s8geip1j3ry4v5vby.png" width="800" height="285"&gt;&lt;/a&gt;&lt;br&gt;
Above: View of monitoring page in Rancher.&lt;/p&gt;

&lt;h2&gt;
  
  
  In short
&lt;/h2&gt;

&lt;p&gt;I've scratch the surface of what you can do and glossed over a lot of detail that you'll probably find better docs for, but in essence if you have the right tooling setup (read: Rancher Monitoring), you're only 3 configuration files away from having monitoring/alerting on services in your Kubernetes cluster. &lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>cloudnative</category>
      <category>devops</category>
      <category>devjournal</category>
    </item>
  </channel>
</rss>
