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] provider/google: Update Container Engine features #5871

Merged
merged 3 commits into from
Apr 15, 2016

Conversation

evandbrown
Copy link
Contributor

This change introduces support for subnetworks and addon configurations
in a Google Container Engine cluster:

  1. Addons may only be customized at create time and may not be updated.
  2. Vendored google.golang.org/api packages were updated

@evandbrown
Copy link
Contributor Author

Would love feedback on builtin/providers/google/resource_container_cluster.go as it's my first introduction to the schema model. I'm sure it can be optimized. Like, it may be a bit nesty. Thoughts, @lwander?

Here's a template using the two new properties:

resource "google_container_cluster" "primary" {
    ...
    network = "prod"
    subnetwork = "default-us-central1"

    addons_config {
      http_load_balancing { 
        disabled = true
      }
      horizontal_pod_autoscaling {
        disabled = true
      }
    }
}

if v, ok := addonsConfig["http_load_balancing"]; ok {
addon := v.([]interface{})[0].(map[string]interface{})
cluster.AddonsConfig.HttpLoadBalancing = &container.HttpLoadBalancing{
Disabled: addon["disabled"].(bool),
Copy link
Contributor

Choose a reason for hiding this comment

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

This will default to false if omitted, since you didn't specify this subattribute as required - is that intended behavior? Same thing below on line 310.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's correct. These two addons are enabled by default (i.e., not disabled). A user would create an addons_config to set disabled to true. Weird, huh?

@lwander
Copy link
Contributor

lwander commented Mar 25, 2016

Hey @phinze, do we normally checkin the vendor directory?

@radeksimko
Copy link
Member

do we normally checkin the vendor directory?

we do, but in a separate commit that usually has a descriptive commit message to make the diff easier to read. See https://github.com/hashicorp/terraform#adding-a-dependency

@evandbrown
Copy link
Contributor Author

OK, I broke out the vendoring change into a separate commit. Also, @lwander, I removed the computed attribute as it's not computed by provided by the user. Finally, docs are updated as well.

Appreciate any more comments or an LGTM/merge when folks have a moment.

Thanks!

@lwander
Copy link
Contributor

lwander commented Apr 15, 2016

LGTM! Nice work

Type: schema.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Copy link

Choose a reason for hiding this comment

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

Why Maxitems: 1? When I try:

        addons_config: {
          http_load_balancing: {
            disabled: false
          },
          horizontal_pod_autoscaling: {
            disabled: false
          }
        },

it errors: addons_config: attribute supports 1 item maximum, config has 2 declared

@evandbrown
Copy link
Contributor Author

evandbrown commented Apr 22, 2016

@devth, MaxItems: 1 means you can only have one addons_config stanza (similarly, http_load_balancing and horizonal_pod_autoscaling have the same value.) Is there possibly another addons_config somewhere in your template?

I was able to deploy the following manifest using terraform and terraform-provider-google built from c6763fd:

provider "google" {
    project = "my-project"
    region = "us-east1"
}

resource "google_container_cluster" "primary" {
    name = "marcellus-wallace"
    zone = "us-central1-a"
    initial_node_count = 3

    master_auth {
        username = "mr.yoda"
        password = "adoy.rm"
    }

    node_config {
        oauth_scopes = [
            "https://www.googleapis.com/auth/compute",
            "https://www.googleapis.com/auth/devstorage.read_only",
            "https://www.googleapis.com/auth/logging.write",
            "https://www.googleapis.com/auth/monitoring"
        ]
    }

    addons_config {
      http_load_balancing { 
        disabled = true
      }
      horizontal_pod_autoscaling {
        disabled = true
      }
    }
}

@devth
Copy link

devth commented Apr 22, 2016

I simplified my config down to:

{
   "provider": {
      "google": {
         "credentials": "mycreds",
         "project": "myproject",
         "region": "us-central1"
      }
   },
   "resource": {
      "google_container_cluster": {
         "test-addons-config": {
            "name": "test-addons-config",
            "addons_config": {
               "http_load_balancing": {
                  "disabled": false
               },
               "horizontal_pod_autoscaling": {
                 "disabled": false
               }
            },
            "initial_node_count": 2,
            "master_auth": {
               "password": "foo",
               "username": "admin"
            },
            "node_config": {
               "machine_type": "n1-standard-8",
               "oauth_scopes": [
                  "https://www.googleapis.com/auth/compute",
                  "https://www.googleapis.com/auth/devstorage.read_only",
                  "https://www.googleapis.com/auth/logging.write",
                  "https://www.googleapis.com/auth/monitoring"
               ]
            },
            "zone": "us-central1-a"
         }
      }
   }
}

terraform plan gives:

There are warnings and/or errors related to your configuration. Please
fix these before continuing.

Errors:

  * google_container_cluster.test-addons-config: addons_config: attribute supports 1 item maximum, config has 2 declared
± terraform -v                                                                               -1-
Terraform v0.6.15-dev (d85df6352621e172da0c3c2037f84a1e9a679694+CHANGES)

If I remove either http_load_balancing or horizontal_pod_autoscaling, it works.

@evandbrown
Copy link
Contributor Author

@phinze, any thoughts here? My config above - which is in Terraform config format - works fine; @devth's config (in JSON) does not work.

If I remove the MaxItems contraint, the JSON manifest works. Possibly an issue with a template parser somewhere?

@ghost
Copy link

ghost commented Apr 26, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

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

Successfully merging this pull request may close these issues.

4 participants