Skip to content

Commit 46503b1

Browse files
authored
Optional OKE cluster creation
1 parent 40023ab commit 46503b1

17 files changed

+665
-34
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
release:
2-
@cd proxy; zip -q ../proxy-stack.zip schema.yaml *.tf; cd ..
3-
@cd hub; zip -q ../hub-stack.zip schema.yaml *.tf; cd ..
4-
@cd hub-apim; zip -q ../hub-apim-stack.zip schema.yaml *.tf; cd ..
2+
@bash release.sh proxy
3+
@bash release.sh hub
4+
@bash release.sh hub-apim
55
@ls -lh *.zip

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# oci-traefiklabs-stacks
22

3-
To launch it locally, you'll need to set those env. variables:
3+
To launch it locally, you'll need to go back to latest terraform version before license change:
4+
5+
```sh
6+
sudo apt-get install terraform=1.5.7-1
7+
```
8+
9+
and set those env. variables:
410

511
```sh
612
export TF_VAR_user_ocid=

hub-apim/provider.tf

+17-5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,24 @@ provider "oci" {
2020
region = var.region
2121
}
2222

23+
module "oke" {
24+
source = "../oke"
25+
count = var.oke_cluster_create ? 1 : 0
26+
27+
tenancy_ocid = var.tenancy_ocid
28+
region = var.region
29+
oke_display_name = var.oke_cluster_name
30+
providers = {
31+
oci = oci
32+
}
33+
}
34+
2335
data "oci_containerengine_cluster" "target" {
24-
cluster_id = var.oke_cluster_id
36+
cluster_id = var.oke_cluster_create ? module.oke[0].cluster_id : var.oke_cluster_id
2537
}
2638

2739
data "oci_containerengine_cluster_kube_config" "target" {
28-
cluster_id = var.oke_cluster_id
40+
cluster_id = data.oci_containerengine_cluster.target.id
2941
}
3042

3143
locals {
@@ -42,8 +54,8 @@ provider "helm" {
4254
exec = {
4355
api_version = "client.authentication.k8s.io/v1beta1"
4456
command = "docker"
45-
# args = ["run", "--rm", "-it", "-v", "/home/michel/.oci:/oracle/.oci", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", var.oke_cluster_id, "--region", var.region]
46-
args = ["run", "--rm", "-t", "-u", "1101:1101", "-v", "/home/orm:/home/orm", "-e", "OCI_CLI_AUTH", "-e", "OCI_CLI_CONFIG_FILE", "-e", "OCI_CLI_CLOUD_SHELL", "-e", "OCI_CLI_USE_INSTANCE_METADATA_SERVICE", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", var.oke_cluster_id, "--region", var.region]
57+
# args = ["run", "--rm", "-it", "-v", "/home/michel/.oci:/oracle/.oci", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", data.oci_containerengine_cluster.target.id, "--region", var.region]
58+
args = ["run", "--rm", "-t", "-u", "1101:1101", "-v", "/home/orm:/home/orm", "-e", "OCI_CLI_AUTH", "-e", "OCI_CLI_CONFIG_FILE", "-e", "OCI_CLI_CLOUD_SHELL", "-e", "OCI_CLI_USE_INSTANCE_METADATA_SERVICE", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", data.oci_containerengine_cluster.target.id, "--region", var.region]
4759
}
4860
}
4961
}
@@ -56,6 +68,6 @@ provider "kubernetes" {
5668
api_version = "client.authentication.k8s.io/v1beta1"
5769
command = "docker"
5870
# args = ["run", "--rm", "-it", "-v", "/home/michel/.oci:/oracle/.oci", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", var.oke_cluster_id, "--region", var.region]
59-
args = ["run", "--rm", "-t", "-u", "1101:1101", "-v", "/home/orm:/home/orm", "-e", "OCI_CLI_AUTH", "-e", "OCI_CLI_CONFIG_FILE", "-e", "OCI_CLI_CLOUD_SHELL", "-e", "OCI_CLI_USE_INSTANCE_METADATA_SERVICE", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", var.oke_cluster_id, "--region", var.region]
71+
args = ["run", "--rm", "-t", "-u", "1101:1101", "-v", "/home/orm:/home/orm", "-e", "OCI_CLI_AUTH", "-e", "OCI_CLI_CONFIG_FILE", "-e", "OCI_CLI_CLOUD_SHELL", "-e", "OCI_CLI_USE_INSTANCE_METADATA_SERVICE", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", data.oci_containerengine_cluster.target.id, "--region", var.region]
6072
}
6173
}

hub-apim/schema.yaml

+26-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,21 @@ variableGroups:
3434

3535
- title: "OKE Configuration"
3636
variables:
37-
- oke_cluster_id
37+
- oke_cluster_create
3838
- oke_insecure
3939

40+
- title: "Create basic OKE"
41+
variables:
42+
- oke_cluster_name
43+
visible: ${oke_cluster_create}
44+
45+
- title: "Use existing OKE"
46+
variables:
47+
- oke_cluster_id
48+
visible:
49+
not:
50+
- ${oke_cluster_create}
51+
4052
- title: "Chart Configuration"
4153
variables:
4254
- chart_create_namespace
@@ -69,10 +81,22 @@ variables:
6981

7082
oke_cluster_id:
7183
type: string
72-
required: true
7384
title: OKE Cluster ID
7485
description: The Oracle Cloud ID of the OKE cluster
7586

87+
oke_cluster_create:
88+
type: boolean
89+
title: Create basic OKE Cluster
90+
description: 3 nodes (VM.Standard.E3.Flex) / 2 OCPU / 4 GB RAM / latest OKE version
91+
92+
oke_cluster_name:
93+
type: string
94+
title: Name of OKE Cluster to create
95+
default: traefik-demo
96+
minLength: 1
97+
maxLength: 25
98+
pattern: "^[a-z][a-zA-Z0-9-]+$"
99+
76100
oke_insecure:
77101
type: boolean
78102
title: Allow insecure connection

hub-apim/variables.tf

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
variable "tenancy_ocid" {}
22
variable "region" {}
3-
variable "oke_cluster_id" {}
43

4+
variable "oke_cluster_id" {
5+
type = string
6+
default = ""
7+
}
8+
variable "oke_cluster_name" {
9+
type = string
10+
default = "traefik-demo"
11+
}
12+
variable "oke_cluster_create" {
13+
type = bool
14+
default = false
15+
}
516
variable "oke_insecure" {
617
type = bool
718
default = false
@@ -10,20 +21,16 @@ variable "oke_insecure" {
1021
variable "chart_values" {
1122
type = string
1223
}
13-
1424
variable "chart_hub_token" {
1525
type = string
1626
sensitive = true
1727
}
18-
1928
variable "chart_hub_version" {
2029
type = string
2130
}
22-
2331
variable "chart_namespace" {
2432
type = string
2533
}
26-
2734
variable "chart_create_namespace" {
2835
type = bool
2936
default = false

hub/provider.tf

+17-5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,24 @@ provider "oci" {
2020
region = var.region
2121
}
2222

23+
module "oke" {
24+
source = "../oke"
25+
count = var.oke_cluster_create ? 1 : 0
26+
27+
tenancy_ocid = var.tenancy_ocid
28+
region = var.region
29+
oke_display_name = var.oke_cluster_name
30+
providers = {
31+
oci = oci
32+
}
33+
}
34+
2335
data "oci_containerengine_cluster" "target" {
24-
cluster_id = var.oke_cluster_id
36+
cluster_id = var.oke_cluster_create ? module.oke[0].cluster_id : var.oke_cluster_id
2537
}
2638

2739
data "oci_containerengine_cluster_kube_config" "target" {
28-
cluster_id = var.oke_cluster_id
40+
cluster_id = data.oci_containerengine_cluster.target.id
2941
}
3042

3143
locals {
@@ -43,7 +55,7 @@ provider "helm" {
4355
api_version = "client.authentication.k8s.io/v1beta1"
4456
command = "docker"
4557
# args = ["run", "--rm", "-it", "-v", "/home/michel/.oci:/oracle/.oci", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", var.oke_cluster_id, "--region", var.region]
46-
args = ["run", "--rm", "-t", "-u", "1101:1101", "-v", "/home/orm:/home/orm", "-e", "OCI_CLI_AUTH", "-e", "OCI_CLI_CONFIG_FILE", "-e", "OCI_CLI_CLOUD_SHELL", "-e", "OCI_CLI_USE_INSTANCE_METADATA_SERVICE", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", var.oke_cluster_id, "--region", var.region]
58+
args = ["run", "--rm", "-t", "-u", "1101:1101", "-v", "/home/orm:/home/orm", "-e", "OCI_CLI_AUTH", "-e", "OCI_CLI_CONFIG_FILE", "-e", "OCI_CLI_CLOUD_SHELL", "-e", "OCI_CLI_USE_INSTANCE_METADATA_SERVICE", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", data.oci_containerengine_cluster.target.id, "--region", var.region]
4759
}
4860
}
4961
}
@@ -55,7 +67,7 @@ provider "kubernetes" {
5567
exec {
5668
api_version = "client.authentication.k8s.io/v1beta1"
5769
command = "docker"
58-
# args = ["run", "--rm", "-it", "-v", "/home/michel/.oci:/oracle/.oci", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", var.oke_cluster_id, "--region", var.region]
59-
args = ["run", "--rm", "-t", "-u", "1101:1101", "-v", "/home/orm:/home/orm", "-e", "OCI_CLI_AUTH", "-e", "OCI_CLI_CONFIG_FILE", "-e", "OCI_CLI_CLOUD_SHELL", "-e", "OCI_CLI_USE_INSTANCE_METADATA_SERVICE", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", var.oke_cluster_id, "--region", var.region]
70+
# args = ["run", "--rm", "-it", "-v", "/home/michel/.oci:/oracle/.oci", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", data.oci_containerengine_cluster.target.id, "--region", var.region]
71+
args = ["run", "--rm", "-t", "-u", "1101:1101", "-v", "/home/orm:/home/orm", "-e", "OCI_CLI_AUTH", "-e", "OCI_CLI_CONFIG_FILE", "-e", "OCI_CLI_CLOUD_SHELL", "-e", "OCI_CLI_USE_INSTANCE_METADATA_SERVICE", "ghcr.io/oracle/oci-cli", "ce", "cluster", "generate-token", "--cluster-id", data.oci_containerengine_cluster.target.id, "--region", var.region]
6072
}
6173
}

hub/schema.yaml

+26-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,21 @@ variableGroups:
3434

3535
- title: "OKE Configuration"
3636
variables:
37-
- oke_cluster_id
37+
- oke_cluster_create
3838
- oke_insecure
3939

40+
- title: "Create basic OKE"
41+
variables:
42+
- oke_cluster_name
43+
visible: ${oke_cluster_create}
44+
45+
- title: "Use existing OKE"
46+
variables:
47+
- oke_cluster_id
48+
visible:
49+
not:
50+
- ${oke_cluster_create}
51+
4052
- title: "Chart Configuration"
4153
variables:
4254
- chart_create_namespace
@@ -69,10 +81,22 @@ variables:
6981

7082
oke_cluster_id:
7183
type: string
72-
required: true
7384
title: OKE Cluster ID
7485
description: The Oracle Cloud ID of the OKE cluster
7586

87+
oke_cluster_create:
88+
type: boolean
89+
title: Create basic OKE Cluster
90+
description: 3 nodes (VM.Standard.E3.Flex) / 2 OCPU / 4 GB RAM / latest OKE version
91+
92+
oke_cluster_name:
93+
type: string
94+
title: Name of OKE Cluster to create
95+
default: traefik-demo
96+
minLength: 1
97+
maxLength: 25
98+
pattern: "^[a-z][a-zA-Z0-9-]+$"
99+
76100
oke_insecure:
77101
type: boolean
78102
title: Allow insecure connection

hub/variables.tf

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
variable "tenancy_ocid" {}
22
variable "region" {}
3-
variable "oke_cluster_id" {}
43

4+
variable "oke_cluster_id" {
5+
type = string
6+
default = ""
7+
}
8+
variable "oke_cluster_name" {
9+
type = string
10+
default = "traefik-demo"
11+
}
12+
variable "oke_cluster_create" {
13+
type = bool
14+
default = false
15+
}
516
variable "oke_insecure" {
617
type = bool
718
default = false
@@ -10,7 +21,6 @@ variable "oke_insecure" {
1021
variable "chart_values" {
1122
type = string
1223
}
13-
1424
variable "chart_hub_token" {
1525
type = string
1626
sensitive = true

0 commit comments

Comments
 (0)