iWay Google Cloud Deployment
Search form
iWay Google Deployment Overview
The goal of this tutorial is to show how to deploy iWay application that was build by iWay iIT tool in previous tutorial here to the Google Cloud.
Google Cloud Platform (GCP) is a collection of Google’s computing resources, made available via services to the general public as a public cloud offering.
The GCP resources consist of physical hardware infrastructure — computers, hard disk drives, solid state drives, and networking — contained within Google’s globally distributed data centers, where any of the components are custom designed using patterns similar to those available in the Open Compute Project.
This hardware is made available to customers in the form of virtualizedresources, such as virtual machines (VMs), as an alternative to customers building and maintaining their own physical infrastructure.
In short this application consists of two Docker containers:
- iWay Application exposing an API(defined via RAML file) which utilized the iIT MongoDB Connector
- MongoDB Server
We brought these containers up and managed communication between two by using Kubernetes technology.
Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.
We deploy this application on Google Cloud by utilizing brand new Microsoft product called Google Kubernetes Service (GKE).
Actually, by utilizing technologies described above we managed to build a Software as a Service (SaaS) managed by Azure Cloud!
Software as a service (SaaS) is a software distribution model in which a third-party provider hosts applications and makes them available to customers over the Internet.
SaaS is one of three main categories of cloud computing, alongside infrastructure as a service (IaaS) and platform as a service (PaaS).
What is GKE?
Kubernetes Engine is a managed, production-ready environment for deploying containerized applications. Kubernetes Engine allows to get up and running with Kubernetes in no time, by completely eliminating the need to install, manage, and operate your own Kubernetes clusters.
Before you begin
Take the following steps to enable the Kubernetes Engine API:
- Visit the Kubernetes Engine page in the Google Cloud Platform Console.
- Create or select a project.
- Wait for the API and related services to be enabled. This can take several minutes.
- Make sure that billing is enabled for your project.
We use can use Google Cloud Platform Dashboard and Google Cloud Shell to complete the task.
Google Cloud Shell is a shell environment for managing resources hosted on Google Cloud Platform (GCP). Cloud Shell comes preinstalled with the gcloud and kubectl command-line tools. gcloud
provides the primary command-line interface for GCP, and kubectl
provides the command-line interface for running commands against Kubernetes clusters.
Here are the steps to deploy an application to the Google Cloud:
I. Create a new project.
II. Activate a Cloud Shell.
Press a button depicted below on Google Cloud Platform Dashboard:
III. Set a default project
To set a default project, run the following command from Cloud Shell:
Replace PROJECT_ID
with your project ID.
IV Set a default compute zone
To set a default time zone, run the following command from Cloud Shell:
whereCOMPUTE_ZONE
is the desired geographical compute zone, such asus-west1-a
.
V. Create a Kubernetes Engine cluster from the Google Cloud Platform Kubernetes Engine console
Also cluster may be created from the shell with the following commnand:
gcloud container clusters create CLUSTER_NAME
where CLUSTER_NAME
is the name you choose for the cluster.
Sample iway-cluster in a Kubernetes Engine console:
VI. Get authentication credentials for the cluster
After creating your cluster, you need to get authentication credentials to interact with the cluster.
To authenticate for the cluster, run the following command:
gcloud container clusters get-credentials CLUSTER_NAME
This command configures kubectl
to use the cluster you created.
VII. Deploying an application to the cluster
In this section, you will finally launch an iWay API application to the Google Cloud.
We start the process with creating Google Storage Class, because Google Kubernetes Engine clusters are not created with any storage classes.
Steps to deploy iWAY API application to the AWS Cloud are:
1. Create Storage by executing the following command: kubectl apply -f gp2.yaml
Here is the file gp2.yaml:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: gp2
name: slow
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
status: {}
Go to the Cloud Console to see Persistent volume claim details:
2. Create the mongodb kubernetes pod: kubectl apply -f mongodb-deployment.yml
Here is the file: mongodb-deployment.yml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: C:\Program Files\docker\kompose-windows-amd64.exe convert -f docker-compose.yml
kompose.version: 1.12.0 (0ab07be)
creationTimestamp: null
labels:
io.kompose.service: mongodb
name: mongodb
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: mongodb
spec:
containers:
- image: bitnami/mongodb:latest
name: mongodb
ports:
- containerPort: 27017
resources: {}
volumeMounts:
- mountPath: /data/db
name: slow
restartPolicy: Always
volumes:
- name: slow
persistentVolumeClaim:
claimName: slow
status: {}
Go to Cloud Console to see the mongodb deployment details:
3. Create myiway kubernetes pod: kubectl apply -f deployment.yml
This Kubernetes command, kubectl apply
, creates a new Deployment named myiway
.
The Deployment's Pod runs the iwaydocker/iwaydemo image in its container.
Here is the file deployment.yml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: myiway
labels:
app: myiway
spec:
replicas: 1
strategy: {}
template:
metadata:
labels:
app: myiway
spec:
containers:
- image: iwaydocker/iwaydemo
imagePullPolicy: Always
name: myiway
ports:
- containerPort: 9999
- containerPort: 9000
- containerPort: 9001
- containerPort: 8081
resources: {}
restartPolicy: Always
status: {}
Go to Cloud Console to see myiway deployment details:
4. Next step should be to create a kubernetes service for myiway: kubectl expose deployment myiway --name=myiway --type=LoadBalancer
5. And create a kubernetes service for the mongodb: kubectl expose deployment mongodb --name=mongodb --type=LoadBalancer
6. Go to Google Cloud Console, then Services, to see if myiway and mongodb kubernetes services where created successfully:
Or by executing the following command kubectl get svc -o wide we list the running services .
7. Go to Cloud Console to see the deployments logs:
8. By using EXTERNAL-IP address and port 9999 for the service myiway, we may visit the iWay Service manager Console:
9. Use EXTERNAL-IP address on port 8081 and iIT iWay Explorer to post JSON document into MongoDB database:
10. Use the API endpoint to browse the posted document: