|
2 | 2 | :idprefix:
|
3 | 3 | :idseparator: -
|
4 | 4 | :sectlinks:
|
5 |
| -:sectnums: |
6 | 5 | :toc: auto
|
7 | 6 |
|
8 | 7 | :uri-cloudinit: https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengusingcustomcloudinitscripts.htm
|
| 8 | +:uri-source-cloudinit-doc: https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/main/docs/instructions.adoc#configuring-cloud-init-for-the-nodepools |
| 9 | +:uri-repo: https://github.com/oracle-terraform-modules/terraform-oci-oke |
| 10 | +:uri-worker-script: link:{uri-repo}/modules/oke/cloudinit/worker.template.sh |
9 | 11 |
|
10 |
| -== Instructions: |
11 | 12 |
|
12 |
| -* {uri-cloudinit}[Using cloud-init in OKE] |
13 |
| -* The default cloud-init script used by this module is as below: |
14 |
| ----- |
15 |
| -#!/bin/bash |
| 13 | +== Configuring cloud-init scripts for node pools: |
| 14 | +There are 2 types of cloud-init scripts that can be configured for node pools: |
16 | 15 |
|
17 |
| -# DO NOT MODIFY |
18 |
| -curl --fail -H "Authorization: Bearer Oracle" -L0 http://169.254.169.254/opc/v2/instance/metadata/oke_init_script | base64 --decode >/var/run/oke-init.sh |
| 16 | +. Common: these are cloud-init scripts that are common to all node pools |
| 17 | +. Node pool specific: these are cloud-init scripts that are specific to particular node pools. |
19 | 18 |
|
20 |
| -## run oke provisioning script |
21 |
| -bash -x /var/run/oke-init.sh |
| 19 | +=== Default cloud-init |
22 | 20 |
|
23 |
| -### adjust block volume size |
24 |
| -/usr/libexec/oci-growfs -y |
| 21 | +By default, the {uri-worker-script}[worker template] is used. The default worker template runs `oci-growfs` and `timedatectl` to configure the boot volume size and timezone respectively. |
25 | 22 |
|
26 |
| -timedatectl set-timezone ${worker_timezone} |
27 |
| ----- |
| 23 | +=== Script precedence |
| 24 | + |
| 25 | +If no value is configured for `cloudinit_nodepool_common` or for `cloudinit_nodepool`, this default template is used. |
| 26 | + |
| 27 | +If a value is configured for `cloudinit_nodepool_common`, then this value is used instead. |
| 28 | + |
| 29 | +If a value is configured for `cloudinit_nodepool`, then this value is used for the specific nodepool only instead. Other nodepools will utilize whatever script is common. |
| 30 | + |
| 31 | +The flowchart below depicts the script selection workflow: |
| 32 | + |
| 33 | +.cloud-init script selection |
| 34 | +image::images/cloud-init-flowchart.png[align="cloud-init script selection"] |
28 | 35 |
|
29 |
| -* To customize this you can modify the above script and pass the script as input variable to `cloudinit_nodepool_common`. This script will be used across all the nodepools. |
30 | 36 |
|
31 |
| -* To use specific cloud-init script for a nodepool pass the script as input variable to `cloudinit_nodepool` as a map.This will take precedence over `cloudinit_nodepool_common` for that nodepool. |
32 |
| -Ex: cloudinit_nodepool = { |
33 |
| - #np1 = "/tmp/np1cloudinit.sh" |
34 |
| - #np3 = "/tmp/np3cloudinit.sh" |
35 |
| -#} |
| 37 | +== Overriding default cloud-init |
36 | 38 |
|
| 39 | +=== Overriding the common cloud-init |
| 40 | + |
| 41 | +The common cloud-init script for all node pools can be overriden as follows: |
| 42 | + |
| 43 | +``` |
| 44 | +cloudinit_nodepool_common = "/tmp/cloudinit_nodepool_common.sh" |
| 45 | +``` |
| 46 | + |
| 47 | +=== Specifying a cloud-init script for specific node pools |
| 48 | + |
| 49 | +Sometimes, it may be desirable to configure additional settings for specific node pools without affecting the behaviour of existing or other node pools. In this case, you can override cloud-init as follows: |
| 50 | + |
| 51 | +---- |
| 52 | +cloudinit_nodepool = { |
| 53 | + np1 = "/tmp/np1_cloud-init.sh" |
| 54 | + np3 = "/tmp/np3_cloud-init.sh" |
| 55 | +} |
| 56 | +---- |
37 | 57 |
|
| 58 | +In the above example, node pool `np1` and `np3` will use `/tmp/np1_cloud-init.sh` and `/tmp/np3_cloud-init.sh` respectively for their cloud-init. |
38 | 59 |
|
| 60 | +NOTE: You must ensure that the node pool name specified for cloud-init matches those you defined in the `node_pools` variable. |
0 commit comments