<p>I have created EKS cluster using terraform-aws-modules/vpc/aws with Terraform, I use one VPC with 3 private subnets on each AZs in Frankfurt. I've created two services (tomcat and psql) and deployment which are exposed via LoadBalancer and accessible via internet. It looks fine so far.
but the problem is that it's only one environment (DEV). I would like to create multiple environments like stage,test and more inside one VPC and inside one cluster, how to do it using terraform? should I create new files per environment? It would not make sense but nothing comes to my mind... I was considering also workspaces but the problem is that new workspace requires new state - it means that I need to create new VPC with new cluster per one workspace! maybe I should divide my terraform files to have something like &quot;general&quot; workspace and there would be a configuration to VPC and cluster, and create new workspaces for each of the environments? do you have any ideas or better solutions?</p>
<pre>
                   VPC - 172.26.0.0/16
+----------------------+----------------------------------+
|                                                         |
|                                                         |
|                 KUBERNETES CLUSTER                      |
|    +-------------------------------------------------+  |
|    |                                                 |  |
|    |                                                 |  |
|    |                                                 |  |
|    | +------------------+       +-----------------+  |  |
|    | |                  |       |                 |  |  |
|    | |     TEST ENV     |       |     DEV ENV     |  |  |
|    | | +------+ +-----+ |       | +-----+ +-----+ |  |  |
|    | | |tomcat| |psql | |       | |tomcat |psql | |  |  |
|    | | +------+ +-----+ |       | +-----+ +-----+ |  |  |
|    | |                  |       |                 |  |  |
|    | +------------------+       +-----------------+  |  |
|    |                                                 |  |
|    |                                                 |  |
|    |                                                 |  |
|    |                                                 |  |
|    |                                                 |  |
|    |                                                 |  |
|    +-------------------------------------------------+  |
|                                                         |
+---------------------------------------------------------+

</pre>

<p>It is possible to create multiple environments in a single K8s cluster. You could use <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/" rel="nofollow noreferrer">namespace</a> for this. To access the different environments from outside the cluster, you can use a different domain name for each environment.</p>
<p>For example <code>dev.abc.com</code> to access the development environment and <code>test.abc.com</code> to access the test environment.</p>
