1+ #! /bin/bash
2+
3+ # Step 1: Install Istio using istioctl
4+ echo " Installing Istio..."
5+ curl -L https://istio.io/downloadIstio | sh -
6+ cd istio-*
7+ export PATH=$PWD /bin:$PATH
8+ istioctl install --set profile=demo -y
9+
10+ # Step 2: Install Kiali using Helm
11+ echo " Installing Kiali..."
12+ helm repo add kiali https://kiali.org/helm-charts
13+ helm repo update
14+ helm install kiali-server kiali/kiali-server --namespace istio-system --set auth.strategy=" anonymous"
15+ helm install \
16+ --namespace kiali-operator \
17+ --create-namespace \
18+ kiali-operator \
19+ kiali/kiali-operator
20+
21+
22+ # Step 3: Enable Istio sidecar injection for all namespaces
23+ echo " Enabling Istio sidecar injection for default namespace..."
24+ kubectl label namespace default istio-injection=enabled
25+ kubectl label namespace codewizard istio-injection=enabled
26+ kubectl label namespace monitoring istio-injection=enabled
27+
28+
29+ # Step 4: Deploy the Bookinfo demo application
30+ echo " Deploying Bookinfo sample app..."
31+ kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
32+
33+ # Step 5: Expose the Bookinfo app through Istio gateway
34+ echo " Exposing Bookinfo app through Istio gateway..."
35+ kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
36+
37+ # Step 6: Apply VirtualService to route traffic to v2 of ratings
38+ echo " Creating VirtualService for ratings..."
39+ cat << EOF | kubectl apply -f -
40+ apiVersion: networking.istio.io/v1alpha3
41+ kind: VirtualService
42+ metadata:
43+ name: ratings-vs
44+ namespace: default
45+ spec:
46+ hosts:
47+ - ratings
48+ http:
49+ - route:
50+ - destination:
51+ host: ratings
52+ subset: v2
53+ EOF
54+ cat << EOF | kubectl apply -f -
55+ apiVersion: kiali.io/v1alpha1
56+ kind: Kiali
57+ metadata:
58+ namespace: istio-system
59+ name: kiali
60+ spec:
61+ istio_namespace: istio-system
62+ auth:
63+ strategy: anonymous
64+ deployment:
65+ view_only_mode: true
66+ external_services:
67+ prometheus:
68+ url: http://prometheus-operated:9090
69+ EOF
70+
71+ sleep 10
72+
73+ # Step 7: Deploy addons
74+ echo " Deploying Istio addons..."
75+ kubectl apply -f samples/addons
76+
77+
78+ # Step 8: Port-forward Kiali for access
79+ echo " Port forwarding Kiali to http://localhost:20001..."
80+ kubectl port-forward -n istio-system svc/kiali 20001:20001 &
81+
82+ echo " Installation complete. Access Kiali at http://localhost:20001."
83+
84+
85+ cat << EOF | kubectl apply -f -
86+ apiVersion: security.istio.io/v1beta1
87+ kind: PeerAuthentication
88+ metadata:
89+ name: mtls-strict
90+ namespace: default
91+ spec:
92+ mtls:
93+ mode: STRICT
94+ EOF
95+
96+ cat << EOF | kubectl apply -f -
97+ apiVersion: networking.istio.io/v1alpha3
98+ kind: DestinationRule
99+ metadata:
100+ name: mtls-destination-rule
101+ namespace: default
102+ spec:
103+ host: "*.default.svc.cluster.local"
104+ trafficPolicy:
105+ tls:
106+ mode: ISTIO_MUTUAL
107+ EOF
0 commit comments