Skip to content

Commit 11fc843

Browse files
committed
OCPGBUGS-56008: creds for Azure image pull
Removing the identity from the Azure nodes in #9538 broke the acr-credentials-provider, which allows pulling images from private registries in Azure. Instead of re-adding the identity attached to the node, we can add a secret which will add credentials to the cloud provider config. Upstream is working on a solution that will use credentials requests. Once that is landed, we can remove this. Track: kubernetes/enhancements#4412
1 parent 7ad0e35 commit 11fc843

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pkg/asset/manifests/openshift.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,37 @@ func (o *Openshift) Generate(ctx context.Context, dependencies asset.Parents) er
280280
assetData["99_baremetal-provisioning-config.yaml"] = applyTemplateData(baremetalConfig.Files()[0].Data, bmTemplateData)
281281
}
282282

283+
if platform == azuretypes.Name && installConfig.Config.CredentialsMode != types.ManualCredentialsMode {
284+
// config is used to created compatible secret to trigger azure cloud
285+
// controller config merge behaviour
286+
// https://github.com/openshift/origin/blob/90c050f5afb4c52ace82b15e126efe98fa798d88/vendor/k8s.io/legacy-cloud-providers/azure/azure_config.go#L83
287+
session, err := installConfig.Azure.Session()
288+
if err != nil {
289+
return err
290+
}
291+
config := struct {
292+
AADClientID string `json:"aadClientId" yaml:"aadClientId"`
293+
AADClientSecret string `json:"aadClientSecret" yaml:"aadClientSecret"`
294+
}{
295+
AADClientID: session.Credentials.ClientID,
296+
AADClientSecret: session.Credentials.ClientSecret,
297+
}
298+
299+
b, err := yaml.Marshal(config)
300+
if err != nil {
301+
return err
302+
}
303+
304+
azureCloudProviderSecret := &openshift.AzureCloudProviderSecret{}
305+
dependencies.Get(azureCloudProviderSecret)
306+
for _, f := range azureCloudProviderSecret.Files() {
307+
name := strings.TrimSuffix(filepath.Base(f.Filename), ".template")
308+
assetData[name] = applyTemplateData(f.Data, map[string]string{
309+
"CloudConfig": string(b),
310+
})
311+
}
312+
}
313+
283314
o.FileList = []*asset.File{}
284315
for name, data := range assetData {
285316
if len(data) == 0 {

0 commit comments

Comments
 (0)