<p>I am having a trouble creating a kubernets using kops inside existing AWS vpc and subnets.
I have an existing vpc with the following CIDR blocks:</p>

<p><strong>IPv4 CIDR:</strong> 10.10.16.0/20</p>

<p>And in that VPC I have my subnets with their assigned CIDR blocks:</p>

<p><strong>SubnetDatabaseA:</strong> 10.10.23.0/24</p>

<p><strong>SubnetDatabaseB:</strong> 10.10.24.0/24</p>

<p><strong>SubnetDatabaseC:</strong> 10.10.20.0/24</p>

<p>And so on...</p>

<p>when trying to create the cluster using kops I get this error:</p>

<pre><code> error running task "Subnet/ap-southeast-2a.clusters.dev1.k8s.local" (9m58s remaining to succeed): error creating subnet: InvalidSubnet.Conflict: The CIDR '10.10.18.0/23' conflicts with another subnet
        status code: 400, request id: 252367d1-d693-47b9-a6c5-a44908a0f6f7
</code></pre>

<p>Which means that one of my subnets is already using that IP range.</p>

<p>How can I assign kops to use a specific CIDR of my choice?</p>

<p>Because I can see that every time I try to create the cluster it assigns a different CIDR (example- CIDR                    10.10.18.0/23)?</p>

Shahar Hamuzim Rajuan
<pre><code>kops create cluster --help
--subnets stringSlice                  Set to use shared subnets
--vpc string                           Set to use a shared VPC
</code></pre>

<p>See following </p>

<pre><code> kops create cluster --name=${CLUSTER_NAME} --vpc=vpc-1010af11 --subnets=subnet- 000e123a,subnet-123b456,subnet-888c9991 --master-zones=${ZONES} --zones=${ZONES}  --networking=weave
</code></pre>

<p>So, if you pass subnet ids, kops doesn't create new CIDR, instead, it will use provided subnet ids and corresponding CIDRs. refer following. </p>

<pre><code>  subnets:
- cidr: 92.145.123.0/26
  id: subnet- 000e123a
  name: us-east-1a
  type: Public
  zone: us-east-1a
- cidr: 92.145.123.64/26
  id: subnet-123b456
  name: us-east-1b
  type: Public
  zone: us-east-1b
- cidr: 92.145.123.128/26
  id: subnet-888c9991
  name: us-east-1c
  type: Public
  zone: us-east-1c
</code></pre>

<p>Or you can edit the cluster with <code>kops edit cluster $CLUSTER_NAME</code> after running <code>kops create cluster</code> without <code>--subnets</code> flag and update the subnets section as seen above. </p>

<p>Reference: <a href="https://github.com/kubernetes/kops/blob/master/docs/cli/kops_create_cluster.md" rel="nofollow noreferrer">https://github.com/kubernetes/kops/blob/master/docs/cli/kops_create_cluster.md</a></p>
