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

Private Cluster Configuration #51

Closed
wants to merge 7 commits into from
Closed

Conversation

Jberlinsky
Copy link
Contributor

@Jberlinsky Jberlinsky commented Jan 3, 2019

Supersedes #21. Includes #48 to allow testing on Concourse.

@Jberlinsky Jberlinsky force-pushed the feature/private-cluster branch 5 times, most recently from c494ed9 to ee437e3 Compare January 3, 2019 19:33
@Jberlinsky Jberlinsky changed the title [WIP] Private Cluster Configuration Private Cluster Configuration Jan 3, 2019
@Jberlinsky Jberlinsky self-assigned this Jan 3, 2019
/******************************************
Create regional cluster
*****************************************/
resource "google_container_cluster" "primary_private" {
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 the reason for needing a separate cluster config for private clusters? Ideally we should minimize how many different google_container_cluster resources we have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies, a commit was missing from this. 719ee8b shows the actual configuration of the private cluster.

The issue here is that Terraform 0.11.x doesn't support conditionally adding this block. Hopefully Terraform 0.12 will make this less painful, but for now I'm not sure there's a better option than duplicating the resource.

Copy link
Contributor

@morgante morgante Jan 7, 2019

Choose a reason for hiding this comment

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

As far as I can tell, the private_cluster_config block itself doesn't force anything. If you set all its arguments to false, you would have a standard public cluster.

it's the enable_private_nodes piece which is what is primarily meant by a private cluster usually.

In terms of arguments, I'd actually like to add 3 new ones:

  • enable_private_endpoint
  • enable_private_nodes
  • master_ipv4_cidr_block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@morgante Unfortunately, the provider requires a master_ipv4_cidr_block to be provided as a valid CIDR whenever the private_cluster_config block is specified, and overriding it from the default (unspecified) value can have hard-to-reason-about results. If we simply don't provide that attribute, things work, but we fall into the Terraform 0.11.x trap where an empty string is not considered the same as null, and we have no way to represent null when it should be so.

I would suggest that we merge this as-is, understanding that there is additional complexity as a result of this, and file an upstream issue to make the validation on master_ipv4_cidr_block less stringent.

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 we should hold off as this is a change which will cause breakage later on if we walk it back and instead file an upstream provider issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's approach this by making a submodule as @aaron-lane suggested.

Copy link
Contributor

@aaron-lane aaron-lane left a comment

Choose a reason for hiding this comment

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

Rather than defining a multitude of resources which may or may not be created based on variable values, can we redesign this as a submodule which can be included if a private cluster is desired? The complexity may be significantly reduced.

Other than that, there are just a few small corrections to be made in the tests.

end

describe "default node pool" do
let(:default_node_pool) { data['nodePools'].select { |p| p['name'] == "default-pool" }.first }
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to be obsolete in this context.


it "is private" do
expect(data['privateClusterConfig']['enablePrivateEndpoint']).to eq true
expect(data['privateClusterConfig']['enablePrivateNodes']).to eq true
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto about single assertions.


it "is private" do
expect(data['privateClusterConfig']['enablePrivateEndpoint']).to eq true
expect(data['privateClusterConfig']['enablePrivateNodes']).to eq true
Copy link
Contributor

Choose a reason for hiding this comment

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

We should try to limit tests to single assertions in order to provide clarity when tests fail.

@morgante
Copy link
Contributor

Closing in favor of #69

@morgante morgante closed this Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants