@@ -13,7 +13,7 @@ az cloud set --name AzureCloud
13
13
az login --service-principal -u " ${AZURE_AUTH_CLIENT_ID} " -p " ${AZURE_AUTH_CLIENT_SECRET} " --tenant " ${AZURE_AUTH_TENANT_ID} " --output none
14
14
az account set --subscription ${AZURE_AUTH_SUBSCRIPTION_ID}
15
15
16
- set -x
16
+ # set -x
17
17
18
18
SP_NAME_PREFIX=" ${NAMESPACE} -${UNIQUE_HASH} "
19
19
KV_NAME=$( < " ${SHARED_DIR} /azure_keyvault_name" )
@@ -24,9 +24,11 @@ COMPONENTS="azure-disk azure-file ciro cloud-provider cncc cpo ingress capz"
24
24
25
25
declare -A component_to_client_id
26
26
declare -A component_to_cert_name
27
+ declare -A component_to_credential_secret_name
27
28
28
29
for component in $COMPONENTS ; do
29
30
name=" ${SP_NAME_PREFIX} -${component} "
31
+ credential_secret_name=" ${SP_NAME_PREFIX} -${component} -secret"
30
32
scopes=" /subscriptions/$AZURE_AUTH_SUBSCRIPTION_ID /resourceGroups/$RG_HC "
31
33
role=" b24988ac-6180-42a0-ab88-20f7382dd24c"
32
34
@@ -57,8 +59,25 @@ for component in $COMPONENTS; do
57
59
client_id=" $( eval " az ad sp create-for-rbac --name $name --role \" $role \" --scopes $scopes --create-cert --cert $name --keyvault $KV_NAME --output json --only-show-errors" | jq -r ' .appId' ) "
58
60
echo " $client_id " >> " ${SHARED_DIR} /azure_sp_id"
59
61
62
+ client_secret_value=" $( az keyvault secret show --vault-name " $KV_NAME " --name " $name " --query value -o tsv) "
63
+ not_before_timestamp=$( date -u -d " $( az keyvault secret show --vault-name " $KV_NAME " --name " $name " | jq -r .attributes.notBefore) " +" %Y-%m-%dT%H:%M:%SZ" )
64
+ not_after_timestamp=$( date -u -d " $( az keyvault secret show --vault-name " $KV_NAME " --name " $name " | jq -r .attributes.expires) " +" %Y-%m-%dT%H:%M:%SZ" )
65
+ cat << EOF >"${SHARED_DIR} "/"$credential_secret_name ".json
66
+ {
67
+ "authentication_endpoint": "https://login.microsoftonline.com/",
68
+ "client_id": "$client_id ",
69
+ "client_secret": "$client_secret_value ",
70
+ "tenant_id": "$AZURE_AUTH_TENANT_ID ",
71
+ "not_after": "$not_after_timestamp ",
72
+ "not_before": "$not_before_timestamp "
73
+ }
74
+ EOF
75
+ echo " created secret $credential_secret_name "
76
+ az keyvault secret set --vault-name " $KV_NAME " --name " $credential_secret_name " --file " ${SHARED_DIR} " /" $credential_secret_name " .json
77
+
60
78
component_to_client_id+=([" $component " ]=" $client_id " )
61
79
component_to_cert_name+=([" $component " ]=" $name " )
80
+ component_to_credential_secret_name+=([" $component " ]=" $credential_secret_name " )
62
81
done
63
82
64
83
# TODO: Remove this once the we used the automated role assignment by "--assign-service-principal-role"
@@ -77,35 +96,52 @@ cat <<EOF >"${SHARED_DIR}"/hypershift_azure_mi_file.json
77
96
},
78
97
"cloudProvider": {
79
98
"clientID": "${component_to_client_id[cloud-provider]} ",
80
- "certificateName": "${component_to_cert_name[cloud-provider]} "
99
+ "certificateName": "${component_to_cert_name[cloud-provider]} ",
100
+ "credentialsSecretName": "${component_to_credential_secret_name[cloud-provider]} ",
81
101
},
82
102
"nodePoolManagement": {
83
103
"clientID": "${component_to_client_id[capz]} ",
84
- "certificateName": "${component_to_cert_name[capz]} "
104
+ "certificateName": "${component_to_cert_name[capz]} ",
105
+ "credentialsSecretName": "${component_to_credential_secret_name[capz]} ",
85
106
},
86
107
"controlPlaneOperator": {
87
108
"clientID": "${component_to_client_id[cpo]} ",
88
- "certificateName": "${component_to_cert_name[cpo]} "
109
+ "certificateName": "${component_to_cert_name[cpo]} ",
110
+ "credentialsSecretName": "${component_to_credential_secret_name[cpo]} ",
89
111
},
90
112
"imageRegistry": {
91
113
"clientID": "${component_to_client_id[ciro]} ",
92
- "certificateName": "${component_to_cert_name[ciro]} "
114
+ "certificateName": "${component_to_cert_name[ciro]} ",
115
+ "credentialsSecretName": "${component_to_credential_secret_name[ciro]} ",
93
116
},
94
117
"ingress": {
95
118
"clientID": "${component_to_client_id[ingress]} ",
96
- "certificateName": "${component_to_cert_name[ingress]} "
119
+ "certificateName": "${component_to_cert_name[ingress]} ",
120
+ "credentialsSecretName": "${component_to_credential_secret_name[ingress]} ",
97
121
},
98
122
"network": {
99
123
"clientID": "${component_to_client_id[cncc]} ",
100
- "certificateName": "${component_to_cert_name[cncc]} "
124
+ "certificateName": "${component_to_cert_name[cncc]} ",
125
+ "credentialsSecretName": "${component_to_credential_secret_name[cncc]} ",
101
126
},
102
127
"disk": {
103
128
"clientID": "${component_to_client_id[azure-disk]} ",
104
- "certificateName": "${component_to_cert_name[azure-disk]} "
129
+ "certificateName": "${component_to_cert_name[azure-disk]} ",
130
+ "credentialsSecretName": "${component_to_credential_secret_name[azure-disk]} ",
105
131
},
106
132
"file": {
107
133
"clientID": "${component_to_client_id[azure-file]} ",
108
- "certificateName": "${component_to_cert_name[azure-file]} "
134
+ "certificateName": "${component_to_cert_name[azure-file]} ",
135
+ "credentialsSecretName": "${component_to_credential_secret_name[azure-file]} ",
109
136
}
110
137
}
111
138
EOF
139
+
140
+
141
+ cat << EOF >"${SHARED_DIR} "/hypershift_azure_data_plane_identities_file.json
142
+ {
143
+ "imageRegistryMSIClientID": "${component_to_client_id[ciro]} ",
144
+ "diskMSIClientID": "${component_to_client_id[azure-disk]} ",
145
+ "fileMSIClientID": "${component_to_client_id[azure-file]} "
146
+ }
147
+ EOF
0 commit comments