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 Oct 23, 2023
1 parent 6d88226 commit e88b206
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 0 deletions.
82 changes: 82 additions & 0 deletions examples/guides/aws_onoard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
page_title: "Onboarding an AWS cluster"
---

EKS is the managed kubernetes offering from AWS. In this example we use a popular terraform module
to create an EKS cluster using Terraform and then onboard it onto OGC.

```terraform
terraform {
required_providers {
ogc = {
version = "0.1.0"
source = "ori-edge/ogc"
}
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "ogc" {}
provider aws {
region = "eu-west-2"
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.0.0"
name = "tf-vpc"
cidr = "10.0.0.0/16"
azs = ["eu-west-2a", "eu-west-2b"]
private_subnets = ["10.0.0.0/19", "10.0.32.0/19"]
public_subnets = ["10.0.64.0/19", "10.0.96.0/19"]
enable_nat_gateway = true
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = "tf-cluster"
cluster_version = "1.28"
cluster_endpoint_public_access = true
eks_managed_node_groups = {
general = {
desired_size = 1
min_size = 1
max_size = 1
instance_types = ["t2.medium"]
capacity_type = "ON_DEMAND"
}
}
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
}
resource "ogc_cluster" "cluster" {
display_name = "tf-eks-cluster"
permit_privileged_containers = false
description = "cluster created by terraform"
labels = {
key = "value"
}
kubernetes_config {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name]
command = "aws"
}
}
}
```
71 changes: 71 additions & 0 deletions examples/guides/azure_onoard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
page_title: "Onboarding an Azure cluster"
---

AKS is the managed kubernetes offering from Azure. In this example we create an AKS cluster
using Terraform and then onboard it onto OGC.

```terraform
terraform {
required_providers {
ogc = {
version = "0.1.0"
source = "ori-edge/ogc"
}
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
}
}
provider "ogc" {}
provider "azurerm" {
features {}
}
resource azurerm_resource_group default {
location = "uksouth"
name = "tf-rg"
}
resource "azurerm_kubernetes_cluster" "main" {
name = "tf-aks"
location = azurerm_resource_group.default.location
resource_group_name = azurerm_resource_group.default.name
dns_prefix = "tf-k8s"
kubernetes_version = "1.26.3"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
os_disk_size_gb = 30
}
identity {
type = "SystemAssigned"
}
role_based_access_control_enabled = true
}
resource "ogc_cluster" "cluster" {
display_name = "tf-aks-cluster"
permit_privileged_containers = false
description = "cluster created by terraform"
labels = {
key = "value"
}
kubernetes_config {
host = azurerm_kubernetes_cluster.main.kube_config.0.host
username = azurerm_kubernetes_cluster.main.kube_config.0.username
password = azurerm_kubernetes_cluster.main.kube_config.0.password
client_certificate = base64decode(azurerm_kubernetes_cluster.main.kube_config.0.client_certificate)
client_key = base64decode(azurerm_kubernetes_cluster.main.kube_config.0.client_key)
cluster_ca_certificate = base64decode(azurerm_kubernetes_cluster.main.kube_config.0.cluster_ca_certificate)
}
}
```
116 changes: 116 additions & 0 deletions examples/guides/gcp_onoard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
page_title: "Onboarding a GCP cluster"
---

GKE is the managed kubernetes offering from GCP. In this example we use a popular terraform module
to create a GKE cluster using Terraform and then onboard it onto OGC.

```terraform
terraform {
required_providers {
ogc = {
version = "0.1.0"
source = "ori-edge/ogc"
}
google = {
source = "hashicorp/google"
version = "~> 4.0"
}
}
}
provider "ogc" {}
provider "google" {
# project = "ori-edge"
# region = "us-central1"
# zone = "us-central1-c"
}
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" "cluster" {
display_name = "tf-gke-cluster"
permit_privileged_containers = false
description = "cluster created by terraform"
labels = {
key = "value"
}
kubernetes_config {
host = "https://${module.gke.endpoint}"
token = data.google_client_config.default.access_token
cluster_ca_certificate = base64decode(module.gke.ca_certificate)
}
}
```

0 comments on commit e88b206

Please sign in to comment.