Multi Hybrid Cloud

Aditisinha
7 min readSep 5, 2020

No business architecture is possible without multi hybrid cloud. Lets first understand about the Hybrid cloud.

The cloud service providers basically offers three types of services :

IAAS: Infrastructure as a service that includes servers, network, storage, etc.

PAAS: Platform as a service , that provides the platform to run your code directly without worrying about the infrastructure of Host. Just tell the requirements and there you go.

SAAS: This is the most widely used service in cloud environment, that directly provide you the software to use. Gmail is the best example in this arena.

Now, for developing a product a company cant rely on a single service , it integrates multiple services or environments to deploy a single product. There are many reasons for this integration, first of all, it can be performance issue, management,security or compliance issues.

And, since, our final intention is to deploy the product and the clients has no issue with the infrastructure you use ,until your system is fully secured and perform well.

So, here comes the role of Hybrid Cloud. In Hybrid Cloud environment multiple services of cloud , as mentioned above, are integrated to deploy a single product.

Here, I would like to present an example for this.

Kubernetes: It is an example of container orchestration engine programs, that manages the containers. It is a single program that offers fault tolerance, Scaling, loadbalancing , reverse proxy, service discovery. So, basically it is a PAAS , here, the developer need not worry about the architecture and can directly deploy its application.

Amazon RDS: AWS is an umbrella of many different services. Among which, RDS is a service that gives Database server as a service. this server is fully managed by service provider, and the data stored there is also fully secured and available. So, basically it is an IAAS, we geta managed server from cloud provider.

So, we going to deploy our WordPress application over Kubernetes, and since this application requires a database, we will create a database in Amazon RDS service.

Also, this entire infrastructure, can be deployed in a single click, so that we can easily share the infrastructure configurations and easily deploy or destroy accordingly, anytime and anywhere.

Again, AWS offers a service , ie, Cloudformation as Infrastructure As Code(IAC) , but using this we can only deploy our environment in AWS. Again this is a major problem, but knock knock!! , we got a solution for this. We use Terraform for IAC , which can deploy your application in multiple environment in a single click.Since, for launching a product, we have different WebUIs, CLI commands . And it is a very difficult job for developer if it would invest time and energy in this arena.

The following code is used:

//Here, I used minikube, a single node k8s cluster.
provider “kubernetes” {
config_context_cluster = “minikube”
}
//AWS provider credentials
provider "aws" {
region = "ap-south-1"
profile = "riya"
}
//Database instance
resource "aws_db_instance" "mysqldb" {
allocated_storage = 10
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t2.micro"
storage_type = "gp2"
name = "mydb"
username = "aditi"
password = "longpassword"
port = "3306"
publicly_accessible = true
skip_final_snapshot = true
parameter_group_name = "default.mysql5.7"
tags = {
Name = "Wp-database"
}
}
//Creating a deployment resource for our application
resource “kubernetes_deployment” “example” {
metadata {
name = “wordpressdeployment”
labels = {
test = “MyExampleApp”
}
}
spec {
replicas = 3
selector {
match_labels = {
test = “MyExampleApp”
}
}
template {
metadata {
labels = {
test = “MyExampleApp”
}
}
spec {
container {
image = “wordpress:4.8-apache”
name = “wordpresscontainer”
}
}
}
}
}
//creating a service, to expose our application to outside world
resource “kubernetes_service” “wp-expose” {
metadata {
name = “terraform-wp-service”
}
spec {
selector = {
test = “MyExampleApp”
}
//valid ports range from:30000-32767
port {
node_port = 32765
port = 80
target_port = 80
}
type = “NodePort”
}
}
Start the minikube cluster
Download the required plugins through “terraform init “
And the application is successfully deployed
Here, your pods are running and exposed also.
The application is running successfully
Enter the details of your databse host.

Also, in single click we can destroy the entire infrastrcture.

Nowadays, in corporate world, for launching many project, they need lots of services to create the infrastructure and finally deploy their product. But,using one single cloud is not a good service, as some service is good in some public cloud providers based on availability , cost or multiple factors.

Typically, due to many reasons they dont restrict themselves to use service from only one cloud provider. So, some part of the project we get services from, public cloud AWS, public Cloud GCP, etc. hence, for different service requirements, they use multiple cloud to deploy their product.

Here, I would like to use the same example as above, except for Kubernetes as a service, we can use public cloud. AWS offers KAAS through EKS, while GCP offers KAAS through kubernetes engine. But, as EKS will cost me more and I still have free tier left in GCP , I will go for GCP for availing KAAS, and AWS for database server, which comes in free tier. So, this is one of the example how a company make decisions while availing services from cloud providers.

Also, since, we are deploying our K8s cluster in public cloud, so it will be better, to create your own customized network. For, Network as a service (NAAS) we will use VPC service of GCP, which is ultimately IAAS, so again we used an Hybrid cloud environment(IAAS (VPC)+ PAAS(kubernetes engine), and availing the database service from AWS. So,we achieved Multi cloud environment(AWS + GCP). And, finally we have a Hybrid Multi Cloud environment.

And, again integrating multiple services we used terraform for this. Following code depicts the entire infrastructure:

provider “aws” {
region = “ap-south-1”
profile = “riya”
}
//Database instance
resource “aws_db_instance” “mysqldb” {
allocated_storage = 10
engine = “mysql”
engine_version = “5.7”
instance_class = “db.t2.micro”
storage_type = “gp2”
name = “mydb”
username = “aditi”
password = “longpassword”
port = “3306”
publicly_accessible = true
skip_final_snapshot = true
parameter_group_name = “default.mysql5.7”
tags = {
Name = “Wp-database”
}
}
provider "google" {
project = "qwiklabs-gcp-02-4aba9d16c1f2"
region = "asia-southeast1"

}
resource "google_compute_network" "vpc_network" {
name = "wp-vpc"
auto_create_subnetworks = false
routing_mode = "REGIONAL"
}
resource "google_compute_subnetwork" "subnet" {
network = google_compute_network.vpc_network.id
name = "wp-lab"
ip_cidr_range = "10.0.11.0/24"
region = "asia-southeast1"
depends_on = [google_compute_network.vpc_network]
}
resource "google_compute_firewall" "firewall" {
name = "wp-firewall"
network = google_compute_network.vpc_network.name
source_ranges = [ "0.0.0.0/0" ]
allow {
protocol = "all"
}
depends_on = [google_compute_subnetwork.subnet]
}
resource "google_container_cluster" "gce" {
name = "wp-cluster"
location = "asia-southeast1"
remove_default_node_pool = true
initial_node_count = 1
network = google_compute_network.vpc_network.name
subnetwork = google_compute_subnetwork.subnet.name
depends_on = [google_compute_firewall.firewall]
}resource "google_container_node_pool" "node_pool" {
location = "asia-southeast1"
name = "wp-node"
cluster = google_container_cluster.gce.name
node_count = 1
node_config {
machine_type = "n1-standard-1"
}
depends_on = [google_container_cluster.gce]
}
resource "null_resource" "one" {
provisioner "local-exec" {
command ="gcloud container clusters get-credentials wp-cluster - region=asia-southeast1"
}

depends_on=[google_container_node_pool.node_pool,]
}
provider "kubernetes" {}
resource "kubernetes_deployment" "example" {
metadata {
name = "wordpressdeployment"
labels = {
test = "MyExampleApp"
}
}
spec {
replicas = 3
selector {
match_labels = {
test = "MyExampleApp"
}
}
template {
metadata {
labels = {
test = "MyExampleApp"
}
}
spec {
container {
image = "wordpress:4.8-apache"
name = "wordpresscontainer"
}
}
}
}
depends_on=[null_resource.one]
}
resource "kubernetes_service" "wp-expose" {
metadata {
name = "terraform-wp-service"
}
spec {
selector = {
test = "MyExampleApp"
}

port {

port = 8080
target_port = 80
}
type = "LoadBalancer"
}
depends_on = [kubernetes_deployment.example]
}
output "WordPress-Address" {
value = "${kubernetes_service.wp-expose.load_balancer_ingress.0.ip}"
}

All these concepts I got to learn under Mr. Vimal Daga. Thankyou so much!

--

--

Aditisinha
0 Followers

B. Tech 3rd Year student. Keen interest in knowing new technologies and spend most of the time in learning them.