mirror of
https://github.com/rancher/rke.git
synced 2025-08-31 14:36:32 +00:00
Add docker config file environment variables for kubelet
This commit is contained in:
committed by
Alena Prokharchyk
parent
8f47078988
commit
d451683abb
@@ -37,6 +37,12 @@ var K8sDockerVersions = map[string][]string{
|
||||
"1.11": {"1.11.x", "1.12.x", "1.13.x", "17.03.x"},
|
||||
}
|
||||
|
||||
type dockerConfig struct {
|
||||
Auths map[string]authConfig `json:"auths,omitempty"`
|
||||
}
|
||||
|
||||
type authConfig types.AuthConfig
|
||||
|
||||
func DoRunContainer(ctx context.Context, dClient *client.Client, imageCfg *container.Config, hostCfg *container.HostConfig, containerName string, hostname string, plane string, prsMap map[string]v3.PrivateRegistry) error {
|
||||
container, err := dClient.ContainerInspect(ctx, containerName)
|
||||
if err != nil {
|
||||
@@ -435,3 +441,17 @@ func isContainerEnvChanged(containerEnv, imageConfigEnv, dockerfileEnv []string)
|
||||
allImageEnv := append(imageConfigEnv, dockerfileEnv...)
|
||||
return sliceEqualsIgnoreOrder(allImageEnv, containerEnv)
|
||||
}
|
||||
|
||||
func GetKubeletDockerConfig(prsMap map[string]v3.PrivateRegistry) (string, error) {
|
||||
auths := map[string]authConfig{}
|
||||
|
||||
for url, pr := range prsMap {
|
||||
auth := base64.URLEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", pr.User, pr.Password)))
|
||||
auths[url] = authConfig{Auth: auth}
|
||||
}
|
||||
cfg, err := json.Marshal(dockerConfig{auths})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(cfg), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user