Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1alpha2 API #1183

Merged
merged 23 commits into from Dec 19, 2016
Merged

v1alpha2 API #1183

merged 23 commits into from Dec 19, 2016

Conversation

justinsb
Copy link
Member

@justinsb justinsb commented Dec 17, 2016

This change is Reviewable

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 17, 2016
@justinsb justinsb force-pushed the use_ig_for_bastions_2 branch 2 times, most recently from fba580c to 13f5ef3 Compare December 18, 2016 21:07
@justinsb
Copy link
Member Author

@kris-nova the TF changes are now manageable I think:

  • The private subnet cannot have the private- prefix (sadly), because our conversion
    logic doesn't have knowledge of the cluster network topology
  • ELB has health check
  • Bastions now have IAM profile & role
  • Renamed bastion_to_master -> all_bastion_to_master
  • Renamed SecurityGroupRules that have a CIDR include the CIDR in the name

So if you have a look at the TF changes here I think they are more understandable now: dfc2fa7

@@ -13,7 +13,7 @@ resource "aws_autoscaling_group" "bastion-privateweave-example-com" {
launch_configuration = "${aws_launch_configuration.bastion-privateweave-example-com.id}"
max_size = 1
min_size = 1
vpc_zone_identifier = ["${aws_subnet.private-us-test-1a-privateweave-example-com.id}"]
vpc_zone_identifier = ["${aws_subnet.utility-us-test-1a-privateweave-example-com.id}"]
Copy link
Contributor

@krisnova krisnova Dec 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinsb

We aren't renaming private subnets to utility subnets are we?

In general the 2 conventions that we were using

Public

These are where the NAT gateways live, and have the synonym utility

Private

These are private, and hold the resources like instances

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this was a PITA because the keyword private was easily confused with what kops calls a private topology

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not, but "normal" public & private subnets (where nodes live) are unqualified i.e. us-east-1a.k8s.example.com in both topologies. We have to do this because when we're doing the version conversion we don't have access to the full cluster state. It does have some advantages though - I think it might be possible to move from topology public <-> private, though I haven't tried it..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The utility subnet (ELBs, NAT gateways) is only used in private topologies, and is always public. I did debate renaming it to dmz (as I think that's the common term) but utility is probably at least as clear and less likely to offend.

@krisnova
Copy link
Contributor

@justinsb your changes LGTM if you could please follow up on my comment about the private keyword.. just wondering about the context you are using it - otherwise the TF changes look great

@chrislovecnm
Copy link
Contributor

Also CI and e2e. Any way we going to get those to pass?

Copy link
Contributor

@chrislovecnm chrislovecnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not resist. I know it is WIP, but I had to take a look. OMG btw. This is amazing!!!!!!

Lots of questions and requests for fmt on errors.


apimachinery:
#go install ./cmd/libs/go2idl/conversion-gen
~/k8s/bin/conversion-gen --input-dirs k8s.io/kops/pkg/apis/kops/v1alpha1 --v=8 --output-file-base=zz_generated.conversion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have the comments parts in another target and have this documented?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... so the challenge is that the fix I had to make it k8s so the conversion generator works only just landed today. So we also have to update k8s to the latest, or pull it out into the shared repo. I'm inclined to do the latter. It's a placeholder for actually installing the code for real

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would encourage us to bump k8s version before this merges.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just starting review but do we have an API machinery doc floating around this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't but we have #1164

Bumping k8s version means going onto the master branch :-(

@@ -96,7 +96,12 @@ func RunCreateInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string,
// Populate some defaults
ig := &api.InstanceGroup{}
ig.ObjectMeta.Name = groupName
ig.Spec.Role = api.InstanceGroupRole(options.Role)

role, ok := api.ParseInstanceGroupRole(options.Role, true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I got coached on using err, so we should use err ;)

Copy link
Contributor

@krisnova krisnova Dec 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another case of weird golangisms...

This is actually fine - the function api.ParseInstanceGroupRole() is not returning an err but rather returning a bool than be used in a very similar way as err

Usually you see this if the function doesn't actually do anything wrong, just returns a bool that the user can trigger off of

cmd.Flags().DurationVar(&rollingupdateCluster.MasterInterval, "master-interval", 5*time.Minute, "Time to wait between restarting masters")
cmd.Flags().DurationVar(&rollingupdateCluster.NodeInterval, "node-interval", 2*time.Minute, "Time to wait between restarting nodes")
cmd.Flags().DurationVar(&rollingupdateCluster.BastionInterval, "bastion-interval", 5*time.Minute, "Time to wait between restarting bastions")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh crap, this will impact my pr ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a change here? This PR is huge - to say the least, in a name of keeping the comments clean can you let us know if anything needs to change? If so - what?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is needed? We have nothing here that suggests a change to be honest.

Don't understand what we need to do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will handle on my PR ;) We cannot drain a Bastion ;)

)

type ClusterSubnetSpec struct {
// TODO: Rename
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this todo still valid?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I probably should do this - I changed it from Name -> SubnetName to force compiler errors, because previous Name was actually Zone. This rename will not be visible outside the code though. But I'll do it!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed we had subnet.SubnetName floating around earlier - if we have a usecase for it let's leave it - but if we can use subnet.Name I would prefer that to keep things consistent.

if len(c.Spec.AdminAccess) == 0 {
c.Spec.AdminAccess = append(c.Spec.AdminAccess, "0.0.0.0/0")
// TODO: Move elsewhere
if len(c.Spec.SSHAccess) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think @vendrov can refactor

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What needs to be changed here?

}

nodeUpTags, err := buildNodeupTags(role, tf.cluster, tf.tags)
if err != nil {
return "", err
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM - might I have a fmt please sir

var r realVPCDHCPOptionsAssociation
if err := json.Unmarshal(data, &r); err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I should stop asking

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Particularly on autogenerated code :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got me on that one

return a[i].Zone < a[j].Zone
}

func assignCIDRsToSubnets(c *kops.Cluster) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fun code. How much test coverage do we have?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see unit tests.. See comment about negative test cases.

@@ -0,0 +1,150 @@
/*
Copyright 2016 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to see some negative test cases. If I am reading this correctly we do not have any, could be wrong

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it in another PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default:
return fmt.Errorf("unknown group type for group %q", group.InstanceGroup.ObjectMeta.Name)
}
}

// Upgrade bastions first; if these go down we can't see anything
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so we update the bastion here. No drain, but definitely validate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no validate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - just get these out of the way first IMHO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test for this PR, push my PR to after this monster

@chrislovecnm
Copy link
Contributor

Think this PR will only address a couple of open bugs... SGTM

We probably shouldn't, but we delete the ASG when you `kops delete ig`.

If the ASG doesn't exist though, we can still delete the IG.
Utility subnets are only for type=Bastion
As the subnets will partition the parent NetworkCIDR, so they require it
to be set.
By testing with data from various schema versions, we effectively check
that they are equivalent.

Also this uncovered a few places where we were not strictly ordering
things - add some sorts in there.
@k8s-ci-robot
Copy link
Contributor

Jenkins Kubernetes AWS e2e failed for commit 91b77ae. Full PR test history.

The magic incantation to run this job again is @k8s-bot aws e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

Copy link
Contributor

@krisnova krisnova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinsb This is amazing - great work..

Left a few comments, most of my notes are semantic or questioning new API property names.. Overall this is solid.. very nice


apimachinery:
#go install ./cmd/libs/go2idl/conversion-gen
~/k8s/bin/conversion-gen --input-dirs k8s.io/kops/pkg/apis/kops/v1alpha1 --v=8 --output-file-base=zz_generated.conversion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just starting review but do we have an API machinery doc floating around this PR?

if existingZones[zone] == nil {
cluster.Spec.Zones = append(cluster.Spec.Zones, &api.ClusterZoneSpec{
Name: zone,
for _, subnetName := range parseZoneList(c.Zones) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zone's and subnets are hard

It looks like parseZoneList return a slice of subnet names..? Is that what we want?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not - thanks :-)

}

if c.Bastion {
return fmt.Errorf("Bastion supports --topology='private' only.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of the command line flag connotations in error messages?

We call kops as a library often, and the users typically have no concept of --topology

Wordsmith:

return fmt.Errorf("Attempting to create bastion, in a non-bastion configuration (Topology: private)")

@@ -96,7 +96,12 @@ func RunCreateInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string,
// Populate some defaults
ig := &api.InstanceGroup{}
ig.ObjectMeta.Name = groupName
ig.Spec.Role = api.InstanceGroupRole(options.Role)

role, ok := api.ParseInstanceGroupRole(options.Role, true)
Copy link
Contributor

@krisnova krisnova Dec 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another case of weird golangisms...

This is actually fine - the function api.ParseInstanceGroupRole() is not returning an err but rather returning a bool than be used in a very similar way as err

Usually you see this if the function doesn't actually do anything wrong, just returns a bool that the user can trigger off of

}

func runTest(t *testing.T, clusterName string, srcDir string) {
func runTest(t *testing.T, clusterName string, srcDir string, private bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woo! Private bool! (No change needed)

}

// SSH is open to AdminCIDR set
if b.Cluster.IsTopologyPublic() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if !b.Cluster.IsTopologyPublic()? Where are defining the security groups that open the IG's to the ELB security groups?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we define that ELB, we do it there. So api_loadbalancer

We can refactor if you'd prefer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS the refactoring will be much easier once we get this in - just normal go refactoring :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes yes indeed - this is far from a deal breaker, and more exciting than anything.. The PRs coming through on this code are going to do just fine - no refactor needed :)

@@ -0,0 +1,25 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convenience functions are good.. and I see when they are useful..

But I have to gripes here..

misc.go

Just naming a file that, opens up the door to contributors dropping in arbitrary logic they don't want to figure out where it should really go

Suggest: convenience.go

s() and i64()

While these are super handy, and I love them in the new models.. they don't really tell the dev (usually me) what the heck they do..

(Yes I mean this) Can we maybe use the convenience functions as wrappers to very specific verbose function names?

func s(v string) *string {
    return stringToStringPointer(v)
}

func stringToStringPointer(v string) *string {
    return &v
}

It might seem like super over kill to dig 3 functions deep just to add a & to the beginning of a string variable name, but pointers are a huge deal. Also when we are working on the models, if we need to see what s() does, the code will document itself immediately.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in general whenever a shortcut name like s() is used, I have found it useful to have it wrap a more verbose function - that's all I am getting at - simple code doc would work too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion.

We actually have aws.String and fi.String so I delegated to those already (and added a comment to fi.String)

I actually debated having a macros package and _ importing them, but I like your convenience.go suggestion a lot better!

@@ -0,0 +1,118 @@
apiVersion: kops/v1alpha2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is great - I love seeing these new tests come to life - Good job @justinsb

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)

@@ -0,0 +1,182 @@
package cloudup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Headers here,

Also GJ on getting the subnets here - you read my mind

default:
return fmt.Errorf("unknown group type for group %q", group.InstanceGroup.ObjectMeta.Name)
}
}

// Upgrade bastions first; if these go down we can't see anything
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - just get these out of the way first IMHO

@krisnova krisnova self-assigned this Dec 19, 2016
@justinsb justinsb changed the title WIP: v1alpha2 API v1alpha2 API Dec 19, 2016
@justinsb
Copy link
Member Author

Removing WIP!

@krisnova krisnova dismissed chrislovecnm’s stale review December 19, 2016 06:42

I think we discussed most of these concerns

@krisnova
Copy link
Contributor

This is a big PR, with a ton of work thanks to @justinsb - This change LGTM

image

@krisnova krisnova merged commit b3e6dab into kubernetes:master Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants