Balance innovation and agility with security and compliance
risks using a 3-step process across all cloud infrastructure.
Step up business agility without compromising
security or compliance
Everything you need to become a Kubernetes expert.
Always for free!
Everything you need to know about Magalix
culture and much more
Organizations are moving towards containerisation for their workloads. While containers give several benefits, it’s important to choose suitable container orchestration according to our requirements and use cases to get full benefit of the container ecosystem.
Kubernetes and Google App Engine are very well-known systems for running containerized workloads.
In this article, we’ll discuss comparisons in the offering of Kubernetes and Google App Engine.
Kubernetes is an open-source container orchestration service and there’s no need to purchase an extra license for it. If we compare the underlying infrastructure cost for both Kubernetes Engine and Google App Engine with 20 CPU and 75 GB of memory, then Google App Engine costs approximately USD $1,156.69, while Kubernetes costs just USD $485.45.
This is a very basic estimate for Google Cloud and includes only CPU and Memory cost, it does not account for other resource costs like Network Traffic, disk space, etc.
Google App Engine doesn’t support stateful applications unfortunately - it’s built for stateless applications exclusively. By contrast, with Kubernetes, you can deploy both stateless and stateful applications in the form of containers.
Google App Engine provides flexibility to spin up underlying Virtual Machines in specific subnetworks, and assign specific network tags to them. Using these subnetwork and network tags, you can ‘whitelist’ your service based on requirement and treat them as an internal service. However, this might become unmanageable after more services are introduced and would require internal-only access. On the other hand, in Kubernetes Engine, you can easily manage both your internal and external services, and scale them as needed for your architecture.
In this Demo, we will deploy a simple python application in both Google App Engine and Kubernetes.
Kindly replace your-project with your actual project in required commands.
You can skip this step if you already have one in your project.
$gcloud app create --project="your-project" --region="asia-south1"
vikassmacbook:~ vikassaini$ gcloud app create --project="your-project" --region="asia-south1" You are creating an app for project [your-project]. WARNING: Creating an App Engine application for a project is irreversible and the region cannot be changed. More information about regions is at . Creating App Engine application in project [your-project] and region [asia-south1]....done. Success! The app is now created. Please use `gcloud app deploy` to deploy your first app.
from flask import Flask flask_app = Flask(__name__) @flask_app.route('/') def hello_world(): return 'Hello World'
runtime: python27 api_version: 1 threadsafe: true handlers: - url: /.* script: app.flask_app libraries: - name: flask version: 0.12
Run below command to deploy application in Google App Engine.
gcloud app deploy ./app.yaml --project="your-project" -q
vikassmacbook:appengine vikassaini$ gcloud app deploy ./app.yaml --project="your-project" -q Services to deploy: descriptor: [/Users/vikassaini/blog/examples/appengine/app.yaml] source: [/Users/vikassaini/blog/examples/appengine] target project: [your-project] target service: [default] target version: [20200420t220922] target url: [https://your-project.el.r.appspot.com] Beginning deployment of service [default]... ╔════════════════════════════════════════════════════════════╗ ╠═ Uploading 1 file to Google Cloud Storage ═╣ ╚════════════════════════════════════════════════════════════╝ File upload done. Updating service [default]...done. Setting traffic split for service [default]...done. Deployed service [default] to [https://your-project.el.r.appspot.com] You can stream logs from the command line by running: $ gcloud app logs tail -s default To view your application in the web browser run: $ gcloud app browse --project=your-project
After this step, your application has been deployed in Google App Engine. You can access your application by target url printed in output or you can also run below command to access your application.
gcloud app browse --project="your-project"
You can skip this step if you already have one. We will use one node single zone cluster for demonstration.
gcloud beta container clusters create "kubernetes-cluster-01" \ --zone "asia-southeast1-a" --machine-type "n1-standard-1" \ --num-nodes "1" --no-enable-stackdriver-kubernetes \ --project "your-project"
gcloud beta container clusters get-credentials "kubernetes-cluster-01" --zone "asia-southeast1-a" --project "your-project"
apiVersion: v1 kind: Namespace metadata: name: example --- apiVersion: apps/v1 kind: Deployment metadata: namespace: example name: flask-app-deployment spec: replicas: 1 selector: matchLabels: app: flask minReadySeconds: 20 template: metadata: labels: app: flask spec: containers: - name: flask-app image: sainivikas/blog-example-flask command: ["flask", "run", "-h", "0.0.0.0", "-p", "80"] --- apiVersion: v1 kind: Service metadata: namespace: example name: flask-app-service spec: selector: app: flask ports: - name: port-80 protocol: TCP port: 80 targetPort: 80 type: ClusterIP
kubectl apply -f app.yaml
You will get output like below after running the above command, It will create a Namespace, Deployment and service as defined in our deployment yaml.
vikassmacbook:kubernetes vikassaini$ kubectl apply -f app.yaml namespace/example created deployment.apps/flask-app-deployment created service/flask-app-service created
After this step, your application has been deployed in Kubernetes. You can check all resources running in your example namespace by running below command.
kubectl get all -n example
vikassmacbook:kubernetes vikassaini$ kubectl get all -n example NAME READY STATUS RESTARTS AGE pod/flask-app-deployment-746bd9fcc-js545 1/1 Running 0 21s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/flask-app-service ClusterIP 10.10.30.6 80/TCP 20s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/flask-app-deployment 1/1 1 0 21s NAME DESIRED CURRENT READY AGE replicaset.apps/flask-app-deployment-746bd9fcc 1 1 1 21s
Kubernetes Deployment also includes some preprocessing of Creating and uploading Docker Image which we have skipped and focused on deployment part only.
You can find used files of this demo in this repo.
While both Kubernetes and Google App Engine have their benefits and limitations, there’s no universal ‘correct’ answer for choosing between the two - this will completely depend on the requirement and use case of the organization.
Feel free to get in touch if you have any questions or helpful suggestions. Happy Reading :)
Find out how to avoid misconfigurations in Kubernetes that may lead to security breaches or sensitive data leaks.
In this episode of the SaC, we will discuss with Daniel Feldman, Zero Trust Architecture, the SPIFFE and SPIRE project, and what the future holds for zero-trust networks.