-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db4fd9a
commit e4c2601
Showing
25 changed files
with
415 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "ogc_package" "pkg" { | ||
name = "example" | ||
project_id = "0e145a36-1ee7-434c-9f30-9e1ba4da2d7c" | ||
} | ||
|
||
resource "ogc_application" "app" { | ||
name = "example" | ||
package_id = ogc_package.pkg.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "ogc_container" "container" { | ||
name = "example" | ||
application_id = ogc_application.app.id | ||
image_name = "nginx" | ||
env { | ||
name = "PORT" | ||
value = "80" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "ogc_container_mount" "mount" { | ||
container_id = ogc_container.container.id | ||
filepath = "/mnt" | ||
storage_request_id = ogc_storage_request.sr.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resource "ogc_container_port" "port" { | ||
display_name = "http" | ||
container_id = ogc_container.container.id | ||
internal = 80 | ||
external = 80 | ||
protocol = "TCP" | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/resources/ogc_container_resource_request/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resource "ogc_container_resource_request" "rr" { | ||
container_id = ogc_container.container.id | ||
resource_type = "memory" | ||
request = "1Gi" | ||
limit = "1Gi" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "ogc_package" "pkg" { | ||
name = "example" | ||
project_id = "0e145a36-1ee7-434c-9f30-9e1ba4da2d7c" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
required_providers { | ||
ogc = { | ||
version = "0.0.1" | ||
source = "hashicorp.com/dev/ogc" | ||
} | ||
kind = { | ||
source = "tehcyx/kind" | ||
} | ||
} | ||
} | ||
|
||
provider "ogc" { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resource "ogc_project" "proj" { | ||
display_name = "tf-proj" | ||
} | ||
|
||
resource "ogc_cluster" "cluster" { | ||
display_name = "tf-cluster" | ||
permit_privileged_containers = false | ||
description = "cluster created by terraform" | ||
labels = { | ||
key = "value" | ||
} | ||
projects = [ogc_project.proj.id] | ||
|
||
kubernetes_config { | ||
config_path = kind_cluster.default.kubeconfig_path | ||
} | ||
} | ||
|
||
# Example local cluster (you can use GKE, EKS, AKS, etc instead) | ||
provider "kind" {} | ||
|
||
resource "kind_cluster" "default" { | ||
name = "test-cluster" | ||
wait_for_ready = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
required_providers { | ||
ogc = { | ||
version = "0.0.1" | ||
source = "hashicorp.com/dev/ogc" | ||
} | ||
kind = { | ||
source = "tehcyx/kind" | ||
} | ||
} | ||
} | ||
|
||
provider "ogc" { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
resource "ogc_project" "proj" { | ||
display_name = "tf-proj" | ||
} | ||
|
||
resource "ogc_project_registry" reg { | ||
name = "tf-reg2" | ||
url = "url.com" | ||
username = "user" | ||
password = "password" | ||
project_id = ogc_project.proj.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "ogc_remote_endpoint" "re" { | ||
display_name = "example" | ||
package_id = ogc_package.pkg.id | ||
address = "0.0.0.0/0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# route policy between 2 applications | ||
resource "ogc_route_policy" "internal" { | ||
package_id = ogc_package.pkg.id | ||
application_id = ogc_application.simple_app.id | ||
port_id = ogc_container_port.port.id | ||
} | ||
|
||
# expose an application to be accessible by the outside world | ||
resource "ogc_route_policy" "external" { | ||
package_id = ogc_package.pkg.id | ||
traffic_source_id = ogc_traffic_source.internet.id | ||
port_id = ogc_container_port.port.id | ||
} | ||
|
||
# give internet access to an application | ||
resource "ogc_route_policy" "internet" { | ||
package_id = ogc_package.pkg.id | ||
application_id = ogc_application.simple_app.id | ||
remote_endpoint_id = ogc_remote_endpoint.internet.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resource "ogc_storage_request" "sr" { | ||
display_name = "MongoDb" | ||
package_id = ogc_package.pkg.id | ||
persistence_type = "Persistent" | ||
type = "StandardHDD" | ||
capacity_requested_mb = "1024" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "ogc_traffic_source" "ts" { | ||
display_name = "example" | ||
package_id = ogc_package.pkg.id | ||
address = "0.0.0.0/0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
data "google_client_config" "default" {} | ||
|
||
data google_project proj { | ||
project_id = "ori-edge" | ||
} | ||
|
||
variable region { | ||
default = "us-central1" | ||
} | ||
|
||
locals { | ||
ip_range_pods_name = "${var.region}-01-gke-01-pods" | ||
ip_range_services_name = "${var.region}-01-gke-01-services" | ||
} | ||
|
||
module "gcp-network" { | ||
source = "terraform-google-modules/network/google" | ||
version = "6.0.0" | ||
project_id = data.google_project.proj.name | ||
network_name = "tf-network" | ||
|
||
subnets = [ | ||
{ | ||
subnet_name = "tf-subnet" | ||
subnet_ip = "10.10.0.0/16" | ||
subnet_region = var.region | ||
}, | ||
] | ||
|
||
secondary_ranges = { | ||
"tf-subnet" = [ | ||
{ | ||
range_name = local.ip_range_pods_name | ||
ip_cidr_range = "10.20.0.0/16" | ||
}, | ||
{ | ||
range_name = local.ip_range_services_name | ||
ip_cidr_range = "10.30.0.0/16" | ||
}, | ||
] | ||
} | ||
} | ||
|
||
module "gke" { | ||
source = "terraform-google-modules/kubernetes-engine/google" | ||
version = "26.1.1" | ||
project_id = data.google_project.proj.name | ||
name = "gke-test-1" | ||
region = var.region | ||
network = module.gcp-network.network_name | ||
subnetwork = module.gcp-network.subnets_names[0] | ||
ip_range_pods = local.ip_range_pods_name | ||
ip_range_services = local.ip_range_services_name | ||
http_load_balancing = false | ||
network_policy = false | ||
horizontal_pod_autoscaling = true | ||
filestore_csi_driver = false | ||
|
||
node_pools = [ | ||
{ | ||
name = "default-node-pool" | ||
machine_type = "e2-medium" | ||
node_locations = "us-central1-b,us-central1-c" | ||
min_count = 1 | ||
max_count = 1 | ||
disk_size_gb = 30 | ||
disk_type = "pd-standard" | ||
# service_account = "project-service-account@<PROJECT ID>.iam.gserviceaccount.com" | ||
}, | ||
] | ||
} | ||
|
||
resource "ogc_cluster" "gke" { | ||
display_name = "tf-gke-cluster" | ||
description = "cluster created by terraform" | ||
labels = { | ||
cloud = "gcp" | ||
} | ||
projects = [for o in values(data.ogc_project.default) : o.id ] | ||
|
||
kubernetes_config { | ||
host = "https://${module.gke.endpoint}" | ||
token = data.google_client_config.default.access_token | ||
cluster_ca_certificate = base64decode(module.gke.ca_certificate) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
resource "ogc_cluster" "kind" { | ||
display_name = "tf-kind-cluster" | ||
description = "cluster created by terraform" | ||
labels = { | ||
cloud = "local" | ||
} | ||
|
||
kubernetes_config { | ||
config_path = kind_cluster.default.kubeconfig_path | ||
} | ||
|
||
projects = [for o in values(data.ogc_project.default) : o.id ] | ||
} | ||
|
||
|
||
|
||
resource "kind_cluster" "default" { | ||
name = "test-cluster" | ||
wait_for_ready = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
data ogc_project "default" { | ||
for_each = toset(["dev", "prod"]) | ||
name = each.key | ||
} | ||
|
||
module "package" { | ||
for_each = toset(["dev", "prod"]) | ||
source = "./package" | ||
env = each.key | ||
} |
Oops, something went wrong.