kubernetes-sigs / aws-ebs-csi-driver

CSI driver for Amazon EBS https://aws.amazon.com/ebs/
Apache License 2.0
974 stars 787 forks source link

Add --kubeconfig flag for out-of-cluster auth #2081

Closed cartermckinnon closed 2 months ago

cartermckinnon commented 2 months ago

Is this a bug fix or adding new feature?

Feature

What is this PR about? / Why do we need it?

This adds a command-line flag, --kubeconfig, that allows an alternative to rest.InClusterConfig(). This is useful when running the CSI driver outside of a Pod.

If --kubeconfig is empty, the behavior is unchanged.

What testing is done?

I see the k8s client instantiated successfully:

> CSI_NODE_NAME=ip-192-168-69-200.us-west-2.compute.internal bin/aws-ebs-csi-driver --kubeconfig ~/.kube/config

I0704 00:50:11.709966   21408 main.go:157] "Initializing metadata"
I0704 00:50:11.710049   21408 metadata.go:66] "The AWS_EC2_METADATA_DISABLED environment variable disables access to EC2 IMDS" enabled="true"
E0704 00:50:11.710363   21408 metadata.go:51] "Retrieving IMDS metadata failed, falling back to Kubernetes metadata" err="could not get EC2 instance identity metadata: operation error ec2imds: GetInstanceIdentityDocument, access disabled to EC2 IMDS via client option, or \"AWS_EC2_METADATA_DISABLED\" environment variable"
I0704 00:50:12.535331   21408 metadata.go:55] "Retrieved metadata from Kubernetes"
k8s-ci-robot commented 2 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: torredil

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/OWNERS)~~ [torredil] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
cartermckinnon commented 2 months ago

/retest