Skip to content

Commit 989b3d1

Browse files
authored
feat: upgraded operator module to 3.1.4 (#598)
* feat: upgraded operator module to 3.1.4 kubectl and helm are now installed with operator's cloud-init. Also renamed context to cluster_name. Signed-off-by: Ali Mukadam <[email protected]> * fix: removed superfluous templates Signed-off-by: Ali Mukadam <[email protected]> Signed-off-by: Ali Mukadam <[email protected]>
1 parent 40943c7 commit 989b3d1

File tree

8 files changed

+17
-77
lines changed

8 files changed

+17
-77
lines changed

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ module "bastion" {
108108

109109
module "operator" {
110110
source = "oracle-terraform-modules/operator/oci"
111-
version = "3.1.3"
111+
version = "3.1.4"
112112

113113

114114
# general oci parameters
@@ -279,7 +279,7 @@ module "oke" {
279279
preferred_load_balancer = var.preferred_load_balancer
280280

281281
# nsgs
282-
pod_nsgs = concat(module.network.pod_nsg_id)
282+
pod_nsgs = concat(module.network.pod_nsg_id)
283283
worker_nsgs = concat(var.worker_nsgs, [module.network.worker_nsg_id])
284284

285285
# tags
@@ -361,6 +361,7 @@ module "extensions" {
361361

362362
# oke cluster parameters
363363
cluster_id = module.oke.cluster_id
364+
cluster_name = var.cluster_name
364365
pods_cidr = var.pods_cidr
365366
use_cluster_encryption = var.use_cluster_encryption
366367
cluster_kms_key_id = var.cluster_kms_key_id

modules/extensions/k8stools.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,13 @@ resource "null_resource" "install_k8stools_on_operator" {
1414
bastion_private_key = local.ssh_private_key
1515
}
1616

17-
provisioner "file" {
18-
content = local.install_kubectl_template
19-
destination = "/home/opc/install_kubectl.sh"
20-
}
21-
22-
provisioner "file" {
23-
content = local.install_helm_template
24-
destination = "/home/opc/install_helm.sh"
25-
}
26-
2717
provisioner "file" {
2818
content = local.install_kubectx_template
2919
destination = "/home/opc/install_kubectx.sh"
3020
}
3121

3222
provisioner "remote-exec" {
3323
inline = [
34-
"if [ -f \"$HOME/install_kubectl.sh\" ]; then bash \"$HOME/install_kubectl.sh\"; rm -f \"$HOME/install_kubectl.sh\";fi",
35-
"if [ -f \"$HOME/install_helm.sh\" ]; then bash \"$HOME/install_helm.sh\"; rm -f \"$HOME/install_helm.sh\";fi",
3624
"if [ -f \"$HOME/install_kubectx.sh\" ]; then bash \"$HOME/install_kubectx.sh\"; rm -f \"$HOME/install_kubectx.sh\";fi",
3725
]
3826
}

modules/extensions/scripts/install_helm.template.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

modules/extensions/scripts/install_kubectl.template.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

modules/extensions/scripts/install_kubectx.template.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ curl -sSfL https://github.com/ahmetb/kubectx/releases/download/v${version}/kubec
66
curl -sSfL https://github.com/ahmetb/kubectx/releases/download/v${version}/kubens_v${version}_linux_$(uname -m).tar.gz | sudo tar zxvf - -C /usr/local --xform='s|^|kubens/|S'
77

88
sudo ln -s /usr/local/kubectx/kubectx /usr/bin/kubectx
9-
sudo ln -s /usr/local/kubens/kubens /usr/bin/kubens
9+
sudo ln -s /usr/local/kubens/kubens /usr/bin/kubens
10+
11+
echo "source <(kubectl completion bash)" >> ~/.bashrc
12+
echo "alias k='kubectl'" >> $HOME/.bashrc
13+
14+
echo "source <(helm completion bash)" >> ~/.bashrc
15+
echo "alias h='helm'" >> ~/.bashrc
1016

1117
echo "alias ktx='kubectx'" >> $HOME/.bashrc
1218
echo "alias kns='kubens'" >> $HOME/.bashrc

modules/extensions/scripts/kubeconfig_set_credentials.template.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ kubectl config set-credentials "user-${cluster-id-11}" --exec-command="$HOME/bin
99
--exec-arg="--cluster-id" \
1010
--exec-arg="${cluster-id}" \
1111
--exec-arg="--region" \
12-
--exec-arg="${region}"
12+
--exec-arg="${region}"
13+
14+
kubectx ${cluster_name}=$(kubectl config current-context)

modules/extensions/templates.tf

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,8 @@ locals {
4646
}
4747
)
4848

49-
install_helm_template = templatefile("${path.module}/scripts/install_helm.template.sh",
50-
{
51-
ol = var.operator_os_version
52-
}
53-
)
54-
55-
install_kubectl_template = templatefile("${path.module}/scripts/install_kubectl.template.sh",
56-
{
57-
ol = var.operator_os_version
58-
}
59-
)
60-
6149
install_kubectx_template = templatefile("${path.module}/scripts/install_kubectx.template.sh", {
62-
version = "0.9.4"
50+
version = "0.9.4"
6351
})
6452

6553
metric_server_template = templatefile("${path.module}/scripts/install_metricserver.template.sh",
@@ -95,6 +83,7 @@ locals {
9583
{
9684
cluster-id = var.cluster_id
9785
cluster-id-11 = substr(var.cluster_id, (length(var.cluster_id) - 11), length(var.cluster_id))
86+
cluster_name = var.cluster_name
9887
region = var.region
9988
}
10089
)

modules/extensions/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ variable "operator_os_version" {}
5555
# oke
5656
variable "cluster_id" {}
5757

58+
variable "cluster_name" {}
59+
5860
variable "pods_cidr" {}
5961

6062
# encryption

0 commit comments

Comments
 (0)