Skip to content

Commit 50150af

Browse files
init: helm-chart deployment via terraform
1 parent 44b3844 commit 50150af

File tree

6 files changed

+319
-0
lines changed

6 files changed

+319
-0
lines changed

logan/terraform/helm.tf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
resource "helm_release" "la-release" {
3+
name = "my-la-release"
4+
chart = "${path.module}/../helm-chart"
5+
#repository = "https://github.com/oracle-quickstart/oci-kubernetes-monitoring"
6+
7+
set {
8+
name = "image.url"
9+
value = var.oke_containerImage_url
10+
}
11+
12+
set {
13+
name = "kubernetesClusterName"
14+
value = var.oke_cluster_name
15+
}
16+
17+
set {
18+
name = "kubernetesClusterID"
19+
value = var.oke_cluster_ocid
20+
}
21+
22+
set {
23+
name = "namespace"
24+
value = var.oke_namespace
25+
}
26+
27+
set {
28+
name = "ociLANamespace"
29+
value = var.la_namespace
30+
}
31+
32+
set {
33+
name = "ociLALogGroupID"
34+
value = var.la_logGroup_id
35+
}
36+
37+
set {
38+
name = "ociCompartmentID"
39+
value = var.oke_cluster_compartment
40+
}
41+
42+
set {
43+
name = "fluentd.baseDir"
44+
value = var.fluentd_baseDir_path
45+
}
46+
47+
48+
}

logan/terraform/inputs.tf

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# When defined in the Terraform configuration,
2+
# the following variables automatically prepopulate with values on the Console pages used to create and edit the stack.
3+
# The stack's values are used when you select the Terraform actions Plan, Apply, and Destroy.
4+
# - tenancy_ocid (tenancy OCID)
5+
# - compartment_ocid (compartment OCID)
6+
# - region (region)
7+
# - current_user_ocid (OCID of the current user)
8+
#
9+
# Ref - https://docs.oracle.com/en-us/iaas/Content/ResourceManager/Concepts/terraformconfigresourcemanager_topic-schema.htm#console-howto__prepop
10+
11+
12+
variable "tenancy_ocid" {
13+
type = string
14+
}
15+
16+
variable "compartment_ocid" {
17+
type = string
18+
}
19+
20+
variable "region" {
21+
type = string
22+
}
23+
24+
variable "current_user_ocid" {
25+
type = string
26+
}
27+
28+
####
29+
## Inputs for HelmChart deployment in OKE Cluster Deployment
30+
####
31+
32+
# OKE Cluster Compartment
33+
variable "oke_cluster_compartment" {
34+
type = string
35+
}
36+
37+
# OKE Cluster OCID
38+
variable "oke_cluster_ocid" {
39+
type = string
40+
}
41+
42+
# OKE Cluster Name
43+
variable "oke_cluster_name" {
44+
type = string
45+
}
46+
47+
# OKE Container Image URL
48+
variable "oke_containerImage_url" {
49+
type = string
50+
}
51+
52+
# OKE Namespace
53+
variable "oke_namespace" {
54+
type = string
55+
}
56+
57+
# fluentd base direcotry path
58+
variable "fluentd_baseDir_path" {
59+
type = string
60+
}
61+
62+
# Logging Analytics namespace
63+
variable "la_namespace" {
64+
type = string
65+
}
66+
67+
# Logging Analytics LogGroupID
68+
variable "la_logGroup_id" {
69+
type = string
70+
}

logan/terraform/oke.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
data "oci_containerengine_cluster_kube_config" "oke" {
2+
cluster_id = var.oke_cluster_ocid
3+
}
4+
5+
# Local kubeconfig for when using Terraform locally. Not used by Oracle Resource Manager
6+
resource "local_file" "oke_kubeconfig" {
7+
content = data.oci_containerengine_cluster_kube_config.oke.content
8+
filename = "${path.module}/kubeconfig"
9+
}
10+
11+
# data "local_file" "oke_kubeconfig" {
12+
# filename = "${path.module}/kubeconfig"
13+
# }

logan/terraform/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Test Output
2+
output "test_output" {
3+
value = "Test Output"
4+
}

logan/terraform/providers.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
provider "oci" {
2+
tenancy_ocid = var.tenancy_ocid
3+
region = var.region
4+
}
5+
6+
# https://docs.cloud.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengdownloadkubeconfigfile.htm#notes
7+
provider "helm" {
8+
kubernetes {
9+
host = local.cluster_endpoint
10+
cluster_ca_certificate = local.cluster_ca_certificate
11+
exec {
12+
api_version = "client.authentication.k8s.io/v1beta1"
13+
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
14+
command = "oci"
15+
}
16+
}
17+
}
18+
19+
20+
locals {
21+
cluster_endpoint = yamldecode(data.oci_containerengine_cluster_kube_config.oke.content)["clusters"][0]["cluster"]["server"]
22+
cluster_ca_certificate = base64decode(yamldecode(data.oci_containerengine_cluster_kube_config.oke.content)["clusters"][0]["cluster"]["certificate-authority-data"])
23+
cluster_id = yamldecode(data.oci_containerengine_cluster_kube_config.oke.content)["users"][0]["user"]["exec"]["args"][4]
24+
cluster_region = yamldecode(data.oci_containerengine_cluster_kube_config.oke.content)["users"][0]["user"]["exec"]["args"][6]
25+
}

logan/terraform/schema.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Title shown in Application Information tab.
2+
title: Logging Analytics HelmChart Deployment to OKE Cluster
3+
# Sub Title shown in Application Information tab.
4+
description: Deploy Logging Analytics Helm Chart to monitor OKE cluster logs
5+
informationalText: Deploy Logging Analytics Helm Chart to monitor OKE cluster logs
6+
schemaVersion: 1.1.0
7+
version: "20221003"
8+
9+
# URL of Logo Icon used on Application Information tab. Logo must be 130x130 pixels.
10+
# (Optional)
11+
#logoUrl: https://cloudmarketplace.oracle.com/marketplace/content?contentId=53066708
12+
13+
source:
14+
type: quickstart
15+
16+
locale: "en"
17+
18+
variableGroups:
19+
- title: "Defualt inputs"
20+
variables:
21+
- tenancy_ocid
22+
- compartment_ocid
23+
- region
24+
- current_user_ocid
25+
visible: false
26+
27+
- title: "OKE Cluster Details"
28+
variables:
29+
- oke_cluster_compartment
30+
- oke_cluster_ocid
31+
- oke_cluster_name
32+
- oke_containerImage_url
33+
- oke_namespace
34+
35+
- title: "Logging Analytics"
36+
variables:
37+
- la_namespace
38+
- la_logGroup_id
39+
40+
- title: "Agent Configuration"
41+
variables:
42+
- fluentd_baseDir_path
43+
44+
45+
variables:
46+
47+
oke_cluster_compartment:
48+
type: oci:identity:compartment:id
49+
required: true
50+
title: OKE Cluster Compartment
51+
description: Compartment which the OKE Cluster belogs to
52+
default: compartment_ocid
53+
54+
oke_cluster_ocid:
55+
type: oci:container:cluster:id
56+
dependsOn:
57+
compartmentId: ${oke_cluster_compartment}
58+
title: OKE Cluster
59+
description: Target OKE Cluster
60+
required: true
61+
62+
# string field
63+
oke_cluster_name:
64+
type: string
65+
minLength: 1
66+
maxLength: 255
67+
title: OKE Cluster Name
68+
description: OKE Cluster Name
69+
required: true
70+
71+
# string field
72+
oke_containerImage_url:
73+
type: string
74+
minLength: 1
75+
maxLength: 255
76+
title: Container Image
77+
description: Enter remote URL to fetch Container Image
78+
required: true
79+
80+
# string field
81+
oke_namespace:
82+
type: string
83+
minLength: 1
84+
maxLength: 255
85+
title: OKE Cluster Namespace (Optional)
86+
description: Enter OKE Namespace to deploy helm-chart
87+
default: kube-system
88+
required: true
89+
90+
# string field
91+
fluentd_baseDir_path:
92+
type: string
93+
maxLength: 255
94+
minLength: 1
95+
title: fluentd Agent Base Directory (Optional)
96+
description: Base Directory Path of fluentd agent
97+
default: /var/log
98+
required: true
99+
100+
# string field
101+
la_namespace:
102+
type: string
103+
maxLength: 40
104+
minLength: 1
105+
title: Logging Analytics Namespace
106+
description: Enter Logging Analytics Namespace
107+
required: true
108+
109+
# string field
110+
la_logGroup_id:
111+
type: string
112+
maxLength: 255
113+
minLength: 1
114+
title: LogGroup OCID
115+
description: This LogGroup will store the data collected from OKE cluster.
116+
required: true
117+
118+
# outputs:
119+
120+
# controlCenterUrl:
121+
# type: link
122+
# title: Control Center
123+
# displayText: Control Center
124+
# visible: false
125+
126+
# schemaRegistryUrl:
127+
# type: link
128+
# title: Schema Registry
129+
# displayText: Schema Registry
130+
131+
# schemaRegistryPublicIps:
132+
# type: csv
133+
# title: Public IPs
134+
135+
# schemaRegistryLoadBalancer:
136+
# type: ocid
137+
# title: Load Balancer
138+
139+
# brokerPublicIps:
140+
# type: csv
141+
142+
# connectUrl:
143+
# type: link
144+
# title: Connect
145+
# displayText: Connect
146+
147+
# connectPublicIps:
148+
# type: csv
149+
# title: Public IPs
150+
151+
# restUrl:
152+
# type: link
153+
# title: Rest API
154+
155+
# # primaryOutputButton is a reference to a link output that creates a primary button
156+
# # on the Application Information tab.
157+
# # (Optional) if not provided, no primary button is shown. Also if the output
158+
# # referenced is not a link output, no button is shown.
159+
# primaryOutputButton: ${controlCenterUrl}

0 commit comments

Comments
 (0)