mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
parent
cadb6c06be
commit
c465e91681
@ -34,6 +34,7 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
|
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
|
||||||
"github.com/aws/aws-sdk-go/aws/ec2metadata"
|
"github.com/aws/aws-sdk-go/aws/ec2metadata"
|
||||||
|
"github.com/aws/aws-sdk-go/aws/request"
|
||||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
"github.com/aws/aws-sdk-go/service/elb"
|
"github.com/aws/aws-sdk-go/service/elb"
|
||||||
@ -205,12 +206,23 @@ type awsSDKProvider struct {
|
|||||||
creds *credentials.Credentials
|
creds *credentials.Credentials
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addHandlers(h *request.Handlers) {
|
||||||
|
h.Sign.PushFrontNamed(request.NamedHandler{
|
||||||
|
Name: "k8s/logger",
|
||||||
|
Fn: awsHandlerLogger,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (p *awsSDKProvider) Compute(regionName string) (EC2, error) {
|
func (p *awsSDKProvider) Compute(regionName string) (EC2, error) {
|
||||||
ec2 := &awsSdkEC2{
|
service := ec2.New(&aws.Config{
|
||||||
ec2: ec2.New(&aws.Config{
|
|
||||||
Region: ®ionName,
|
Region: ®ionName,
|
||||||
Credentials: p.creds,
|
Credentials: p.creds,
|
||||||
}),
|
})
|
||||||
|
|
||||||
|
addHandlers(&service.Handlers)
|
||||||
|
|
||||||
|
ec2 := &awsSdkEC2{
|
||||||
|
ec2: service,
|
||||||
}
|
}
|
||||||
return ec2, nil
|
return ec2, nil
|
||||||
}
|
}
|
||||||
@ -220,6 +232,9 @@ func (p *awsSDKProvider) LoadBalancing(regionName string) (ELB, error) {
|
|||||||
Region: ®ionName,
|
Region: ®ionName,
|
||||||
Credentials: p.creds,
|
Credentials: p.creds,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
addHandlers(&elbClient.Handlers)
|
||||||
|
|
||||||
return elbClient, nil
|
return elbClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +243,9 @@ func (p *awsSDKProvider) Autoscaling(regionName string) (ASG, error) {
|
|||||||
Region: ®ionName,
|
Region: ®ionName,
|
||||||
Credentials: p.creds,
|
Credentials: p.creds,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
addHandlers(&client.Handlers)
|
||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
pkg/cloudprovider/providers/aws/log_handler.go
Normal file
34
pkg/cloudprovider/providers/aws/log_handler.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
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 aws
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/aws/aws-sdk-go/aws/request"
|
||||||
|
"github.com/golang/glog"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Handler for aws-sdk-go that logs all requests
|
||||||
|
func awsHandlerLogger(req *request.Request) {
|
||||||
|
service := req.Service.ServiceName
|
||||||
|
|
||||||
|
name := "?"
|
||||||
|
if req.Operation != nil {
|
||||||
|
name = req.Operation.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(4).Infof("AWS request: %s %s", service, name)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user