Skip to content

Commit d70ea89

Browse files
author
jmanuelcorral
committed
Tested on AKS
1 parent b19d4f2 commit d70ea89

21 files changed

Lines changed: 520 additions & 502 deletions

k8s/helm/deploy-all-istio.ps1

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Param(
2+
[parameter(Mandatory=$false)][string]$registry,
3+
[parameter(Mandatory=$false)][bool]$installIstioOnSystem=$false,
4+
[parameter(Mandatory=$false)][string]$dockerUser,
5+
[parameter(Mandatory=$false)][string]$dockerPassword,
6+
[parameter(Mandatory=$false)][string]$externalDns="aks",
7+
[parameter(Mandatory=$false)][string]$dnsname="eshoptestistio",
8+
[parameter(Mandatory=$false)][string]$appName="eshop",
9+
[parameter(Mandatory=$false)][bool]$deployInfrastructure=$true,
10+
[parameter(Mandatory=$false)][string]$kialiuser="admin",
11+
[parameter(Mandatory=$false)][string]$kialipasswrd="admin",
12+
[parameter(Mandatory=$false)][bool]$clean=$true,
13+
[parameter(Mandatory=$false)][string]$aksName="",
14+
[parameter(Mandatory=$false)][string]$aksRg="",
15+
[parameter(Mandatory=$false)][string]$imageTag="latest",
16+
[parameter(Mandatory=$false)][bool]$useLocalk8s=$false
17+
)
18+
19+
$dns = $externalDns
20+
21+
# Instalamos Istio
22+
# Specify the Istio version that will be leveraged throughout these instructions
23+
$ISTIO_VERSION="1.0.6"
24+
25+
# Windows
26+
$ProgressPreference = 'SilentlyContinue';
27+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
28+
Invoke-WebRequest -URI "https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istio-$ISTIO_VERSION-win.zip" -OutFile "istio-$ISTIO_VERSION.zip"
29+
Remove-Item istio-$ISTIO_VERSION -Recurse -ErrorAction Ignore
30+
Expand-Archive -Path "istio-$ISTIO_VERSION.zip" -DestinationPath .
31+
32+
if($installIstioOnSystem -eq $true) {
33+
New-Item -ItemType Directory -Force -Path "C:\Program Files\Istio"
34+
mv ./istio-$ISTIO_VERSION/bin/istioctl.exe "C:\Program Files/Istio/"
35+
$PATH = [environment]::GetEnvironmentVariable("PATH", "User")
36+
[environment]::SetEnvironmentVariable("PATH", $PATH + "; C:\Program Files\Istio", "User")
37+
}
38+
# Primero Desinstalamos cualquier cosa que haya en el cluster
39+
if ($clean -eq $true) {
40+
Write-Host "Cleaning previous helm releases..." -ForegroundColor Green
41+
helm delete --purge $(helm ls -q)
42+
kubectl delete -f istio-$ISTIO_VERSION/install/kubernetes/helm/istio/templates/crds.yaml -n istio-system
43+
Write-Host "Previous releases deleted" -ForegroundColor Green
44+
}
45+
46+
Write-Host "Generating Kiali Credentials" -ForegroundColor Green
47+
#generamos la credenciales para que kiali arranque sin problemas
48+
kubectl -n istio-system create secret generic kiali --from-literal=username=$kialiuser --from-literal=passphrase=$kialipasswrd
49+
50+
51+
Write-Host "Deploying Istio in the cluster" -ForegroundColor Green
52+
helm install istio-$ISTIO_VERSION/install/kubernetes/helm/istio --wait --name istio --namespace istio-system --set global.controlPlaneSecurityEnabled=true --set grafana.enabled=true --set tracing.enabled=true --set kiali.enabled=true
53+
54+
Write-Host "Setting Up Gateway"
55+
kubectl delete gateway istio-autogenerated-k8s-ingress -n istio-system
56+
kubectl apply -f ./istio/gateway.yml
57+
58+
if ($useLocalk8s -eq $true) {
59+
$dns="localhost"
60+
}
61+
else {
62+
Write-Host "Resolving DNS to Gateway public IP" -ForegroundColor Green
63+
$ipaddress = $(kubectl get service istio-ingressgateway -n istio-system)[1] | %{ $_.Split(' ')[9];}
64+
$query = "[?ipAddress!=null]|[?contains([ipAddress], '$ipaddress')].[id]"
65+
$resid = az network public-ip list --query $query --output tsv
66+
$jsonresponse = az network public-ip update --ids $resid --dns-name $dnsname
67+
$externalDns = ($jsonresponse | ConvertFrom-Json).dnsSettings.fqdn
68+
Write-Host "$externalDns is pointing to Cluster public ip $ipaddress"
69+
}
70+
71+
$useCustomRegistry=$false
72+
if (-not [string]::IsNullOrEmpty($registry)) {
73+
$useCustomRegistry=$true
74+
if ([string]::IsNullOrEmpty($dockerUser) -or [string]::IsNullOrEmpty($dockerPassword)) {
75+
Write-Host "Error: Must use -dockerUser AND -dockerPassword if specifying custom registry" -ForegroundColor Red
76+
exit 1
77+
}
78+
}
79+
Write-Host "Begin eShopOnContainers installation using Helm" -ForegroundColor Green
80+
81+
$infras = ("sql-data", "nosql-data", "rabbitmq", "keystore-data", "basket-data")
82+
$charts = ("eshop-common", "apigwmm", "apigwms", "apigwwm", "apigwws", "basket-api","catalog-api", "identity-api", "locations-api", "marketing-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus", "webhooks-api", "webhooks-web")
83+
84+
if ($deployInfrastructure) {
85+
foreach ($infra in $infras) {
86+
Write-Host "Installing infrastructure: $infra" -ForegroundColor Green
87+
helm install --values app.yaml --values inf.yaml --set app.name=$appName --set inf.k8s.dns=$externalDns --name="$appName-$infra" $infra
88+
}
89+
}
90+
91+
foreach ($chart in $charts) {
92+
Write-Host "Installing: $chart" -ForegroundColor Green
93+
if ($useCustomRegistry) {
94+
helm install --set inf.registry.server=$registry --set inf.registry.login=$dockerUser --set inf.registry.pwd=$dockerPassword --set inf.registry.secretName=eshop-docker-scret --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
95+
}
96+
else {
97+
if ($chart -ne "eshop-common") { # eshop-common is ignored when no secret must be deployed
98+
helm install --values app.yaml --values inf.yaml --set app.name=$appName --set inf.k8s.dns=$externalDns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
99+
}
100+
}
101+
}
102+
103+
Write-Host "helm charts installed." -ForegroundColor Green
104+
Write-Host "Appling Virtual Services for routing." -ForegroundColor Green
105+
kubectl apply -f ./istio/virtualservices.yml
106+
107+
Remove-Item istio-$ISTIO_VERSION -Recurse -ErrorAction Ignore
108+
Remove-Item istio-$ISTIO_VERSION.zip -Recurse -ErrorAction Ignore
109+
110+
111+
112+
113+
114+
115+

k8s/helm/deploy-all.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Param(
22
[parameter(Mandatory=$false)][string]$registry,
33
[parameter(Mandatory=$false)][string]$dockerUser,
44
[parameter(Mandatory=$false)][string]$dockerPassword,
5-
[parameter(Mandatory=$false)][string]$externalDns,
5+
[parameter(Mandatory=$false)][string]$externalDns="eshoptestistio.westus.cloudapp.azure.com",
66
[parameter(Mandatory=$false)][string]$appName="eshop",
77
[parameter(Mandatory=$false)][bool]$deployInfrastructure=$true,
88
[parameter(Mandatory=$false)][bool]$clean=$true,
@@ -66,7 +66,8 @@ $charts = ("eshop-common", "apigwmm", "apigwms", "apigwwm", "apigwws", "basket-a
6666
if ($deployInfrastructure) {
6767
foreach ($infra in $infras) {
6868
Write-Host "Installing infrastructure: $infra" -ForegroundColor Green
69-
helm install --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --name="$appName-$infra" $infra
69+
#helm install --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --name="$appName-$infra" $infra
70+
helm install --values app.yaml --values inf.yaml --set app.name=$appName --set inf.k8s.dns=$dns --name="$appName-$infra" $infra
7071
}
7172
}
7273

@@ -77,7 +78,8 @@ foreach ($chart in $charts) {
7778
}
7879
else {
7980
if ($chart -ne "eshop-common") { # eshop-common is ignored when no secret must be deployed
80-
helm install --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
81+
#helm install --values app.yaml --values inf.yaml --values $ingressValuesFile --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
82+
helm install --values app.yaml --values inf.yaml --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart
8183
}
8284
}
8385
}

0 commit comments

Comments
 (0)