<?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 Shashank Joshi on Medium]]></title>
        <description><![CDATA[Stories by Shashank Joshi on Medium]]></description>
        <link>https://medium.com/@shashank.joshi?source=rss-bddd930bf9e6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DvLQ-s2maW0HEpZ-p60cxw.jpeg</url>
            <title>Stories by Shashank Joshi on Medium</title>
            <link>https://medium.com/@shashank.joshi?source=rss-bddd930bf9e6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 01:56:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shashank.joshi/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[Beyond Lift and Shift: Why Application-Centric Migration Strategy Works Better]]></title>
            <link>https://medium.com/@shashank.joshi/beyond-lift-and-shift-why-application-centric-migration-strategy-works-better-f9c265b8defc?source=rss-bddd930bf9e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9c265b8defc</guid>
            <category><![CDATA[application-modernization]]></category>
            <category><![CDATA[cloud-strategy]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud-migration]]></category>
            <dc:creator><![CDATA[Shashank Joshi]]></dc:creator>
            <pubDate>Tue, 04 Feb 2025 04:25:11 GMT</pubDate>
            <atom:updated>2025-02-12T21:49:01.213Z</atom:updated>
            <content:encoded><![CDATA[<p>Earlier we explored the shortcomings of a VM-centric migration strategy [<a href="https://medium.com/p/789c62cd9e34"><em>Beyond Lift and Shift: Why a VM-Centric Cloud Migration Strategy Falls Short</em></a>], Now let’s look at the application-centric migration approach.</p><h4>Understanding Application-Centric Migration Approach</h4><p>In application-centric approach, an “application”* is treated as the primary unit of migration estimation, planning and execution. To follow an application-centric approach, you need to identify common architecture patterns within your portfolio, come-up with dispositions and migration patterns for each. You then use this information to make estimations, migration schedules and detailed wave/sprint plans.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DbdWkaiErOlmU4Q6OB_a5w.jpeg" /><figcaption>Image Credit: Gemini</figcaption></figure><h4>Adopting Application-Centric Migration Approach</h4><p>Now let’s look at how can you adopt an application-centric migration approach:</p><ul><li><strong>Elevate discovery &amp; analysis:</strong> With an application-centric approach, you don’t have to distill everything down to VM/server level. This lets you plan for diverse technologies. So, in addition to infrastructure discovery; utilize application discovery tooling, application data repositories and application discovery/interview sessions.</li><li><strong>Analyze discovery data with application lens:</strong> Use discovery data to identify “Architecture Patterns” (you may have many applications, but you will likely have fewer unique architecture patterns). Identify architecture patterns that are repeated/reused across multiple apps. Define the target state (“Disposition”) and migration approach (“Migration Pattern”) for each Architecture Pattern. (<em>Note, these terms are flexible. Use what works for you and your organization. </em>)</li><li><strong>Create realistic estimations and plans:</strong> As there is no false sense of uniformity across all your applications, the teams will have to put more thought and effort in discovery, analysis, estimation and planning resulting in realistic estimations and plans. You should still be able to achieve standardization and repeatability by defining different categories of applications based on complexity, business criticality, complexity of the migration patterns and so on.</li><li><strong>Simplify project &amp; program management:</strong> Most applications have well-defined project management practices for their own application lifecycle management outside the migration event. With an application-centric approach you can leverage the already functioning application-level project management practices for migration activities. This allows for lower complexity, greater flexibility and better assessment of program management effort.</li><li><strong>Align incentives and priorities:</strong> Organizations are structured around business and functions, which map to applications, and not to servers or infrastructure. With an application-centric approach, application and business teams will be able to influence dispositions and migration patterns for their applications to have better alignment with their KPIs. They will also have “skin in the game” to make the migration a success.</li></ul><h4>Additional Considerations</h4><ul><li><strong>Technical Debt and Fragmentation:</strong> VM-centric migration may not address technical debt, simply transferring servers to the cloud environment. An application-centric approach provides an opportunity to address technical debt by highlighting possible dispositions and migration patterns for older stacks and their relative costs &amp; benefits. It also provides an opportunity to standardize on a limited number of architecture patterns, thereby reducing fragmentation.</li><li><strong>Scale of modernization:</strong> Cloud migration presents an opportunity to modernize applications and leverage cloud-native features such as serverless computing, containers, and managed services. Unlike VM-centric approach, with an application-centric approach you can consider more possible dispositions and migration patterns and make informed decisions on the scale of modernization per architecture pattern based on the cost-benefit analysis.</li><li><strong>Clarity on ROI:</strong> In some cases, a VM-centric lift-and-shift migration may not deliver the expected return on investment. In the application-centric migration approach, informed decisions are made on the cost and benefit of various modernization options. For some applications, the benefit of modernization may not justify the cost, so you move those apps as they are, for others you will be able to decide the extent of modernization to justify the potential benefit. Either way you will have better clarity on the ROI with this approach.</li><li><strong>“Platforms”, “Services” and other special cases:</strong> There are systems that are not traditional applications. “Platforms” such as API management or Container management platforms. “Services” or microservices such as message bus, authentication, caching and so on. “Special Cases” such as infrastructure (e.g. active directory, shared storage, tooling) and data &amp; analytics services (e.g. data warehouses, ETL pipelines, reporting systems). These services are often difficult to address using a VM-centric approach, as there is no direct mapping between these services and VMs. However, an application-centric approach can be used to address them appropriately.</li></ul><h4>Things to watch out for</h4><ul><li><strong>Analysis paralysis:</strong> There is a possibility of unnecessary complexity in defining and applying different dispositions and migration patterns. Use permissible but clear criteria to avoid analysis paralysis</li><li><strong>Decentralized program execution:</strong> Application-centric migration tends to be more decentralized from the project/program management perspective. If your organization is not used to such a paradigm, make sure your teams are prepared</li><li><strong>Time-constrained migrations:</strong> There can be situations with external constraints (such as expiring contracts, data center exits, mergers etc.). Do a quick due diligence to make sure an application-centric approach will meet your timeline</li></ul><h4>Conclusion</h4><p>In summary, an application-centric approach provides a more strategic and effective approach to cloud migration than a VM-centric strategy. With this approach organizations can better account for diverse technologies, align with existing business structures, and make informed decisions about modernization and ROI. While careful planning is crucial to avoid some potential pitfalls, the application-centric strategy ultimately enables a smoother, more successful cloud migration that addresses technical debt, leverages cloud-native capabilities, and maximizes the value of cloud investments.</p><h4>What Next?</h4><p>I’d love to hear your thoughts on this application-centric migration approach. Have you encountered similar challenges with VM-centric migrations? What are your experiences with application-focused strategies? Share your insights and feedback in the comments below.</p><p><strong>Notes:</strong></p><p>*Defining what an application is, and is not, is beyond the scope of this post, but most technologists in big and small organizations intuitively understand what an application is. Most organizations will also have some kind of an application repository where each application has some kind of an “app ID” and other details.</p><p><strong>Disclaimer:</strong> The views and opinions expressed in this article are solely my own and do not necessarily represent those of my employer or any other organization with which I am affiliated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9c265b8defc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Lift and Shift: Why a VM-Centric Cloud Migration Strategy Falls Short]]></title>
            <link>https://medium.com/@shashank.joshi/beyond-lift-and-shift-why-a-vm-centric-cloud-migration-strategy-falls-short-789c62cd9e34?source=rss-bddd930bf9e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/789c62cd9e34</guid>
            <category><![CDATA[cloud-migration-strategy]]></category>
            <category><![CDATA[cloud-migration]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Shashank Joshi]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 03:35:17 GMT</pubDate>
            <atom:updated>2025-02-12T21:47:48.218Z</atom:updated>
            <content:encoded><![CDATA[<p>Migrating existing applications and services to cloud has been the primary way for businesses aiming to harness its scalability, agility, and cost-efficiency benefits. When choosing a migration strategy, a VM-centric approach is often considered due to its perceived simplicity and speed. However, this approach may not always be the most effective path to achieve your cloud goals. In this post, I will delve into the drawbacks of the VM-centric migration approach, and in a subsequent post, explore why a more application-centric strategy might be the key to unlocking the full potential of the cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZZBx1vR-HJo4UXiEgXBqA.png" /><figcaption>Image Credit: Gemini</figcaption></figure><h4>Understanding VM-Centric Migration Approach</h4><p>In a VM-centric migration approach, Virtual Machines (VMs)* are treated as the primary units of migration estimation, planning and execution. This approach is also known as “lift-and-shift” or “Rehost”. This technique focuses on the number of servers; and the time and resources needed to move them. It then uses this information to make migration schedules and detailed wave/sprint plans. The models even go further to estimate what is called the “<em>per VM migration cost</em>” as a measure of benchmarking or comparing competing proposals. While this may seem straightforward, it overlooks the complexities of modern application environments and can lead to several challenges.</p><h4>Challenges of VM-Centric Migration</h4><ol><li><strong>Diverse Technology Platforms:</strong> Today’s data centers and cloud environments house a wide variety of technologies, including different hardware &amp; software platforms, databases, data &amp; analytics systems and numerous tools. A VM-centric approach often fails to account for these diverse components, potentially leading to unforeseen challenges and delays during migration.</li><li><strong>False Sense of Repeatability and “<em>Velocity</em>”:</strong> One of the key selling points of the VM-Centric approach is that you can achieve a “<em>factory-style</em>” maturity in migration because migration tasks are assumed to be repeatable, and effort predictable. While VMs may appear similar, each application has unique dependencies and requirements. Another underappreciated fact is; <em>a lot</em> needs to happen before (and after) the actual “<em>movement</em>” of a VM. This makes it difficult to achieve a true “<em>factory-style</em>” migration process.</li><li><strong>Underestimation of Technical Complexity:</strong> The focus on VMs often leads to an underestimation of the technical complexity involved in migration. Because the focus is on migrating VMs; factors such as landing zone, networking, security, operational readiness, shared services, and required application changes are often overlooked, resulting in inaccurate timelines and resource estimations.</li><li><strong>Underestimation of Project/Program Management Complexity: </strong>When migrating VMs, it’s easy to think that since you’re just moving virtual machines, you’ll mostly need to coordinate with the infrastructure teams and will have limited touch-points with other teams. In reality though, migration affects <em>many</em> (if not, most) teams and departments, making effective coordination and communication much more complex. This requires a more structured project management approach than you might initially expect.</li><li><strong>Misalignment with Organizational Structures &amp; Incentives:</strong> Organizations are structured around business and technology functions, which map to applications, and not to servers or infrastructure. A VM-centric approach can create misalignment with these structures, making it difficult to engage application teams and demonstrate the value of migration to the business.</li></ol><h4>Additional Considerations</h4><ol><li><strong>Technical Debt and Fragmentation:</strong> Many organizations carry technical debt in the form of dated hardware, software, and architectures. A VM-centric migration may not address these issues, simply transferring them to the cloud environment.</li><li><strong>Missed Opportunities for Modernization:</strong> Cloud migration presents an opportunity to modernize applications and leverage cloud-native features such as serverless computing, containers, and managed services. When following a VM-centric approach you may miss identifying such opportunities, limiting the potential benefits of the cloud.</li><li><strong>Uncertain ROI:</strong> In some cases, a VM-centric lift-and-shift migration may not deliver the expected return on investment. The costs of migration and ongoing cloud expenses may outweigh the marginal improvements in performance and reliability.</li></ol><h4>When VM-Centric Migration Might Be Suitable</h4><p>While VM-centric migration has its limitations, there are scenarios where it can be a viable option. For example:</p><ul><li>When there is a broader transformation roadmap involving “<em>migrate first and transform later</em>”</li><li>When there is no business case for modernization — Apps that are nearing end of life, low value apps and so on</li><li>Situations with external constraints (such as expiring contracts or data center closures, mergers &amp; divestitures and so on)</li></ul><h4>Conclusion</h4><p>While VM-centric migration can be a quick way to move applications to the cloud, it’s essential to consider its limitations. A more application-centric approach, focusing on modernization and optimization, can unlock the full potential of the cloud and deliver greater value to your organization. Remember, cloud migration is not just about moving VMs; it’s about transforming your applications and IT infrastructure for the future. By adopting a holistic approach that considers the unique needs of your applications and leverages cloud-native services, you can achieve a more successful and impactful cloud migration journey.</p><h4>What Next?</h4><p>We explored the limitations of the VM-centric migration approach in this post. Please share your thoughts, experiences, and perspectives on cloud migration strategies in the comments below. Have you encountered similar challenges in your own cloud journey? How did you address them? What did you learn from them?</p><p><strong>Notes:</strong><br>* I have used the words “VM” and “Server” interchangeably. In the on-prem world there can be physical as well as virtual machines, but when migrated to public clouds they <em>usually</em> land-up as VMs. Hyperscalers may provide some limited ability to move and host physical servers, but it’s more of an exception than a norm.</p><p><strong>Disclaimer:</strong> The views and opinions expressed in this article are solely my own and do not necessarily represent those of my employer or any other organization with which I am affiliated.</p><p><em>A follow-up post </em><a href="https://medium.com/p/f9c265b8defc"><strong><em>Beyond Lift and Shift: Why Application-Centric Migration Strategy Works Better</em></strong></a><strong><em> </em></strong><em>is now published covering what migration approach you can adopt instead, to increase the probability of success and also improve the overall experience for everyone involved.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=789c62cd9e34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using gcloud and Python Client Library with Google Compute Engine]]></title>
            <link>https://medium.com/google-cloud/using-gcloud-and-python-client-library-with-google-compute-engine-eaf1b19d8099?source=rss-bddd930bf9e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaf1b19d8099</guid>
            <category><![CDATA[python-client-library]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[google-cloud-sdk]]></category>
            <category><![CDATA[google-compute-engine]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Shashank Joshi]]></dc:creator>
            <pubDate>Mon, 16 Jul 2018 20:32:13 GMT</pubDate>
            <atom:updated>2023-04-17T16:02:32.301Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ivFJZZ1S4GuklgKyy-lGww.png" /></figure><p>In my earlier post (<a href="https://medium.com/google-cloud/using-gcloud-to-get-google-cloud-platform-data-you-need-c4985b416278">Using gcloud to get Google Cloud Platform data you need</a>) we looked at how we can use gcloud by itself and with bash scripts to get the Google Cloud Platform data you need. Even though that is useful when you want to quickly get something working, using a higher level language such as Python gives you far greater flexibility, functionality and ease of development &amp; maintenance. In this post I am using Python in two ways. First is using gcloud within a Python script and second is using the Python Client Library provided by Google. All the examples in this post and more are available at <a href="https://github.com/shashyajoshi/code-samples"><strong>https://github.com/shashyajoshi/code-samples</strong></a></p><h4>Example 1: Get instance labels and metadata using gcloud &amp; Python</h4><p>In the <a href="https://medium.com/google-cloud/using-gcloud-to-get-google-cloud-platform-data-you-need-c4985b416278">earlier post</a> we looked at how you can get the instance labels and metadata using gcloud with bash scripting. Here is the approach for using gcloud with Python to get the instance labels and metadata:</p><ul><li>Use subprocess module to execute gcloud command (You can use shlex to convert gcloud command to the format required by subprocess module)</li><li>Get the JSON formatted data returned by gcloud in a variable</li><li>Process the data as you want</li></ul><p>The flow is like this:</p><ul><li>Get a list of all projects</li><li>Use the individual project IDs to get a list of instances and other details</li><li>Parse through the required fields using the JSON structure (For example, instance_row[“name”], instance_row[“labels”][“app-name”] and so on. Instance metadata is a nested field, so it will need further processing)</li><li>In my example I am getting all of that data and adding it to a list for printing it to stdout later.</li></ul><p>The complete example script is available here: <br><a href="https://github.com/shashyajoshi/code-samples/blob/master/gcloud-python/get_instance_data_gcloud.py"><strong>code-samples/gcloud-python/get_instance_data_gcloud.py</strong></a></p><h4>Example 2: Get instance labels and metadata using Python Client Library</h4><p>The key thing you will realize when using Python Client Library, as against using gcloud is that, gcloud does a lot of heavy lifting for you. So when you use Client Library you have more things to think about and do yourself. Here is the approach I am taking for using Python Client Library:</p><ul><li>Use application default credentials</li><li>Execute a set of API calls to get the data</li><li>Process the JSON formatted output as required</li></ul><p>The flow is as follows:</p><ul><li>Get billing accounts using <a href="https://developers.google.com/resources/api-libraries/documentation/cloudbilling/v1/python/latest/cloudbilling_v1.billingAccounts.html#list">Cloud Billing API . billingAccounts . list</a> (in order to get the project list using the API, you need to get the billing ID first). If you know the billing account you can skip this step and pass it on as a command-line argument.</li><li>Get a list of all projects for the billing ID using <a href="https://developers.google.com/resources/api-libraries/documentation/cloudbilling/v1/python/latest/cloudbilling_v1.billingAccounts.projects.html#list">Cloud Billing API . billingAccounts . projects . list</a></li><li>In order to get the instance data for each of the projects, you first need to get the <em>zones </em>using <a href="https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.zones.html#list">Compute Engine API . zones . list</a></li><li>Get the instance details for every zone using <a href="https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.instances.html#list">Compute Engine API . instances . list</a></li><li>For every zone that contains instances, parse through the required fields using the JSON structure (For example, instance_row[“name”], instance_row[“labels”][“app-name”] and so on. Instance metadata is a nested field, so it will need further processing)</li><li>In my example I am getting all of that data and adding it to a list for printing it to stdout</li></ul><p>The complete example script is available here: <br><a href="https://github.com/shashyajoshi/code-samples/blob/master/python-client-library/get_instance_data_api.py"><strong>code-samples/python-client-library/get_instance_data_api.py</strong></a> The output is exactly same as example 1 above.</p><h3>Apply the learning to other use cases</h3><p>Now with this knowledge, you can automate different operations. The approach you can adopt is as follows:</p><ul><li>Research the <a href="https://cloud.google.com/sdk/gcloud/reference/">gcloud documentation</a> or the <a href="https://developers.google.com/api-client-library/python/apis/">API documentation</a> required for your use-case</li><li>Understand the prerequisites/mandatory fields and research on them first</li><li>Understand the output structure for processing the output as required</li></ul><p>Let’s look at a couple more examples:</p><h4>Example 3: Start/stop instances based on label values</h4><p>You may want to start and stop a set of instances based on labels. You may have a bunch of dev environments that you want to shutdown at the end of every working day or before a long-weekend. The flow is similar to the earlier examples:</p><ul><li>Get the list of projects</li><li>Get the list of instances and check the label key/values for a match with the required values</li><li>If matched, execute the action (start or stop) on the instances (the instance action commands need the instance zone as well, so you need to capture that from the instance data output)</li></ul><p>The complete example script is available here: <br>(gcloud Python) <a href="https://github.com/shashyajoshi/code-samples/blob/master/gcloud-python/start_stop_instances_labels_gcloud.py"><strong>code-samples/gcloud-python/start_stop_instances_labels_gcloud.py</strong></a></p><p>(Python Client Library) <a href="https://github.com/shashyajoshi/code-samples/blob/master/python-client-library/start_stop_instances_labels_api.py"><strong>code-samples/python-client-library/start_stop_instances_labels_api.py</strong></a></p><p>The sample output of the script is given below for label_key=”env-name”, label_value=”non-prod” and instance_action= stop</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c94df49bacd5b676a5d15fcabbe4b005/href">https://medium.com/media/c94df49bacd5b676a5d15fcabbe4b005/href</a></iframe><h4>Example 4: Delete unattached disks based on labels</h4><p>In the last post you saw how you can find out the orphaned or unattached disks. Similar to instances, you can add labels to persistent disks. For example, you can add a label for delete-protection to important disks.</p><p>The flow is similar to earlier examples:</p><ul><li>Get the list of projects</li><li>Get the list of disks and check if it is attached to any instance</li><li>If not, check the label key/values for a match with the required values</li><li>If matched, execute the action (delete) on the disk (the disk action command needs the disk zone as well, so you need to capture that from the disk data output)</li></ul><p>The complete example script is available here: <br><a href="https://github.com/shashyajoshi/code-samples/blob/master/gcloud-python/delete_unattached_disks_gcloud.py"><strong>code-samples/gcloud-python/ delete_unattached_disks_gcloud.py</strong></a> <br>The sample output of the script is given below for label_key=”delete-protect” and label_value=”no”</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e86a8e4fda6b091fcee96129cb26ef73/href">https://medium.com/media/e86a8e4fda6b091fcee96129cb26ef73/href</a></iframe><h4>Disclaimers and other important points</h4><ul><li>The examples here will probably not work in your environment as-is. For example, the label key and values used here should be changed as per your labeling strategy. My advice would be to read and understand the code first and then modify it to fit your environment.</li><li>Completeness — The example scripts are provided to serve as an example of using gcloud and the Python Client Library. They are in no way complete solutions in themselves.</li><li>Coding best practices — In real-world deployment you should think about coding best practices, such as, error checking/handling, functionality to check and wait for actions to complete, log/print meaningful messages and so on.</li></ul><h3>References and further reading</h3><p>These are just a few of many possible ways you can use gcloud and Python Client Library to get the data, or perform certain actions based on the data, from Google Cloud Platform. I hope these examples provide you a high level idea on how to do it. Refer to following links for more details:</p><ul><li><a href="https://developers.google.com/api-client-library/python/apis/">https://developers.google.com/api-client-library/python/apis/</a></li><li><a href="https://github.com/GoogleCloudPlatform/python-docs-samples">https://github.com/GoogleCloudPlatform/python-docs-samples</a></li><li><a href="https://cloud.google.com/compute/docs/tutorials/python-guide">https://cloud.google.com/compute/docs/tutorials/python-guide</a></li><li><a href="https://cloud.google.com/sdk/gcloud/reference/">https://cloud.google.com/sdk/gcloud/reference/</a></li></ul><p>Let me know what you think and how you use gcloud and Python Client Library in your environment.</p><p>(Disclaimer: Views expressed here are my own. Information is provided “as-is”.)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaf1b19d8099" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/using-gcloud-and-python-client-library-with-google-compute-engine-eaf1b19d8099">Using gcloud and Python Client Library with Google Compute Engine</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using gcloud to get Google Cloud Platform data you need]]></title>
            <link>https://medium.com/google-cloud/using-gcloud-to-get-google-cloud-platform-data-you-need-c4985b416278?source=rss-bddd930bf9e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4985b416278</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[google-cloud-sdk]]></category>
            <category><![CDATA[reporting]]></category>
            <dc:creator><![CDATA[Shashank Joshi]]></dc:creator>
            <pubDate>Wed, 04 Jul 2018 06:12:07 GMT</pubDate>
            <atom:updated>2018-07-16T21:55:16.978Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*98d3woelrazYb36SvXQ3cQ.png" /></figure><p>As you move from simple to advanced use-cases on Google Cloud Platform, and as your environment gets bigger and more complex, you need to move beyond the basic ways of interacting with Google Cloud services. gcloud is a powerful tool provided by Google Cloud SDK that can get you quickly up and running. Using some real-life examples I will demonstrate how you can use gcloud and scripting to extract various data-items from Google Cloud Platform for automation and reporting purposes.</p><h4>Collect project data</h4><p>Projects is one of the most fundamental features of Google Cloud Platform. Projects are used to distribute cloud resources across various teams, applications, environments and so on. You can assign custom labels to projects which can help tremendously in reporting, tracking and resource management. You should definitely have a robust labeling strategy and labeling standards for all of your GCP resources including projects.</p><h4>Example 1: Collect project labels</h4><p>Now let’s say you have many projects in your environment and you want to extract their labels data. You may need that for Reporting (standards-compliance reports, cost allocation reports to name a few. You would use labels such as owner, business unit, billing ID and so on) and Automation (perform certain automation activities on a subset of resources. You would use labels such as environment, app-name and so on)</p><p>Depending on your data processing and reporting requirements, you will need to extract only specific data-points and convert them into a format suitable for your setup. I am considering CSV format here, which is fairly simple to ingest into storage options such as BigQuery, ElasticSearch and so on, or can simply be examined with the help of spreadsheets.</p><p>Now let’s look at the information provided by gcloud about projects. It is always good to check the JSON format output first, as that will clearly show various field-names and the structure. Here is a sample output of the gcloud projects list command:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc874a3cc99c8393e6d34f8c66cf3496/href">https://medium.com/media/bc874a3cc99c8393e6d34f8c66cf3496/href</a></iframe><p>Let’s say you want project ID, project name and the labels in CSV format and don’t need fields such as creation time, project number etc. Looking at the output, you should identify the fields you want and how they are structured. Considering our requirement, here are two sample commands:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0675aa4f052effbb97187a6da8cc5ab7/href">https://medium.com/media/0675aa4f052effbb97187a6da8cc5ab7/href</a></iframe><p>In option 1, you get the comma-separated header row and then corresponding values from the output. And because labels is a nested field (as evident from the JSON output above), you get all of the label values in one field of CSV, separated by semicolon. Depending on your data processing pipeline, that may or may not be appropriate. So you may want to go for specific labels as shown in option 2.</p><p>Also you have to be careful to use the right field name from the JSON output. For example, if you use projectid instead of projectId you will not get the expected output.</p><h4>Collect instance data</h4><p>Instances support labels as well as metadata that can be useful for reporting, tracking and automation. We saw how labels can be used in the context of projects. Same is applicable in case of instances. You can be more granular with labels specific to instances such as, app-tier, technology-stack and so on. Instance metadata can play a crucial role in the overall automation solution for managing your instances. For example, having custom metadata such as server-role or server-type can be useful for your configuration management tools. Custom metadata such as environment, patching window and so on can help you write effective automation scripts.</p><p>Let’s take a look at what data is provided by the platform for instances:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/790ba597274fe9d59fb26cd48e1a17e7/href">https://medium.com/media/790ba597274fe9d59fb26cd48e1a17e7/href</a></iframe><p>Again, checking the JSON format output helps you clearly understand the fields and structure.</p><h4>Example 2: Collect instance labels and metadata</h4><p>Let’s say we want to capture specific label values and metadata values for reporting. Here is one example command and output</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66e9ff2b0c12832ca73677ba2270c27b/href">https://medium.com/media/66e9ff2b0c12832ca73677ba2270c27b/href</a></iframe><p>What is not immediately evident here is that the list of instances is only from the <em>current </em>project. If you want to see the instance details from another project, you need to use --project flag. But in a real-life environment you will have tens or hundreds of projects, and hence using --project flag every time will not be very efficient. You can use a simple shell script to first get the list of all projects and then loop through the list to get instance details from each project. Here is how it looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43382091409359146687892edfa1ac56/href">https://medium.com/media/43382091409359146687892edfa1ac56/href</a></iframe><p>The sample output is given below. As you can see, you get details for instances from all projects (in this case, three different projects) and not just one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6c9e3ca1897d114a96d326d763aa09a/href">https://medium.com/media/f6c9e3ca1897d114a96d326d763aa09a/href</a></iframe><h4>Example 3: Collect instance OS license data</h4><p>Another interesting use-case for instance data is getting what OS image is used. This will have direct impact on your monthly bill. You would want to know how many instances are using free vs paid OS images. The script below gets that data using disks.licenses field:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89a6720a4b4f4f508b46eda47a1a2c83/href">https://medium.com/media/89a6720a4b4f4f508b46eda47a1a2c83/href</a></iframe><p>Sample output is shown below. As you can see, there is one rhel-7 image and rest are CentOS</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10c795cb0bb997bd930d187bf1cb19ed/href">https://medium.com/media/10c795cb0bb997bd930d187bf1cb19ed/href</a></iframe><h4>Example 4: Find orphaned disks</h4><p>Another important use-case is to find out how many orphaned, i.e. not attached to any server, disks you have. If you don’t delete the disks you no longer use, you will keep on paying for those. In a big environment, the costs can quickly add up. The script below gets the details using gcloud compute disks list command and the users field.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cf6d41d21e636f661c0640037674212/href">https://medium.com/media/9cf6d41d21e636f661c0640037674212/href</a></iframe><p>Sample output is shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b79591f90917b02fa889e8b8e8910b14/href">https://medium.com/media/b79591f90917b02fa889e8b8e8910b14/href</a></iframe><p>As you can see the disk orphan-disk-1 and orphan-disk-2 don’t have any user. That means they are not attached to any server.</p><h4>References and further reading</h4><p>These are just a few of many possible ways you can use gcloud with scripting to get the data you need from Google Cloud Platform. I hope these examples provide you a high level idea on how to do it. Refer to following links for further details.</p><p>Let me know what you think and how you use gcloud in your environment. I am looking forward to writing another post on using the Google Cloud Client Libraries instead-of/in-addition-to gcloud and how that is different. (Edit: Check out “<a href="https://medium.com/google-cloud/using-gcloud-and-python-client-library-with-google-compute-engine-eaf1b19d8099">Using gcloud and Python Client Library with Google Compute Engine</a>”)</p><ul><li><a href="https://cloudplatform.googleblog.com/2016/06/filtering-and-formatting-fun-with.html">https://cloudplatform.googleblog.com/2016/06/filtering-and-formatting-fun-with.html</a></li><li><a href="https://cloud.google.com/sdk/docs/scripting-gcloud">https://cloud.google.com/sdk/docs/scripting-gcloud</a></li><li><a href="https://cloud.google.com/sdk/gcloud/reference/topic/formats">https://cloud.google.com/sdk/gcloud/reference/topic/formats</a></li><li><a href="https://cloud.google.com/resource-manager/docs/creating-managing-labels">https://cloud.google.com/resource-manager/docs/creating-managing-labels</a></li></ul><p>(Disclaimer: Views expressed here are my own. Information is provided “as-is”. )</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4985b416278" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/using-gcloud-to-get-google-cloud-platform-data-you-need-c4985b416278">Using gcloud to get Google Cloud Platform data you need</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>