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,
|
||||
// and creates an IP address and forwarding rule pointing to that target pool.
|
||||
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{
|
||||
Name: s(b.NameForHealthcheck("api")),
|
||||
Port: i64(wellknownports.KubeAPIServerHealthCheck),
|
||||
|
@ -53,6 +46,14 @@ func createPublicLB(b *APILoadBalancerBuilder, c *fi.CloudupModelBuilderContext)
|
|||
}
|
||||
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{
|
||||
Name: s(b.NameForPoolHealthcheck("api")),
|
||||
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" {
|
||||
description = ""
|
||||
health_checks = [google_compute_http_health_check.api-minimal-gce-plb-example-com.self_link]
|
||||
name = "api-minimal-gce-plb-example-com"
|
||||
session_affinity = ""
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (e *HTTPHealthcheck) TerraformAddress() *terraformWriter.Literal {
|
||||
return terraformWriter.LiteralProperty("google_compute_http_health_check", *e.Name, "id")
|
||||
func (e *HTTPHealthcheck) TerraformLink() *terraformWriter.Literal {
|
||||
return terraformWriter.LiteralSelfLink("google_compute_http_health_check", *e.Name)
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import (
|
|||
// +kops:fitask
|
||||
type TargetPool struct {
|
||||
Name *string
|
||||
HealthCheck *HTTPHealthcheck
|
||||
|
||||
Lifecycle fi.Lifecycle
|
||||
}
|
||||
|
||||
|
@ -56,6 +58,7 @@ func (e *TargetPool) Find(c *fi.CloudupContext) (*TargetPool, error) {
|
|||
actual.Name = fi.PtrTo(r.Name)
|
||||
|
||||
// Avoid spurious changes
|
||||
actual.HealthCheck = e.HealthCheck
|
||||
actual.Lifecycle = e.Lifecycle
|
||||
|
||||
return actual, nil
|
||||
|
@ -105,10 +108,7 @@ func (_ *TargetPool) RenderGCE(t *gce.GCEAPITarget, a, e, changes *TargetPool) e
|
|||
|
||||
type terraformTargetPool struct {
|
||||
Name string `cty:"name"`
|
||||
Description string `cty:"description"`
|
||||
HealthChecks []string `cty:"health_checks"`
|
||||
Instances []string `cty:"instances"`
|
||||
SessionAffinity string `cty:"session_affinity"`
|
||||
HealthChecks []*terraformWriter.Literal `cty:"health_checks"`
|
||||
}
|
||||
|
||||
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{
|
||||
Name: name,
|
||||
HealthChecks: []*terraformWriter.Literal{
|
||||
e.HealthCheck.TerraformLink(),
|
||||
},
|
||||
}
|
||||
|
||||
return t.RenderResource("google_compute_target_pool", name, tf)
|
||||
|
|
Loading…
Reference in New Issue