Understanding Anthos components
Working with Anthos
Anthos is an enterprise-grade solution from Google aimed at nothing less than modernizing and unifying your entire server infrastructure, wherever it currently exists. Anthos encompasses a very broad spectrum of components, yet it’s still very new, so there isn’t a lot of good documentation and training material available for it yet. This can all make Anthos seem very daunting to learn, but this course aims to show you that the very purpose of Anthos is to simplify your infrastructure complexities for you.
- Understand what Anthos is and does
- Identify how Anthos fits in with other existing hybrid and multi-cloud solutions
- Investigate options to modernize existing infrastructure configurations to use Anthos
- Learn about the key components that make up Anthos, and how to configure them
- Build and test a modern microservice application for Anthos on GCP
- Create a CI/CD pipeline for deploying to Anthos
- Developers interested in learning about the latest in modern cloud-based development strategies
- Familiarity with Kubernetes and GKE
- Have a Google Cloud Platform account
- Have the Google Cloud SDK installed and initialized
- Have Git installed
It is also highly recommended that you have Docker Desktop and Visual Studio Code pre-installed as well.
Building microservices on Anthos with Google Cloud Run. In the previous lecture, we installed and configured the Cloud Code extension in Visual Studio Code. Earlier in this course, we already deployed an Anthos cluster on Google Cloud Platform. Now let's take a look and see how easily we can build a new microservice application on our Anthos deployment using Google Cloud Run, all directly from our IDE.
First, what is Cloud Run? For just a simple microservice, managing the full scope of a Kubernetes cluster to serve our application can be a difficult and daunting task. Cloud Run is a managed microservices platform that allows us to just build our application into a container, then let Google worry about handling all the infrastructure management from there. Cloud Run is built on GKE and essentially abstracts a lot of the Kubernetes complexity for us by handling things like application scaling and load balancing automatically.
Since Cloud Run is built on GKE, it's also inherently tightly integrated with Anthos. Anthos essentially gives us the capability of taking Cloud Run off of the GCP platform so we can run the same Cloud Run applications on another cloud provider, or using our own on premise server. For the purposes of this demo though, we'll just be creating a Cloud Run application for Anthos on GCP. To get started, we'll click on New Application on the status bar, then select Cloud Run application.
We'll be using Python for this demo, but you can see there are some sample starter projects for other languages available here as well. We can make changes to and expand on this starter project, then test our changes locally using the Cloud Run Emulator. Once you've made some changes to the source code and saved them, open the Command Palette and select Run on Cloud Run Emulator. This will use Docker and minikube on our local machine to emulate the Cloud Run service so we can quickly test changes to our code without needing to deploy it anywhere else.
Scaffold is also running behind the scenes here, so if we make further changes to our code now, our Docker container is rebuilt and redeployed automatically for seamless testing in our development environment. We can view deployment logs right from within the IDE, with this Cloud Logs Viewer. We don't have any logs to view in here just yet, but we'll come back and check on this again later. Check that we are using the cloud-run-dev-internal minikube cluster here, and then we can also add breakpoints, and use the debug sidebar and debug console in our IDE, just like we normally would with any other code.
We can almost forget that our application is actually running in a container now. We can see our container running locally in our cloud-run-dev-internal cluster in the Kubernetes Explorer now, and if we check the kubectl logs in the Log Viewer we can now see all kinds of log data here. Once we're satisfied with our project, we're ready to take our code from our local development environment and push it to a testing or staging environment on GCP. We'll want to make sure our application works the same way on Google's server environment as it did on our local machine before we deem our application version as fully functional and ready for a customer-facing production environment.
Since we are deploying to Cloud Run for Anthos, there are a few extra steps we need to take first. Basically we're going to create a GKE cluster on our Anthos deployment that will run our Cloud Run applications, instead of deploying to the standard GCP Cloud Run service. We'll click on the Kubernetes Explorer here, then click Add a Cluster to the KubeConfig, then Choose Google Kubernetes Engine and click on Create a new GKE Cluster. We want to choose Standard or Autopilot here. This will pop up in our browser to complete the cluster setup.
We just need to fill in a couple fields here, then click the Features tab, and make sure Enable Cloud Run for Anthos is checked. Then we'll click Create, and once the cluster is created, we should see it now visible and ready for use in the Kubernetes Explorer. Now we can deploy our Cloud Run for Anthos service using Cloud Code in basically the same way we would deploy to Cloud Run on GCP. Open the Command Palette again and select Deploy to Cloud Run. We just change the option here to Cloud Run for Anthos and select the cluster we made, then click Deploy.
Once that's done, we can see it gave our demo a service URL for example.com that obviously isn't going to work. By default our Cloud Run applications are mapped to a domain assigned to our cluster, but we haven't set up a domain yet. If we go to Cloud Run for Anthos in the Google Cloud Console, we can see our new application here, and some instructions where we can confirm our application is working, even if only from the Cloud Shell command line. Our production Cloud Run environment on Anthos should be mapped to a domain though, and we can add those domain settings here.
You would also need to follow this step by updating the DNS records for that domain next. We now know how to build and test a basic microservice application built for Cloud Run for Anthos. We could further refine and restrict our application by customizing service mesh and policy controller configuration files along with our application source code, like we learned about in the previous lecture group. Coming up in our final lecture, we'll add version control to our project and complete our continuous integration, continuous delivery pipeline.
Arthur spent seven years managing the IT infrastructure for a large entertainment complex in Arizona where he oversaw all network and server equipment and updated many on-premise systems to cloud-based solutions with Google Cloud Platform. Arthur is also a PHP and Python developer who specializes in database and API integrations. He has written several WordPress plugins, created an SDK for the Infusionsoft API, and built a custom digital signage management system powered by Raspberry Pis. Most recently, Arthur has been building Discord bots and attempting to teach a Python AI program how to compose music.