Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Cloud Native Python
Cloud Native Python

Cloud Native Python: Build and deploy resilent applications on the cloud using microservices, AWS, Azure and more

eBook
€8.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Cloud Native Python

Introducing Cloud Native Architecture and Microservices

Here we go! Before we begin to build our application, we need to find answers to some of the following queries:

  • What is cloud computing? What are its different types?
  • What is microservices and its concept?
  • What are the basic requirements for good to go?

In this chapter, we will focus on the different concepts that a developer or application programmer should understand before they start writing an application.

Let's first understand a bit about system building and how it evolves.

For a long time now, we have been discovering better approaches to constructing frameworks. With advances in new technologies and adoption of better approaches, the IT framework becomes more reliable and effective for clients (or customers), and makes engineers happy.

Continuous delivery helps us move our software development cycle into production, and lets us identify different error-prone perspectives of software, insisting on us the idea of considering every check-in to code as a suitable candidate to release it to production.

Our comprehension of how the web functions has driven us to grow better methods for having machines converse with other machines. The virtualization platform has permitted us to make arrangements and resize our machines freely, with foundation computerization giving us an approach to deal with these machines at scale. Some huge, effective cloud platforms, such as Amazon, Azure, and Google have embraced the perspective of little groups owning the full life cycle of their services. Concepts such as Domain-Driven Design (DDD), continuous delivery (CD), on-request virtualization, infrastructure robotization, small self-governing groups, and systems at scale are different traits, which effectively, and efficiently, get our software into production. And now, microservices has risen up out of this world. It wasn't developed or portrayed before the reality; it rose as a pattern, or, for example, from true utilization. All through this book, I will haul strands out of this earlier work to help illustrate how to fabricate, oversee, and advance microservices.

Numerous associations have found that by grasping fine-grained microservice structures, they can convey programming speedily, and grasp more up-to-date advancements. Microservices gives us, fundamentally, more flexibility to respond and settle on various choices, permitting us to react quickly to the unavoidable changes that affect every one of us.

Introduction to cloud computing

Before we begin with microservices and cloud native concepts, let's first understand what cloud computing is all about.

Cloud computing is a wide term that portrays a wide scope of administrations. Similarly, as with other huge advancements in innovation, numerous merchants have grabbed the expression cloud and are utilizing it for items that sit outside of the basic definition. Since the cloud is an expansive accumulation of administrations, associations can pick where, when, and how they utilize cloud computing.

The cloud computing services can be categorized as follows:

  • SaaS: These are baked applications that are ready to be grasped by end users
  • PaaS: These are a collection of tools and services that are useful for users/developers who want to either build their application or quickly host them directly to production without caring about the underlying hardware
  • IaaS: This is for customers who want to build their own business model and customize it

Cloud computing, as a stack, can be explained as follows:

  • Cloud computing is often referred to as stack, which is basically a wide range of services in which each service is built on top of another under a common term, such as cloud
  • The cloud computing model is considered as a collection of different configurable computing resources (such as servers, databases, and storage), which communicate with each other, and can be provisioned with minimal supervision

The following diagram showcases the cloud computing stack components:

Let's understand cloud computing components in detail, along with their use cases.

Software as a Service

The following are the key points that describe SaaS:

  • Software as a Service (SaaS) offers users the ability to access software hosted on service provider premises, which is provided as a service over the internet through a web browser by a provider. These services are based on subscriptions, and are also referred to as on-demand software.

  • SaaS-offering companies include the Google Docs productivity suite, Oracle CRM (Customer Relationships Management), Microsoft and their Office 365 offering, and Salesforce CRM and QuickBooks.

  • SaaS can be further categorized as a vertical SaaS that focuses on the needs of specific industries, such as healthcare and agriculture, or a horizontal SaaS that focuses on the software industry, such as human resources and sales.

  • SaaS offerings are, basically, for organizations that quickly want to grasp existing applications that are easy to use and understand, even for a non-technical person. Based on the organization's usage and budget, enterprises to select support plans. Additionally, you can access these SaaS applications from anywhere around the globe, and from any device with the internet enabled.

Platform as a Service

The following are the key points that describe PaaS:

  • In PaaS offerings, the organization/enterprise need not worry about hardware and software infrastructure management for their in-house applications

  • The biggest benefits of PaaS are for the development teams (local or remote), which can efficiently build, test, and deploy their applications on a common framework, wherein, the underlying hardware and software is managed by the PaaS service provider

  • The PaaS service provider delivers the platform, and also provides different services around the platform

  • The examples of PaaS providers include Amazon Web Services (AWS Elastic Beanstalk), Microsoft Azure (Azure Websites), Google App Engine, and Oracle (Big Data Cloud Service)

Infrastructure as a Service

The following are the key points that describe IaaS:

  • Unlike SaaS offerings, in IaaS, the customer is provided with IT resources, such as bare metal machines to run applications, hard disk for storage, and network cable for network capability, which they can customize based on their business model.

  • In IaaS offerings, since the customer has full access to their infrastructure, they can scale their IT resources based on their application requirement. Also, in IaaS offerings, the customer has to manage the security of the application/resources, and needs to build disaster recovery models in case of sudden failures/crashes.

  • In IaaS, services are on an on-demand basis, where the customer is charged on usage. So, it's the customer's responsibility to do cost analysis against their resources, which will help restrict them from exceeding their budget.

  • It allows customers/consumers to customize their infrastructure based on the requirements of the application, then tear down the infrastructure and recreate it again very quickly and efficiently.

  • The pricing model for IaaS-based services is basically on-demand, which means you pay as you go. You are charged as per your usage of resources and the duration of the usage.

  • Amazon Web Services (offering Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Simple Storage Service (Amazon S3)) was the first out of the gate in this cloud offering; however, players such as Microsoft Azure (virtual machine), Rackspace (virtual cloud servers) and Oracle (bare metal cloud services) have also made a name for themselves.

The cloud native concepts

Cloud native is structuring teams, culture, and technology to utilize automation and architectures to manage complexity and unlock velocity.

The cloud native concept goes beyond the technologies with which it is associated. We need to understand how companies, teams, and people are successful in order to understand where our industry is going.

Currently, companies such as Facebook and Netflix have dedicated a large amount of resources working towards cloud native techniques. Even now, small and more flexible companies have realized the value of these techniques.
With feedback from the proven practices of cloud native, the following are some of the advantages that come to light:

  • Result-oriented and team satisfaction: The cloud native approach shows the way to break a large problem into smaller ones, which allows each team to focus on the individual part.

  • Grunt work: Automation reduces the repetitive manual tasks that cause operations pain, and reduces the downtime. This makes your system more productive, and it gives more efficient outcomes.

  • Reliable and efficient application infrastructure: Automation brings more control over deployment in different environments--whether it is development, stage, or production--and also handles unexpected events or failures. Building automation not only helps normal deployment, but it also makes deployment easy when it comes to a disaster recovery situation.

  • Insights over application: The tools built around cloud native applications provide more insights into applications, which make them easy to debug, troubleshoot, and audit.

  • Efficient and reliable security: In every application, the main concern is toward its security, and making sure that it is accessible via required channels with authentication. The cloud native approach provides different ways for the developer to ensure the security of the application.

  • Cost-effective system: The cloud approach to managing and deploying your application enables efficient usage of resources, which also includes application release and, hence, makes the system cost effective by reducing the wastage of resources.

Cloud native - what it means and why it matters?

Cloud native is a broad term which makes use of different techniques, such as infrastructure automation, developing middleware, and backing services, which are basically a part of your application delivery cycle. The cloud native approach includes frequent software releases that are bug-free and stable, and can scale the application as per the business requirement.

Using the cloud native approach, you will be able to achieve your goal toward application building in a systematic manner.

The cloud native approach is much better than the legacy virtualization-oriented orchestration, which needs a lot of effort to build an environment suitable for development, and then, a far more different one for the software delivery process. An ideal cloud native architecture should have automation and composition functionalities, which work on your behalf. These automation techniques should also be able to manage and deploy your application across different platforms and provide you with results.

There are a couple of other operation factors that your cloud native architecture should be able to identify, such as steady logging, monitoring application and infrastructure in order to make sure the application is up and running.

The cloud native approach really helps developers build their application across different platforms using tools such as Docker, which is lightweight and easy to create and destroy.

The cloud native runtimes

Containers are the best solutions for how to get software to run reliably when moved from one computing environment to another. This could be from one developer machine to the stage environment into production, and perhaps from a physical machine to a virtual machine in a private or public cloud. Kubernetes has become synonymous with container services, and is getting popular nowadays.

With the rise of cloud native frameworks and an increase in the applications built around it, the attributes of container orchestration have received more attention and usage. Here is what you need from a container runtime:

  • Managing container state and high availability: Be sure to maintain the state (such as create and destroy) of containers, specifically in production, as they are very important from a business perspective, and should be able to scale as well, based on business needs
  • Cost analysis and realization: Containers give you control over resource management as per your business budget, and can reduce costs to a large extent
  • Isolated environment: Each process that runs within a container should remain isolated within that container
  • Load balancing across clusters: Application traffic, which is basically handled by a cluster of containers, should be redirected equally within the containers, which will increase the applications response and maintain high availability
  • Debugging and disaster recovery: Since we are dealing with the production system here, we need to make sure we have the right tools to monitor the health of the application, and to take the necessary action to avoid downtime and provide high availability

Cloud native architecture

The cloud native architecture is similar to any application architecture that we create for a legacy system, but in the cloud native application architecture, we should consider a few characteristics, such as a twelve-factor application (collection of patterns for app development), microservices (decomposition of a monolithic business system into independent deployable services), self-service agile infrastructure (self-service platform), API-based collaboration (interaction between services via API), and antifragility (self-realizing and strengthening the application).

First, let's discuss what is microservices all about?

Microservices is a broader term that breaks large applications into smaller modules to get them developed and make them mature enough for release. This approach not only helps to manage each module efficiently, but it also identifies the issue at the lower level itself. The following are some of the key aspects of microservices:

  • User-friendly interfaces: Microservices enable a clear separation between microservices. Versioning of microservices enables more control over APIs, and it also provides more freedom for both the consumers and producers of these services.
  • Deployment and management of APIs across the platform: Since each microservice is a separate entity, it is possible to update a single microservice without making changes to the others. Also, it is easier to roll back changes for a microservice. This means the artifacts that are deployed for microservices should be compatible in terms of API and data schemas. These APIs must be tested across different platforms, and the test results should be shared across different teams, that is, operation, developers, and so on, to maintain a centralized control system.
  • Flexibility in application: Microservices that are developed should be capable of handling the request and must respond back, irrespective of the kind of request, which could be a bad input or an invalid request. Also, your microservice should be able to deal with an unexpected load request and respond appropriately. All of these microservices should be tested independently, as well as with integration.
  • Distribution of microservices: It's better to split the services into small chunks of services so that they can be tracked and developed individually and combined to form a microservice. This technique makes microservices development more efficient and stable in manner.

The following diagram shows a cloud native application's high-level architecture:

The application architecture should ideally start with two or three service, try to expand it with further versions. It is very important to understand application architecture, as it may need to integrate with different components of the system, and it is possible that a separate team manages those components when it comes to large organizations. Versioning in microservices is vital, as it identifies the supported method during the specified phase of development.

Are microservices a new concept?

Microservices has been in the industry for a very long time now. It is another way of creating a distinction between the different components of a large system. Microservices work in a similar fashion, where they act as a link between the different services, and handle the flow of data for a particular transaction based on the type of requests.

The following diagram depicts the architecture of microservices:

Why is Python the best choice for cloud native microservices development?

Why do I choose Python, and recommend it to as many people as possible? Well, it comes down to the reasons explained in the upcoming subsections.

Readability

Python is highly expressive and an easy-to-learn programming language. Even an amateur can easily discover the different functionalities and scope of Python. Unlike other programming languages, such as Java, which focus more on parenthesis, brackets, commas, and colons, Python let's you spend more time on programming and less time on debugging the syntax.

Libraries and community

Python's broad range of libraries is very portable over different platforms, such as Unix, Windows, or OS X. These libraries can be easily extended based on your application/program requirement. There is a huge community that works on building these libraries and this makes it the best fit for business use cases.

As far as the Python community is concerned, the Python User Group (PUG) is a community that works on the community-based development model to increase the popularity of Python around the globe. These group members give talks on Python-based frameworks, which help us build large systems.

Interactive mode

The Python interactive mode helps you debug and test a snippet of code, which can later be added as a part of the main program.

Scalable

Python provides better structure and concept, such as modules, to maintain large programs in a more systematic manner than any other scripting language, such as shell scripting.

Understanding the twelve-factor app

Cloud native applications fit in with an agreement intended to augment versatility through predictable practices. This application maintains a manifesto of sorts called the twelve-factor app. It outlines a methodology for developers to follow when building modern web-based applications. Developers must change how they code, creating a new contract between the developers and the infrastructure that their applications run on.

The following are a few points to consider when developing a cloud native application:

  • Use an informative design to increase application usage with minimal time and cost to customers using automation

  • Use application portability across different environments (such as stage and production) and different platforms (such as Unix or Windows)

  • Use application suitability over cloud platforms and understand the resource allocation and management

  • Use identical environments to reduce bugs with continuous delivery/deployment for maximum agility of software release

  • Enable high availability by scaling the application with minimal supervision and designing disaster-recovery architectures

Many of the twelve-factors interact with each other. They focus on speed, safety, and scale by emphasizing on declarative configuration. A twelve-factor app can be described as follows:

  • Centralized code base: Every code that is deployed is tracked in revision control, and should have multiple instances deployed on multiple platforms.

  • Dependencies management: An app should be able to declare the dependencies, and isolate them using tools such as Bundler, pip, and Maven.

  • Defining configuration: Configurations (that is, environment variables) that are likely to be different in different deployment environments (such as development, stage, and production) should be defined at the operating-system level.

  • Backing services: Every resource is treated as a part of the application itself. Backing services such as databases and message queues should be considered as an attached resource, and consumed equally in all environments.

  • Isolation in build, release, and run cycle: This involves strict separation between build artifacts, then combining with configuration, and then starting one or more instances from the artifact and configuration combination.

  • Stateless processes: The app should execute one or more instances/processes (for example, master/workers) that share nothing.

  • Services port binding: The application should be self-contained, and if any/all services need to be exposed, then it should be done via port binding (preferably HTTP).

  • Scaling stateless processes: The architecture should emphasize stateless process management in the underlying platform instead of implementing more complexity to the application.

  • Process state management: Processes should scale up very quickly and shut down gracefully within a small time period. These aspects enable rapid scalability, deployment of changes, and disaster recovery.

  • Continuous delivery/deployment to production: Always try to keep your different environments similar, whether it is development, stage, or production. This will ensure that you get similar results across multiple environments, and enable continuous delivery from development to production.

  • Logs as event streams: Logging is very important, whether it is platform level or application level, as this helps understand the activity of the application. Enable different deployable environments (preferably production) to collect, aggregate, index, and analyze the events via centralized services.

  • Ad hoc tasks as on-off processes: In the cloud native approach, management tasks (for example, database migration) that run as a part of a release should be run as one-off processes into the environment as opposed to the regular app with long-running processes.

Cloud application platforms such as Cloud Foundry, Heroku, and Amazon Beanstalk are optimized for deploying twelve-factor apps.

Considering all these standards and integrating applications with steady engineering interfaces, that is, handling stateless outline design, makes disseminated applications that are cloud prepared. Python revolutionized application systems with its obstinate, tradition-over-setup way to deal with web improvements.

Setting up the Python environment

As we will demonstrate throughout this book, having the right environment (local or for your automated builds) is crucial to the success of any development project. If a workstation has the right tools, and is set up properly, developing on that workstation can feel like a breath of fresh air. Conversely, a poorly set up environment can suffocate any developer trying to use it.

The following are the prerequisite accounts that we require in the later part of the book:

  • A GitHub account needs to be created for source code management. Use the article on the following link to do so:

https://medium.com/appliedcode/setup-github-account-9a5ec918bcc1

Now, let's set up some of the tools that we will need during our development project.

Installing Git

Git (https://git-scm.com) is a free and open source distributed, version control system designed to handle everything, ranging from small to very large projects, with speed and efficiency.

Installing Git on Debian-based distribution Linux (such as Ubuntu)

There are a couple of ways by which you can install Git on a Debian system:

  1. Using the Advanced Package Tool (APT) package management tools:

You can use the APT package management tools to update your local package index. Then, you can download and install the latest Git using the following commands as the root user:

      $ apt-get update -y
      $ apt-get install git -y  

The preceding commands will download and install Git on your system.

  1. Using the source code, you can do the following:
    1. Download the source from the GitHub repository, and compile the software from the source.

Before you begin, let's first install the dependencies of Git; execute the following commands as the root user to do so:

      $ apt-get update -y 
      $ apt-get install build-essential libssl-dev
libcurl4-gnutls-dev libexpat1-dev gettext unzip -y

2. After we have installed the necessary dependencies, let's go to the Git project repository (https://github.com/git/git) to download the source code, as follows:

      $ wget https://github.com/git/git/archive/v1.9.1.zip -Ogit.zip  

3. Now, unzip the downloaded ZIP file using the following commands:

      $ unzip git.zip
      $ cd git-*  

4. Now you have to make the package and install it as a sudo user. For this, use the commands given next:

      $ make prefix=/usr/local all
      $ make prefix=/usr/local install

The preceding commands will install Git on your system at /usr/local.

Seting up Git on a Debian-based distribution

Now that we have installed Git on our system, we need to set some configuration so that the commit messages that will be generated for you contain your correct information.

Basically, we need to provide the name and email in the config. Let's add these values using the following commands:

$ git config --global user.name "Manish Sethi"
$ git config --global user.email manish@sethis.in  

Installing Git on Windows

Let's install Git on Windows; you can download the latest version of Git from the official website (https://git-scm.com/download/win). Follow the steps listed next to install Git on a Windows system:

  1. Once the .exe file is downloaded, double-click on it to run it. First of all, you will be provided with a GNU license, as seen in this screenshot:

Click on Next:

In the section shown in the preceding screenshot, you will customize your setup based on tools that are needed, or you can keep it default, which is okay from the book's perspective.

  1. Additionally, you can install Git Bash along with Git; click on Next:
  1. In the section seen in the next screenshot, you can enable other features that come along with Git packages. Then, click on Next:

  1. You can skip the rest of the steps by clicking on Next, and go for the installation part.

Once you complete the installation, you will be able to see a screen like this:

Great!! We have successfully installed Git on Windows!!

Using Chocolatey

This is my preferred way to install Git for Windows on Windows 10. It installs the same package as before, but in one line. If you have not heard of Chocolatey, stop everything, and go learn a bit more. It can install the software with a single command; you don't have to use click-through installers anymore!

Chocolatey is very powerful, and I use it in combination with Boxstarter to set up my dev machines. If you are in charge of setting up machines for developers on Windows, it is definitely worth a look.

Let's see how you would install Git using Chocolatey. I assume you have Chocolatey installed (https://chocolatey.org/install) already (it's a one-liner in Command Prompt). Then, simply open the Administrator Command window, and type this command:

$ choco install git -params '"/GitAndUnixToolsOnPath"'  

This will install Git and the BASH tools, and add them to your path.

Installing Git on Mac

Before we begin with the Git installation, we need to install command-line tools for OS X.

Installing the command-line tools for OS X

In order to install any developer, you will need to install Xcode (https://developer.apple.com/xcode/), which is a nearly 4 GB developer suite. Apple offers this for free from the Mac App Store. In order to install Git and the GitHub setup, you will need certain command-line tools, which are part of the Xcode development tools.

If you have enough space, download and install Xcode, which is basically a complete package of development tools.

You will need to create an Apple developer account at developer.apple.com in order to download command-line tools. Once you have set up your account, you can select the command-line tools or Xcode based on the version, as follows:

  • If you are on OS X 10.7.x, download the 10.7 command-line tools. If you are on OS X 10.8.x, download the 10.8 command-line tools.
  • Once it is downloaded, open the DMG file, and follow the instructions to install it.

Installing Git for OS X

Installing Git on Mac is pretty much similar to how you install it on Windows. Instead of using the .exe file, we have the dmg file, which you can download from the Git website (https://git-scm.com/download/mac) for installation as follows:

  1. Double-click on the dmg file that got downloaded. It will open a finder with the following files:
  1. Double-click on the package (that is, git-2.10.1-intel-universal-mavericks.dmg) file; it will open the installation wizard to install, as seen in the following screenshot:
  1. Click on Install to begin the installation:
  1. Once the installation is complete, you will see something like this:
If you are using OS X 10.8 and haven't already modified your security settings to allow the installation of third-party applications, you'll need to make that adjustment before OS X lets you install these tools.

Installing and configuring Python

Now, let's install Python, which we will use to build our microservices. We will be using the Python 3.x version throughout the book.

Installing Python on a Debian-based distribution (such as Ubuntu)

There are different ways to install Python on a Debian-based distribution.

Using the APT package management tools

You can use the APT package management tools to update your local package index. Then, you can download and install the latest Python using the following commands as a root user:

$ apt-get update -y
$ apt-get install python3 -y  

The following packages will automatically be downloaded and installed, as these are the prerequisites for Python 3 installation:

libpython3-dev libpython3.4 libpython3.4-dev python3-chardet

python3-colorama python3-dev python3-distlib python3-html5lib

python3-requests python3-six python3-urllib3 python3-wheel python3.4-de

Once the prerequisites are installed, it will download and install Python on your system.

Using source code

You can download the source code from the GitHub repository and compile the software from the source, as follows:

  1. Before you begin, let's first install the dependencies of Git; execute the following commands as the root user to do so:
      $ apt-get update -y 
      $ apt-get install build-essential checkinstall libreadline-gplv2-
dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-
dev libc6-dev libbz2-dev -y
  1. Now, let's download Python (https://www.python.org) using the following command from Python's official website. You can also download the latest version in place, as specified:
      $ cd /usr/local
      $ wget https://www.python.org/ftp/python/3.4.6/Python-3.4.6.tgz  
  1. Now, let's extract the downloaded package with this command:
      $ tar xzf Python-3.4.6.tgz  
  1. Now we have to compile the source code. Use the following set of commands to do so:
      $ cd python-3.4.6
      $ sudo ./configure
      $ sudo make altinstall  
  1. The preceding commands will install Python on your system at /usr/local. Use the following command to check the Python version:
      $ python3 -V                                                                                                                                                                             
        Python 3.4.6

Installing Python on Windows

Now, let's see how we can install Python on Windows 7 or later systems. Installation of Python on Windows is pretty simple and quick; we will be using Python 3 and above, which you can download from Python's download page (https://www.python.org/downloads/windows/). Now perform the following steps:

  1. Download the Windows x86-64 executable installer based on your system configuration, and open it to begin the installation, as shown in the following screenshot:
  1. Next, select the type of installation you want to go with. We will click on Install Now to go for the default installation, as seen in this screenshot:
  1. Once the installation is complete, you will see the following screen:

Great! We have successfully installed Python on Windows.

Installing Python on Mac

Before we begin with the Python installation, we need to install the command-line tools for OS X. If you have already installed the command-line tools at the time of Git installation, you can ignore this step.

Installing the command-line tools for OS X

In order to install any developer, you need to install Xcode (https://developer.apple.com/xcode/); you will need to set up an account on connect.apple.com to download the respective Xcode version tools.

However, there is another way you can install command-line tools using a utility, which comes along with an Xcode called xcode-select, which is shown here:

% xcode-select --install  

The preceding command should trigger an installation wizard for the command-line tools. Follow the installation wizard, and you will be able to install it successfully.

Installing Python for OS X

Installing Python on Mac is quite similar to how you install Git on Windows. You can download the Python package from the official website (https://www.python.org/downloads/). Proceed with the following steps:

  1. Once the Python package is downloaded, double-click on it to begin the installation; it will show the following pop-up window:
  1. The next step will be about the release note and the respective Python version information:
  1. Next, you will need to Agree with the license, which is mandatory for installation:
  1. Next, it will show you the installation-related information, such as the disk occupied and the path. Click on Install to begin:
  1. Once the installation is complete, you will see the following screen:
  2. Use the following command to see whether the Python version is installed:
      % python3 -V  
Python 3.5.3

Great!! Python is successfully installed.

Getting familiar with the GitHub and Git commands

In this section, we will go through a list of Git commands, which we will be using frequently throughout the book:

  • git init: This command initializes your local repository once when you are setting it up for the first time
  • git remote add origin <server>: This command links your local <indexentry content="Git command:git remote add origin " dbid="164250" state="mod">directory to the remote server repository so that all the changes pushed are saved in the remote repository
  • git status: This command lists the files/directories that are yet to be added, or are modified and need to be committed
  • git add * or git add <filename>: This command adds files/directories so that <indexentry content="Git command:git add * or git add " dbid="164250" state="mod">they can be tracked, and makes them ready to be committed
  • git commit -m "Commit message": This command helps you commit your track changes in the local machine and generate the commit ID by which the updated code can be identified
  • git commit -am "Commit message": The only difference between the previous command and this command is that this opens a default editor to add the commit message based on an operating system such as Ubuntu (Vim) or Windows (Notepad++) after adding all the files to stage
  • git push origin master: This command pushes the last committed code from the local directory to the remote repository

Test everything to make sure our environment works.

Here we go. We have installed both Git and Python in the last section, which are needed to begin with building microservices. In this section, we will focus on testing the installed packages and try to get familiar with them.

The first thing we can do is to exercise the Git command, which fetches an external Python code from a repository (usually GitHub) over HTTPs, and copies it into our current workspace in the appropriate directory:

$ git clone https://github.com/PacktPublishing/Cloud-Native-
Python.git

The preceding command will create a directory named Cloud-Native-Python on your local machine; switch to the Cloud-Native-Python/chapter1 path from the current location.

We will need to install the requirements of the apps that are needed to run it. In this case, we just need the Flask module to be available:

$ cd hello.py
$ pip install requirements.txt

Here, Flask works as the web server; we will understand more about it in detail in the next chapter.

Once it is installed successfully, you can run the app using the following command:

$ python hello.py
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)  

I think we are good to see the output, which is as follows:

$ curl http://0.0.0.0:5000/
Hello World!  

If you see this output, then our Python development environment is correctly set up.

Now it's time to write some Python code!

Summary

In this chapter, we began with exploring the cloud platform and the cloud computing stack. During this chapter, you learned what the different twelve-factor apps methodologies are, and how they can help develop microservices. Lastly, you got to know about what kind of ideal setup environment a developer machine should have to create or get started with application creation.

In the next chapter, we will start building our microservices by creating backend REST APIs, and testing with the API call or using the Python framework as well.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • ? This is the only reliable resource that showcases the tools and techniques you need build robust and resilient cloud native applications in Python
  • ? Learn how to architect your application on both, the AWS and Azure clouds for high availability
  • ? Assess, monitor, and troubleshoot your applications in the cloud

Description

Businesses today are evolving so rapidly that having their own infrastructure to support their expansion is not feasible. As a result, they have been resorting to the elasticity of the cloud to provide a platform to build and deploy their highly scalable applications. This book will be the one stop for you to learn all about building cloud-native architectures in Python. It will begin by introducing you to cloud-native architecture and will help break it down for you. Then you’ll learn how to build microservices in Python using REST APIs in an event driven approach and you will build the web layer. Next, you’ll learn about Interacting data services and building Web views with React, after which we will take a detailed look at application security and performance. Then, you’ll also learn how to Dockerize your services. And finally, you’ll learn how to deploy the application on the AWS and Azure platforms. We will end the book by discussing some concepts and techniques around troubleshooting problems that might occur with your applications after you’ve deployed them. This book will teach you how to craft applications that are built as small standard units, using all the proven best practices and avoiding the usual traps. It's a practical book: we're going to build everything using Python 3 and its amazing tooling ecosystem. The book will take you on a journey, the destination of which, is the creation of a complete Python application based on microservices over the cloud platform

Who is this book for?

This book is ideal for developers with a basic knowledge of Python who want to learn to build, test, and scale their Python-based applications. No prior experience of writing microservices in Python is required.

What you will learn

  • • Get to know “the way of the cloud”, including why developing good cloud software is fundamentally about mindset and discipline
  • • Know what microservices are and how to design them
  • • Create reactive applications in the cloud with third-party messaging providers
  • • Build massive-scale, user-friendly GUIs with React and Flux
  • • Secure cloud-based web applications: the do's, don'ts, and options
  • • Plan cloud apps that support continuous delivery and deployment

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 21, 2017
Length: 374 pages
Edition : 1st
Language : English
ISBN-13 : 9781787129313
Vendor :
Amazon
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jul 21, 2017
Length: 374 pages
Edition : 1st
Language : English
ISBN-13 : 9781787129313
Vendor :
Amazon
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 120.97
Python Microservices Development
€41.99
Cloud Native Python
€41.99
Cloud Native Development Patterns and Best Practices
€36.99
Total 120.97 Stars icon
Banner background image

Table of Contents

13 Chapters
Introducing Cloud Native Architecture and Microservices Chevron down icon Chevron up icon
Building Microservices in Python Chevron down icon Chevron up icon
Building a Web Application in Python Chevron down icon Chevron up icon
Interacting Data Services Chevron down icon Chevron up icon
Building WebViews with React Chevron down icon Chevron up icon
Creating UIs to Scale with Flux Chevron down icon Chevron up icon
Learning Event Sourcing and CQRS Chevron down icon Chevron up icon
Securing the Web Application Chevron down icon Chevron up icon
Continuous Delivery Chevron down icon Chevron up icon
Dockerizing Your Services Chevron down icon Chevron up icon
Deploying on the AWS Platform Chevron down icon Chevron up icon
Implementing on the Azure Platform Chevron down icon Chevron up icon
Monitoring the Cloud Application Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9
(7 Ratings)
5 star 71.4%
4 star 0%
3 star 0%
2 star 0%
1 star 28.6%
Filter icon Filter
Top Reviews

Filter reviews by




V.Ramachandran Dec 18, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent book in proper time
Amazon Verified review Amazon
Amazon Customer Sep 05, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book has clear steps to learn python automation. Best book to learn automation in cloud infrastructure.
Amazon Verified review Amazon
book_buff Aug 22, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A good practical book. It covers both basic as well as advanced techniques. CORS, event sourcing and CQRS, practical deployment to Docker/Swarm or AWS, Azure etc. Plus a collection of well-known (React.js) as wellas little known (Knockout.js) libraries/tools. Definitely stands out among practical books. I am waiting for the next book from Manish. He gives you value.
Amazon Verified review Amazon
Amazon Customer Aug 17, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book for any new or experienced Cloud professional, especially when you prefer Python
Amazon Verified review Amazon
Munikumar Aug 22, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very good book for developing applications and automating your cloud-based infrastructure amd step-by-step approach clearly explaining the most efficient automation methodologies using Python. Recommended who are interested for learning Python scripting in cloud infrastructure.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.