func extractCredentialsAsSecret(podname string, namespace string) ([]byte, error) {
	k8s, err := clients.Kubernetes()
	if err != nil {
		return nil, fmt.Errorf("Unable to retrive kubernetes client - %v", err)
	}
	secret, err := k8s.GetSecretData(podname, namespace)
	if err != nil {
		return nil, fmt.Errorf("Unable to retrieve secret [ %v ] - %v", podname, err)
	}
	return secret["fields"], nil
}
ExtractCredentialsAsSecret - Extract credentials from APB as secret in namespace.
package runtime
import (
	"bufio"
	"bytes"
	"encoding/base64"
	"fmt"
	"time"
	"github.com/automationbroker/bundle-lib/clients"
	log "github.com/sirupsen/logrus"
	"k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/runtime/serializer"
	"k8s.io/client-go/kubernetes/scheme"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/remotecommand"
)
const (
	GatherCredentialsCommand = "broker-bind-creds"
	bundleWatchInterval      = 5
	bundleWatchRetries       = 7200
)
type extractCredentialsFunc func(string, string) ([]byte, error)
func (p provider) ExtractCredentials(podname string, ns string, runtime int) ([]byte, error) {
	extractCredsFunc, err := getExtractCreds(runtime)
	if err != nil {
		return nil, err
	}
	return extractCredsFunc(podname, ns)
}
func extractCredentialsAsFile(podname string, namespace string) ([]byte, error) {
	k8scli, err := clients.Kubernetes()
	if err != nil {
		log.Errorf("error creating k8s client: %v", err)
		return nil, nil
	}
	clientConfig := k8scli.ClientConfig
	clientConfig.GroupVersion = &v1.SchemeGroupVersion
	clientConfig.NegotiatedSerializer =
		serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
	clientConfig.APIPath = "/api"
	restClient, err := rest.RESTClientFor(clientConfig)
	if err != nil {
		log.Errorf("error creating rest client: %v", err)
		return nil, err
	}
	req := restClient.Post().
		Resource("pods").
		Name(podname).
		Namespace(namespace).
		SubResource("exec")
	req.VersionedParams(&v1.PodExecOptions{
		Command: []string{GatherCredentialsCommand},
		Stdin:   false,
		Stdout:  true,
		Stderr:  true,
		TTY:     false,
	}, scheme.ParameterCodec)
	exec, err := remotecommand.NewSPDYExecutor(clientConfig, "POST", req.URL())
	if err != nil {
		log.Errorf("error getting new remotecommand executor - %v", err)
	}
	for r := 1; r <= bundleWatchRetries; r++ {
		var stdoutBuffer, stderrBuffer bytes.Buffer
		stdoutWriter := bufio.NewWriter(&stdoutBuffer)
		stderrWriter := bufio.NewWriter(&stderrBuffer)
		cmderr := exec.Stream(remotecommand.StreamOptions{
			Stdout: stdoutWriter,
			Stderr: stderrWriter,
		})
		if cmderr == nil {
			log.Infof("[%v] bind credentials found", podname)
			decodedOutput, err := decodeOutput(stdoutBuffer.Bytes())
			if err != nil {
				return nil, err
			}
			return decodedOutput, nil
		}
		status, err := k8scli.GetPodStatus(podname, namespace)
		if err != nil {
			log.Errorf("unable to find pod: %v in namespace: %v - err: %v", podname, namespace, err)
			return nil, err
		}
		switch status.Phase {
		case v1.PodFailed:
			log.Errorf("pod: %v in namespace: %v failed", podname, namespace)
			return nil, fmt.Errorf("[%v] APB failed", podname)
		case v1.PodSucceeded:
			log.Infof("pod: %v in namespace: %v has been completed", podname, namespace)
			return nil, nil
		default:
			log.Infof("command output: %v - err: %v", stdoutBuffer.String(), stderrBuffer.String())
			log.Infof("retry attempt: %v pod: %v in namespace: %v failed to exec into the container", r, podname, namespace)
		}
		time.Sleep(time.Duration(bundleWatchInterval) * time.Second)
	}
	return nil, fmt.Errorf("[%s] ExecTimeout: Failed to gather bind credentials after %d retries", podname, bundleWatchRetries)
}