Google Cloud Platform (GCP) is a public cloud provider service from Google. GCP has been following in the steps of Amazon Web Service (AWS), and if you're coming from AWS world, you'll notice many similarities between these two cloud providers. Today I'm going to talk about where GCP is setting itself apart from other cloud providers—specifically by making it easier to work with containers and Kubernetes.
Last July, Google had its annual GCP conference, Next. They launched many new and improved services, some of which are related to containers and Kubernetes. I'll discuss a few of them in this post. Google was using containers before they got popular with Borg, the predecessor of Kubernetes. It's not a surprise, then, why GCP has pretty good services for containers and Kubernetes.
As the official docs from Kubernetes say, "Google open-sourced the Kubernetes project in 2014" after a decade of working with containers. Later that year, GCP was the first public cloud provider launching a managed service for Kubernetes.
Let's take a look at some of GCP's services for containers.
Cloud-Managed Kubernetes Clusters With GKE
GCP has the best offering among public cloud providers for fully managed Kubernetes clusters. Kubernetes Engine, or GKE, is a service where you can quickly create a Kubernetes cluster managed by Google with these commands:
gcloud container clusters create CLUSTER_NAME
gcloud container clusters get-credentials CLUSTER_NAME
After the cluster is up and running, you can continue to interact with Kubernetes as you would usually do with kubectl. For example, you can run a "hello world" app by running the following command:
kubectl run hello-server --image gcr.io/google-samples/hello-app:1.0 --port 8080
What's appealing with GKE is that you can automatically scale your Kubernetes cluster up or down based on resource utilization. Upgrades to the cluster can be made pretty quickly. You can also enable the auto repair feature so that if a node in the cluster goes down for any reason, GKE will initiate a repair when needed.
Even though there's a great guide you can reference to understand Kubernetes's architecture components, you shouldn't waste time provisioning and configuring a Kubernetes cluster if you don't need to. But if you want to start moving your containerized apps to the cloud, use a platform-as-a-service solution like GKE.
Containers at Scale With App Engine
If you're starting with containers and don't know why or how Kubernetes can help you, then start with App Engine and its flexible environments. Kubernetes's learning curve is quite big, so App Engine is a good way to get your toes wet. Later, when you need to have more control over deployments or orchestrate more containers, go with GKE.
I don't have a magic formula for how your company should get started using containers with Kubernetes. Whether you use a program like App Guide or GKE will depend on your company's needs. But if you're not sure, you can just do what Google's team advises, which is to "try both." You don't have to create a complex app to get an idea of what these two services offer and how they're different. You can have an app up and running by doing the following:
- Create a GCP project.
- Download and install Google Cloud SDK.
- Run this command: "gcloud app create".
You can get more info on GCP's getting started page. After you've finished setting things up, you can deploy easily by running the "gcloud app deploy" command. You can test the app locally because all you need is an app.yaml definition for GCP and a Dockerfile to define the Docker's image.
With App Engine and containers, you have the ability to log, monitor, run diagnostics, version, split traffic, and more. That's everything you need to run your app at scale. But wait, there's more.
Serverless Containers With Cloud Functions
Recently, I've been reading about the discussion of containers versus serverless computing—which one is better, and what the tradeoffs of each are. But in my opinion, each technology serves different purposes and they become better when they're combined. I've been using AWS Lambda for quite some time, and there's one problem I've had consistently. I would test code locally and everything would be fine, but after uploading it, the code would start having issues. It's possible to test your app locally, but I think it's much smoother to test with containers.
Cloud Functions is one of GCPs offering for serverless, precisely as a hosting service for your application code. These types of services are called serverless because you don't have to worry about anything that has to do with servers, similar to what AWS Lambda offers. What I like about GCP's offering is that they recently announced that their serverless compute stack would support containers.
When you start working with a serverless platform, you'll stop having to maintain the patching, operating, and scaling of Kubernetes clusters. You'll also pay less because you don't pay for any server when the function isn't being used. Google also announced a Kubernetes plugin to deploy serverless workloads into GKE, which will allow you to reutilize an existing cluster.
But what's even more interesting than that is the announcement for the Kubernetes-based serverless framework called Knative. It's Google's way of extending serverless workloads to Kubernetes anywhere, not just with GKE. I think Knative will become the new standard to deploy robust applications to Kubernetes, even if they're not using containers.
On-Prem Kubernetes Clusters With GKE
GCP understands that some enterprises will never go to a public cloud. Compliance, regulations, and data security/integrity are the most common reasons why a company will host on premises. For that reason, GCP just announced an alpha version of GKE On-Prem. At the time of writing, you can request early access to this service. GKE On-Prem opens the door to have GKE running anywhere. There might be some occasions when it will be too expensive or complicated to migrate the apps somewhere else. But if you want (or need) to migrate, which is both challenging and time-consuming, having GKE under your belt is a start.
I think GKE On-Prem is how Google is helping companies start their migration to the cloud too. Enterprises could at least have all the cool features you get from the cloud in their data centers, like having an API to administrate and treat infrastructure as code. With GKE you'll be able to administrate Kubernetes clusters more easily.
Just like serverless offerings for containers, GKE On-Prem is a new service Google launched a few months ago. Because it's so new, I can't tell you exactly how it will be received or how to use it. But again, it looks great.
Containers Everywhere With Ease
As you can see, with GCP you can build, deploy, and run containers in very different ways. Google is putting a lot of effort into making it much easier to administrate, operate, and scale Kubernetes, not just in their cloud, but also in other cloud providers or on your premises. We're now at a time when you can focus on making cool apps instead of provisioning clusters and other operational tasks that you could leverage on GCP. As long as you package your app into a container, you're pretty much done.
You're going to be able to start deploying your app with the serverless approach where you only pay for memory and CPU, and just for the time the container runs. On top of that, you don't have to worry about scaling. While your application keeps growing and getting more complicated, you can start thinking about Kubernetes and switch to GKE. What's cool about this is that you can run GKE on-premises or in any other cloud.
Google is creating an ecosystem where it's more comfortable to work with containers and Kubernetes. If you want a new car, you don't build one from scratch. You go to the dealer and buy one. And just like that, if you're not in the cloud business, you shouldn't waste valuable time doing extra work that a service like GCP could take care of for you. Instead, focus on doing more important things, like creating apps.