0

I am following this blog post to create kubernetes in existing AWS infrastructure: https://insights.ubuntu.com/2017/02/08/automate-the-deployment-of-kubernetes-in-existing-aws-infrastructure/

$ juju --version
2.2.6-xenial-amd64

My differences:

  • I did not use cloudformation as the VPCs already exist (3x priv + 3x pub subnets in a VPC)
  • I created a new model, since I want to build multiple clusters (one per environment) using models.

I am at the part where I'm trying to define the public and private subnets that exist in AWS (roughly halfway down the page), but I'm getting error messages that give little insight.

$ juju add-model dev-k8s
$ juju add-space public
$ juju add-space private
$ juju add-subnet subnet-12345678 private
ERROR cannot add subnet: no subnets defined

This error message seems very chicken-egg. I can't add a subnet without a subnet?

I've checked out the documentation: https://jujucharms.com/docs/2.2/commands#add-subnet

Usage: juju add-subnet [options] <CIDR>|<provider-id> <space> [<zone1> <zone2> ...]

So I've tried variations, but all end up with similar results

$ juju add-subnet 1.2.3.4/20 private us-east-1a
ERROR cannot add subnet: no subnets defined
$ juju add-subnet 1.2.3.4/20 private subnet-12345678
ERROR cannot add subnet: no subnets defined
$ juju add-subnet subnet-12345678 private us-east-1a
ERROR cannot add subnet: no subnets defined
... + many more that stretch the usage definition above

What's strange is that the subnets are not populated in the new dev-k8s model

$ juju switch dev-k8s && juju list-subnets
pre-ops-k8s:admin/default -> pre-ops-k8s:admin/dev-k8s
No subnets to display.

But the default model contains all the subnets

$ juju switch default && juju list-subnets
pre-ops-k8s:admin/dev-k8s -> pre-ops-k8s:admin/default
subnets:
  1.2.3.4/20:
    type: ipv4
    provider-id: subnet-12345678
    provider-network-id: vpc-12345678
    status: in-use
    space: ""
    zones:
    - us-east-1a
... cropped output

1 Answer 1

0

It turns out that the entire issue revolved around the fact that the model was not connected to any VPC and didn't inherit anything upon creation with no parameters.

Running the following populated the subnets automatically:

juju add-model <common-model-name> aws/us-east-1 --config vpc-id=vpc-12345678 --config vpc-id-force=true

There were still complications surrounding the usage of spaces due to a bug:

Which makes spaces un-editable via add-subnet. This is further complicated by the fact that spaces cannot be deleted. So spaces are literally Write-Once, with the exception that a subnet can be stolen from one space by new space if you create a new space with a subnet that existed in an old space. Yes, this can break old spaces without giving you any options to rebuild the broken space.

To create a space with multiple subnets, you have to specify all the subnets in the original create-space call

juju add-space <space name> 1.2.3.4/32 2.3.4.5/32 3.4.5.6/32

If you screw up creating a space, you'll either need to rebuild the model to wipe the spaces, or go with a new name.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .