Skip to content

Commit f2dfee8

Browse files
committed
initial commit
0 parents  commit f2dfee8

18 files changed

+2723
-0
lines changed

LICENSE

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2018-2022 Oracle and/or its affiliates. All rights reserved.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this
6+
software, associated documentation and/or data (collectively the "Software"), free of charge and under any and
7+
all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor
8+
hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or
9+
(ii) the Larger Works (as defined below), to deal in both
10+
11+
(a) the Software, and
12+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software
13+
(each a “Larger Work” to which the Software is contributed by such licensors),
14+
15+
without restriction, including without limitation the rights to copy, create derivative works of, display,
16+
perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have
17+
sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms.
18+
19+
This license is subject to the following condition:
20+
The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must
21+
be included in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
24+
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27+
IN THE SOFTWARE.

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# oke-flink
2+
3+
Deploy Flink Operator on a Kubernetes cluster on Oracle Cloud Infrastructure.
4+

datasources.tf

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# ## Copyright © 2021, Oracle and/or its affiliates.
2+
# ## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
3+
4+
data "oci_containerengine_cluster_option" "cluster_options" {
5+
cluster_option_id = "all"
6+
}
7+
8+
data "oci_containerengine_node_pool_option" "oci_oke_node_pool_option" {
9+
node_pool_option_id = "all"
10+
}
11+
12+
# Gets home and current regions
13+
data "oci_identity_tenancy" "tenant_details" {
14+
tenancy_id = var.tenancy_ocid
15+
16+
provider = oci.current_region
17+
}
18+
19+
data "oci_identity_regions" "home_region" {
20+
filter {
21+
name = "key"
22+
values = [data.oci_identity_tenancy.tenant_details.home_region_key]
23+
}
24+
25+
provider = oci.current_region
26+
}
27+
28+
# Gets kubeconfig
29+
data "oci_containerengine_cluster_kube_config" "oke" {
30+
cluster_id = oci_containerengine_cluster.oci_oke_cluster.id
31+
}
32+
33+
data "oci_core_services" "all_oci_services" {
34+
count = var.use_existing_vcn ? 0 : 1
35+
filter {
36+
name = "name"
37+
values = ["All .* Services In Oracle Services Network"]
38+
regex = true
39+
}
40+
}
41+
42+
data "oci_identity_availability_domains" "ADs" {
43+
compartment_id = var.tenancy_ocid
44+
}
45+
46+
# data "oci_containerengine_cluster_kube_config" "KubeConfig" {
47+
# cluster_id = oci_containerengine_cluster.oci_oke_cluster.id
48+
# token_version = var.cluster_kube_config_token_version
49+
# }
50+
51+
52+
# locals {
53+
# gpu = {
54+
# sources = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.sources : s if length(regexall(".*Gen2-GPU.*", s.source_name)) > 0]
55+
# shapes = {
56+
# BM = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.shapes : s if length(regexall("BM[.]GPU.*", s)) > 0]
57+
# VM = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.shapes : s if length(regexall("VM[.]GPU.*", s)) > 0]
58+
# }
59+
# }
60+
# arm = {
61+
# sources = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.sources : s if length(regexall(".*aarch64.*", s.source_name)) > 0]
62+
# shapes = {
63+
# BM = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.shapes : s if length(regexall("BM[.]Standard[.]A1.*", s)) > 0]
64+
# VM = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.shapes : s if length(regexall("VM[.]Standard[.]A1.*", s)) > 0]
65+
# }
66+
# }
67+
# x86 = {
68+
# sources = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.sources : s if length(regexall(".*(aarch64|Gen2-GPU).*", s.source_name)) == 0]
69+
# shapes = {
70+
# BM = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.shapes : s if length(regexall(".*(GPU|A1).*", s)) == 0 && length(regexall("BM.*", s)) > 0]
71+
# VM = [for s in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.shapes : s if length(regexall(".*(GPU|A1).*", s)) == 0 && length(regexall("VM.*", s)) > 0]
72+
# }
73+
# }
74+
# }
75+
76+
data "oci_limits_limit_definitions" "limit_def" {
77+
compartment_id = var.tenancy_ocid
78+
service_name = "compute"
79+
}
80+
81+
locals {
82+
availability_map = [for def in data.oci_limits_limit_definitions.limit_def.limit_definitions : def if contains(compact([var.np1_node_shape, var.np2_node_shape, var.np3_node_shape]), def.description)]
83+
limits_definitions = [
84+
for ad in range(length(data.oci_identity_availability_domains.ADs.availability_domains)) : [
85+
for shape in data.oci_core_shapes.valid_shapes[ad].shapes : { "${shape.name}" = { "${data.oci_identity_availability_domains.ADs.availability_domains[ad].name}" = shape.quota_names } }
86+
if contains(compact([var.np1_node_shape, var.np2_node_shape, var.np3_node_shape]), shape.name)
87+
]
88+
]
89+
shape_ad_availability = transpose(
90+
merge([
91+
for ad in range(length(data.oci_identity_availability_domains.ADs.availability_domains)) : {
92+
"${data.oci_identity_availability_domains.ADs.availability_domains[ad].name}" = [
93+
for shape in data.oci_core_shapes.valid_shapes[ad].shapes : "${shape.name}"
94+
if contains(compact([var.np1_node_shape, var.np2_node_shape, var.np3_node_shape]), shape.name)
95+
]
96+
}
97+
]...)
98+
)
99+
}
100+
101+
data "oci_core_shapes" "valid_shapes" {
102+
count = length(data.oci_identity_availability_domains.ADs.availability_domains)
103+
compartment_id = var.cluster_compartment_id
104+
availability_domain = data.oci_identity_availability_domains.ADs.availability_domains[count.index].name
105+
}
106+
107+
# output valid_shapes {
108+
# value = data.oci_core_shapes.valid_shapes.*.shapes
109+
# }
110+
111+
# output "shape_ad_availability" {
112+
# value = local.shape_ad_availability
113+
# }
114+
115+
# output "limits" {
116+
# value = local.availability_map
117+
# }
118+
119+
# output "limits_definitions" {
120+
# value = local.limits_definitions
121+
# }
122+
123+
resource "random_string" "deploy_id" {
124+
length = 4
125+
special = false
126+
min_numeric = 4
127+
}

helm_cert_manager.tf

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## https://github.com/jetstack/cert-manager/blob/master/README.md
2+
## https://artifacthub.io/packages/helm/cert-manager/cert-manager
3+
4+
locals {
5+
enable_cert_manager = var.enable_flink ? true : var.enable_cert_manager
6+
}
7+
8+
resource "helm_release" "cert_manager" {
9+
count = local.enable_cert_manager ? 1 : 0
10+
name = "cert-manager"
11+
repository = "https://charts.jetstack.io"
12+
chart = "cert-manager"
13+
version = "1.8.2"
14+
namespace = "cert-manager"
15+
create_namespace = true
16+
wait = true # wait to allow the webhook be properly configured
17+
18+
set {
19+
name = "installCRDs"
20+
value = true
21+
}
22+
23+
set {
24+
name = "webhook.timeoutSeconds"
25+
value = "30"
26+
}
27+
depends_on = [oci_containerengine_cluster.oci_oke_cluster]
28+
}

helm_flink.tf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resource "helm_release" "flink_operator" {
2+
count = var.enable_flink ? 1 : 0
3+
name = "flink-operator"
4+
repository = "https://downloads.apache.org/flink/flink-kubernetes-operator-1.2.0/"
5+
chart = "flink-kubernetes-operator"
6+
namespace = "flink"
7+
create_namespace = true
8+
wait = true
9+
10+
depends_on = [
11+
oci_containerengine_cluster.oci_oke_cluster,
12+
helm_release.cert_manager
13+
]
14+
}

helm_metrics.tf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
locals {
2+
enable_metrics_server = var.np1_enable_autoscaler || var.np2_enable_autoscaler || var.np3_enable_autoscaler ? true : var.enable_metrics_server
3+
}
4+
5+
resource "helm_release" "metrics_server" {
6+
count = local.enable_metrics_server ? 1 : 0
7+
name = "metrics-server"
8+
repository = "https://kubernetes-sigs.github.io/metrics-server/"
9+
chart = "metrics-server"
10+
namespace = "kube-system"
11+
version = "3.8.2"
12+
wait = false
13+
14+
set {
15+
name = "replicas"
16+
value = "3"
17+
}
18+
depends_on = [oci_containerengine_cluster.oci_oke_cluster]
19+
}

images.tf

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Check if there is an OKE image for the image selected
2+
data "oci_core_image" "np1_image" {
3+
count = var.node_pool_count >= 1 ? 1 : 0
4+
image_id = var.np1_image_id
5+
}
6+
data "oci_core_image" "np2_image" {
7+
count = var.node_pool_count >= 2 ? 1 : 0
8+
image_id = var.np2_image_id
9+
}
10+
data "oci_core_image" "np3_image" {
11+
count = var.node_pool_count >= 3 ? 1 : 0
12+
image_id = var.np3_image_id
13+
}
14+
15+
locals {
16+
k8s_version = replace(local.kubernetes_version, "v", "")
17+
np1_oke_image = var.node_pool_count >= 1 ? [for option
18+
in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.sources :
19+
option if length(regexall("${data.oci_core_image.np1_image[0].display_name}-OKE-${local.k8s_version}", option.source_name)) > 0] : []
20+
np1_oke_image_id = length(local.np1_oke_image) > 0 ? local.np1_oke_image[0].image_id : var.np1_image_id
21+
np2_oke_image = var.node_pool_count >= 2 ? [for option
22+
in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.sources :
23+
option if length(regexall("${data.oci_core_image.np2_image[0].display_name}-OKE-${local.k8s_version}", option.source_name)) > 0] : []
24+
np2_oke_image_id = length(local.np2_oke_image) > 0 ? local.np2_oke_image[0].image_id : var.np2_image_id
25+
np3_oke_image = var.node_pool_count >= 3 ? [for option
26+
in data.oci_containerengine_node_pool_option.oci_oke_node_pool_option.sources :
27+
option if length(regexall("${data.oci_core_image.np3_image[0].display_name}-OKE-${local.k8s_version}", option.source_name)) > 0] : []
28+
np3_oke_image_id = length(local.np3_oke_image) > 0 ? local.np3_oke_image[0].image_id : var.np3_image_id
29+
}
30+
31+
# output "images" {
32+
# value = {
33+
# k8s_version = local.k8s_version
34+
# np1_oke_image = local.np1_oke_image
35+
# np2_oke_image = local.np2_oke_image
36+
# np3_oke_image = local.np3_oke_image
37+
# }
38+
# }

0 commit comments

Comments
 (0)