test/e2e_node: install and configure kubelet credential provider

Signed-off-by: Andrew Sy Kim <andrewsy@google.com>
Co-authored-by: Aditi Sharma <adi.sky17@gmail.com>
This commit is contained in:
Andrew Sy Kim
2022-03-10 15:57:25 +00:00
parent 1580b69e8c
commit f440a69c70
3 changed files with 41 additions and 1 deletions

View File

@@ -48,6 +48,16 @@ const cniConfig = `{
}
`
const credentialProviderConfig = `kind: CredentialProviderConfig
apiVersion: kubelet.config.k8s.io/v1alpha1
providers:
- name: credential-provider
apiVersion: credentialprovider.kubelet.k8s.io/v1alpha1
matchImages:
- "gcr.io"
- "*.gcr.io"
defaultCacheDuration: 1m`
// Install the cni plugin and add basic bridge configuration to the
// configuration directory.
func setupCNI(host, workspace string) error {
@@ -76,6 +86,19 @@ func setupCNI(host, workspace string) error {
return nil
}
func configureCredentialProvider(host, workspace string) error {
klog.V(2).Infof("Configuring kubelet credential provider on %q", host)
cmd := getSSHCommand(" ; ",
fmt.Sprintf("echo %s > %s", quote(credentialProviderConfig), filepath.Join(workspace, "credential-provider.yaml")),
)
if output, err := SSH(host, "sh", "-c", cmd); err != nil {
return fmt.Errorf("failed to write credential provider configuration on %q: %v output: %q", host, err, output)
}
return nil
}
// configureFirewall configures iptable firewall rules.
func configureFirewall(host string) error {
klog.V(2).Infof("Configure iptables firewall rules on %q", host)