mirror of https://github.com/kubernetes/kops.git
Connection settings loadbalancer
This commit is contained in:
parent
fd51303622
commit
ef73285659
|
@ -88,12 +88,12 @@ loadBalancerAttachment/bastion-elb-attachment.{{ ClusterName }}:
|
|||
# By default ELB has an idle timeout of 60 seconds to close connection
|
||||
# Modified the idle timeout for bastion elb
|
||||
# --------------------------------------------------------------------
|
||||
loadBalancerConnectionSettings/bastion.{{ ClusterName }}:
|
||||
idleTimeout: 120
|
||||
loadBalancerAttributes/bastion.{{ ClusterName }}:
|
||||
loadBalancer: loadBalancer/bastion.{{ ClusterName }}
|
||||
connectionSettings: loadBalancerConnectionSettings/bastion.{{ ClusterName }}
|
||||
|
||||
loadBalancerConnectionSettings/bastion.{{ ClusterName }}:
|
||||
loadBalancer: loadBalancer/bastion.{{ ClusterName }}
|
||||
idleTimeout: 120
|
||||
# ---------------------------------------------------------------
|
||||
# ASG - The Bastion itself
|
||||
#
|
||||
|
|
|
@ -77,10 +77,11 @@ func findELB(cloud awsup.AWSCloud, name string) (*elb.LoadBalancerDescription, e
|
|||
request := &elb.DescribeLoadBalancersInput{
|
||||
LoadBalancerNames: []*string{&name},
|
||||
}
|
||||
|
||||
var found []*elb.LoadBalancerDescription
|
||||
err := cloud.ELB().DescribeLoadBalancersPages(request, func(p *elb.DescribeLoadBalancersOutput, lastPage bool) (shouldContinue bool) {
|
||||
for _, lb := range p.LoadBalancerDescriptions {
|
||||
fmt.Println(aws.StringValue(lb.LoadBalancerName))
|
||||
fmt.Println(name)
|
||||
if aws.StringValue(lb.LoadBalancerName) == name {
|
||||
found = append(found, lb)
|
||||
} else {
|
||||
|
|
|
@ -47,16 +47,11 @@ type LoadBalancerCrossZoneLoadBalancing struct {
|
|||
Enabled *bool
|
||||
}
|
||||
|
||||
//go:generate fitask -type=LoadBalancerConnectionSettings
|
||||
type LoadBalancerConnectionSettings struct {
|
||||
Name *string
|
||||
IdleTimeout *int64
|
||||
}
|
||||
|
||||
//go:generate fitask -type=LoadBalancerAttributes
|
||||
type LoadBalancerAttributes struct {
|
||||
Name *string
|
||||
LoadBalancer *LoadBalancer
|
||||
Name *string
|
||||
LoadBalancer *LoadBalancer
|
||||
|
||||
AccessLog *LoadBalancerAccessLog
|
||||
AdditionalAttributes []*LoadBalancerAdditionalAttribute
|
||||
ConnectionDraining *LoadBalancerConnectionDraining
|
||||
|
@ -102,6 +97,7 @@ func (e *LoadBalancerAttributes) Find(c *fi.Context) (*LoadBalancerAttributes, e
|
|||
}
|
||||
|
||||
actual := &LoadBalancerAttributes{}
|
||||
actual.Name = e.Name
|
||||
actual.LoadBalancer = e.LoadBalancer
|
||||
|
||||
if lbAttributes != nil {
|
||||
|
@ -124,7 +120,9 @@ func (e *LoadBalancerAttributes) Find(c *fi.Context) (*LoadBalancerAttributes, e
|
|||
Timeout: lbAttributes.ConnectionDraining.Timeout,
|
||||
}
|
||||
actual.ConnectionSettings = &LoadBalancerConnectionSettings{
|
||||
IdleTimeout: lbAttributes.ConnectionSettings.IdleTimeout,
|
||||
Name: e.Name,
|
||||
LoadBalancer: e.LoadBalancer,
|
||||
IdleTimeout: lbAttributes.ConnectionSettings.IdleTimeout,
|
||||
}
|
||||
actual.CrossZoneLoadBalancing = &LoadBalancerCrossZoneLoadBalancing{
|
||||
Enabled: lbAttributes.CrossZoneLoadBalancing.Enabled,
|
||||
|
@ -138,31 +136,38 @@ func (e *LoadBalancerAttributes) Run(c *fi.Context) error {
|
|||
return fi.DefaultDeltaRunMethod(e, c)
|
||||
}
|
||||
|
||||
func (e *LoadBalancerConnectionSettings) Run(c *fi.Context) error {
|
||||
return fi.DefaultDeltaRunMethod(e, c)
|
||||
}
|
||||
|
||||
func (s *LoadBalancerAttributes) CheckChanges(a, e, changes *LoadBalancerAttributes) error {
|
||||
if a == nil {
|
||||
if e.Name == nil {
|
||||
return fi.RequiredField("Name")
|
||||
}
|
||||
if e.LoadBalancer == nil {
|
||||
return fi.RequiredField("LoadBalancer")
|
||||
}
|
||||
if e.AccessLog.Enabled == nil {
|
||||
return fi.RequiredField("Acceslog.Enabled")
|
||||
}
|
||||
if *e.AccessLog.Enabled {
|
||||
if e.AccessLog.S3BucketName == nil {
|
||||
return fi.RequiredField("Acceslog.S3Bucket")
|
||||
if e.AccessLog != nil {
|
||||
if e.AccessLog.Enabled == nil {
|
||||
return fi.RequiredField("Acceslog.Enabled")
|
||||
}
|
||||
if *e.AccessLog.Enabled {
|
||||
if e.AccessLog.S3BucketName == nil {
|
||||
return fi.RequiredField("Acceslog.S3Bucket")
|
||||
}
|
||||
}
|
||||
}
|
||||
if e.ConnectionDraining.Enabled == nil {
|
||||
return fi.RequiredField("ConnectionDraining.Enabled")
|
||||
if e.ConnectionDraining != nil {
|
||||
if e.ConnectionDraining.Enabled == nil {
|
||||
return fi.RequiredField("ConnectionDraining.Enabled")
|
||||
}
|
||||
}
|
||||
if e.ConnectionSettings.IdleTimeout == nil {
|
||||
return fi.RequiredField("ConnectionSettings.IdleTimeout")
|
||||
if e.ConnectionSettings != nil {
|
||||
if e.ConnectionSettings.IdleTimeout == nil {
|
||||
return fi.RequiredField("ConnectionSettings.IdleTimeout")
|
||||
}
|
||||
}
|
||||
if e.CrossZoneLoadBalancing.Enabled == nil {
|
||||
return fi.RequiredField("CrossZoneLoadBalancing.Enabled")
|
||||
if e.CrossZoneLoadBalancing != nil {
|
||||
if e.CrossZoneLoadBalancing.Enabled == nil {
|
||||
return fi.RequiredField("CrossZoneLoadBalancing.Enabled")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package awstasks
|
||||
|
||||
import (
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||
)
|
||||
|
||||
//go:generate fitask -type=LoadBalancerConnectionSettings
|
||||
type LoadBalancerConnectionSettings struct {
|
||||
Name *string
|
||||
LoadBalancer *LoadBalancer
|
||||
|
||||
IdleTimeout *int64
|
||||
}
|
||||
|
||||
func (e *LoadBalancerConnectionSettings) Find(c *fi.Context) (*LoadBalancerConnectionSettings, error) {
|
||||
cloud := c.Cloud.(awsup.AWSCloud)
|
||||
elbName := fi.StringValue(e.LoadBalancer.ID)
|
||||
|
||||
lb, err := findELB(cloud, elbName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if lb == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
lbAttributes, err := findELBAttributes(cloud, elbName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if lbAttributes == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
actual := &LoadBalancerConnectionSettings{}
|
||||
actual.Name = e.Name
|
||||
actual.LoadBalancer = e.LoadBalancer
|
||||
|
||||
if lbAttributes != nil {
|
||||
actual.IdleTimeout = lbAttributes.ConnectionSettings.IdleTimeout
|
||||
}
|
||||
|
||||
return actual, nil
|
||||
}
|
||||
|
||||
func (e *LoadBalancerConnectionSettings) Run(c *fi.Context) error {
|
||||
return fi.DefaultDeltaRunMethod(e, c)
|
||||
}
|
||||
|
||||
func (s *LoadBalancerConnectionSettings) CheckChanges(a, e, changes *LoadBalancerConnectionSettings) error {
|
||||
if a == nil {
|
||||
if e.LoadBalancer == nil {
|
||||
return fi.RequiredField("LoadBalancer")
|
||||
}
|
||||
if e.IdleTimeout == nil {
|
||||
return fi.RequiredField("IdleTimeout")
|
||||
}
|
||||
if e.Name == nil {
|
||||
return fi.RequiredField("Name")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ *LoadBalancerConnectionSettings) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *LoadBalancerConnectionSettings) error {
|
||||
return nil
|
||||
}
|
|
@ -191,7 +191,7 @@ func (tf *TemplateFunctions) WithBastion() bool {
|
|||
}
|
||||
|
||||
func (tf *TemplateFunctions) IsBastionDNS() bool {
|
||||
if tf.cluster.Spec.Topology.Bastion.PublicName != "" {
|
||||
if tf.cluster.Spec.Topology.Bastion.PublicName == "" {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue