Skip to content

Commit cf0e1f9

Browse files
authored
Merge pull request #4 from oracle-quickstart/bugfix/autoscaler-nsg
bugfix + update
2 parents 30f5ac3 + d436603 commit cf0e1f9

File tree

5 files changed

+38
-15
lines changed

5 files changed

+38
-15
lines changed

helm_cert_manager.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ resource "helm_release" "cert_manager" {
3030
}
3131
depends_on = [
3232
data.oci_containerengine_cluster_kube_config.oke,
33-
oci_containerengine_cluster.oci_oke_cluster
33+
oci_containerengine_cluster.oci_oke_cluster,
34+
oci_containerengine_node_pool.oci_oke_node_pool,
3435
]
3536
}

helm_metrics.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ resource "helm_release" "metrics_server" {
1515
wait = false
1616

1717
set {
18-
name = "replicas"
19-
value = "3"
18+
name = "addonResizer.enabled"
19+
value = "true"
2020
}
2121
depends_on = [
2222
data.oci_containerengine_cluster_kube_config.oke,

k8s_autoscaler.tf

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ locals {
1717
k8s_minor_version = regex("^\\d+", replace(local.kubernetes_version, "v1.", ""))
1818
}
1919

20-
resource "kubernetes_service_account" "cluster_autoscaler_sa" {
20+
resource "kubernetes_service_account_v1" "cluster_autoscaler_sa" {
2121
count = local.cluster_autoscaler_enabled ? 1 : 0
2222

2323
metadata {
@@ -48,7 +48,7 @@ resource "kubernetes_secret" "cluster_autoscaler_sa_token" {
4848
type = "kubernetes.io/service-account-token"
4949

5050
depends_on = [
51-
kubernetes_service_account.cluster_autoscaler_sa,
51+
kubernetes_service_account_v1.cluster_autoscaler_sa,
5252
oci_containerengine_node_pool.oci_oke_node_pool]
5353
}
5454

@@ -304,6 +304,14 @@ resource "kubernetes_deployment" "cluster_autoscaler_deployment" {
304304
oci_containerengine_node_pool.oci_oke_node_pool,
305305
helm_release.metrics_server
306306
]
307+
308+
lifecycle {
309+
ignore_changes = [
310+
spec[0].template[0].spec[0].container[0].env
311+
]
312+
}
313+
314+
307315
}
308316

309317
resource "kubernetes_pod_disruption_budget_v1" "core_dns_pod_disruption_budget" {

policies.tf

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Copyright © 2022, Oracle and/or its affiliates.
22
## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
33

4-
# Cluster dynamic group policy needed for nodes to access the encryption key if it was defined
4+
# Policy needed for nodes to access the encryption key if it was defined
55
resource "oci_identity_policy" "oke_key_access_policy" {
66
count = (var.enable_secret_encryption && var.secrets_key_id != null) || (var.enable_image_validation && var.image_validation_key_id != null) ? 1 : 0
77
#Required
@@ -13,6 +13,22 @@ resource "oci_identity_policy" "oke_key_access_policy" {
1313
var.enable_image_validation && var.image_validation_key_id != null ? "Allow any-user to use keys in tenancy where ALL {request.principal.type = 'cluster', target.key.id='${var.image_validation_key_id}'}" : ""
1414
])
1515
}
16+
locals {
17+
nsg_name = "cluster_${random_string.deploy_id.result}"
18+
}
19+
20+
resource "oci_identity_network_source" "node_pool_network_source" {
21+
provider = oci.home_region
22+
#Required
23+
compartment_id = var.tenancy_ocid
24+
description = "NSG for ${local.nsg_name} autoscaler"
25+
name = local.nsg_name
26+
27+
virtual_source_list {
28+
vcn_id = var.use_existing_vcn ? var.vcn_id : oci_core_vcn.oke_vcn[0].id
29+
ip_ranges = local.node_pool_subnets_cidrs
30+
}
31+
}
1632

1733
resource "oci_identity_policy" "autoscaler_policy" {
1834
count = (var.np1_enable_autoscaler || var.np2_enable_autoscaler || var.np3_enable_autoscaler) ? 1 : 0
@@ -22,12 +38,12 @@ resource "oci_identity_policy" "autoscaler_policy" {
2238
name = "cluster_autoscaler_${random_string.deploy_id.result}"
2339
provider = oci.home_region
2440
statements = compact([
25-
"Allow any-user to manage cluster-node-pools in compartment id ${var.cluster_compartment_id} where ALL {request.principal.type = 'cluster', request.principal.id = ${oci_containerengine_cluster.oci_oke_cluster.id}}",
26-
"Allow any-user to manage instance-family in compartment id ${var.cluster_compartment_id} where ALL {request.principal.type = 'cluster', request.principal.id = ${oci_containerengine_cluster.oci_oke_cluster.id}}",
27-
"Allow any-user to use subnets in compartment id ${var.vcn_compartment_id} where ALL {request.principal.type = 'cluster', request.principal.id = ${oci_containerengine_cluster.oci_oke_cluster.id}}",
28-
"Allow any-user to read virtual-network-family in compartment id ${var.vcn_compartment_id} where ALL {request.principal.type = 'cluster', request.principal.id = ${oci_containerengine_cluster.oci_oke_cluster.id}}",
29-
"Allow any-user to use vnics in compartment id ${var.vcn_compartment_id} where ALL {request.principal.type = 'cluster', request.principal.id = ${oci_containerengine_cluster.oci_oke_cluster.id}}",
30-
"Allow any-user to inspect compartments in compartment id ${var.cluster_compartment_id} where ALL {request.principal.type = 'cluster', request.principal.id = ${oci_containerengine_cluster.oci_oke_cluster.id}}",
31-
"Allow any-user to inspect compartments in compartment id ${var.vcn_compartment_id} where ALL {request.principal.type = 'cluster', request.principal.id = ${oci_containerengine_cluster.oci_oke_cluster.id}}"
41+
"Allow any-user to manage cluster-node-pools in compartment id ${var.cluster_compartment_id} where ALL {request.networkSource.name='${local.nsg_name}'}",
42+
"Allow any-user to manage instance-family in compartment id ${var.cluster_compartment_id} where ALL {request.networkSource.name='${local.nsg_name}'}",
43+
"Allow any-user to use subnets in compartment id ${var.vcn_compartment_id} where ALL {request.networkSource.name='${local.nsg_name}'}",
44+
"Allow any-user to read virtual-network-family in compartment id ${var.vcn_compartment_id} where ALL {request.networkSource.name='${local.nsg_name}'}",
45+
"Allow any-user to use vnics in compartment id ${var.vcn_compartment_id} where ALL {request.networkSource.name='${local.nsg_name}'}",
46+
"Allow any-user to inspect compartments in compartment id ${var.cluster_compartment_id} where ALL {request.networkSource.name='${local.nsg_name}'}",
47+
"Allow any-user to inspect compartments in compartment id ${var.vcn_compartment_id} where ALL {request.networkSource.name='${local.nsg_name}'}",
3248
])
3349
}

schema.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ variables:
272272
- "v1.25.4"
273273
- "v1.24.1"
274274
- "v1.23.4"
275-
- "v1.22.5"
276-
- "v1.21.5"
277275
required: true
278276
default: "v1.25.4"
279277
description: The Kubernetes version for the cluster.

0 commit comments

Comments
 (0)