Skip to content

Commit

Permalink
V1
Browse files Browse the repository at this point in the history
  • Loading branch information
advissor committed Apr 12, 2021
0 parents commit f76725d
Show file tree
Hide file tree
Showing 121 changed files with 38,398 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Exclude all .tfvars files, which are likely to contain sentitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
#
*.tfvars
.terraform.lock.hcl
.DS_Store
.gitattributes
# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
22 changes: 22 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Terraform kubernetes provider with minikube

# Prerequisites

- terraform
- minikube
- kubectl

# Example 1 : Creating namespaces on local minikube cluster via terraform

cd namespaces

minikube start
terraform init
terraform apply


# Example 2 : Deploying sample hello world app on local minikube cluster via terraform

minikube start

terraform apply
103 changes: 103 additions & 0 deletions applications/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Configuring terraform kubernetes provider with minikube context and pointing to local kube config

provider "kubernetes" {
config_context_cluster = "minikube"
config_path = "~/.kube/config"
}

# Creating namespaces

resource "kubernetes_namespace" "applications-namespace" {
metadata {
name = "applications"
}
}

resource "kubernetes_namespace" "monitoring-namespace" {
metadata {
name = "monitoring"
}
}



# Deploying apps
# https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/deployment

# Deployment

resource "kubernetes_deployment" "nginx" {
metadata {
name = "scalable-nginx-example"
namespace = kubernetes_namespace.applications-namespace.id
labels = {
App = "ScalableNginxExample"
}
}

spec {
replicas = 2
selector {
match_labels = {
App = "ScalableNginxExample"
}
}
template {
metadata {
labels = {
App = "ScalableNginxExample"
}
}
spec {
container {
image = "nginx:1.7.8"
name = "example"

port {
container_port = 80
}

resources {
limits = {
cpu = "0.5"
memory = "512Mi"
}
requests = {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}
}


# Service





resource "kubernetes_service" "nginx-svc" {
metadata {
name = "nginx-example"
namespace = kubernetes_namespace.applications-namespace.id
}
spec {
selector = {
App = kubernetes_deployment.nginx.spec.0.template.0.metadata[0].labels.App
}
port {
node_port = 30201
port = 80
target_port = 80
}

type = "NodePort"
}
}

# minikube ip
# Visit : <minikube ip>:30201
11 changes: 11 additions & 0 deletions helm-istio/istio.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: install.istio.io/v1alpha2
kind: IstioControlPlane
spec:
# Use the default profile as the base
# More details at: https://istio.io/docs/setup/additional-setup/config-profiles/
profile: default
values:
global:
# Ensure that the Istio pods are only scheduled to run on Linux nodes
defaultNodeSelector:
beta.kubernetes.io/os: linux
Loading

0 comments on commit f76725d

Please sign in to comment.