Skip to content

Commit

Permalink
log useful information about the cluster and the instance
Browse files Browse the repository at this point in the history
Signed-off-by: Davanum Srinivas <[email protected]>
  • Loading branch information
dims committed Jun 29, 2024
1 parent 9c64eec commit 7a4b309
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/providers/v1/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,14 @@ func (c *Cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder,
c.eventBroadcaster.StartStructuredLogging(0)
c.eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: c.kubeClient.CoreV1().Events("")})
c.eventRecorder = c.eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "aws-cloud-provider"})

v, err := c.kubeClient.Discovery().ServerVersion()
if err != nil {
klog.Errorf("Error looking up cluster version: %q", err)
} else {
klog.Infof("cluster version: v%s.%s. git version: %s. git tree state: %s. commit: %s. platform: %s",
v.Major, v.Minor, v.GitVersion, v.GitTreeState, v.GitCommit, v.Platform)
}
}

// Clusters returns the list of clusters.
Expand Down
15 changes: 15 additions & 0 deletions pkg/providers/v1/aws_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/aws/aws-sdk-go/service/kms"
"k8s.io/client-go/pkg/version"
"k8s.io/klog/v2"

"k8s.io/cloud-provider-aws/pkg/providers/v1/config"
"k8s.io/cloud-provider-aws/pkg/providers/v1/iface"
Expand Down Expand Up @@ -208,6 +209,20 @@ func (p *awsSDKProvider) Metadata() (config.EC2Metadata, error) {
}
client := ec2metadata.New(sess)
p.addAPILoggingHandlers(&client.Handlers)

identity, err := client.GetInstanceIdentityDocument()
if err != nil {
return nil, fmt.Errorf("unable to get instance identity document: %v", err)
}
klog.Info("instance metadata identity",
"region", identity.Region,
"availability-zone", identity.AvailabilityZone,
"instance-type", identity.InstanceType,
"architecture", identity.Architecture,
"instance-id", identity.InstanceID,
"private-ip", identity.PrivateIP,
"account-id", identity.AccountID,
"image-id", identity.ImageID)
return client, nil
}

Expand Down

0 comments on commit 7a4b309

Please sign in to comment.