You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: added support for cloud-init. Closes#457. Added support for cloud-init. Updated docs and
added subsections for bastion, operator instructions to make
table of content render better.
* fix: changed timezone from hardcoded in cloud-init, changed default
timezone to Etc/UTC
This section assumes you have completed the following:
61
61
62
62
. all the {uri-prereqs}[prerequisites]
63
63
. all the required {uri-configuration}[configuration]
64
64
65
-
=== KMS Integration
65
+
== KMS Integration
66
66
67
-
==== OKE Variables
67
+
== OKE Variables
68
68
69
69
If you wish to use {uri-oci-kms}[OCI KMS] to encrypt Kubernetes secrets, the following is required:
70
70
@@ -86,7 +86,7 @@ If you wish to encrypt data in transit between the instance, the boot volume, an
86
86
87
87
* enable_pv_encryption_in_transit must be _true_
88
88
89
-
==== Operator Variables
89
+
== Operator Variables
90
90
91
91
If you wish to use {uri-oci-kms}[OCI KMS] to encrypt operator boot/block volume, the following is required:
92
92
@@ -96,7 +96,7 @@ If you wish to encrypt data in transit between the instance, the boot volume, an
96
96
97
97
* enable_operator_pv_encryption_in_transit must be _true_
98
98
99
-
=== Creating the OKE Cluster
99
+
== Creating the OKE Cluster
100
100
101
101
Initialize a working directory containing Terraform configuration files:
102
102
@@ -114,14 +114,11 @@ You can create a Kubernetes cluster with the latest version of Kubernetes availa
114
114
115
115
Use the parameter *cluster_name* to change the name of the cluster as per your needs.
116
116
117
-
117
+
== Using the bastion host
118
118
=== Adding the bastion host
119
119
120
120
If you want to use bastion host, set the parameter *create_bastion_host* to *true* in terraform.tfvars. Refer to {uri-terraform-options}#bastion-host[Bastion Host] for other available bastion related parameters.
121
121
122
-
123
-
=== Using the bastion host
124
-
125
122
****
126
123
*Assumption: you have set the create_bastion_host parameter to true in terraform.tfvars*
127
124
****
@@ -134,13 +131,22 @@ terraform output
134
131
135
132
You can then copy the ssh_to_bastion command, paste and run it in a terminal.
136
133
134
+
=== Shutting down the bastion host
135
+
136
+
You can also shutdown the bastion host. Shutting down the bastion host does not destroy it and its public IP address will be preserved.
137
+
138
+
To turn off the bastion host, set `bastion_state= "STOPPED"` and run `terraform apply` again.
139
+
140
+
To turn it on again, set `bastion_state= "RUNNING"` and run `terraform apply` again.
141
+
142
+
== Using the operator host
137
143
=== Adding the operator host
138
144
139
145
The operator host is used to minimize local dependencies such as oci-cli, kubectl and so on.
140
146
141
147
If you want to use the operator host, set the parameter *create_operator* to *true* in terraform.tfvars. Refer to {uri-terraform-options}#operator-host[Admin Host] for other available bastion related parameters.
142
148
143
-
==== Upgrading the operator host
149
+
=== Upgrading the operator host
144
150
145
151
There is 1 additional parameter for the operator:
146
152
@@ -152,12 +158,6 @@ _upgrade_operator_ will upgrade the operator compute packages on first boot.
152
158
N.B. It is good and recommended practice to upgrade your package host to the latest packages to minimize the possibility of vulnerabilities. However, it will also take slightly longer before the package host is available.
153
159
****
154
160
155
-
=== Using the operator host
156
-
157
-
****
158
-
*Assumption: you have set the create_operator parameter to true in terraform.tfvars*
159
-
****
160
-
161
161
Once the terraform apply is successful you will get the operator_private_ip as output and also a ssh command. You can also run the below command to get the output:
162
162
163
163
----
@@ -166,6 +166,15 @@ terraform output
166
166
167
167
You can then copy the ssh_to_operator command, paste and run it in a terminal.
168
168
169
+
=== Shutting down the operator host
170
+
171
+
You can also shutdown the operator host. Shutting down the operator host does not destroy it.
172
+
173
+
To turn off the operator host, set `operator_state= "STOPPED"` and run `terraform apply` again.
174
+
175
+
To turn it on again, set `operator_state= "RUNNING"` and run `terraform apply` again.
176
+
177
+
=== Using instance_principal on the operator host
169
178
==== Enabling instance_principal on the operator host
170
179
{uri-oci-instance-principal}[instance_principal] is an IAM service feature that enables instances to be authorized actors (or principals) to perform actions on service resources. Each compute instance has its own identity, and it authenticates using the certificates that are added to it. These certificates are automatically created, assigned to instances and rotated, preventing the need for you to distribute credentials to your hosts and rotate them.
171
180
@@ -211,7 +220,7 @@ terraform apply
211
220
. Enable instance_principal *_if and only if_* you are using link:#kms-integration[KMS Integration], calico, metricserver or creating the OCIR secret.
212
221
. Disable instance_principal once the cluster is created
213
222
214
-
=== Interacting with the OKE Cluster
223
+
== Interacting with the OKE Cluster
215
224
216
225
kubectl installed on the operator host by default and the kubeconfig file is set in the default location (~/.kube/config) so you don't need to set the KUBECONFIG environment variable every time you log in to the operator host.
*Ensure you install the same kubectl version as the OKE Kubernetes version for compatibility.*
232
241
****
233
242
234
-
=== Creating a Secret for OCIR
243
+
== Creating a Secret for OCIR
235
244
236
245
{uri-oci-ocir}[Oracle Cloud Infrastructure Registry] is a highly available private container registry service for storing and sharing container images within the same regions as the OKE Cluster. Use the following rules to determine if you need to create a Kubernetes Secret for OCIR:
237
246
@@ -244,15 +253,15 @@ You must then {uri-oci-secret}[create a Secret in OCI Vault to store] the value
244
253
245
254
Finally, assign the Secret OCID to *secret_id* in terraform.tfvars. Refer to {uri-terraform-options}#ocir[OCIR parameters] for other parameters to be set.
246
255
247
-
=== Installing Calico
256
+
== Installing Calico
248
257
249
258
Calico enables network policy in Kubernetes clusters. To install calico set the parameter *enable_calico = true* in terraform.tfvars. By default its set to false. Refer to {uri-terraform-options}#calico[Calico parameters] for other available parameters.
250
259
251
-
=== Installing Kubernetes Metrics Server
260
+
== Installing Kubernetes Metrics Server
252
261
253
262
{uri-metricserver}[Kubernetes Metrics Server] can be installed by setting the parameter *enable_metric_server = true* in terraform.tfvars. By default, the latest version is installed in kube-system namespace. This is required if you need to use Horizontal Pod Autoscaling.
254
263
255
-
=== Installing Vertical Pod Autoscaler
264
+
== Installing Vertical Pod Autoscaler
256
265
257
266
{uri-kubernetes-vpa}[Vertical Pod Autoscaler] can be installed by configuring the `vpa` parameter:
258
267
@@ -263,7 +272,7 @@ Calico enables network policy in Kubernetes clusters. To install calico set the
263
272
264
273
NOTE: Installing the Vertical Pod Autoscaler also requires installing the Metrics Server, so you need to enable that too.
265
274
266
-
=== Scaling the node pools
275
+
== Scaling the node pools
267
276
268
277
There are 2 ways you can scale the node pools:
269
278
@@ -276,7 +285,83 @@ Scaling changes to the number and size of node pools are immediate after changin
276
285
277
286
Set the parameter *node_pools* to the desired quantities to scale the node pools accordingly. Refer to {uri-topology}#node-pools[Nodepool].
278
287
279
-
=== Accessing the Kubernetes dashboard
288
+
== Configuring cloud-init for the nodepools
289
+
290
+
To install additional packages, configure settings or execute certain extra commands on node pools, you can use cloud-init to do that for you.
291
+
292
+
By default, there is a `worker.template.sh` file under the cloudinit directory in the `oke` module. Follow the following steps to add your own:
293
+
294
+
. Add your own script in the cloudinit directory. An example is provided by `second.template.sh`. If you need to parameterize the script, enclose the parameter within `${}`. For example:
295
+
296
+
+
297
+
----
298
+
yum install -y package-${version}
299
+
----
300
+
301
+
302
+
. Declare your script as a template in the cloudinit.tf in the locals section. A corresponding example for the `second.template.sh` is provided.
303
+
304
+
+
305
+
If you do *_not_* need to pass a parameter to the script, leave the 2^nd^ argument to the template file function as empty:
. Add the part in the `cloudinit_config worker` section:
325
+
326
+
+
327
+
----
328
+
part {
329
+
filename = "second.sh"
330
+
content_type = "text/x-shellscript"
331
+
content = local.second_script_template
332
+
}
333
+
----
334
+
335
+
. You can add more scripts and have them loaded in the order you need. For example:
336
+
337
+
+
338
+
----
339
+
data "cloudinit_config" "worker" {
340
+
gzip = false
341
+
base64_encode = true
342
+
343
+
part {
344
+
filename = "worker.sh"
345
+
content_type = "text/x-shellscript"
346
+
content = local.worker_script_template
347
+
}
348
+
349
+
part {
350
+
filename = "second.sh"
351
+
content_type = "text/x-shellscript"
352
+
content = local.second_script_template
353
+
}
354
+
355
+
part {
356
+
filename = "third.sh"
357
+
content_type = "text/x-shellscript"
358
+
content = local.third_script_template
359
+
}
360
+
}
361
+
----
362
+
363
+
364
+
== Accessing the Kubernetes dashboard
280
365
281
366
By default, the Kubernetes dashboard is now disabled. To enable it, set the *dashboard_enabled = true* _before_ creating the cluster. The dashboard will then be deployed.
282
367
@@ -288,7 +373,7 @@ kubectl proxy
288
373
289
374
Open a browser and go to {uri-k8s-dashboard}[Kubernetes Dashboard] to display the Kubernetes Dashboard.
290
375
291
-
=== Destroying the cluster
376
+
== Destroying the cluster
292
377
293
378
Run the below command to destroy the infrastructure created by terraform:
294
379
@@ -301,7 +386,7 @@ terraform destroy
301
386
****
302
387
303
388
304
-
=== Creating a service account for CI/CD tools
389
+
== Creating a service account for CI/CD tools
305
390
306
391
OKE now uses Kubeconfig v2 which means the default token has a limited lifespan. In order to allow CI/CD tools to deploy to OKE, a service account must be created.
You can monitor and protect the load balancers created by OKE using {uri-oci-waf}[OCI Web Application Firewall].
323
408
@@ -340,7 +425,7 @@ N.B.
340
425
. WAF protection currently only works if you use a public load balancer as a front end to your services. This means that services deployed as NodePort services are currently *not protected* by WAF.
341
426
****
342
427
343
-
=== Enabling PodSecurityPolicy
428
+
== Enabling PodSecurityPolicy
344
429
345
430
If you would like to enable the PodSecurityPolicy Admission Controller, set
346
431
@@ -355,7 +440,7 @@ Ensure you also read {uri-psp}[the documentation] before enabling it.
355
440
N.B. This field is updatable. You can set to `true` and `false` and run terraform apply again.
356
441
****
357
442
358
-
=== Using Dynamic and Flexible Load Balancers
443
+
== Using Dynamic and Flexible Load Balancers
359
444
360
445
When you create a service of type LoadBalancer, by default, an OCI Load Balancer with dynamic shape 100Mbps will be created.
0 commit comments