<?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 Aneesh Puttur on Medium]]></title>
        <description><![CDATA[Stories by Aneesh Puttur on Medium]]></description>
        <link>https://medium.com/@aneeshputtur?source=rss-440a3200dc17------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*H7zNfGefPyuVvbbNO4I-Ew.png</url>
            <title>Stories by Aneesh Puttur on Medium</title>
            <link>https://medium.com/@aneeshputtur?source=rss-440a3200dc17------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 05:00:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aneeshputtur/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[Can Helm and Operators coexist]]></title>
            <link>https://medium.com/@aneeshputtur/can-helm-and-operators-coexist-4568f36bde7c?source=rss-440a3200dc17------2</link>
            <guid isPermaLink="false">https://medium.com/p/4568f36bde7c</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[operator-sdk]]></category>
            <category><![CDATA[operators]]></category>
            <category><![CDATA[helm]]></category>
            <dc:creator><![CDATA[Aneesh Puttur]]></dc:creator>
            <pubDate>Mon, 27 Jul 2020 22:28:55 GMT</pubDate>
            <atom:updated>2020-07-28T20:18:10.078Z</atom:updated>
            <content:encoded><![CDATA[<p>[You take the blue pill and the story ends. You wake in your bed and believe whatever you want to believe and continue with Helm charts. You take the red pill and you stay in Wonderland and I show you how deep the operator goes. ]</p><p>No, we are not talking about humans and robots, but Helm and Operators</p><p>I have worked with operators since the beginning of its birth. Started with Golang operators because I like Golang and then started slowly to spread my operators to Ansible, but paused when getting into Helm. At first, I couldn’t understand why these two technology coexists</p><p>And then I started receiving questions about Helm charts and operators within my teams and colleagues and most of the questions seemed to imply that these two are engaged in a “Mortal Kombat”. Some suggested we have Helm-based Operators with limited functionality and some suggested building tools to migrate Helm templates to pure operators without having to depend on a Helm template or to need to maintain them.</p><h3>Helm: the package manager for Kubernetes</h3><h3>What Is Helm?</h3><p>In Short, Helm is a tool for Kubernetes packages called charts.</p><p>Going back in time, Great Scott! It was precisely on <a href="https://github.com/helm/helm-classic/tree/0.0.1">Nov. 2, 2015</a>, the first version of Helm charts was released at the same time when Kubernetes was at version 1.1.0 and was gearing up to their <a href="https://ti.to/kubecon/kubecon-2015/en">very first KubeCon</a> that was about to take place in 2015.</p><p>The mission statement was</p><p><strong>Helm provides package management for Kubernetes</strong></p><p>From the beginning, Helm was designed to solve one big problem: How do we share reusable Kubernetes resources for installing (and upgrading and uninstalling) things on Kubernetes? And they did achieve it, many k8s users quickly adapted Helm charts today, Helm has over a million downloads a month, and there are many publicly available charts in the repo.</p><h3>Enter The Operators — There is no opponent</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*k1lNWjUTVHGhLZH0" /><figcaption><strong>Tank</strong> was the <strong>operator</strong> on board the Nebuchadnezzar</figcaption></figure><h3>Operators: a design pattern for operational knowledge</h3><p>Almost exactly one year after Helm 0.0.1, <strong>Nov 13, 2016,</strong> to be precious, Brandon Philips, then CTO of CoreOS, posted on a blog post: <a href="https://coreos.com/blog/introducing-operators.html">Introducing Operators: Putting Operational Knowledge into Software.</a></p><p>Philips pointed out that we often relied upon humans to manage the runtime needs of applications. But with a system like Kubernetes, much of the material once set down in run books and user manuals could now be transformed into code.</p><p>A <a href="https://www.redhat.com/en/resources/oreilly-kubernetes-operators-automation-ebook?intcmp=701f2000001OMH6AAO">Kubernetes operator</a> is a method of packaging, deploying, and managing a Kubernetes application</p><p>An Operator is an application-specific controller that extends the Kubernetes API to create, configure, and manage instances of complex stateful applications on behalf of a Kubernetes user.</p><p>It builds upon the basic Kubernetes resource and controller concepts but includes domain or application-specific knowledge to automate common tasks.</p><p>As time passed Operators mature and quickly adapt to vanilla Kubernetes and RedHat Openshift. Mainly because of the completion of CRD and maturity of Kubernetes API. Also, thanks to Kube-builder and Operator-SDK these two tools made it possible to write a complex operator very easily.</p><p>The dev-Ops and Support engineers celebrated the birth of operators, it was the tool to solve day to day operations and beyond. It’s not just the package manager for Kubernetes any more. The operator design pattern is here to stay</p><p>But then I have Helm charts, Why do I need operators?</p><p>Didn’t I say, There is no opponent?</p><h3>What happens in the Helm template stays in the Helm templates.</h3><p>Helm charts cannot have fully operational knowledge besides just specifying the Kubernetes resource and how they can be configured via defaults override.</p><p><strong>I want Helm to run as operators, I know they are package managers.</strong></p><p>The answers lie in Helm-based operators that were made possible by the operator SDK team.</p><p><em>Helm Operator enables pairing a Helm Chart with the operational knowledge of installing, upgrading, and managing the application on Kubernetes clusters.</em></p><p>There is a current version of Helm-based operators and the newer hybrid version of Helm-Ansible Operators. Both of the implementations are tightly coupled with Helm charts. You have to maintain Helm templates.</p><p>All your Kubernetes resources stay in Helm templates and In the later version, the operators convert Helm templates into ansible templates on the fly and allow to pass defaults via ansible default variables, but the user still has to maintain their Helm charts to define their resources.</p><p>This brings to the limitation of not able to expand Helm charts into full-blown operators. Cannot make beyond install and upgrade.</p><h3>It was said that you would destroy the Helm, not join them, bring balance to the force, not leave it in darkness.</h3><p>Are Helm and Operators competitors? do they hate each other?. Or is it merely because there are too many Helm charts. Like I said millions and they refuse to let it go and join the force… Or the Darkside… Depends on which side you are.</p><p>Then why do I hear people discuss like they are competitors to each other?.</p><p>I think the answer is because Helm and operators use some same terminology, <strong>install</strong>, <strong>upgrades, lifecycle, configure</strong>.</p><p>People can use helm charts to do their job to some degree if not fully like operators do, but then we have helm-based operators which are a wrapper around helm charts and watches for changes and it makes it easier for some users to stay with helm and continue to adopt the operator SDK path of creating a helm-based operator.</p><h3>Helm? Where We’re Going, We Don’t Need Helm.</h3><p>Helm is a package manager for Kubernetes, period. They are what they are defined to be. But Operators are designed pattern-driven code that encapsulates business logic for running your application. It knows not only to deploy the application but also configure, scale, backup, Monitor, etc</p><p>As a Helm chart user<strong> “I want to write some template and be able to install my resources without having to edit them but still able to pass some arguments and able to build a deployment logic”.</strong></p><p>When a Helm user mentions managing applications they are thinking of having simple templates able to deploy and able to upgrade/rollback or delete the application.</p><p>For operators, it will be like <strong>“I want an operator to write, because I want to install, upgrade, maintain the state, scale, and monitor”</strong>.</p><p>Here it’s often detailed, I want day two operations, monitoring my application, rolling back from failure, automatic backup, keeping my application in a healthy state.</p><p>So we have two kinds of users, with different needs. But then the helm user needs able to sufficient in the initial stage, as the application matures Helm user might think of moving to full-blown operators and they have two choices, either use Helm-based operators offered by Operator-SDK which will take you two seamless upgrades but still not an operator with full capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZEk_aB4a-4Zg2VPV" /></figure><p><strong>“I am superior, sir, in many ways, but I would gladly give up to be Helm”.</strong> Its clear Operators by itself are superior, but not as a Helm-based operator, they won’t function in their fullest capacity, Instead, you rather stay as Helm charts.</p><p>Helm is merely templated YAML, which is Go Templates, decorated with Sprig functions. Operators are a bunch of CRDs and Controllers to manage application life cycles. But that doesn’t mean CRD’s and Controllers solve all problems. They are two different technologies made to fulfill two different purposes.</p><h3>Who is the winner?</h3><p><em>In the short term probably both. Operators have a different focus than the Helm charts. Helm fulfills the need for packaging and managing your applications.</em></p><p><em>Helm has its place, maybe not as Operators.</em></p><p><em>And in the long term as more and more advances happen in the operator’s world, and there are more and more resources available to support and develop in operators. As the operator framework matures, helm users might find it hard to stay as helm-based operators and too complex to migrate to Operators.</em></p><p><em>So if you need to take advantage of operators, then now is the time to make the move.</em></p><p><strong>But for now, Helm has now graduated from incubation at the Cloud Native Computing Foundation as a fully-fledged CNCF project.</strong></p><p><strong>CNCF Landscape — Showing HELM graduated</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/0*rVrxi4WthWoNNEVd" /></figure><p>Helm’s project status was boosted further by an independent security audit, completed in November 2019, that concluded Helm was “highly mature” software built with good security practices and could be recommended for public deployment.</p><p><strong>Helm is here to stay! <em>But Operators are superior!</em></strong></p><h3>Wait! , What if I want to migrate from Helm to Operators to take advantage of the full capabilities of the operators?.</h3><p>There is no easy way to migrate Helm charts to Ansible Templates or Go structs to build Ansible Operators Or Go Operators.</p><p>Below is the tool <strong><em>Helm Ansible Template Exporter </em></strong>I worked on along with a colleague, a few months ago to help Helm users to transition into Ansible Operators.</p><p>Why ansible? Ansible uses Jinja2 Templates which is equivalent to Helm Go Templates. But there is a caveat, Helm Classic’s template tool includes an array of built-in functions And there are 40+ functions available. These functions are supplied by the built-in Go text/template package and the<a href="https://github.com/Masterminds/sprig"> Sprig template function library</a>. So the tool I developed will help you migrate most of the Helm templates to Jinja2 Templates but then there are some workarounds required which you will see as you read the tool documentation below. Overall you can achieve 60% of porting from Helm to Ansible operator and the rest requires manual intervention.</p><h3>Helm Ansible Template Exporter</h3><p>Helm Ansible Template Exporter is a set of tools aimed at helping K8S application developers transition from Helm to Ansible Role-Based Operators. This project is separated into two main tools:</p><ol><li><a href="https://github.com/redhat-nfvpe/helm-ansible-template-exporter/blob/master/README.md">Helm To Ansible Exporter</a></li><li><a href="https://github.com/redhat-nfvpe/helm-ansible-template-exporter/blob/master/hack/README.md">Ansible Operator Builder</a></li></ol><h3>Helm To Ansible Exporter</h3><p>This tool automates conversion from <a href="https://helm.sh/">Helm Chart</a> to <a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html">Ansible Playbook Role</a>. Helm Charts are defined utilizing <a href="https://golang.org/pkg/text/template/">Go Template Language</a>, and Ansible Playbook Roles are defined using Yaml and <a href="https://jinja.palletsprojects.com/">Jinja2 Template Language</a>. Because Go Template Language and Jinja2 Template Language are completely separate languages, some facets of Helm charts are difficult or impossible to convert automatically. This tool performs a best attempt conversion of a Helm chart into an Ansible Playbook Role, but some aspects of the conversion process must be performed manually after utilizing this tool. Additionally, when ambiguities in conversion arise, this tool makes a best attempt to emit warnings where a manual conversion or inspection is needed after running the tool.</p><p>The output of this tool is an Ansible Role which can be installed using <a href="https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html">Ansible Playbook</a>, or built into an operator using the Ansible Operator Builder.</p><h3>Helm To Ansible Exporter Current Capabilities</h3><p>The current offering does the following:</p><ol><li>Creates a role in the workspace directory using ansible-galaxy.</li><li>Raw copies templates into the generated Ansible Playbook Role templates directory, renaming each template with a “.j2” extension.</li><li>Merges values.yml (or values.yaml) into the generated Ansible Playbook Role defaults/main.yml file.</li><li>Searches the generated Ansible Playbook Role’s defaults/main.yml file for self-references (i.e., references to .Values.) and comments them out. Ansible Playbook is incapable of expressing self-references in defaults/main.yml, a clear technology gap between Ansible Playbook and Helm charts. A “WARN” message is output indicating that a manual change is required to defaults/main.yml on the appropriate lines.</li><li>Convert Branch syntax for if, range &lt;list&gt; and range &lt;map&gt; in each template to utilize proper Jinja2 syntax. This includes a heuristic which attempts to determine if conditionals are checking for definition v.s. boolean evaluation.</li><li>Convert boolean composition ordering. Go Templating utilizes “and “ format. On the other hand, Jinja2 utilizes “ and “ formatting. helmExport handles this conversion automatically.</li><li>Template functions invocations are converted to Jinja2 Ansible Filter invocations. This requires converting direct function invocations to piped invocations, as well as inserting the appropriate parentheses and commas for argument lists.</li><li>Removes references to “.Values.” in the generated Ansible Playbook’s Roles’ templates. Ansible Playbook can directly reference the values in defaults/main.yml, so this reference isn’t needed.</li><li>If the “generateFilters” flag is set to true, some stub Ansible Filter implementations are installed for use in converting Go template functions to Ansible Playbook Filters.</li></ol><h3>Helm To Ansible Exporter Known Limitations</h3><h4>Go/Sprig Template Function Limitations</h4><p><a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html">Ansible Playbook Filter(s)</a> is one candidate to replace Go/Sprig Template Functions. However, they are not a direct 1:1 mapping, so a few extra steps must be taken after conversion.</p><h4>Implement or Replace Template Function Invocations with Ansible Filters</h4><p>There are several <a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html">Ansible Playbook Filters</a> built directly into Ansible. For instances where there does not seem to be a replacement, you will need to <a href="https://www.dasblinkenlichten.com/creating-ansible-filter-plugins/">create your replacement</a>. If you utilize the “generateFilters” command-line argument, some example filters will be installed into your generated Ansible Playbook Role.</p><h4>“template” and “include” are not supported</h4><p>Go Templates provide “template” and “include” to support dynamic template creation. Ansible has no direct replacement, and although there are some similar constructs, helmExport currently doesn’t support any conversion. Instead, consider using Ansible defaults as a replacement.</p><h3>Where We Go From Here Is A Choice I Leave To You.</h3><p>Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4568f36bde7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Operators with External Configmap]]></title>
            <link>https://medium.com/@aneeshputtur/kubernetes-operators-with-external-configmap-b972c9c36bbe?source=rss-440a3200dc17------2</link>
            <guid isPermaLink="false">https://medium.com/p/b972c9c36bbe</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[kubernetes-operator]]></category>
            <category><![CDATA[configmap]]></category>
            <dc:creator><![CDATA[Aneesh Puttur]]></dc:creator>
            <pubDate>Wed, 29 May 2019 20:10:33 GMT</pubDate>
            <atom:updated>2019-07-09T14:03:02.440Z</atom:updated>
            <content:encoded><![CDATA[<p>Kubernetes Operators is a great way to package your application deployment and manage them.</p><p>This blog is not about “what is Kubernetes Operators?”, but more about an approach I used to monitor an external configmap in operators.</p><p>Generally, Operators creates and manages Kubernetes resources like configmap, roles, service account, etc. The idea behind this is to abstract all admin user details from regular users and let the operators watch and manage those resources.</p><p>But in my case, I had a well-defined configuration file used by the application that should be managed and deployed by an operator.</p><p>But since the config file is complex, I rather apply the configuration outside the operators and then act upon any changes to that configuration, as opposed to trying to bake in the configuration details into Go code.</p><p>The solution I came up is to read the content of configmap in operator reconcile loop and read the config resource version and store it in deployment spec as annotation, and during a reconcile, check for the delta and perform an action.</p><p><strong>Let me break it down.</strong></p><p>[configmap] →[get the resource version]→[store in deployment spec]→[deploy pod]</p><p>[update configmap]→[get the new resource version ]→[retrive the old config resource version from deployment spec]→[compare]→[if different, delete pod and redeploy]</p><p><strong>Rules to follow</strong></p><p>Rule no 1: The operator should not deploy the pod if the config map is not found.</p><p>Rule no 2: The operator should delete and redeploy the application if there is a change in configurations.</p><p>Now let see how it can be achieved.</p><p><strong>Follow….</strong></p><p>Step 1, you need to watch for config map in controller reconcile loop along with deployment and other resources you want to manage.</p><p>Global variable</p><pre>var OperatorName = “UNKNOW”</pre><p><strong>func add(mgr manager.Manager, r reconcile.Reconciler) error {</strong></p><pre><em><br>// Watch for configmap<br></em>configFn := handler.ToRequestsFunc(func(configMapObject handler.MapObject) []reconcile.Request {<br>instance := &amp;v1alpha1.Mediumblog{}<br>depKey := types.NamespacedName{Namespace: configMapObject.Meta.GetNamespace(), Name: OperatorName}</pre><pre>log.Info(&quot;OPERATOR_NAME&quot;)<br>log.Info(OperatorName)</pre><pre>err := mgr.GetClient().Get(context.TODO(), depKey, instance)<br>if err != nil {<br>log.Info(&quot;Could not find Mediumblog instance, for reconciling configmap.&quot;)<br>return []reconcile.Request{}<br>}</pre><pre>return []reconcile.Request{<br>{  NamespacedName: types.NamespacedName{<br>   Name:      OperatorName,<br>   Namespace: configMapObject.Meta.GetNamespace(),<br>}},</pre><pre>}</pre><pre><strong><em>//watch for secondary resources not owned by CR</em></strong><em><br></em>err = c.Watch(&amp;source.Kind{Type: &amp;corev1.ConfigMap{}}, &amp;handler.EnqueueRequestsFromMapFunc{<br>ToRequests: configFn})<br>if err != nil {<br>return err<br>}</pre><p>Step2, Check for configMap, if not present do not deploy a container (or deploy with default, based on your design), loopback. Rule 1 satisfied.</p><pre>configMapFound := &amp;corev1.ConfigMap{}</pre><pre>err = r.client.Get(context.TODO(), types.NamespacedName{Name: “mediumblog-config”, Namespace: instance.Namespace}, configMapFound)</pre><pre>if err != nil &amp;&amp; errors.IsNotFound(err) {</pre><pre>reqLogger.Error(err, “ConfigMap not found… wont deploy untill config map is found\n”)</pre><pre>return reconcile.Result{}, err</pre><pre>}</pre><p>Step 3, When configmap found, get the ResourceVersion of configmap.</p><pre><strong><em>//Set instance as the owner and controller for this configmap</em></strong><em><br></em>if err := controllerutil.SetControllerReference(instance, configMapFound, r.scheme); err != nil {<br>return reconcile.Result{}, err<br>}<br>currentConfigVersion := configMapFound.ResourceVersion</pre><p>Step 4, Now you got the configmap, check for deployment, and annotate the deployment spec with the config resource version from step3.</p><p>(dep.Annotations[“configversion”] = currentConfigVersion)</p><pre>func (r *ReconcileMediumblo) Reconcile(request reconcile.Request) (reconcile.Result, error) {</pre><pre>..........<br>..........</pre><pre><strong>OperatorName = instance.GetName()</strong><br>depFound := &amp;appsv1.DaemonSet{}<br>err = r.client.Get(context.TODO(), types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace}, depFound)<br>if err != nil &amp;&amp; errors.IsNotFound(err) <strong>{</strong><br><em>// Define a new deployment<br></em>dep := deployments.NewDaemonSetForCR(instance)</pre><pre>//This where the magic happens. Store the configversion annotation <br>if dep.Annotations == nil {<br>dep.Annotations = make(map[string]string)<br>}</pre><pre><strong>dep.Annotations[&quot;</strong>configversion<strong>&quot;] = currentConfigVersion<br></strong><em>// Set instance as the owner and controller</em></pre><pre>if err := controllerutil.SetControllerReference(instance, dep, r.scheme); err != nil {<br>return reconcile.Result{}, err<br>}<br>reqLogger.Info(&quot;Creating a new Deployment&quot;, &quot;Daemonset&quot;, dep)<br>err = r.client.Create(context.TODO(), dep)<br>if err != nil {<br>reqLogger.Error(err, &quot;Failed to create new Daemonset\n&quot;)<br>return reconcile.Result{}, err<br>}<br>return reconcile.Result{Requeue: true}, nil</pre><pre><strong>}</strong> else if err != nil {<br>   reqLogger.Error(err, &quot;Failed to get Daemonset\n&quot;)<br>  return reconcile.Result{}, err<br>}</pre><h4><strong>If Deployment is already running, check if the configmap version changed. If it does, delete and redeploy.</strong></h4><h4><strong>Rule 2 satisfied.</strong></h4><pre>deployedConfigVersion := depFound.Annotations[&quot;<strong>configversion</strong>&quot;]</pre><pre>if deployedConfigVersion != <strong>currentConfigVersion</strong> {<br>     reqLogger.Info(&quot;Change in configMap , delete deployment.&quot;)<br>      err = r.client.Delete(context.TODO(), depFound)<br>      return reconcile.Result{Requeue: true}, nil<br>    }</pre><h3><strong>Kubernetes Resources</strong></h3><ol><li>Configmap</li></ol><pre>kind: ConfigMap<br>apiVersion: v1<br>metadata:<br>name: mediumblog-config<br>namespace: default<br>data:<br>node-mediumblog.conf: |-<br>ConnectionString =&quot;&quot;<br>CatagoryLevel=5<br>&lt;Category enabled=true&gt;<br>    &lt;Name&gt;Books&lt;/Name&gt;<br>&lt;/Category&gt;    </pre><p>2. Deployment code</p><pre><em>// Create NewDaemonSetForCR method to create daemonset</em></pre><pre>func NewDaemonSetForCR(m *v1alpha1.Mediumblog) *appsv1.DaemonSet {<br>labels := selectors.LabelsForMediumblog(m.Name)<br>ds := &amp;appsv1.DaemonSet{<br>TypeMeta: metav1.TypeMeta{<br>APIVersion: &quot;apps/v1&quot;,<br>Kind:       &quot;DaemonSet&quot;,<br>},<br>ObjectMeta: metav1.ObjectMeta{<br>Name:      m.Name,<br>Namespace: m.Namespace,<br>},<br>Spec: appsv1.DaemonSetSpec{<br>Selector: &amp;metav1.LabelSelector{<br>MatchLabels: labels,<br>},<br>Template: corev1.PodTemplateSpec{<br>ObjectMeta: metav1.ObjectMeta{<br>Labels: labels,<br>Annotations: map[string]string{<br>&quot;configVersion&quot;: &quot;&quot;,<br>},<br>},</pre><pre>Spec: corev1.PodSpec{<br>HostNetwork:        true,<br>ServiceAccountName: m.Name,<br>Containers:         []corev1.Container{containers.ContainerForMediumblog(m)},<br>},<br>},<br>},<br>}<br>volumes := []corev1.Volume{<br>{<br>Name: m.Name,<br>VolumeSource: corev1.VolumeSource{<br>ConfigMap: &amp;corev1.ConfigMapVolumeSource{<br>LocalObjectReference: corev1.LocalObjectReference{<br><strong>Name: &quot;mediumblog-config&quot;,</strong><br>},<br>Items: []corev1.KeyToPath{<br>{<br>Key:  &quot;node-mediumblog.conf&quot;,<br>Path: &quot;mediumblog-config&quot;,<br>},<br>},<br>},<br>},<br>},<br>}<br>ds.Spec.Template.Spec.Volumes = volumes<br>return ds<br>}</pre><p>That&#39;s all folks. Thank you for reading my blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b972c9c36bbe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Kubernetes on nucs (1 master and 2 workers) and using the laptop as a router]]></title>
            <link>https://medium.com/@aneeshputtur/running-kubernetes-on-nucs-1-master-and-2-workers-and-using-the-laptop-as-a-router-59aea1abc9f5?source=rss-440a3200dc17------2</link>
            <guid isPermaLink="false">https://medium.com/p/59aea1abc9f5</guid>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Aneesh Puttur]]></dc:creator>
            <pubDate>Wed, 29 May 2019 19:02:59 GMT</pubDate>
            <atom:updated>2019-05-29T19:02:59.519Z</atom:updated>
            <content:encoded><![CDATA[<pre>Running Kubernetes on  nucs (1 master and 2 worker) and using laptop as router</pre><h3>Running Kubernetes on nucs (1 master and 2 workers) and using the laptop as a router</h3><pre>-------------               ________              _________ (192.168.173.2)  <br>|  Lap top  |-eth0-&gt;|lan|  |        |&lt;-----------&gt;|_master__|      ___________ (192.168.173.3)  <br>|           |---eth1------ | swtich |&lt;--------------------------&gt;|_worker 1__|      __________ <br>-------------              |________|&lt;--------------------------------------------&gt;|_worker-2_| (192.168.173.4)<br>      eth1-192.168.173.10</pre><h3>LAPTOP</h3><p>**Laptop eth0 is on LAN, eth2 is private subnet 192.168.173.10 connected to <em>switch_1</em> **</p><pre>sudo iptables -t nat -A POSTROUTING -o enp0s31f6 -j MASQUERADE &amp;&amp; \<br>              sudo iptables -I FORWARD -o eth0 -s 192.168.0.0/16 -j ACCEPT &amp;&amp; \ <br>              sudo iptables -I INPUT -s 192.168.0.0/16 -j ACCEPT &amp;&amp; \<br>              sudo ifdown eth1 &amp;&amp; sudo ifup eth1</pre><h3>NUCS setup</h3><p>Nucs node connected to switch_1</p><p>1.Set network master 192.168.173.2 node1 192.168.173.3 node2 192.168.173.4 Set gateway in ifcfg to laptop 192.168.173.10</p><p>Network script example</p><pre>TYPE=Ethernet<br>PROXY_METHOD=none<br>BROWSER_ONLY=no<br>BOOTPROTO=none<br>DEFROUTE=yes<br>IPV4_FAILURE_FATAL=no<br>IPV6INIT=yes<br>IPADDR=192.168.173.2<br>IPV6_AUTOCONF=yes<br>IPV6_DEFROUTE=yes<br>IPV6_FAILURE_FATAL=no<br>IPV6_ADDR_GEN_MODE=stable-privacy<br>NAME=enp0s20f0u4<br>DEVICE=enp0s20f0u4<br>ONBOOT=no<br>USERCTL=yes<br>GATEWAY=192.168.173.10</pre><pre>2. Edit /etc/resolve.conf and copy from your laptop</pre><pre>3. On all nodes install kubelet and docker.</pre><h3>Installing Master in Nucs</h3><ol><li>ssh to master node and run kubeadm init as shown below. ** for flannel to work correctly, you must pass — pod-network-cidr=10.244.0.0/16 to kubeadm init.**</li></ol><pre>kubeadm init --cri-socket=&quot;/var/run/dockershim.sock&quot; --pod-network-cidr=10.244.0.0/16<br>~~ kubeadm init --cri-socket=&quot;/var/run/crio/crio.sock&quot;  --pod-network-cidr=10.244.0.0/16 ~~</pre><p>2. Check nodes are running</p><pre>To start using your cluster, you need to run the following as a regular user:</pre><pre>  mkdir -p $HOME/.kube<br>  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config<br>  sudo chown $(id -u):$(id -g) $HOME/.kube/config</pre><pre>kubectl get nodes<br>NAME          STATUS   ROLES    AGE    VERSION<br>kube-master   NotReady    master   151m   v1.14.0</pre><ol><li>Install flannel cni</li></ol><pre>Set /proc/sys/net/bridge/bridge-nf-call-iptables to 1 by running sysctl net.bridge.bridge-nf-call-iptables=1</pre><p>to pass bridged IPv4 traffic to iptables’ chains. This is a requirement for some CNI plugins to work, for more information please see here. <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/#network-plugin-requirements">https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/#network-plugin-requirements</a> For any error check this link to troubleshoot <a href="https://kubernetes.io/docs/setup/independent/troubleshooting-kubeadm/">https://kubernetes.io/docs/setup/independent/troubleshooting-kubeadm/</a></p><pre>kubectl -n kube-system apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml<br>Once a pod network has been installed, you can confirm that it is working by checking that the CoreDNS pod is Running in the output of kubectl get pods --all-namespaces. And once the CoreDNS pod is up and running, you can continue by joining your nodes</pre><p>To avoid cgroups error</p><pre>edit vi /etc/systemd/system/kubelet.service.d/11-cgroups.conf<br>and add following line<br>[Service]<br>CPUAccounting=true<br>MemoryAccounting=true<br>systemctl daemon-reload<br>systemctl restart kubelet</pre><h3>Join worker nodes,</h3><p>login to each node and run join commands. Join command is presented after the master is created, or you can get one as shown below.</p><p>[ preflight check , install kubelet and docker]</p><pre>echo 1 &gt; /proc/sys/net/ipv4/ip_forward</pre><p>copy this from master nodes, if the token is not found use this command to list token:-</p><pre>kubeadm token list</pre><p>The initial token expires in 24 hours, you can create, never expire token using this command</p><pre>kubeadm token create --ttl=0 --print-join-command</pre><pre>or copy the line from master</pre><pre>kubeadm join 192.168.173.5:6443 --token q8cxif.3eeaa5sfwqlnjthk     --discovery-token-ca-cert-hash sha256:8a6b0b2782bbf1bb87a28c226c131676c3f10ea8edcf40867e6316eb281af82f</pre><p>Optional, to add a label to a worker node</p><pre>kubectl label node  kube-node-1 node-role.kubernetes.io/worker=worker</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59aea1abc9f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Openstack attached Volume: Resize Docker volume for Openshift master node]]></title>
            <link>https://medium.com/@aneeshputtur/openstack-attached-volume-resize-docker-volume-for-openshift-master-node-ddb6a4293944?source=rss-440a3200dc17------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddb6a4293944</guid>
            <category><![CDATA[openstack]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[resize-docker-volume]]></category>
            <category><![CDATA[docker-volume]]></category>
            <category><![CDATA[openshift]]></category>
            <dc:creator><![CDATA[Aneesh Puttur]]></dc:creator>
            <pubDate>Mon, 19 Nov 2018 17:17:05 GMT</pubDate>
            <atom:updated>2018-11-19T20:57:18.405Z</atom:updated>
            <content:encoded><![CDATA[<h3>Openshift on Openstack : Resize attached docker volumes for Openshift nodes</h3><p>Recently I deployed Openshift 3.9 on Openstack 10z and had ansible variable for docker volume set to 15GiB, later onceI started deploying containers ,I quickly ran out of space in docker volume and couldn’t access openshift console etc . <strong><br>set openshift_openstack_docker_volume_size: “15”.</strong></p><p>Little intro to Docker Volume in Openshift nodes</p><pre><strong>set openshift_openstack_docker_volume_size: “15”.</strong></pre><p>The master and node instances contain a volume to store <strong>docker</strong> images. The purpose of the volume is to ensure that a large image or container does not compromise node performance or abilities of the existing node.</p><p>The docker volume is created by the OpenShift Ansible installer via the variable<strong>openshift_openstack_docker_volume_size</strong>.</p><p>Like in my case I needed to resize the docker volume without tearing down and redeploying Openshift.</p><p>The following process to resize a volume can be applied to any volume resize situation. I am just stating my scenario and experience in Openshift deployment.</p><p>Here you can see the highlighted volume is attached to a master node and it is set to 15GiB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BqBV6q4TEH0keadsrr6Lzg.png" /></figure><p>With df -h command on master node we see that volume is full and Openshit performance will be degraded due to lack of space to run containers on this volume.(Example , Openshift console may not respond).</p><pre><strong>df -h</strong></pre><pre><em>...<br>/dev/mapper/docker — vol-dockerlv is created with </em><strong><em>15Gib</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*uifsho4hQFrp8OJwZV2_mw.png" /><figcaption>df -h</figcaption></figure><p>Running Volume list will show , cinder volume in use and attached to master node with 15Gb</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUZxUDIpAUjcI3emyzGtkw.png" /><figcaption>openstack volume list</figcaption></figure><p>Now I need to increase the volume size to 40Gib. Now this can be done two ways. At this time I am not sure which one is safer to do.</p><ol><li>By creating new partition and extending the volume group to include the new logical volume from the new partition.</li><li>Or b y deleting the existing partition and recreating the new partition (hoping it starts from same sector block) with new size of 40GiB</li></ol><h3><strong>Step one, First we need to resize the volume in cinder.</strong></h3><h4>open stack volume list and Openstack server list to identify volume id and server id that is attached to</h4><pre>volume id: 3f382414-b6ed-4499–8b06-a3fa6794c532</pre><pre>server id :68e9c4ba-1ad7–44f8-bb76–053ba1efa5fa</pre><p><strong>Stop the server and remove the volume list</strong></p><pre>openstack server stop 68e9c4ba-1ad7–44f8-bb76–053ba1efa5fa</pre><pre>openstack server remove volume 68e9c4ba-1ad7–44f8-bb76–053ba1efa5fa 3f382414-b6ed-4499–8b06-a3fa6794c532</pre><h4>Resize the volume</h4><pre>openstack volume set 3f382414-b6ed-4499–8b06-a3fa6794c532 — size 40</pre><p>Re-attach the volume and restart the server</p><pre>openstack server add volume 68e9c4ba-1ad7–44f8-bb76–053ba1efa5fa 3f382414-b6ed-4499–8b06-a3fa6794c532</pre><pre>openstack server start 68e9c4ba-1ad7–44f8-bb76–053ba1efa5fa</pre><h4>Now when you run volume list you should see 40GiB, and also running fdisk -l shows the available disk is 40GiB. We have successfully grown the volume to desired size, But Wait! we have not grown the Physical volume, logical volume and filesystem.</h4><pre><strong>fdisk -l</strong><br><em>Disk /dev/vdb:</em><strong><em> 42.9 GB</em></strong><em>, 42949672960 bytes, 83886080 sectors<br>Units = sectors of 1 * 512 = 512 bytes<br>Sector size (logical/physical): 512 bytes / 512 bytes<br>I/O size (minimum/optimal): 512 bytes / 512 bytes<br>Disk label type: dos<br>Disk identifier: 0x00094295</em></pre><h3>Step two, Logical Volume extending</h3><p>(ref:<a href="https://www.tecmint.com/extend-and-reduce-lvms-in-linux/">https://www.tecmint.com/extend-and-reduce-lvms-in-linux/</a>)</p><p>Lets run PVS(Physical volume) vgs(volume group) and lvs(logical volme) command .</p><p>previously running df -h , we have seen there are no space in our virtual disk.</p><p>Running pvs command shows us there is 0 free space in physical volume</p><pre><strong>sudo pvs</strong></pre><pre><em>PV | VG |Fmt |Attr |PSize |PFree<br>/dev/vdb1| docker-vol |lvm2 | a |- | &lt;15.00g 0</em></pre><p>Running vgs also shows there is no free space available in volume group</p><pre><strong>sudo vgs</strong><br><em> VG #PV #LV #SN Attr VSize VFree<br> docker-vol 1 1 0 wz — n- &lt;15.00g 0</em></pre><p>Running lvs shows there is one logical volume which is again full.</p><pre><strong>sudo lvs</strong><br><em> LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert<br> dockerlv docker-vol -wi-ao — — &lt;15.00g</em></pre><p>So in order to extend this we need to add a physical volume and then extend the volume group .By doing this we get enough space to extend the logical volume and regrow the filesystem.</p><p>First step, add physical volume (if you want to modify existing physical volume then you delete the partition and recreate new pv with new size and you will skip the vgextened (volume extend step)</p><h3>Step three, Add Physical Volume</h3><p>In my case I have docker volume mapped to /dev/vdb1 .</p><p>running fdisk -l shows me that /dev/vdb is now 40Gib, since we ran volume resize</p><pre><em>Disk /dev/vdb: 42.9 GB, 42949672960 bytes, 83886080 sectors<br>Units = sectors of 1 * 512 = 512 bytes<br>Sector size (logical/physical): 512 bytes / 512 bytes<br>I/O size (minimum/optimal): 512 bytes / 512 bytes<br>Disk label type: dos<br>Disk identifier: 0x00094295</em></pre><p>So I know I have resized the volume to 40GiB and I have extra space available in /dev/vbd</p><h4>Lets create partition /dev/vbd2</h4><pre><strong>sudo fdisk /dev/vdb</strong><br><em>Welcome to fdisk (util-linux 2.23.2).<br>Changes will remain in memory only, until you decide to write them.<br>Be careful before using the write command.</em></pre><pre><em>Command (m for help): n<br>Partition type:<br> p primary (1 primary, 0 extended, 3 free)<br> e extended<br>Select (default p): p<br>Partition number (2–4, default 2): 2<br>First sector (31457280–83886079, default 31457280): <br>Using default value 31457280<br>Last sector, +sectors or +size{K,M,G} (31457280–83886079, default 83886079): <br>Using default value 83886079<br>Partition 2 of type Linux and of size 25 GiB is set</em></pre><pre><em>Command (m for help): t<br>Partition number (1,2, default 2): 2<br>Hex code (type L to list all codes): 8e<br>Changed type of partition ‘Linux’ to ‘Linux LVM’ <br>Command (m for help): w<br>The partition table has been altered!</em></pre><p>Now running fdisk , displays dev/vdb1 and /dev/vbd2</p><pre><strong>sudo fdisk -l</strong></pre><pre><em>……</em></pre><pre><em>.….</em></pre><pre><em>Device Boot Start End Blocks Id System<br>/dev/vdb1 2048 31457279 15727616 8e Linux LVM<br>/dev/vdb2 31457280 83886079 26214400 8e Linux LVM</em></pre><p>We successfully created partition. But the partition won’t be available until next boot,Kernel is still reading from old table… partprobe to rescue.</p><p>Run partprobe to inform the OS of partition table changes without reboot.</p><pre><strong>sudo partprobe -s</strong></pre><pre><em>/dev/vda: msdos partitions 1<br>/dev/vdb: msdos partitions 1 2</em></pre><h4>Now partition is available for us to create the physical volume.</h4><pre><strong>sudo pvcreate /dev/vdb2</strong><br><em>Physical volume “/dev/vdb2” successfully created.</em></pre><p>Running pvs command shows the new physical volume without any volume group associated with it</p><pre><strong>sudo pvs</strong><br><em> PV VG Fmt Attr PSize PFree <br> /dev/vdb1 docker-vol lvm2 a — &lt;15.00g 0 <br></em><strong><em> /dev/vdb2 lvm2 — — 25.00g 25.00g</em></strong></pre><h3>Step four, Extending the Volume Group by adding the new created physical volume (pv)</h3><p>vgextend — Add physical volumes to a volume group</p><pre><strong>vgextend docker-vol /dev/vdb2</strong></pre><p>Checking volume groups with vgs command. We can clearly see we have two pv’s under group docker -vol</p><pre><strong>sudo vgs</strong><br><em> VG #PV #LV #SN Attr VSize VFree<br> docker-vol 2 1 0 wz — n- 39.99g 0</em></pre><p>But running df -h still shows 15GiB.</p><blockquote>/dev/mapper/docker — vol-dockerlv 15G 1.9G 14G 13% /var/lib/docker</blockquote><pre><strong>df -h</strong><br><em>Filesystem Size Used Avail Use% Mounted on<br>/dev/vda1 30G 13G 18G 43% /<br>devtmpfs 7.8G 0 7.8G 0% /dev<br>tmpfs 7.8G 0 7.8G 0% /dev/shm<br>tmpfs 7.8G 1.4M 7.8G 1% /run<br>tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup<br></em><strong><em>/dev/mapper/docker — vol-dockerlv 15G 1.9G 14G 13% /var/lib/docker</em></strong><em><br>tmpfs 1.6G 0 1.6G 0% /run/user/1000</em></pre><h3>Step five, resize logical volume</h3><p>Because we still have to resize logical volume by running lvresize to grow 100%</p><pre><strong>sudo lvresize -l +100%FREE /dev/mapper/docker — vol-dockerlv&#39;</strong></pre><pre> Size of logical volume docker-vol/dockerlv changed<strong> from &lt;15.00</strong> GiB (3839 extents) to<strong> 39.99 GiB</strong> (10238 extents).<br> Logical volume docker-vol/dockerlv successfully resized.</pre><h3>Step six, grow the file system</h3><p>After resizing logical volume , now we need to grow the file-system, using either xfs_growxfs or resize2fs , depending on your underlying filesystem.</p><pre><strong>sudo xfs_growfs /dev/mapper/docker — vol-dockerlv</strong></pre><pre><em>meta-data=/dev/mapper/docker--vol-dockerlv isize=512    agcount=4, agsize=982784 blks<br>         =                       sectsz=512   attr=2, projid32bit=1<br>         =                       crc=1        finobt=0 spinodes=0<br>data     =                       bsize=4096   blocks=3931136, imaxpct=25<br>         =                       sunit=0      swidth=0 blks<br>naming   =version 2              bsize=4096   ascii-ci=0 ftype=1<br>log      =internal               bsize=4096   blocks=2560, version=2<br>         =                       sectsz=512   sunit=0 blks, lazy-count=1<br>realtime =none                   extsz=4096   blocks=0, rtextents=0<br>data blocks changed from 3931136 to 10483712</em></pre><p>Now running df-h, you should see the docuker volume is fully grown to 40GiB</p><pre><strong>df -h</strong><br><em>Filesystem Size Used Avail Use% Mounted on<br>/dev/vda1 30G 13G 18G 43% /<br>devtmpfs 7.8G 0 7.8G 0% /dev<br>tmpfs 7.8G 0 7.8G 0% /dev/shm<br>tmpfs 7.8G 1.4M 7.8G 1% /run<br>tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup<br></em><strong><em>/dev/mapper/docker — vol-dockerlv 40G 1.9G 39G 5% /var/lib/docker</em></strong><em><br>tmpfs 1.6G 0 1.6G 0% /run/user/1000</em></pre><p>That’s all folks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddb6a4293944" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Export data from Prometheus to CSV]]></title>
            <link>https://medium.com/@aneeshputtur/export-data-from-prometheus-to-csv-b19689d780aa?source=rss-440a3200dc17------2</link>
            <guid isPermaLink="false">https://medium.com/p/b19689d780aa</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[prometheus]]></category>
            <dc:creator><![CDATA[Aneesh Puttur]]></dc:creator>
            <pubDate>Wed, 13 Jun 2018 14:30:21 GMT</pubDate>
            <atom:updated>2019-05-29T19:07:13.115Z</atom:updated>
            <content:encoded><![CDATA[<p>We can query Prometheus data via API. for an example to query data for metric named CPU, you can use following API</p><p><a href="http://prom_server:9090/api/v1/query?query=cpu"><em>http://prom_server:9090/api/v1/query?query=cpu</em></a></p><p>or if you need data for past 1 hour then add filters like [1h] or [1m] etc.</p><p><a href="http://prom_server:9090/api/v1/query?query=cpu[1h]"><em>http://prom_server:9090/api/v1/query?query=cpu[1h]</em></a></p><p>sample output</p><p>{&quot;status&quot;:&quot;success&quot;,&quot;data&quot;:{&quot;resultType&quot;:&quot;vector&quot;,&quot;result&quot;:[{&quot;metric&quot;:{&quot;__name__&quot;:&quot;collectd_cpu&quot;,&quot;cpu&quot;:&quot;0&quot;,&quot;instance&quot;:&quot;overcloud-cephstorage-0.localdomain&quot;,&quot;job&quot;:&quot;collectd&quot;,&quot;service&quot;:&quot;idle&quot;},&quot;value&quot;:[1528895820.304,&quot;2033227691&quot;]},</p><p>Now this is very tedious job if we have 100&#39;s of metrics and if need to go over each metric names and query them individually and export to a file .So I used a python script based on Robust Perception blog on query result as CSV.</p><p><a href="https://www.robustperception.io/prometheus-query-results-as-csv/">Prometheus query results as CSV</a></p><p>and modified the script to query all metric names and then query individual metrics with this list of metric names and save to a file. Now, this can be run as a cron job configured to run hourly. The python script will get last 1 hours of data and put it in an archive file.</p><p><strong>python prom_csv.py </strong><a href="http://prom_server:9090/"><strong>http://prom_server:9090</strong></a><strong> | gzip &gt; $(date +&quot;%Y_%m_%d_%I_%M_%p&quot;)_metrics.gz</strong></p><p><strong>Python Script</strong></p><pre><em>import csv<br>import requests<br>import sys<br>def GetMetrixNames(url):<br>    response = requests.get(&#39;{0}/api/v1/label/__name__/values&#39;.format(url))<br>    names = response.json()[&#39;data&#39;]</em></pre><pre><em>    #Return metrix names<br>    return names<br></em></pre><pre><em>&quot;&quot;&quot;<br>Prometheus hourly data as csv.<br>&quot;&quot;&quot;<br>writer = csv.writer(sys.stdout)</em></pre><pre><em>if len(sys.argv) != 2:<br>    print(&#39;Usage: {0} </em><a href="http://localhost:9090&#39;.format(sys.argv[0]))"><em>http://localhost:9090&#39;.format(sys.argv[0]))</em></a><em><br>    sys.exit(1)<br>metrixNames=GetMetrixNames(sys.argv[1])</em></pre><pre><em>writeHeader=True<br>for metrixName in metrixNames:<br>     #now its hardcoded for hourly<br>     response = requests.get(&#39;{0}/api/v1/query&#39;.format(sys.argv[1]),<br>      params={&#39;query&#39;: </em>metrixName<em>+&#39;[1h]&#39;})<br>      results = response.json()[&#39;data&#39;][&#39;result&#39;]<br>      # Build a list of all labelnames used.<br>      #gets all keys and discard __name__<br>      labelnames = set()<br>      for result in results:<br>          labelnames.update(result[&#39;metric&#39;].keys())<br>      # Canonicalize<br>      labelnames.discard(&#39;__name__&#39;)<br>      labelnames = sorted(labelnames)<br>      # Write the samples.<br>      if writeHeader:<br>          writer.writerow([&#39;name&#39;, &#39;timestamp&#39;, &#39;value&#39;] + labelnames)<br>          writeHeader=False<br>      for result in results:<br>          l = [result[&#39;metric&#39;].get(&#39;__name__&#39;, &#39;&#39;)] + result[&#39;values&#39;]<br>          for label in labelnames:<br>              l.append(result[&#39;metric&#39;].get(label, &#39;&#39;))<br>              writer.writerow(l)</em></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b19689d780aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Benchmark Kafka Messaging Queue Latency]]></title>
            <link>https://medium.com/@aneeshputtur/benchmark-kafka-messaging-queue-latency-931f3e24e860?source=rss-440a3200dc17------2</link>
            <guid isPermaLink="false">https://medium.com/p/931f3e24e860</guid>
            <category><![CDATA[messaging]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Aneesh Puttur]]></dc:creator>
            <pubDate>Mon, 13 Nov 2017 14:13:36 GMT</pubDate>
            <atom:updated>2017-11-13T14:13:36.638Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="http://aneeshputtur.blogspot.com/2017/11/benchmarking-kafka-for-nfv-work.html"><strong>http://aneeshputtur.blogspot.com/2017/11/benchmarking-kafka-for-nfv-work.html</strong></a></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=931f3e24e860" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Containers based openstack overcloud deploy with RDO registry]]></title>
            <link>https://medium.com/@aneeshputtur/containers-based-openstack-overcloud-deploy-with-rdo-registry-79338c7e51bf?source=rss-440a3200dc17------2</link>
            <guid isPermaLink="false">https://medium.com/p/79338c7e51bf</guid>
            <category><![CDATA[nfv]]></category>
            <category><![CDATA[tripleo]]></category>
            <category><![CDATA[rdo]]></category>
            <category><![CDATA[openstack]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Aneesh Puttur]]></dc:creator>
            <pubDate>Mon, 13 Nov 2017 14:07:57 GMT</pubDate>
            <atom:updated>2017-11-13T14:07:57.647Z</atom:updated>
            <content:encoded><![CDATA[<p>I was trying to deploy Containers based openstack overcloud by following this document<a href="https://docs.openstack.org/tripleo-docs/latest/install/containers_deployment/overcloud.html"> https://docs.openstack.org/tripleo-docs/latest/install/containers_deployment/overcloud.html</a> and found out I couldn’t get conatiners images from RDO registry with tag mentioned in the document.</p><p>The document shows how to copy pre-built images from rdoproject registry to the local repository.</p><pre>openstack overcloud container image prepare \<br>  --namespace trunk.registry.rdoproject.org/master \<br>  --tag tripleo-ci-testing \<br>  --push-destination 192.168.24.1:8787 \<br>  --output-images-file overcloud_containers.yaml</pre><p>If you try to follow the above steps, it will create overcloud_containers but when you actually use the file to deploy will result in 404 error</p><pre>docker pull failed: Error: image master/centos-binary-aodh-api:tripleo-passed-ci not found<br>retrying pulling image: <a href="http://trunk.registry.rdoproject.org/master/centos-binary-aodh-api">trunk.registry.rdoproject.org/master/centos-binary-aodh-api</a><br>docker pull failed: Error: image master/centos-binary-aodh-api:tripleo-passed-ci not found<br>retrying pulling image: <a href="http://trunk.registry.rdoproject.org/master/centos-binary-aodh-api">trunk.registry.rdoproject.org/master/centos-binary-aodh-api</a><br>docker pull failed: Error: image master/centos-binary-aodh-api:tripleo-passed-ci not found</pre><p>This is because the tag used is invalid outside CI environment.</p><p>The short term solution for this is to get the hash from last passed-ci RDO trunk and use it as tag</p><p>Step 1. get the has tag</p><p>$ python -c ‘import urllib2;import \</p><p>yaml;c=yaml.load(urllib2.urlopen(“<a href="https://trunk.rdoproject.org/centos7-master/current-tripleo/commit.yaml">https://trunk.rdoproject.org/centos7-master/current-tripleo/commit.yaml</a>&quot;)) \</p><p>[“commits”][0];print “%s_%s” % (c[“commit_hash”],c[“distro_hash”][0:8])’</p><p>This will return hash tag 3b85715c6488a692fcdf4e4c6a589d77c60eb5a6_a3792c8d</p><p># a quick test that container image is there:</p><p>$ skopeo inspect docker://<a href="http://trunk.registry.rdoproject.org/master/centos-binary-nova-api:3b85715c6488a692fcdf4e4c6a589d77c60eb5a6_a3792c8d">trunk.registry.rdoproject.org/master/centos-binary-nova-api:3b85715c6488a692fcdf4e4c6a589d77c60eb5a6_a3792c8d</a></p><p>Now use it to populate overcloud_conatiners.yaml</p><pre>openstack overcloud container image prepare \<br>  --namespace trunk.registry.rdoproject.org/master \<br>  --tag 3b85715c6488a692fcdf4e4c6a589d77c60eb5a6_a3792c8d \<br>  --push-destination 172.16.0.1:8787 \<br>  --output-images-file overcloud_containers.yaml</pre><p>Then upload the images to the local registry using the generated file:</p><pre>openstack overcloud container image upload --config-file overcloud_containers.yaml</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79338c7e51bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>