add variable project_id
This commit is contained in:
parent
4af016b0c4
commit
5e40ed2cc9
@ -1 +1,3 @@
|
|||||||
project_terraform: /home/valentin/terraform
|
project_terraform: "/home/valentin/terraform"
|
||||||
|
region_k8s: "fr-par"
|
||||||
|
project_name: "terraform-test"
|
@ -1,6 +1,6 @@
|
|||||||
- name: Get id of cluster
|
- name: Get id of cluster
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: https://api.scaleway.com/k8s/v1/regions/fr-par/clusters
|
url: "https://api.scaleway.com/k8s/v1/regions/{{ region_k8s }}/clusters"
|
||||||
status_code: 200
|
status_code: 200
|
||||||
return_content: yes
|
return_content: yes
|
||||||
method: GET
|
method: GET
|
||||||
@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
- name: Download kubeconfig
|
- name: Download kubeconfig
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: "https://api.scaleway.com/k8s/v1/regions/fr-par/clusters/{{ item.id }}/kubeconfig?dl=1"
|
url: "https://api.scaleway.com/k8s/v1/regions/{{ region_k8s }}/clusters/{{ item.id }}/kubeconfig?dl=1"
|
||||||
status_code: 200
|
status_code: 200
|
||||||
dest: "{{ project_terraform }}/kubeconfig"
|
dest: "{{ project_terraform }}/kubeconfig"
|
||||||
method: GET
|
method: GET
|
||||||
headers:
|
headers:
|
||||||
X-Auth-Token: "{{ scw_secret_key }}"
|
X-Auth-Token: "{{ scw_secret_key }}"
|
||||||
when: item.name == "terraform-test"
|
when: item.name == "{{ project_name }}"
|
||||||
with_items: "{{ (output.content |from_json).clusters }}"
|
with_items: "{{ (output.content |from_json).clusters }}"
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
scaleway = {
|
||||||
|
source = "scaleway/scaleway"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
required_version = ">= 0.13"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resource "scaleway_k8s_cluster" "{{ project_name }}" {
|
||||||
|
name = "{{ project_name }}"
|
||||||
|
version = "1.24.3"
|
||||||
|
cni = "cilium"
|
||||||
|
project_id = "{{ project_id }}"
|
||||||
|
region = "{{ region_k8s }}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "scaleway_k8s_pool" "john" {
|
||||||
|
cluster_id = scaleway_k8s_cluster.{{ project_name }}.id
|
||||||
|
name = "john"
|
||||||
|
node_type = "DEV1-M"
|
||||||
|
size = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "null_resource" "kubeconfig" {
|
||||||
|
depends_on = [scaleway_k8s_pool.john] # at least one pool here
|
||||||
|
triggers = {
|
||||||
|
host = scaleway_k8s_cluster.{{ project_name }}.kubeconfig[0].host
|
||||||
|
token = scaleway_k8s_cluster.{{ project_name }}.kubeconfig[0].token
|
||||||
|
cluster_ca_certificate = scaleway_k8s_cluster.{{ project_name }}.kubeconfig[0].cluster_ca_certificate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
provider "kubernetes" {
|
||||||
|
load_config_file = "false"
|
||||||
|
|
||||||
|
host = null_resource.kubeconfig.triggers.host
|
||||||
|
token = null_resource.kubeconfig.triggers.token
|
||||||
|
cluster_ca_certificate = base64decode(
|
||||||
|
null_resource.kubeconfig.triggers.cluster_ca_certificate
|
||||||
|
)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user