# Private Kubernetes on Scaleway with Terraform
**Summary**: This wiki page shows how to create a private kubernetes cluster in Scaleway, one of the upcoming European Cloud Providers, using Terraform. It is a followup of [[scalewayprivatenetworkwithk8s]].\\
**Date**: 1 July 2026 \\
{{tag>scaleway kubernetes terraform}}
Let's first review the network diagram of what we created manually using the console in [[scalewayprivatenetworkwithk8s]]:
[{{scalewayprivatenetworkwithk8s.drawio.png?800|Network diagram for Scaleway Private Network with K8s}}] \\
In this page we'll try to do the same, only then using the [[https://registry.terraform.io/providers/scaleway/scaleway/latest/docs |Scaleway Terraform Provider]].
## The Terraform App
To deploy all required resources using terraform I've defined a new terraform app within my [[https://github.com/getshifting/getshifting/tree/main/terraform/apps/scwPrivateK8s |public repo]]. The setup regarding resources is roughly the same, as we define various resources, mostly using modules. We do have a few extra's though, of which the most eye-catching is the option to add a public ssh key. These are the kind of things you don't really think about when deploying resourcing using clickOps but they are crucial when trying to connect to your resources. Another interesting option is the ability to configure the k8s network. Using terraform exposes way more options to the API then the console does, which means we can now configure the pod and service CIDR as well as the DNS service IP.\\
\\
All together the following resources and modules are used:
* [[https://github.com/getshifting/getshifting/tree/main/terraform/apps/scwPrivateK8s/main.tf |main.tf]]: Defines the provider. Note that the details in the scaleway provider are fake and need to be replaced. I use a [[terraformoverride|override]] file for that.
* [[https://github.com/getshifting/getshifting/tree/main/terraform/apps/scwPrivateK8s/network.tf |network.tf]]: Creates the VPC using this [[https://github.com/getshifting/getshifting/tree/main/terraform/modules/scw_vpc |module]], as well as the private networks using this [[https://github.com/getshifting/getshifting/tree/main/terraform/modules/scw_private_network |module]].
* [[https://github.com/getshifting/getshifting/tree/main/terraform/apps/scwPrivateK8s/instance.tf |instance.tf]]: Creates a linux instance into the private network using this [[https://github.com/getshifting/getshifting/tree/main/terraform/modules/scw_instance_server |module]].
* [[https://github.com/getshifting/getshifting/tree/main/terraform/apps/scwPrivateK8s/public_gateway.tf |public_gateway.tf]]: Creates the public gateway to allow access to the instance and the k8s cluster using this [[https://github.com/getshifting/getshifting/tree/main/terraform/modules/scw_public_gateway |module]].
* [[https://github.com/getshifting/getshifting/tree/main/terraform/apps/scwPrivateK8s/private_kapsule.tf |private_kapsule.tf]]: Creates an isolated kapsule k8s cluster using this [[https://github.com/getshifting/getshifting/tree/main/terraform/modules/scw_private_kapsule |module]].
* [[https://github.com/getshifting/getshifting/tree/main/terraform/apps/scwPrivateK8s/container_registry.tf |container_registry.tf]]: Creates the private container registry to be used by the k8s cluster.
* [[https://github.com/getshifting/getshifting/tree/main/terraform/apps/scwPrivateK8s/ssh_key.tf |ssh_key.tf]]: Creates the ssh key to be used with the linux instance and k8s cluster.
## Use the App
To use the app, simply clone the repository, navigate to the app folder (`scwPrivateK8s`)), replace the values in the `main.tf` file and issue the following commands:
terraform init
terraform plan
terraform apply
Always read the terraform plan very careful, to avoid the unintended removal of resources.
If needed, you can remove all resources again using `terraform destroy`
//This wiki has been made possible by://