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

[WIP] Add container cluster network policy addon #630

Merged
merged 15 commits into from
Nov 27, 2017

Conversation

sebglon
Copy link
Contributor

@sebglon sebglon commented Oct 25, 2017

Add #583

@sebglon
Copy link
Contributor Author

sebglon commented Oct 25, 2017

Actualy i open a case on google because with api, on create cluster param networkPolicyConfig disabled=false is not set on created cluster.
Case: 14016662

@sebglon sebglon changed the title Add container cluster network policy addon [WIP] Add container cluster network policy addon Oct 25, 2017
@sebglon sebglon force-pushed the networkpolicy branch 2 times, most recently from 8f07134 to 75d8672 Compare October 26, 2017 08:38
@danawillow danawillow self-requested a review October 26, 2017 22:13
@danawillow
Copy link
Contributor

Hey @sebglon, I see the WIP in the PR description. Do you have anything you're looking to get feedback on with things as they are now?

@sebglon
Copy link
Contributor Author

sebglon commented Nov 2, 2017

Actualy, when i set disable NetworkPolicy tu fase, the network policy is not enabled on create.
For that i have open a case on google to understand why.

@wmuizelaar
Copy link

I just tried to use this, and when I looked at the webinterface of GKE, you it looked like you first need to enable it on the master-node, and then as well on the nodes. So probably there are two places in the API to look for?

@sebglon
Copy link
Contributor Author

sebglon commented Nov 20, 2017

After many exchange with google team, i have changed network_policy on addons by the global network_policy.
Now the code only support global network_policy.
If the value change, it recreate the cluster.

@sebglon
Copy link
Contributor Author

sebglon commented Nov 20, 2017

After many exchange with google team, i have changed network_policy on addons by the global network_policy.
Now the code only support global network_policy.
If the value change, it recreate the cluster.

@danawillow all is good for me. can you review it?

Type: schema.TypeBool,
ForceNew: true,
Optional: true,
Default: true,
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 actually enabled by default?

Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you added update functionality, these doesn't need to be ForceNew


func flattenNetworkPolicy(c *container.NetworkPolicy) []map[string]interface{} {
if c == nil {
c = &container.NetworkPolicy{}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like reassigning pointers this way. Instead, how about something like:

result := []map[string]interface{}{}
if c != nil {
  result = append(result, map[string]interface{}{
    "enabled": c.Enabled,
    "provider": c.Provider,
  })
}
return result

}`, acctest.RandString(10))

var testAccContainerCluster_updateNetworkPolicyEnabled = fmt.Sprintf(`
resource "google_container_cluster" "with_network_policy_enabled" {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you indent this block one more to the left to match the previous var?


var testAccContainerCluster_updateNetworkPolicyEnabled = fmt.Sprintf(`
resource "google_container_cluster" "with_network_policy_enabled" {
name = "cluster-test-%s"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this config and the previous one both use random strings as part of the cluster name, this will destroy+recreate the cluster so it's not actually testing update.

zone = "us-central1-a"
initial_node_count = 1

// remove network_policy is equal than enabled=false
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this comment, what about renaming the test var to testAccContainerCluster_removeNetworkPolicy? Right now it's a bit hard to understand.

Sébastien GLON added 2 commits November 21, 2017 16:02
@sebglon
Copy link
Contributor Author

sebglon commented Nov 21, 2017

@danawillow thanks for your review. All changes are made

Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused why you've decided to allow adding/removing the network policy but not changing the values within it. Was that intentional? If so, can you add a comment explaining why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry @danawillow i don't understand exactly what do you say about 'changing the value".
if you do not put network_policy block, it's the same than disable it.
if you put network_policy block, you can choice to enable or diable it.

@@ -911,7 +949,7 @@ resource "google_container_cluster" "primary" {

var testAccContainerCluster_withMasterAuth = fmt.Sprintf(`
resource "google_container_cluster" "with_master_auth" {
name = "cluster-test-%s"
name = "%s"
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 you changed the wrong test here

@sebglon
Copy link
Contributor Author

sebglon commented Nov 24, 2017

@danawillow Can i have a feedback

@danawillow
Copy link
Contributor

Just added a few small things, but looks good overall, thanks!

@danawillow danawillow merged commit 39f22ef into hashicorp:master Nov 27, 2017
@sebglon sebglon deleted the networkpolicy branch November 27, 2017 21:56
chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
* replalce TypeList by TypeSet

* Add network policy

* test improvement

* correct test

* Add cluster network polocy enabled

* Replalce network_policy addons by global network_policy enabled

* Update node_config.go

* Update resource_container_cluster.go

* clean

* clean

* Correct PR

* COrrect PR

* pr

* fix test to use same name

* add more documentation
luis-silva pushed a commit to luis-silva/terraform-provider-google that referenced this pull request May 21, 2019
@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants