mirror of https://github.com/kubernetes/kops.git
gcp: Update terraform rendering for Target Pool
This commit is contained in:
parent
1db17ab949
commit
88fd444987
|
@ -38,13 +38,6 @@ var _ fi.CloudupModelBuilder = &APILoadBalancerBuilder{}
|
||||||
// createPublicLB validates the existence of a target pool with the given name,
|
// createPublicLB validates the existence of a target pool with the given name,
|
||||||
// and creates an IP address and forwarding rule pointing to that target pool.
|
// and creates an IP address and forwarding rule pointing to that target pool.
|
||||||
func createPublicLB(b *APILoadBalancerBuilder, c *fi.CloudupModelBuilderContext) error {
|
func createPublicLB(b *APILoadBalancerBuilder, c *fi.CloudupModelBuilderContext) error {
|
||||||
// TODO: point target pool to instance group managers, as done in internal LB.
|
|
||||||
targetPool := &gcetasks.TargetPool{
|
|
||||||
Name: s(b.NameForTargetPool("api")),
|
|
||||||
Lifecycle: b.Lifecycle,
|
|
||||||
}
|
|
||||||
c.AddTask(targetPool)
|
|
||||||
|
|
||||||
healthCheck := &gcetasks.HTTPHealthcheck{
|
healthCheck := &gcetasks.HTTPHealthcheck{
|
||||||
Name: s(b.NameForHealthcheck("api")),
|
Name: s(b.NameForHealthcheck("api")),
|
||||||
Port: i64(wellknownports.KubeAPIServerHealthCheck),
|
Port: i64(wellknownports.KubeAPIServerHealthCheck),
|
||||||
|
@ -53,6 +46,14 @@ func createPublicLB(b *APILoadBalancerBuilder, c *fi.CloudupModelBuilderContext)
|
||||||
}
|
}
|
||||||
c.AddTask(healthCheck)
|
c.AddTask(healthCheck)
|
||||||
|
|
||||||
|
// TODO: point target pool to instance group managers, as done in internal LB.
|
||||||
|
targetPool := &gcetasks.TargetPool{
|
||||||
|
Name: s(b.NameForTargetPool("api")),
|
||||||
|
HealthCheck: healthCheck,
|
||||||
|
Lifecycle: b.Lifecycle,
|
||||||
|
}
|
||||||
|
c.AddTask(targetPool)
|
||||||
|
|
||||||
poolHealthCheck := &gcetasks.PoolHealthCheck{
|
poolHealthCheck := &gcetasks.PoolHealthCheck{
|
||||||
Name: s(b.NameForPoolHealthcheck("api")),
|
Name: s(b.NameForPoolHealthcheck("api")),
|
||||||
Healthcheck: healthCheck,
|
Healthcheck: healthCheck,
|
||||||
|
|
|
@ -565,9 +565,8 @@ resource "google_compute_subnetwork" "us-test1-minimal-gce-plb-example-com" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_target_pool" "api-minimal-gce-plb-example-com" {
|
resource "google_compute_target_pool" "api-minimal-gce-plb-example-com" {
|
||||||
description = ""
|
health_checks = [google_compute_http_health_check.api-minimal-gce-plb-example-com.self_link]
|
||||||
name = "api-minimal-gce-plb-example-com"
|
name = "api-minimal-gce-plb-example-com"
|
||||||
session_affinity = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_project_iam_binding" "serviceaccount-control-plane" {
|
resource "google_project_iam_binding" "serviceaccount-control-plane" {
|
||||||
|
|
|
@ -113,6 +113,6 @@ func (_ *HTTPHealthcheck) RenderTerraform(t *terraform.TerraformTarget, a, e, ch
|
||||||
return t.RenderResource("google_compute_http_health_check", *e.Name, tf)
|
return t.RenderResource("google_compute_http_health_check", *e.Name, tf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *HTTPHealthcheck) TerraformAddress() *terraformWriter.Literal {
|
func (e *HTTPHealthcheck) TerraformLink() *terraformWriter.Literal {
|
||||||
return terraformWriter.LiteralProperty("google_compute_http_health_check", *e.Name, "id")
|
return terraformWriter.LiteralSelfLink("google_compute_http_health_check", *e.Name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ import (
|
||||||
// +kops:fitask
|
// +kops:fitask
|
||||||
type TargetPool struct {
|
type TargetPool struct {
|
||||||
Name *string
|
Name *string
|
||||||
|
HealthCheck *HTTPHealthcheck
|
||||||
|
|
||||||
Lifecycle fi.Lifecycle
|
Lifecycle fi.Lifecycle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +58,7 @@ func (e *TargetPool) Find(c *fi.CloudupContext) (*TargetPool, error) {
|
||||||
actual.Name = fi.PtrTo(r.Name)
|
actual.Name = fi.PtrTo(r.Name)
|
||||||
|
|
||||||
// Avoid spurious changes
|
// Avoid spurious changes
|
||||||
|
actual.HealthCheck = e.HealthCheck
|
||||||
actual.Lifecycle = e.Lifecycle
|
actual.Lifecycle = e.Lifecycle
|
||||||
|
|
||||||
return actual, nil
|
return actual, nil
|
||||||
|
@ -105,10 +108,7 @@ func (_ *TargetPool) RenderGCE(t *gce.GCEAPITarget, a, e, changes *TargetPool) e
|
||||||
|
|
||||||
type terraformTargetPool struct {
|
type terraformTargetPool struct {
|
||||||
Name string `cty:"name"`
|
Name string `cty:"name"`
|
||||||
Description string `cty:"description"`
|
HealthChecks []*terraformWriter.Literal `cty:"health_checks"`
|
||||||
HealthChecks []string `cty:"health_checks"`
|
|
||||||
Instances []string `cty:"instances"`
|
|
||||||
SessionAffinity string `cty:"session_affinity"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ *TargetPool) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *TargetPool) error {
|
func (_ *TargetPool) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *TargetPool) error {
|
||||||
|
@ -116,6 +116,9 @@ func (_ *TargetPool) RenderTerraform(t *terraform.TerraformTarget, a, e, changes
|
||||||
|
|
||||||
tf := &terraformTargetPool{
|
tf := &terraformTargetPool{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
HealthChecks: []*terraformWriter.Literal{
|
||||||
|
e.HealthCheck.TerraformLink(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return t.RenderResource("google_compute_target_pool", name, tf)
|
return t.RenderResource("google_compute_target_pool", name, tf)
|
||||||
|
|
Loading…
Reference in New Issue