@@ -29,16 +29,41 @@ provider "ovh" {
2929
3030locals {
3131 service_name = " b309c78177f1458187add722e8db8dc2"
32+ cluster_name = " ovh2"
3233 # TODO: pick a region
3334 # GRA9 is colocated with registry
3435 region = " GRA9"
3536}
3637
38+ # create a private network for our cluster
39+ resource "ovh_cloud_project_network_private" "network" {
40+ service_name = local. service_name
41+ name = local. cluster_name
42+ regions = [local . region ]
43+ }
44+
45+ resource "ovh_cloud_project_network_private_subnet" "subnet" {
46+ service_name = local. service_name
47+ network_id = ovh_cloud_project_network_private. network . id
48+
49+ region = local. region
50+ start = " 10.0.0.100"
51+ end = " 10.0.0.254"
52+ network = " 10.0.0.0/24"
53+ dhcp = true
54+ }
55+
3756resource "ovh_cloud_project_kube" "cluster" {
3857 service_name = local. service_name
39- name = " mybinder-ovh "
58+ name = local . cluster_name
4059 region = local. region
4160 version = " 1.23"
61+ # make sure we wait for the subnet to exist
62+ depends_on = [ovh_cloud_project_network_private_subnet . subnet ]
63+
64+ # private_network_id is an openstackid for some reason?
65+ private_network_id = tolist (ovh_cloud_project_network_private. network . regions_attributes )[0 ]. openstackid
66+
4267 customization {
4368 apiserver {
4469 admissionplugins {
@@ -87,7 +112,7 @@ resource "ovh_cloud_project_kube_nodepool" "user" {
87112 template {
88113 metadata {
89114 labels = {
90- " mybinder.org/pool-type" = " user "
115+ " mybinder.org/pool-type" = " users "
91116 }
92117 }
93118 }
@@ -100,10 +125,10 @@ output "kubeconfig" {
100125 sensitive = true
101126 description = << EOF
102127 # save output with:
103- export KUBECONFIG=$PWD/../../secrets/ovh2-kubeconfig.yaml
128+ export KUBECONFIG=$PWD/../../secrets/ovh2-kubeconfig.yml
104129 terraform output -raw kubeconfig > $KUBECONFIG
105130 chmod 600 $KUBECONFIG
106- kubectl config rename-context kubernetes-admin@mybinder-ovh ovh2
131+ kubectl config rename-context kubernetes-admin@ovh2 ovh2
107132 kubectl config use-context ovh2
108133 EOF
109134}
0 commit comments