Skip to content

Commit

Permalink
[GHA] Update examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
ori-github-bot committed Nov 7, 2023
1 parent db4fd9a commit e4c2601
Show file tree
Hide file tree
Showing 25 changed files with 415 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions examples/resources/ogc_application/resource.tf
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
}
9 changes: 9 additions & 0 deletions examples/resources/ogc_container/resource.tf
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"
}
}
5 changes: 5 additions & 0 deletions examples/resources/ogc_container_mount/resource.tf
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
}
7 changes: 7 additions & 0 deletions examples/resources/ogc_container_port/resource.tf
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 examples/resources/ogc_container_resource_request/resource.tf
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"
}
4 changes: 4 additions & 0 deletions examples/resources/ogc_package/resource.tf
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"
}
14 changes: 14 additions & 0 deletions examples/resources/ogc_project/provider.tf
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" {
}
25 changes: 25 additions & 0 deletions examples/resources/ogc_project/resource.tf
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
}
14 changes: 14 additions & 0 deletions examples/resources/ogc_project_registry/provider.tf
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" {
}
11 changes: 11 additions & 0 deletions examples/resources/ogc_project_registry/resource.tf
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
}
5 changes: 5 additions & 0 deletions examples/resources/ogc_remote_endpoint/resource.tf
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"
}
20 changes: 20 additions & 0 deletions examples/resources/ogc_route_policy/resource.tf
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
}
7 changes: 7 additions & 0 deletions examples/resources/ogc_storage_request/resource.tf
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"
}
5 changes: 5 additions & 0 deletions examples/resources/ogc_traffic_source/resource.tf
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"
}
86 changes: 86 additions & 0 deletions examples/use_case/wordpress/gke.tf
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)
}
}
20 changes: 20 additions & 0 deletions examples/use_case/wordpress/kind.tf
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
}
10 changes: 10 additions & 0 deletions examples/use_case/wordpress/package.tf
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
}
Loading

0 comments on commit e4c2601

Please sign in to comment.