K8s Nodepool

k8s_nodepool

This is a simple module that supports creating or removing K8s Nodepools. This module has a dependency on ionoscloud >= 6.0.2

Example Syntax


name: Create k8s cluster nodepool
ionoscloudsdk.ionoscloud.k8s_nodepool:
  name: my-nodepool-
  k8s_cluster: ''
  datacenter: ''
  node_count: 2
  cpu_family: INTEL_SKYLAKE
  cores_count: 1
  ram_size: 2048
  availability_zone: AUTO
  storage_type: HDD
  storage_size: 100
  public_ips: ''
  lans:
  - id: ''
    dhcp: false
  auto_scaling:
    min_node_count: 1
    max_node_count: 3
  labels:
    foo: bar
    color: red
    size: '10'
  annotations:
    ann1: value1
    ann2: value2
  wait: true
register: result


name: Update k8s cluster nodepool no change
ionoscloudsdk.ionoscloud.k8s_nodepool:
  k8s_cluster: ''
  datacenter: ''
  k8s_nodepool: ''
  name: ''
  node_count: 2
  cpu_family: INTEL_SKYLAKE
  cores_count: '1'
  ram_size: '2048'
  availability_zone: AUTO
  storage_type: HDD
  storage_size: '100'
  public_ips: ''
  lans:
  - id: ''
    dhcp: false
  auto_scaling:
    min_node_count: 1
    max_node_count: 3
  labels:
    foo: bar
    color: red
    size: '10'
  annotations:
    ann1: value1
    ann2: value2
  wait: true
  state: update
register: result_no_change


name: Delete k8s cluster nodepool
ionoscloudsdk.ionoscloud.k8s_nodepool:
  k8s_cluster: ''
  k8s_nodepool: ''
  wait: false
  state: absent

Returned object

{
    "changed": true,
    "failed": false,
    "action": "create",
    "nodepool": {
        "href": "https://api.ionos.com/cloudapi/v6/k8s/b08b63ff-8bee-4091-ad5f-f8296eedd93b/nodepools/2d5b0b1c-67aa-4b9f-a899-c729619fa4ce",
        "id": "2d5b0b1c-67aa-4b9f-a899-c729619fa4ce",
        "metadata": {
            "created_by": "<USER_EMAIL>",
            "created_by_user_id": "<USER_ID>",
            "created_date": "2023-05-31T09:48:08+00:00",
            "etag": "ddb146ab080132c5d4ecc05871c32c74",
            "last_modified_by": "<USER_EMAIL>",
            "last_modified_by_user_id": "<USER_ID>",
            "last_modified_date": "2023-05-31T09:48:08+00:00",
            "state": "DEPLOYING"
        },
        "properties": {
            "annotations": {
                "ann1": "value1",
                "ann2": "value2"
            },
            "auto_scaling": {
                "max_node_count": 3,
                "min_node_count": 1
            },
            "availability_zone": "AUTO",
            "available_upgrade_versions": null,
            "cores_count": 1,
            "cpu_family": "INTEL_SKYLAKE",
            "datacenter_id": "c38a3861-3af3-4ecf-9c83-54021512e9d9",
            "k8s_version": null,
            "labels": {
                "foo": "bar",
                "color": "red",
                "size": "10"
            },
            "lans": [
                {
                    "datacenter_id": null,
                    "dhcp": false,
                    "id": 1,
                    "routes": []
                }
            ],
            "maintenance_window": {
                "day_of_the_week": "Friday",
                "time": "22:00:08Z"
            },
            "name": "my-nodepool-54",
            "node_count": 2,
            "public_ips": [
                "<IP1>",
                "<IP2>",
                "<IP3>",
                "<IP4>"
            ],
            "ram_size": 2048,
            "storage_size": 100,
            "storage_type": "HDD"
        },
        "type": "nodepool"
    }
}

For more examples please check out the tests here.

NOTE: If you are using a versions 7.0.0 and up: modules can replace resources if certain set parameters differ from the results found in the API!

Parameters that can trigger a resource replacement:

  • datacenter

  • name

  • cpu_family

  • cores_count

  • ram_size

  • availability_zone

  • storage_type

  • storage_size

state: present

  
name: Create k8s cluster nodepool
ionoscloudsdk.ionoscloud.k8s_nodepool:
  name: my-nodepool-
  k8s_cluster: ''
  datacenter: ''
  node_count: 2
  cpu_family: INTEL_SKYLAKE
  cores_count: 1
  ram_size: 2048
  availability_zone: AUTO
  storage_type: HDD
  storage_size: 100
  public_ips: ''
  lans:
  - id: ''
    dhcp: false
  auto_scaling:
    min_node_count: 1
    max_node_count: 3
  labels:
    foo: bar
    color: red
    size: '10'
  annotations:
    ann1: value1
    ann2: value2
  wait: true
register: result

Available parameters for state present:

Name
Required
Description

k8s_cluster str

True

The ID or name of the K8s cluster.

name str

True

A Kubernetes node pool name. Valid Kubernetes node pool name must be 63 characters or less and must be empty or begin and end with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

k8s_version str

False

The Kubernetes version running in the node pool. Note that this imposes restrictions on which Kubernetes versions can run in the node pools of a cluster. Also, not all Kubernetes versions are suitable upgrade targets for all earlier versions.

datacenter str

True

The unique identifier of the VDC where the worker nodes of the node pool are provisioned.Note that the data center is located in the exact place where the parent cluster of the node pool is located.

lans list

False

The array of existing private LANs to attach to worker nodes.

node_count int

False

The number of worker nodes of the node pool.

cpu_family str

True

The CPU type for the nodes.

cores_count int

True

The total number of cores for the nodes.

ram_size int

True

The RAM size for the nodes. Must be specified in multiples of 1024 MB, with a minimum size of 2048 MB.

availability_zone str

False

The availability zone in which the target VM should be provisioned. Options: ['AUTO', 'ZONE_1', 'ZONE_2']

storage_type str

True

The storage type for the nodes. Options: ['HDD', 'SSD']

storage_size int

True

The allocated volume size in GB. The allocated volume size in GB. To achieve good performance, we recommend a size greater than 100GB for SSD.

maintenance_window dict

False

The maintenance window is used to update the software on the node pool nodes and update the K8s version of the node pool. If no value is specified, a value is selected dynamically, so there is no fixed default value.

labels dict

False

The labels attached to the node pool.

annotations dict

False

The annotations attached to the node pool.

auto_scaling dict

False

Property to be set when auto-scaling needs to be enabled for the nodepool. By default, auto-scaling is not enabled.

public_ips list

False

Optional array of reserved public IP addresses to be used by the nodes. The IPs must be from the exact location of the node pool's data center. If autoscaling is used, the array must contain one more IP than the maximum possible number of nodes (nodeCount+1 for a fixed number of nodes or maxNodeCount+1). The extra IP is used when the nodes are rebuilt.

allow_replace bool

False

Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead Default: False

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 3600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

state: absent

  
name: Delete k8s cluster nodepool
ionoscloudsdk.ionoscloud.k8s_nodepool:
  k8s_cluster: ''
  k8s_nodepool: ''
  wait: false
  state: absent

Available parameters for state absent:

Name
Required
Description

k8s_cluster str

True

The ID or name of the K8s cluster.

k8s_nodepool str

True

The ID or name of the K8s nodepool.

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 3600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

state: update

  
name: Update k8s cluster nodepool no change
ionoscloudsdk.ionoscloud.k8s_nodepool:
  k8s_cluster: ''
  datacenter: ''
  k8s_nodepool: ''
  name: ''
  node_count: 2
  cpu_family: INTEL_SKYLAKE
  cores_count: '1'
  ram_size: '2048'
  availability_zone: AUTO
  storage_type: HDD
  storage_size: '100'
  public_ips: ''
  lans:
  - id: ''
    dhcp: false
  auto_scaling:
    min_node_count: 1
    max_node_count: 3
  labels:
    foo: bar
    color: red
    size: '10'
  annotations:
    ann1: value1
    ann2: value2
  wait: true
  state: update
register: result_no_change

Available parameters for state update:

Name
Required
Description

k8s_cluster str

True

The ID or name of the K8s cluster.

k8s_nodepool str

True

The ID or name of the K8s nodepool.

name str

False

A Kubernetes node pool name. Valid Kubernetes node pool name must be 63 characters or less and must be empty or begin and end with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

k8s_version str

False

The Kubernetes version running in the node pool. Note that this imposes restrictions on which Kubernetes versions can run in the node pools of a cluster. Also, not all Kubernetes versions are suitable upgrade targets for all earlier versions.

datacenter str

False

The unique identifier of the VDC where the worker nodes of the node pool are provisioned.Note that the data center is located in the exact place where the parent cluster of the node pool is located.

lans list

False

The array of existing private LANs to attach to worker nodes.

node_count int

False

The number of worker nodes of the node pool.

cpu_family str

False

The CPU type for the nodes.

cores_count int

False

The total number of cores for the nodes.

ram_size int

False

The RAM size for the nodes. Must be specified in multiples of 1024 MB, with a minimum size of 2048 MB.

availability_zone str

False

The availability zone in which the target VM should be provisioned. Options: ['AUTO', 'ZONE_1', 'ZONE_2']

storage_type str

False

The storage type for the nodes. Options: ['HDD', 'SSD']

storage_size int

False

The allocated volume size in GB. The allocated volume size in GB. To achieve good performance, we recommend a size greater than 100GB for SSD.

maintenance_window dict

False

The maintenance window is used to update the software on the node pool nodes and update the K8s version of the node pool. If no value is specified, a value is selected dynamically, so there is no fixed default value.

labels dict

False

The labels attached to the node pool.

annotations dict

False

The annotations attached to the node pool.

auto_scaling dict

False

Property to be set when auto-scaling needs to be enabled for the nodepool. By default, auto-scaling is not enabled.

public_ips list

False

Optional array of reserved public IP addresses to be used by the nodes. The IPs must be from the exact location of the node pool's data center. If autoscaling is used, the array must contain one more IP than the maximum possible number of nodes (nodeCount+1 for a fixed number of nodes or maxNodeCount+1). The extra IP is used when the nodes are rebuilt.

allow_replace bool

False

Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead Default: False

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 3600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

Last updated