Skip to content

Commit

Permalink
implementation of MISE middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
SrinivasAtmakuri committed Oct 1, 2024
1 parent 817438f commit f07130f
Show file tree
Hide file tree
Showing 24 changed files with 1,076 additions and 76 deletions.
2 changes: 1 addition & 1 deletion pkg/deploy/assets/gateway-production.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions pkg/deploy/assets/rp-production-parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
"fpServicePrincipalId": {
"value": ""
},
"fpTenantId": {
"value": ""
},
"gatewayDomains": {
"value": ""
},
Expand All @@ -99,6 +102,12 @@
"mdsdEnvironment": {
"value": ""
},
"miseValidAppIDs": {
"value": ""
},
"miseValidAudiences": {
"value": ""
},
"nonZonalRegions": {
"value": [
"eastasia",
Expand Down
11 changes: 10 additions & 1 deletion pkg/deploy/assets/rp-production.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions pkg/deploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type Configuration struct {
ExtraServiceKeyvaultAccessPolicies []interface{} `json:"extraServiceKeyvaultAccessPolicies,omitempty" value:"required"`
FluentbitImage *string `json:"fluentbitImage,omitempty" value:"required"`
FPClientID *string `json:"fpClientId,omitempty" value:"required"`
FPTENANTID *string `json:"fpTenantId,omitempty" value:"required"`
FPServerCertCommonName *string `json:"fpServerCertCommonName,omitempty"`
FPServicePrincipalID *string `json:"fpServicePrincipalId,omitempty" value:"required"`
GatewayDomains []string `json:"gatewayDomains,omitempty"`
Expand All @@ -78,6 +79,8 @@ type Configuration struct {
KeyvaultPrefix *string `json:"keyvaultPrefix,omitempty" value:"required"`
MDMFrontendURL *string `json:"mdmFrontendUrl,omitempty" value:"required"`
MDSDEnvironment *string `json:"mdsdEnvironment,omitempty" value:"required"`
MISEVALIDAUDIENCES []string `json:"miseValidAudiences,omitempty"`
MISEVALIDAPPIDs []string `json:"miseValidAppIDs,omitempty"`
NonZonalRegions []string `json:"nonZonalRegions,omitempty"`
PortalAccessGroupIDs []string `json:"portalAccessGroupIds,omitempty" value:"required"`
PortalClientID *string `json:"portalClientId,omitempty" value:"required"`
Expand Down
9 changes: 9 additions & 0 deletions pkg/deploy/devconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func DevConfig(_env env.Core) (*Config, error) {
},
FluentbitImage: ptr.To(version.FluentbitImage(azureUniquePrefix + "aro." + _env.Environment().ContainerRegistryDNSSuffix)),
FPClientID: ptr.To(os.Getenv("AZURE_FP_CLIENT_ID")),
FPTENANTID: ptr.To(os.Getenv("AZURE_TENANT_ID")),
FPServicePrincipalID: ptr.To(os.Getenv("AZURE_FP_SERVICE_PRINCIPAL_ID")),
GatewayDomains: []string{
"eastus-shared.ppe.warm.ingest.monitor.core.windows.net",
Expand All @@ -174,6 +175,13 @@ func DevConfig(_env env.Core) (*Config, error) {
MDMFrontendURL: ptr.To("https://global.ppe.microsoftmetrics.com/"),
MDSDEnvironment: ptr.To(version.DevGenevaLoggingEnvironment),
MsiRpEndpoint: ptr.To("https://iamaplaceholder.com"),
MISEVALIDAUDIENCES: []string{
"https://management.core.windows.net/",
_env.Environment().ResourceManagerEndpoint,
},
MISEVALIDAPPIDs: []string{
"2187cde1-7e28-4645-9104-19edfa500053",
},
PortalAccessGroupIDs: []string{
os.Getenv("AZURE_PORTAL_ACCESS_GROUP_IDS"),
},
Expand All @@ -191,6 +199,7 @@ func DevConfig(_env env.Core) (*Config, error) {
"EnableOCMEndpoints",
"RequireOIDCStorageWebEndpoint",
"UseMockMsiRp",
"EnableMISE",
},
// TODO update this to support FF
RPImagePrefix: ptr.To(azureUniquePrefix + "aro.azurecr.io/aro"),
Expand Down
21 changes: 21 additions & 0 deletions pkg/deploy/generator/resources_rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ func (g *generator) rpVMSS() *arm.Resource {
"databaseAccountName",
"fluentbitImage",
"fpClientId",
"fpTenantId",
"fpServicePrincipalId",
"gatewayDomains",
"gatewayResourceGroupName",
Expand Down Expand Up @@ -408,6 +409,18 @@ func (g *generator) rpVMSS() *arm.Resource {
)
}

// convert array variables to string using ARM string() function to be passed via customScript later
for _, variable := range []string{
"miseValidAudiences",
"miseValidAppIDs",
} {
parts = append(parts,
fmt.Sprintf("'%s=$(base64 -d <<<'''", strings.ToUpper(variable)),
fmt.Sprintf("base64(string(parameters('%s')))", variable),
"''')\n'",
)
}

for _, variable := range []string{
"adminApiCaBundle",
"armApiCaBundle",
Expand All @@ -423,6 +436,14 @@ func (g *generator) rpVMSS() *arm.Resource {
"'MDMIMAGE=''"+version.MdmImage("")+"''\n'",
)

parts = append(parts,
"'OTELIMAGE=''"+version.OTelImage("")+"''\n'",
)

parts = append(parts,
"'MISEIMAGE=''"+version.MiseImage("")+"''\n'",
)

parts = append(parts,
"'LOCATION=$(base64 -d <<<'''",
"base64(resourceGroup().location)",
Expand Down
9 changes: 9 additions & 0 deletions pkg/deploy/generator/scripts/gatewayVMSS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ RPIMAGE='$rpimage'"
["gateway_config"]="aro_gateway_conf_file"
["fluentbit"]="fluentbit_conf_file"
["mdsd"]="mdsd_config_version"
["static_ip_address"]="static_ip_addresses"
)

# shellcheck disable=SC2034
# use default podman network with range 10.88.0.0/16
local -rA static_ip_addresses=(
["gateway"]="10.88.0.2"
["fluentbit"]="10.88.0.7"
["mdm"]="10.88.0.8"
)

configure_vmss_aro_services role_gateway \
Expand Down
45 changes: 29 additions & 16 deletions pkg/deploy/generator/scripts/rpVMSS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ main() {
)

dnf_install_pkgs install_pkgs \
retry_wait_time \
"$pkg_retry_count"
retry_wait_time \
"$pkg_retry_count"

fips_configure

Expand All @@ -56,22 +56,21 @@ main() {
# shellcheck disable=SC2153 disable=SC2034
local -r mdmimage="${RPIMAGE%%/*}/${MDMIMAGE#*/}"
local -r rpimage="$RPIMAGE"
local -r miseimage="${RPIMAGE%%/*}/${MISEIMAGE#*/}"
local -r otelimage="$OTELIMAGE"
# shellcheck disable=SC2034
local -r fluentbit_image="$FLUENTBITIMAGE"
# shellcheck disable=SC2034
local -rA aro_images=(
["mdm"]="mdmimage"
["rp"]="rpimage"
["fluentbit"]="fluentbit_image"
["mise"]="miseimage"
["otel"]="otelimage"
)

pull_container_images aro_images

local -r aro_network="aro"
# shellcheck disable=SC2034
local -rA networks=(
["$aro_network"]="192.168.254.0/24"
)
# shellcheck disable=SC2034
local -ra enable_ports=(
# RP frontend
Expand Down Expand Up @@ -121,6 +120,26 @@ main() {
Match *
Port 29230"

# values are references to variables, they should not be dereferenced here
# shellcheck disable=SC2034
local -rA aro_configs=(
["rp_config"]="aro_rp_conf_file"
["fluentbit"]="fluentbit_conf_file"
["mdsd"]="mdsd_config_version"
["static_ip_address"]="static_ip_addresses"
)

# shellcheck disable=SC2034
# use default podman network with range 10.88.0.0/16
local -rA static_ip_addresses=(
["rp"]="10.88.0.2"
["monitor"]="10.88.0.3"
["portal"]="10.88.0.4"
["mise"]="10.88.0.5"
["otel_collector"]="10.88.0.6"
["fluentbit"]="10.88.0.7"
["mdm"]="10.88.0.8"
)

# shellcheck disable=SC2034
local -r mdsd_config_version="$RPMDSDCONFIGVERSION"
Expand All @@ -144,6 +163,7 @@ KEYVAULT_PREFIX='$KEYVAULTPREFIX'
MDM_ACCOUNT='$RPMDMACCOUNT'
MDM_NAMESPACE='${role_rp^^}'
MDSD_ENVIRONMENT='$MDSDENVIRONMENT'
MISE_ADDRESS='http://${static_ip_addresses["mise"]}:5000'
RP_FEATURES='$RPFEATURES'
RPIMAGE='$rpimage'
ARO_INSTALL_VIA_HIVE='$CLUSTERSINSTALLVIAHIVE'
Expand All @@ -154,22 +174,15 @@ OIDC_STORAGE_ACCOUNT_NAME='$OIDCSTORAGEACCOUNTNAME'
MSI_RP_ENDPOINT='$MSIRPENDPOINT'
"

# values are references to variables, they should not be dereferenced here
# shellcheck disable=SC2034
local -rA aro_configs=(
["rp_config"]="aro_rp_conf_file"
["fluentbit"]="fluentbit_conf_file"
["mdsd"]="mdsd_config_version"
["network"]="aro_network"
)

configure_vmss_aro_services role_rp \
aro_images \
aro_configs

# shellcheck disable=SC2034
local -ra aro_services=(
"aro-mise"
"aro-monitor"
"aro-otel-collector"
"aro-portal"
"aro-rp"
"azsecd"
Expand Down
Loading

0 comments on commit f07130f

Please sign in to comment.