diff --git a/examples/guides/aws_onoard.md b/examples/guides/aws_onboard.md similarity index 100% rename from examples/guides/aws_onoard.md rename to examples/guides/aws_onboard.md diff --git a/examples/guides/azure_onoard.md b/examples/guides/azure_onboard.md similarity index 100% rename from examples/guides/azure_onoard.md rename to examples/guides/azure_onboard.md diff --git a/examples/guides/gcp_onoard.md b/examples/guides/gcp_onboard.md similarity index 100% rename from examples/guides/gcp_onoard.md rename to examples/guides/gcp_onboard.md diff --git a/examples/resources/ogc_application/resource.tf b/examples/resources/ogc_application/resource.tf new file mode 100644 index 0000000..54f736d --- /dev/null +++ b/examples/resources/ogc_application/resource.tf @@ -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 +} \ No newline at end of file diff --git a/examples/resources/ogc_container/resource.tf b/examples/resources/ogc_container/resource.tf new file mode 100644 index 0000000..273bde0 --- /dev/null +++ b/examples/resources/ogc_container/resource.tf @@ -0,0 +1,9 @@ +resource "ogc_container" "container" { + name = "example" + application_id = ogc_application.app.id + image_name = "nginx" + env { + name = "PORT" + value = "80" + } +} \ No newline at end of file diff --git a/examples/resources/ogc_container_mount/resource.tf b/examples/resources/ogc_container_mount/resource.tf new file mode 100644 index 0000000..fc31d9a --- /dev/null +++ b/examples/resources/ogc_container_mount/resource.tf @@ -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 +} \ No newline at end of file diff --git a/examples/resources/ogc_container_port/resource.tf b/examples/resources/ogc_container_port/resource.tf new file mode 100644 index 0000000..58283d4 --- /dev/null +++ b/examples/resources/ogc_container_port/resource.tf @@ -0,0 +1,7 @@ +resource "ogc_container_port" "port" { + display_name = "http" + container_id = ogc_container.container.id + internal = 80 + external = 80 + protocol = "TCP" +} \ No newline at end of file diff --git a/examples/resources/ogc_container_resource_request/resource.tf b/examples/resources/ogc_container_resource_request/resource.tf new file mode 100644 index 0000000..a8e8935 --- /dev/null +++ b/examples/resources/ogc_container_resource_request/resource.tf @@ -0,0 +1,6 @@ +resource "ogc_container_resource_request" "rr" { + container_id = ogc_container.container.id + resource_type = "memory" + request = "1Gi" + limit = "1Gi" +} \ No newline at end of file diff --git a/examples/resources/ogc_package/resource.tf b/examples/resources/ogc_package/resource.tf new file mode 100644 index 0000000..9885087 --- /dev/null +++ b/examples/resources/ogc_package/resource.tf @@ -0,0 +1,4 @@ +resource "ogc_package" "pkg" { + name = "example" + project_id = "0e145a36-1ee7-434c-9f30-9e1ba4da2d7c" +} \ No newline at end of file diff --git a/examples/resources/ogc_project/provider.tf b/examples/resources/ogc_project/provider.tf new file mode 100644 index 0000000..0da4ccb --- /dev/null +++ b/examples/resources/ogc_project/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + ogc = { + version = "0.0.1" + source = "hashicorp.com/dev/ogc" + } + kind = { + source = "tehcyx/kind" + } + } +} + +provider "ogc" { +} \ No newline at end of file diff --git a/examples/resources/ogc_project/resource.tf b/examples/resources/ogc_project/resource.tf new file mode 100644 index 0000000..a1da951 --- /dev/null +++ b/examples/resources/ogc_project/resource.tf @@ -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 +} \ No newline at end of file diff --git a/examples/resources/ogc_project_registry/provider.tf b/examples/resources/ogc_project_registry/provider.tf new file mode 100644 index 0000000..0da4ccb --- /dev/null +++ b/examples/resources/ogc_project_registry/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + ogc = { + version = "0.0.1" + source = "hashicorp.com/dev/ogc" + } + kind = { + source = "tehcyx/kind" + } + } +} + +provider "ogc" { +} \ No newline at end of file diff --git a/examples/resources/ogc_project_registry/resource.tf b/examples/resources/ogc_project_registry/resource.tf new file mode 100644 index 0000000..9722661 --- /dev/null +++ b/examples/resources/ogc_project_registry/resource.tf @@ -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 +} \ No newline at end of file diff --git a/examples/resources/ogc_remote_endpoint/resource.tf b/examples/resources/ogc_remote_endpoint/resource.tf new file mode 100644 index 0000000..268a946 --- /dev/null +++ b/examples/resources/ogc_remote_endpoint/resource.tf @@ -0,0 +1,5 @@ +resource "ogc_remote_endpoint" "re" { + display_name = "example" + package_id = ogc_package.pkg.id + address = "0.0.0.0/0" +} \ No newline at end of file diff --git a/examples/resources/ogc_route_policy/resource.tf b/examples/resources/ogc_route_policy/resource.tf new file mode 100644 index 0000000..ecc3422 --- /dev/null +++ b/examples/resources/ogc_route_policy/resource.tf @@ -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 +} \ No newline at end of file diff --git a/examples/resources/ogc_storage_request/resource.tf b/examples/resources/ogc_storage_request/resource.tf new file mode 100644 index 0000000..6f31d5a --- /dev/null +++ b/examples/resources/ogc_storage_request/resource.tf @@ -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" +} \ No newline at end of file diff --git a/examples/resources/ogc_traffic_source/resource.tf b/examples/resources/ogc_traffic_source/resource.tf new file mode 100644 index 0000000..cc3850b --- /dev/null +++ b/examples/resources/ogc_traffic_source/resource.tf @@ -0,0 +1,5 @@ +resource "ogc_traffic_source" "ts" { + display_name = "example" + package_id = ogc_package.pkg.id + address = "0.0.0.0/0" +} \ No newline at end of file diff --git a/examples/use_case/wordpress/gke.tf b/examples/use_case/wordpress/gke.tf new file mode 100644 index 0000000..7634ba4 --- /dev/null +++ b/examples/use_case/wordpress/gke.tf @@ -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@.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) + } +} \ No newline at end of file diff --git a/examples/use_case/wordpress/kind.tf b/examples/use_case/wordpress/kind.tf new file mode 100644 index 0000000..cb2ae5f --- /dev/null +++ b/examples/use_case/wordpress/kind.tf @@ -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 +} \ No newline at end of file diff --git a/examples/use_case/wordpress/package.tf b/examples/use_case/wordpress/package.tf new file mode 100644 index 0000000..b1797d6 --- /dev/null +++ b/examples/use_case/wordpress/package.tf @@ -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 +} \ No newline at end of file diff --git a/examples/use_case/wordpress/package/main.tf b/examples/use_case/wordpress/package/main.tf new file mode 100644 index 0000000..016928a --- /dev/null +++ b/examples/use_case/wordpress/package/main.tf @@ -0,0 +1,116 @@ +data ogc_project "default" { + name = var.env +} + +resource ogc_package "default" { + name = "wordpress" + project_id = data.ogc_project.default.id +} + +resource ogc_application "fe" { + name = "wordpress-fe" + package_id = ogc_package.default.id + replicas = var.env == "prod"? 3 : 1 + + selector { + key = "cloud" + values = ["gcp"] + } + + selector { + key = "env" + values = [var.env] + } +} + +resource ogc_container "fe" { + name = "wordpress" + image_name = "docker.io/wordpress" + image_tag = "6.3-apache" + application_id = ogc_application.fe.id + + env { + name = "WORDPRESS_DB_PASSWORD" + value = "mypassword" + } + + env { + name = "WORDPRESS_DB_HOST" + value = "${ogc_application.db.name}.orinet.ori.cloud" + } + + env { + name = "WORDPRESS_DB_USER" + value = "wordpress" + } +} + +resource ogc_traffic_source "internet" { + display_name = "internet" + package_id = ogc_package.default.id + address = "0.0.0.0/0" +} + +resource ogc_container_port "fe" { + display_name = "http" + container_id = ogc_container.fe.id + internal = 80 + external = 80 +} + +resource ogc_route_policy "fe" { + package_id = ogc_package.default.id + port_id = ogc_container_port.fe.id + traffic_source_id = ogc_traffic_source.internet.id +} + +resource ogc_application "db" { + name = "database" + package_id = ogc_package.default.id + replicas = var.env == "prod"? 3 : 1 + + selector { + key = "cloud" + values = ["local"] + } +} + +resource ogc_container "db" { + name = "database" + image_name = "docker.io/mysql" + image_tag = "8.0" + application_id = ogc_application.db.id + + env { + name = "MYSQL_ROOT_PASSWORD" + value = "mypassword" + } + + env { + name = "MYSQL_DB_PASSWORD" + value = "mypassword" + } + + env { + name = "MYSQL_DATABASE" + value = "wordpress" + } + + env { + name = "MYSQL_USER" + value = "wordpress" + } +} + +resource ogc_container_port "db" { + display_name = "mysql" + container_id = ogc_container.db.id + internal = 3306 + external = 3306 +} + +resource ogc_route_policy "internal" { + package_id = ogc_package.default.id + port_id = ogc_container_port.db.id + application_id = ogc_application.fe.id +} diff --git a/examples/use_case/wordpress/package/outputs.tf b/examples/use_case/wordpress/package/outputs.tf new file mode 100644 index 0000000..775e97c --- /dev/null +++ b/examples/use_case/wordpress/package/outputs.tf @@ -0,0 +1,3 @@ +output "package_id" { + value = ogc_package.default.id +} \ No newline at end of file diff --git a/examples/use_case/wordpress/package/provider.tf b/examples/use_case/wordpress/package/provider.tf new file mode 100644 index 0000000..f4f70e1 --- /dev/null +++ b/examples/use_case/wordpress/package/provider.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + ogc = { + version = "0.0.1" + source = "hashicorp.com/dev/ogc" + } + } +} \ No newline at end of file diff --git a/examples/use_case/wordpress/package/variables.tf b/examples/use_case/wordpress/package/variables.tf new file mode 100644 index 0000000..33a1fef --- /dev/null +++ b/examples/use_case/wordpress/package/variables.tf @@ -0,0 +1,4 @@ +variable "env" { + type = string + default = "dev" +} \ No newline at end of file diff --git a/examples/use_case/wordpress/provider.tf b/examples/use_case/wordpress/provider.tf new file mode 100644 index 0000000..ce6feb6 --- /dev/null +++ b/examples/use_case/wordpress/provider.tf @@ -0,0 +1,27 @@ +terraform { + required_providers { + ogc = { + version = "0.0.1" + source = "hashicorp.com/dev/ogc" + } + google = { + source = "hashicorp/google" + version = "~> 4.0" + } + + kind = { + source = "tehcyx/kind" + version = "0.2.1" + } + } +} + +provider "ogc" {} + +provider "google" { + project = "ori-edge" + region = "us-central1" + zone = "us-central1-c" +} + +provider "kind" {}