Skip to content

dragonknight919/terraform-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nuvolar

...Test Assignment 🚀...

Preconditions

Install the following software:

Minikube Setup

Run minikube:

$ sudo usermod -aG docker $USER && newgrp docker #(Optional)
$ minikube start

If you run Optional command, you can run docker command without sudo command.

Enable the Nginx Ingress.

$ minikube addons enable ingress

API Gateway Setup

Configure the k8s cluster using Terraform, it can take near 1 min estimated. Terraform will use the context minikube configured in ~/.kube/config

$ terraform init
$ terraform plan
$ terraform apply

If you want to destroy the K8S cluster, please run.

$ terraform destroy

Append the host endpoint entry to /etc/hosts

$ sudo echo $(minikube ip) test.com >> /etc/hosts

Test

You can test api-gateway using curl command:

$ curl -X GET http://test.com:31016/order
$ curl --head http://test.com:31016/order

Commands to Debugs

minikube

$ minikube stop
$ minikube start
$ minikube status
$ minikube ssh
$ minikube service list
$ minikube addons list | grep enabled

K8S

$ kubectl get pods -A
$ kubectl get services -A
$ kubectl get ingress -A
$ kubectl get deployments -A
$ kubectl config set-context --current --namespace=NAMESPACE_NAME
$ kubectl describe pod POD_NAME -n NAMESPACE_NAME
$ kubectl describe service SERVICE_NAME -n NAMESPACE_NAME
$ kubectl describe ingress INGRESS_NAME -n NAMESPACE_NAME
$ kubectl describe deployment DEPLOYMENT_NAME -n NAMESPACE_NAME
$ kubectl logs POD_NAME -n NAMESPACE_NAME
$ kubectl exec --stdin --tty POD_NAME -- /bin/sh

Why I choose what I choose ?

terraform:

Because, it is an standard in IaC, it has a long community. Many people contribute writing code, modules, libraries. On the other hand, is very fast, maintain the state of the infrastructure, can work in a CI/CD, support many provider, low curve to learn. In this example, I use to create the K8S using minikube, but we can adapt to run in Google Cloud, Amazon AWS, Azure an others. We can create monitors, dashboard, alert in Datadog, NewRelic and other providers while we are creating the K8S cluster.

minikube:

I was a long time using minikube as there is simply alternatives and to be honest it does a pretty good job at being a local Kubernetes for development environment. You can create the cluster, wait a few minutes and you are ready to go.

docker:

It is the de facto Standard to build and share containerized applications and supported for many providers and container orchestrators. It provides:

  • Security
  • Isolation
  • Reproducible Image
  • Easy CI/CD

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages