Skip to content

Commit 1a44e24

Browse files
Merge pull request #8 from paliwalparitosh/main
terraform module for helm-chart deployment
2 parents 44b3844 + 5211932 commit 1a44e24

File tree

5 files changed

+246
-0
lines changed

5 files changed

+246
-0
lines changed

logan/terraform/oke/helm.tf

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

logan/terraform/oke/inputs.tf

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# When defined in the Terraform configuration, the following variables automatically prepopulate with values on the Console pages used to create and edit the stack.
2+
# The stack's values are used when you select the Terraform actions Plan, Apply, and Destroy.
3+
# - tenancy_ocid (tenancy OCID)
4+
# - region (region)
5+
#
6+
# Ref - https://docs.oracle.com/en-us/iaas/Content/ResourceManager/Concepts/terraformconfigresourcemanager_topic-schema.htm#console-howto__prepop
7+
8+
9+
variable "tenancy_ocid" {
10+
type = string
11+
}
12+
13+
variable "region" {
14+
type = string
15+
}
16+
17+
####
18+
## Inputs for deploying helm-chart
19+
####
20+
21+
# OKE Cluster Compartment
22+
variable "oke_cluster_compartment" {
23+
type = string
24+
}
25+
26+
# OKE Cluster OCID
27+
variable "oke_cluster_ocid" {
28+
type = string
29+
}
30+
31+
# OKE Cluster Name
32+
variable "oke_cluster_name" {
33+
type = string
34+
}
35+
36+
# OCI LA Fluentd Container Image
37+
variable "container_image_url" {
38+
type = string
39+
}
40+
41+
# Kubernetes Namespace
42+
variable "kubernetes_namespace" {
43+
type = string
44+
}
45+
46+
# Fluentd Base Directory
47+
variable "fluentd_baseDir_path" {
48+
type = string
49+
}
50+
51+
# OCI Logging Analytics Namespace
52+
variable "oci_la_namespace" {
53+
type = string
54+
}
55+
56+
# OCI Logging Analytics LogGroup OCID
57+
variable "oci_la_logGroup_id" {
58+
type = string
59+
}

logan/terraform/oke/oke.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
data "oci_containerengine_cluster_kube_config" "oke" {
2+
cluster_id = var.oke_cluster_ocid
3+
}
4+
5+
# kubeconfig 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+
}

logan/terraform/oke/providers.tf

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

logan/terraform/oke/schema.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
title: OCI Kubernetes Monitoring Solution
2+
description: Monitoring Solution for Kubernetes offered by OCI Logging Analytics
3+
informationalText: Monitoring Solution for Kubernetes offered by OCI Logging Analytics
4+
schemaVersion: 1.1.0
5+
version: "20221004"
6+
7+
# URL of Logo Icon used on Application Information tab. Logo must be 130x130 pixels.
8+
# (Optional)
9+
#logoUrl: https://cloudmarketplace.oracle.com/marketplace/content?contentId=53066708
10+
11+
source:
12+
type: quickstart
13+
14+
locale: "en"
15+
16+
variableGroups:
17+
- title: "Defualt inputs"
18+
variables:
19+
- tenancy_ocid
20+
- region
21+
visible: false
22+
23+
- title: "OKE Cluster Information"
24+
variables:
25+
- oke_cluster_compartment
26+
- oke_cluster_ocid
27+
- oke_cluster_name
28+
- container_image_url
29+
- kubernetes_namespace
30+
31+
- title: "OCI Logging Analytics Information"
32+
variables:
33+
- oci_la_namespace
34+
- oci_la_logGroup_id
35+
36+
- title: "Fluentd Configuration"
37+
variables:
38+
- fluentd_baseDir_path
39+
40+
variables:
41+
oke_cluster_compartment:
42+
type: oci:identity:compartment:id
43+
required: true
44+
title: OKE Cluster Compartment
45+
default: compartment_ocid
46+
47+
oke_cluster_ocid:
48+
type: oci:container:cluster:id
49+
dependsOn:
50+
compartmentId: ${oke_cluster_compartment}
51+
title: OKE Cluster
52+
required: true
53+
54+
# string field
55+
oke_cluster_name:
56+
type: string
57+
minLength: 1
58+
maxLength: 255
59+
title: OKE Cluster Name
60+
required: true
61+
62+
# string field
63+
container_image_url:
64+
type: string
65+
minLength: 1
66+
maxLength: 255
67+
title: OCI LA Fluentd Container Image
68+
description: Image URL of OCI LA Fluentd Container
69+
required: true
70+
71+
# string field
72+
kubernetes_namespace:
73+
type: string
74+
minLength: 1
75+
maxLength: 255
76+
title: Kubernetes Namespace
77+
description: Kubernetes Namespace in which the monitoring solution to be deployed
78+
default: kube-system
79+
required: true
80+
81+
# string field
82+
fluentd_baseDir_path:
83+
type: string
84+
maxLength: 255
85+
minLength: 1
86+
title: Fluentd Base Directory
87+
description: Base directory on the node (with read write permission) to store fluentd plugin's related data
88+
default: /var/log
89+
required: true
90+
91+
# string field
92+
oci_la_namespace:
93+
type: string
94+
maxLength: 40
95+
minLength: 1
96+
title: OCI Logging Analytics Namespace
97+
required: true
98+
99+
# string field
100+
oci_la_logGroup_id:
101+
type: string
102+
maxLength: 255
103+
minLength: 1
104+
title: OCI Logging Analytics LogGroup OCID
105+
description: The LogGroup in which the collected log data to be stored
106+
required: true

0 commit comments

Comments
 (0)