<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jamal Shahverdiev on Medium]]></title>
        <description><![CDATA[Stories by Jamal Shahverdiev on Medium]]></description>
        <link>https://medium.com/@jamalshahverdiev?source=rss-d8b7392d2f3b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jJD1jji6Gskhtv4V5XEqhg.jpeg</url>
            <title>Stories by Jamal Shahverdiev on Medium</title>
            <link>https://medium.com/@jamalshahverdiev?source=rss-d8b7392d2f3b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 20:29:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jamalshahverdiev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Kyverno ClusterPolicy Rules]]></title>
            <link>https://jamalshahverdiev.medium.com/kyverno-clusterpolicy-rules-89fa1bd42c36?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/89fa1bd42c36</guid>
            <category><![CDATA[kyverno]]></category>
            <category><![CDATA[policy]]></category>
            <category><![CDATA[mutate]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[validate]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Sun, 13 Aug 2023 12:06:52 GMT</pubDate>
            <atom:updated>2023-08-13T15:33:33.334Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cy-0TulZ-waKQ0Pc2yanfA.png" /></figure><p><a href="https://kyverno.io/docs/"><strong>Kyverno</strong></a> is a policy engine built for Kubernetes. It allows you to validate, mutate, and generate configurations using policies. Below is a brief overview of several <strong>ClusterPolicy </strong>rules which we can use in our <strong>Production </strong>environment.</p><h3>1. Rule: prom-rule-check</h3><p>This rule validates <strong>VMRule</strong> and <strong>PrometheusRule </strong>resources to ensure there aren&#39;t any unnecessary symbols in the expressions used.</p><ul><li>It checks that the number of left and right curly brackets, parentheses, and double quotes match.</li><li>Any mismatch will trigger a validation error.</li></ul><h3>2. Rule: audit-event-on-exec</h3><p>This rule generates an event when an <strong>exec </strong>the command is executed on a <strong>Pod</strong>.</p><ul><li>The event will list the user who executed the command and the exact command used.</li><li>This helps to track and monitor exec commands for security and audit purposes (We can send events from our cluster to the <strong>Elasticsearch </strong>with the <a href="https://github.com/opsgenie/kubernetes-event-exporter"><strong>Kubernetes Event Exporter</strong></a>).</li></ul><h3>3. Rule: validate-public-dns-eligible-update</h3><p>This rule ensures updates or creations of <strong>VirtualService</strong> resources of <strong>Istio </strong>within specific gateways.</p><ul><li>It checks against a list of allowed private hosts.</li><li>Any host not in this list will be flagged with a warning.</li></ul><h3>4. Rule: istio-deny-vs-hosts</h3><p>This rule denies the use of specific hosts in <strong>VirtualService </strong>resources.</p><ul><li>It targets specific forbidden domains (e.g., beta.opso.org, prime.opso.net, etc.). Of course we must define our domain names in the list to validate them.</li><li>Any configuration containing these hosts will be denied.</li></ul><h3>5. Rule: block-user-for-ns</h3><p>This rule blocks specific users from deploying to specific namespaces.</p><ul><li>It is particularly useful in clusters where certain users should not have access to deploy to specific namespaces.</li></ul><h3>6. Rule: disallow-latest-tag</h3><p>This rule disallows the use of the <strong>latest </strong>tag in container images for both main <strong>containers </strong>and <strong>init containers</strong>.</p><ul><li>Using the <strong>latest </strong>tag can be risky as it may pull an untested or unstable version of an image.</li><li>The rule enforces that specific, versioned tags be used instead.</li></ul><h3>Repository &amp; Video Simulation</h3><p>For a deeper dive and more details on these rules:</p><ul><li>All related code files for these rules can be found in <a href="https://github.com/jamalshahverdiev/kyverno/tree/main/kyvernorules"><strong>this repository</strong></a>.</li><li>Watch the simulation of these rules in action</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLXDSVm4rxM6ThobBSUy5Btnc_3TTNAcBK&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fplaylist%3Flist%3DPLXDSVm4rxM6ThobBSUy5Btnc_3TTNAcBK&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKXFT5Borz3I%2Fhqdefault.jpg%3Fsqp%3D-oaymwEWCKgBEF5IWvKriqkDCQgBFQAAiEIYAQ%3D%3D%26rs%3DAOn4CLCSlAg_3jQi11GRq5Mi3ReGna_K2g%26days_since_epoch%3D19582&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="853" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc13474a497556ef89a671862362f469/href">https://medium.com/media/bc13474a497556ef89a671862362f469/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89fa1bd42c36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extension to the Kube-Scheduler mostly for the on-premise Kubernetes clusters]]></title>
            <link>https://jamalshahverdiev.medium.com/extension-to-the-kube-scheduler-mostly-for-the-on-premise-kubernetes-clusters-923db5836847?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/923db5836847</guid>
            <category><![CDATA[kube-api-server]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kube-scheduler]]></category>
            <category><![CDATA[extension]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Sat, 05 Aug 2023 12:02:56 GMT</pubDate>
            <atom:updated>2023-08-05T12:02:56.194Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1clKh9VvljvaQ4-fnItEDQ.png" /></figure><h3>Introduction</h3><p>When we use affinity rules for our deployment, we often prefer to use preferredDuringSchedulingIgnoredDuringExecution. This rule is a soft requirement that attempts to allocate pods across different nodes. However, when only one worker node is in the Ready state, all replicas can be allocated to the single available worker node.</p><p>This is where this CronJob helps us. This script periodically checks the node and deployment status, and if necessary, performs a rollout restart to redistribute the pods across nodes. This tool is helpful when running deployments that should have their pods spread out over multiple nodes for redundancy.</p><h3>Solution Architecture</h3><p>The script is designed to run as a Kubernetes CronJob that periodically performs checks and initiates deployment rollouts if necessary. The solution uses the Python Kubernetes client to interact with the cluster.</p><p>To enable the script for certain deployments, we use a namespace annotation (collectdeployments: allow). This makes the script flexible and prevents unnecessary restarts on deployments that don&#39;t require this level of redundancy.</p><p>The solution includes a Dockerfile for packaging the script, a Kubernetes CronJobto periodically run the check, and RBACconfigurations to allow the script to interact with the Kubernetes API.</p><h3>How it works</h3><p>The restart_deployments_if_needed the function is at the heart of our CronJob. This function:</p><ol><li>Checks the number of Ready worker nodes.</li><li>If at least two nodes are ready, it fetches the list of namespaces with the collectdeployments: allow annotation.</li><li>It then fetches the deployments in these namespaces, and for each deployment, it checks if the deployment’s pods are spread across at least two nodes.</li><li>If all replicas of a deployment are on a single node, it performs a rollout restart for that deployment.</li></ol><p>All written code files are located <a href="https://github.com/jamalshahverdiev/kubernetes-python-operators/tree/main/scheduler-inform-rollout-restart-deployment"><strong>in this repository</strong></a>.</p><p>This is a real simulation of how it works</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPkPvVAlGXXc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPkPvVAlGXXc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPkPvVAlGXXc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3d7ae0e44f0f51fcaf98b6ff35b0eb5/href">https://medium.com/media/b3d7ae0e44f0f51fcaf98b6ff35b0eb5/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=923db5836847" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Operator for Kyverno Policy rules]]></title>
            <link>https://jamalshahverdiev.medium.com/kubernetes-operator-for-kyverno-policy-rules-f0318008f4b4?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0318008f4b4</guid>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[mutating-webhook]]></category>
            <category><![CDATA[operators]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kyverno]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Sun, 30 Jul 2023 12:48:44 GMT</pubDate>
            <atom:updated>2023-07-30T12:48:44.295Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vr_pkUxvY8x2BHrUOvU_vA.png" /></figure><h3>Overview</h3><p>In this document, we will discuss the Kyverno PolicyWriter Operator which is housed <a href="https://github.com/jamalshahverdiev/kubernetes-python-operators/tree/main/operator-kyverno"><strong>in this GitHub repository</strong></a>.</p><p>This operator is specifically built for Kubernetes using a Kind named PolicyWriter. Its main function is to dynamically generate Kyverno policy rules based on the specifications of the PolicyWriter and enforce these rules whenever a specific event, such as an update, occurs in the target Kubernetes resource.</p><h3>How does it work?</h3><p>The PolicyWriter kind accepts four fields: namespace, Kind (which can be either DaemonSet or Deployment), name of the Kind, and name of the secret that these kinds are observing. Once these fields are defined, the operator will automatically generate a Kyverno policy rule.</p><p>These policy rules look for changes in the designated Kubernetes secret. Whenever an update event is triggered in the <strong>secret </strong>object, the operator will proceed to patch the relevant DaemonSet or Deployment. The patching process will annotate the DaemonSet or Deployment with a new version annotation in the following format: daemonset-version: resourceversionofthesecret or deployment-version: resourceversionofthesecret respectively.</p><p>This on-the-fly generation of policy rules allows for real-time enforcement of policies based on changes in Kubernetes secrets.</p><p>For the real-time simulation please look at this video</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fz7LqOfZS1eo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dz7LqOfZS1eo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fz7LqOfZS1eo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ed5889974178382e728f2b9c060ad2b/href">https://medium.com/media/4ed5889974178382e728f2b9c060ad2b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0318008f4b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes WebHooks (Init to Kyverno)]]></title>
            <link>https://jamalshahverdiev.medium.com/kubernetes-webhooks-init-to-kyverno-d1de6dcb7f31?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1de6dcb7f31</guid>
            <category><![CDATA[kyverno]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[webhooks]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 17:34:37 GMT</pubDate>
            <atom:updated>2023-07-25T05:42:49.929Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LmXm3ERhp7CBf-SslMlvmg.png" /></figure><p>I will try to explain how webhooks work inside Kubernetes and how we use the same logic with Kyverno.</p><p>Before starting to go in deep into <a href="https://kyverno.io/"><strong>Kyverno</strong></a> <strong>Policy</strong> and <strong>ClusterPolicy</strong> rules, we must understand how <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/"><strong>Admission controllers work</strong></a> and how they communicate with <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#validatingadmissionwebhook"><strong>Validation</strong></a>/<a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook"><strong>Mutation</strong> </a>webhooks in Kubernetes.</p><p>I offer to read <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/"><strong>this documentation</strong></a> before starting to watch the video.</p><p>All code files used in the video are located in <a href="https://github.com/jamalshahverdiev/kubernetes-python-operators/tree/main/webhooks"><strong>this repository</strong></a>.</p><p>I hope it will be useful.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKXFT5Borz3I%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKXFT5Borz3I&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKXFT5Borz3I%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/968906a79c5e3579d239534fda2530b7/href">https://medium.com/media/968906a79c5e3579d239534fda2530b7/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1de6dcb7f31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Python operator DB Insert/Update/Delete by CRD]]></title>
            <link>https://jamalshahverdiev.medium.com/kubernetes-python-operator-db-insert-update-delete-by-crd-dd52c25cee36?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd52c25cee36</guid>
            <category><![CDATA[kopf]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[operators]]></category>
            <category><![CDATA[custom-resource]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Mon, 06 Feb 2023 17:12:46 GMT</pubDate>
            <atom:updated>2023-02-07T09:34:19.234Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5d4C3iVd2_4h3iwiM5mwTw.png" /></figure><p>In this article I will try to explain usage of Kubernetes operators with Python <strong>Kopf. </strong>Unfortunately I cannot write real use case of operator which we use right now but, I have tried to write details which used in our operator. Just imagine when you will apply CRD with kind PgdbWriter and with right spec fields, it will go to insert new data inside of the companies table of PostgreSQL database. In case of change some fields of existing CRD it will be updated and in case of deletion of existing CRD will be deleted row from database too.</p><p>Topology looks like as the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z50tqBdCvlJojmqx2OxrFQ.png" /></figure><p>We have PostgreSQLdatabase with credentials. Our table name companies with the following structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3T-fcm4FGxYtAP96htSSQ.png" /></figure><p>In the following video I am trying to explain code files and simulate all flow to be more understandable</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzrRXETU2cfM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzrRXETU2cfM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FzrRXETU2cfM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce2586895490be6aabb665bfae7d1509/href">https://medium.com/media/ce2586895490be6aabb665bfae7d1509/href</a></iframe><p>All code files which I have used located <a href="https://github.com/jamalshahverdiev/kubernetes-python-operators/tree/main/kubernetes-db-writer">in this repository</a>. I hope it will be useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd52c25cee36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detect rogue in Cisco switches with Python]]></title>
            <link>https://jamalshahverdiev.medium.com/detect-rogue-in-cisco-switches-with-python-b677883ba41c?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b677883ba41c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cisco]]></category>
            <category><![CDATA[rogue]]></category>
            <category><![CDATA[switch]]></category>
            <category><![CDATA[detection]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Mon, 05 Dec 2022 08:20:16 GMT</pubDate>
            <atom:updated>2022-12-05T11:28:08.394Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*xTetVtOzjqPWV5UIDfKADg.jpeg" /></figure><p>With this <a href="https://github.com/jamalshahverdiev/python-general-public-codes/tree/master/switch-notificator"><strong>Python code files</strong></a>, we will compare statically defined MAC address list with MAC addresses of selected Cisco switches for special <strong>VlanID</strong>. Statically defined MAC address list you must write in the <strong>StaticMacs</strong> file. If script couldn’t find statically defined <strong>StaticMacs</strong> file it will print you how you can prepare this with <strong>createstaticmacs.py</strong> script. <strong>switchnotificator.py</strong> script needs <strong>3</strong> arguments (<strong>switchusername</strong>, <strong>switchpassword</strong> and <strong>vlanID</strong>). If you execute script without needed arguments it will prompt information about this.</p><p><strong><em>Note</em></strong>: I did refactor all code files from <strong>Python2</strong> to <strong>Python3</strong> and I don’t have real environment to test all these stuff. I hope everything will work as it was in <strong>Python2 </strong>and sorry if it is not working :(.</p><p>Script connects to selected switches and get MAC address list. If script cannot find one of MAC addresses from Cisco switches in the statically defined MAC address list file, it will send email immediately to the Network engineer(defined in the <strong>lib/variables.py </strong>file).</p><p>Script reads <strong>iplist</strong> file to get IP address of Cisco switches. That is why you must write IP address list of Cisco switches to this file.</p><p>To configure gmail settings just edit <strong>frommail</strong>, <strong>fromemailpass</strong>, <strong>tomail</strong> variables in the <strong>lib/variables.py</strong> file.</p><p>Execute the following commands to download and use code files:</p><pre># git clone https://github.com/jamalshahverdiev/python-general-codes.git<br># cd python-general-codes/switch-notificator<br># ./switchnotificator.py switchusername &#39;switch_long_password&#39; vlanID</pre><p>If you want use this script automatically every minute, just add the following line to your crontab file:</p><pre>* * * * * /path/to/switchnotificator.py switchusername &#39;switch_long_password&#39; vlanID</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b677883ba41c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate DB access via tunnel with GIT Pull Requests in Google Cloud]]></title>
            <link>https://jamalshahverdiev.medium.com/automate-db-access-via-tunnel-with-git-pull-requests-in-google-cloud-30cfc32f0902?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/30cfc32f0902</guid>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[bastion]]></category>
            <category><![CDATA[automate]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Sat, 26 Nov 2022 08:01:29 GMT</pubDate>
            <atom:updated>2022-11-28T06:25:35.209Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*sghvMezLMGHa8c8TKulLiA.png" /></figure><p>In this article I will show the way how to connect to some database which, works in Private subnet in GCP with automated secure way. What does it means, each time when some member of our team comes to devops engineers to get an access to the database, after official approve we must go to the GCP and prepare all permissions by hand. Just imagine some engineer have PUBLIC IP address and to give an access to some DB we must add PUBLIC IP address of the user to firewall whitelist, then create new username in the SSH Jumping server with predefined user PUBLIC key(which, only after that user can connect to the DB via Jumper server). All these stuff triggered by CircleCI if PR will be <strong>approved</strong> by one of the member DevOps team group from Github and merged to <strong>main </strong>branch. To automate these stuff in GCP I wrote in bash which you can get all code files <a href="https://github.com/jamalshahverdiev/gcp-bash-codes.git"><strong>from this repository</strong></a>.</p><p><strong><em>Note</em></strong>: The source of the syncronization for <strong><em>PUBLIC keys</em></strong> and <strong><em>PUBLIC IP</em></strong> addresses of the users will be repository where code files will be located. It means if some another PUBLIC IP and PUBLIC key will be added by hand to the remote server and firewall, they will be deleted by code. So it means code files tracks state from source of the repository.</p><p>In the following video I am trying to simulate it. I hope it will be useful.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxG-qTfPQ1OQ&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxG-qTfPQ1OQ&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4435f0744a6d58325fb2e44fbe99f232/href">https://medium.com/media/4435f0744a6d58325fb2e44fbe99f232/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30cfc32f0902" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ArgoCD Image updater scale Up/Down by release date time.]]></title>
            <link>https://jamalshahverdiev.medium.com/argocd-image-updater-scale-up-down-by-release-date-time-67c5bce3a233?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/67c5bce3a233</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[release-dates]]></category>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Sun, 20 Nov 2022 14:14:12 GMT</pubDate>
            <atom:updated>2022-11-21T06:46:43.814Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wyEVQgfe-t0ktcxjTv3YKQ.png" /></figure><p>Before starting go in deep to the article I want to explain how I became to prepare these code files to achieve goal. With my team we agreed on that we will block any of new deployments to production for none working days (<strong>Saturday</strong> and <strong>Sunday</strong>) and times (<strong>EST </strong>time after <strong>16:00</strong> until early morning <strong>09:00</strong>).</p><p>I started to think write some code which can get 4 environment variable as argument. <strong>2</strong> of them will define Scale Up/Down count and <strong>2</strong> of them will define time range to do ArgoCD image updater scale up/down. I needed to configure these variable dynamic which we can change this any time and my code must work inside of some <strong>Cronjob </strong>which can get arguments any time. Due that I created secret where will store <strong>base64</strong> encoded values for my CronJob as arguments. Then I created <strong>ServiceAccount</strong>, <strong>ClusterRole </strong>and <strong>ClusterRoleBindings</strong> to give an access to my <strong>Cronjob</strong> to get access to the deployment <strong>argocd-imageupdater</strong> in the argocd namespace. At the end I wrote small code which will be executed via <strong>Cronjob </strong>each one hour and <strong>Cronjob</strong> itself. All code files located <a href="https://github.com/jamalshahverdiev/kubernetes/tree/main/argo-image-scaler-by-release-date-time"><strong>in this GitHub repository</strong></a><strong> (</strong>just follow README file to achive goal<strong>)</strong>.</p><p>I show simulation in the following video. I hope it will be useful.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtSVkjHeqmrU&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtSVkjHeqmrU&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f708ad9f43cbac8322cc906a9c72a9a/href">https://medium.com/media/0f708ad9f43cbac8322cc906a9c72a9a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67c5bce3a233" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hashicorp Vault restart pods when key changed in Kubernetes]]></title>
            <link>https://jamalshahverdiev.medium.com/hashicorp-vault-restart-pods-when-key-changed-in-kubernetes-b8926a34b3b4?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8926a34b3b4</guid>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[restart]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Mon, 14 Nov 2022 06:42:31 GMT</pubDate>
            <atom:updated>2022-11-14T06:53:20.799Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AqrSwrChr1AYQrFtzbhhjg.png" /></figure><p>In this article I will show the way how to automatically restart all pods in your deployment when secret value changed in predefined secret path. Hashicorp Vault deployed with HA mode (configured autounseal) and GC bucket backend. For authentication integrated with GitHub and Google OIDC. To get secrets inside of pods I use here <strong>vault-agent sidecar container </strong>with annotations. It looks like as following:</p><pre>sidecar.istio.io/inject: &quot;true&quot;<br>traffic.sidecar.istio.io/excludeOutboundPorts: &quot;8200&quot;<br>vault.hashicorp.com/auth-path: &quot;auth/kubernetes&quot;<br>vault.hashicorp.com/agent-init-first: &quot;true&quot;<br>vault.hashicorp.com/agent-inject: &quot;true&quot;<br>vault.hashicorp.com/role: &quot;company&quot;<br>vault.hashicorp.com/agent-inject-secret-config: &quot;company/account-service&quot;<br>vault.hashicorp.com/log-level: &quot;debug&quot;<br>vault.hashicorp.com/template-static-secret-render-interval: &quot;2m&quot;<br>vault.hashicorp.com/agent-inject-template-config: |<br>  {{- with secret &quot;company/some-service&quot; -}}<br>      export AUTH_PASSWORD=&quot;{{ .Data.data.AUTH_PASSWORD }}&quot;<br>      export SERVICE_PASSWORD=&quot;{{ .Data.data.SERVICE_PASSWORD }}&quot;<br>      export AUTH_USERNAME=&quot;{{ .Data.data.AUTH_USERNAME }}&quot;<br>      export SECRET_KEY_BASE=&quot;{{ .Data.data.SECRET_KEY_BASE }}&quot;<br>  {{- end }}</pre><p>From the previous annotations we can understand our deployment will use <strong>auth/kubernetes</strong> method to authenticate to Vault service with role <strong>company </strong>and <strong>serviceAccount (</strong>It is configured inside of hashicorp vault to give access for this <strong>namespace</strong> and <strong>serviceAccount</strong>). All secret values defined in Hashicorp Vault path <strong>company/some-service</strong> will be added to file <strong>/vaut/secrets/config</strong> file (comes from this annotation <em>vault.hashicorp.com/agent-inject-secret-</em><strong>config</strong>) inside of the container. It will work wonderful but if you will change some value of existing key then pods will not be restarted. To achieve this I went to <a href="http://vault.hashicorp.com/agent-inject-command">official page of Hashicorp Vault</a> and found <a href="https://developer.hashicorp.com/vault/docs/platform/k8s/injector/annotations#vault-hashicorp-com-agent-inject-command">vault.hashicorp.com/agent-inject-command</a> annotation (<a href="https://developer.hashicorp.com/vault/docs/platform/k8s/injector/annotations#vault-hashicorp-com-agent-image">Hasicorp Vault Image annotation</a>). Then I went to look at the logs of <a href="https://developer.hashicorp.com/vault/docs/platform/k8s/injector/annotations#vault-hashicorp-com-agent-inject-command">vault-agent-injector</a> pod to see mutation happening when I am changing the secret in Vault(it works). All code files which I have used <a href="https://github.com/jamalshahverdiev/vault/tree/main/vault-secrets-update-pod-restarts">in this GitHub repository</a>.</p><p><strong><em>Note</em></strong>: <strong>shareProcessNamespace: true </strong>must be defined inside of your deployment.</p><p>I simulate all flow in the following video. I hope it will be useful.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FnUtt3hi-l-U&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DnUtt3hi-l-U&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/31c9c21502745bdd295e632b5ef9e5d8/href">https://medium.com/media/31c9c21502745bdd295e632b5ef9e5d8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8926a34b3b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BanzaiCloud Bank-Vaults]]></title>
            <link>https://jamalshahverdiev.medium.com/banzaicloud-bank-vaults-a98fb78eacc6?source=rss-d8b7392d2f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a98fb78eacc6</guid>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[sensitive-data]]></category>
            <dc:creator><![CDATA[Jamal Shahverdiev]]></dc:creator>
            <pubDate>Sat, 05 Nov 2022 09:43:25 GMT</pubDate>
            <atom:updated>2022-11-05T09:43:25.789Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYWUbIDtbdESsvYwtIYJiA.png" /></figure><p>In this article I will show usage of <a href="https://banzaicloud.com/docs/bank-vaults/overview/"><strong>Bank-Vaults</strong></a> prepared with BANZAICLOUD (now part of <strong>Cisco</strong>)team. Bank-Vaults have three components <a href="https://github.com/banzaicloud/bank-vaults/tree/main/charts/vault-operator"><strong>vault-operator</strong></a><strong> ,</strong> <a href="https://github.com/banzaicloud/bank-vaults/tree/main/charts/vault-secrets-webhook"><strong>vault-secrets-webhook</strong></a>, and <a href="https://github.com/banzaicloud/bank-vaults/tree/main/charts/vault"><strong>Hashicorp Vault </strong></a>itself.</p><p><a href="https://banzaicloud.com/docs/bank-vaults/operator/"><strong>Vault Operator </strong></a>— after deployment of this operator we can install and configure Hashicorp vault in HA or single mode with CRD of operator.</p><p><a href="https://banzaicloud.com/docs/bank-vaults/mutating-webhook/"><strong>Vault Secret Webhook</strong></a><strong> </strong>— With help of this webhook vault-env init container brings secrets to in memory of POD and with it microservice app can get secret key value from Hashicorp Vault.</p><p><a href="https://developer.hashicorp.com/vault/docs/configuration"><strong>Hashicorp Vault</strong></a> — Wonderful application which gives us possibility store our secrets with multiple ways (Very clear API).</p><p>With Bank-Vaults we don’t need <strong>vault-agent sidecar</strong> container and we cannot get secret real value inside of the microservice container.</p><p>To see real illustration how it works just look at the following gif which I got from their official page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mtiYtBdt-nNNEEyw442USA.gif" /></figure><p>The code files which I have used located in <a href="https://github.com/jamalshahverdiev/vault.git"><strong>this GitHub repository</strong></a>. I have used GC bucket as backend with auto unseal in HA mode. For authentication I have used GitHub and Google OIDC.</p><p>We can see the real simulation in the following video. I hope it will be useful to all of us.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F6ZW8Q7qZI-M%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6ZW8Q7qZI-M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F6ZW8Q7qZI-M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f32a7e24de239be6d63d065ffa68b641/href">https://medium.com/media/f32a7e24de239be6d63d065ffa68b641/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a98fb78eacc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>