Skip to content

Commit 02bba70

Browse files
authored
Skip deploying the ARO Operator identity secret at install-time (Azure#3905)
1 parent 98e5056 commit 02bba70

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

pkg/cluster/workloadidentityresources.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
kruntime "k8s.io/apimachinery/pkg/runtime"
1717

1818
"github.com/Azure/ARO-RP/pkg/api"
19+
pkgoperator "github.com/Azure/ARO-RP/pkg/operator"
1920
)
2021

2122
const (
@@ -72,6 +73,13 @@ func (m *manager) generatePlatformWorkloadIdentitySecrets() ([]*corev1.Secret, e
7273
secrets := []*corev1.Secret{}
7374
for _, identity := range m.doc.OpenShiftCluster.Properties.PlatformWorkloadIdentityProfile.PlatformWorkloadIdentities {
7475
if role, ok := roles[identity.OperatorName]; ok {
76+
// Skip creating a secret for the ARO Operator. This will be
77+
// generated by the ARO Operator deployer instead
78+
// (see pkg/operator/deploy/deploy.go#generateOperatorIdentitySecret())
79+
if role.OperatorName == pkgoperator.OperatorIdentityName {
80+
continue
81+
}
82+
7583
secrets = append(secrets, &corev1.Secret{
7684
TypeMeta: metav1.TypeMeta{
7785
APIVersion: corev1.SchemeGroupVersion.Identifier(),

pkg/cluster/workloadidentityresources_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,55 @@ func TestGeneratePlatformWorkloadIdentitySecrets(t *testing.T) {
281281
roles: []api.PlatformWorkloadIdentityRole{},
282282
want: []*corev1.Secret{},
283283
},
284+
{
285+
name: "skips ARO operator identity",
286+
identities: []api.PlatformWorkloadIdentity{
287+
{
288+
OperatorName: "foo",
289+
ClientID: "00f00f00-0f00-0f00-0f00-f00f00f00f00",
290+
},
291+
{
292+
OperatorName: "ServiceOperator",
293+
ClientID: "00ba4ba4-0ba4-0ba4-0ba4-ba4ba4ba4ba4",
294+
},
295+
},
296+
roles: []api.PlatformWorkloadIdentityRole{
297+
{
298+
OperatorName: "foo",
299+
SecretLocation: api.SecretLocation{
300+
Namespace: "openshift-foo",
301+
Name: "azure-cloud-credentials",
302+
},
303+
},
304+
{
305+
OperatorName: "ServiceOperator",
306+
SecretLocation: api.SecretLocation{
307+
Namespace: "openshift-bar",
308+
Name: "azure-cloud-credentials",
309+
},
310+
},
311+
},
312+
want: []*corev1.Secret{
313+
{
314+
TypeMeta: metav1.TypeMeta{
315+
APIVersion: "v1",
316+
Kind: "Secret",
317+
},
318+
ObjectMeta: metav1.ObjectMeta{
319+
Namespace: "openshift-foo",
320+
Name: "azure-cloud-credentials",
321+
},
322+
Type: corev1.SecretTypeOpaque,
323+
StringData: map[string]string{
324+
"azure_client_id": "00f00f00-0f00-0f00-0f00-f00f00f00f00",
325+
"azure_subscription_id": subscriptionId,
326+
"azure_tenant_id": tenantId,
327+
"azure_region": location,
328+
"azure_federated_token_file": azureFederatedTokenFileLocation,
329+
},
330+
},
331+
},
332+
},
284333
} {
285334
t.Run(tt.name, func(t *testing.T) {
286335
controller := gomock.NewController(t)

0 commit comments

Comments
 (0)