Skip to content

Commit

Permalink
add support for credential provider plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Kuromesi <[email protected]>
  • Loading branch information
Kuromesi committed May 15, 2024
1 parent 13fe9ca commit 2690c5d
Show file tree
Hide file tree
Showing 53 changed files with 7,346 additions and 4 deletions.
18 changes: 15 additions & 3 deletions cmd/daemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package main

import (
"k8s.io/kubernetes/pkg/credentialprovider/plugin"

"flag"
"math/rand"
"net/http"
Expand All @@ -37,9 +39,11 @@ import (
)

var (
bindAddr = flag.String("addr", ":10221", "The address the metric endpoint and healthz binds to.")
pprofAddr = flag.String("pprof-addr", ":10222", "The address the pprof binds to.")
enablePprof = flag.Bool("enable-pprof", true, "Enable pprof for daemon.")
bindAddr = flag.String("addr", ":10221", "The address the metric endpoint and healthz binds to.")
pprofAddr = flag.String("pprof-addr", ":10222", "The address the pprof binds to.")
enablePprof = flag.Bool("enable-pprof", true, "Enable pprof for daemon.")
pluginConfigFile string
pluginBinDir string
)

func main() {
Expand Down Expand Up @@ -68,6 +72,14 @@ func main() {
if err != nil {
klog.Fatalf("Failed to new daemon: %v", err)
}

flag.StringVar(&pluginConfigFile, "pluginConfigFile", "/kruise/CredentialProviderPlugin.yaml", "The path of plugin config file.")
flag.StringVar(&pluginBinDir, "pluginBinDir", "/kruise/plugins", "The path of directory of plugin binaries.")
err = plugin.RegisterCredentialProviderPlugins(pluginConfigFile, pluginBinDir)
if err != nil {
klog.Fatalf("Failed to register credential provider plugins: %v", err)
}

if err := d.Run(ctx); err != nil {
klog.Fatalf("Failed to start daemon: %v", err)
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/util/secret/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

daemonutil "github.com/openkruise/kruise/pkg/daemon/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/credentialprovider"
credentialprovidersecrets "k8s.io/kubernetes/pkg/credentialprovider/secrets"
)
Expand All @@ -22,10 +23,14 @@ func AuthInfos(ctx context.Context, imageName, tag string, pullSecrets []corev1.
}

var (
keyring = credentialprovider.NewDockerKeyring()
keyring credentialprovider.DockerKeyring
)

func ConvertToRegistryAuths(pullSecrets []corev1.Secret, repo string) (infos []daemonutil.AuthInfo, err error) {
if keyring == nil {
klog.Infof("init docker keyring")
keyring = credentialprovider.NewDockerKeyring()
}
keyring, err := credentialprovidersecrets.MakeDockerKeyring(pullSecrets, keyring)
if err != nil {
return nil, err
Expand Down
214 changes: 214 additions & 0 deletions vendor/golang.org/x/sync/singleflight/singleflight.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2690c5d

Please sign in to comment.