Skip to content
This repository was archived by the owner on Dec 22, 2022. It is now read-only.

Commit c7fdf55

Browse files
author
Mathieu Benoit
committed
fixes with walkthrough until authz
1 parent fc7f18a commit c7fdf55

File tree

9 files changed

+128
-18
lines changed

9 files changed

+128
-18
lines changed

content/configure-authorization-policies/asm-ingress.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ spec:
2525
rules:
2626
- to:
2727
- operation:
28-
ports: ["8080"]
28+
ports: ["80"]
2929
EOF
3030
```

content/configure-authorization-policies/onlineboutique.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,83 @@ weight: 2
44
---
55
In this section we will configure `AuthorizationPolicy` for the OnlineBoutique namespace.
66

7+
Create Kubernetes `ServiceAccount` per app:
8+
```Bash
9+
cat <<EOF | kubectl apply -n $ONLINEBOUTIQUE_NAMESPACE -f -
10+
apiVersion: v1
11+
kind: ServiceAccount
12+
metadata:
13+
name: adservice
14+
---
15+
apiVersion: v1
16+
kind: ServiceAccount
17+
metadata:
18+
name: cartservice
19+
---
20+
apiVersion: v1
21+
kind: ServiceAccount
22+
metadata:
23+
name: checkoutservice
24+
---
25+
apiVersion: v1
26+
kind: ServiceAccount
27+
metadata:
28+
name: currencyservice
29+
---
30+
apiVersion: v1
31+
kind: ServiceAccount
32+
metadata:
33+
name: emailservice
34+
---
35+
apiVersion: v1
36+
kind: ServiceAccount
37+
metadata:
38+
name: frontend
39+
---
40+
apiVersion: v1
41+
kind: ServiceAccount
42+
metadata:
43+
name: loadgenerator
44+
---
45+
apiVersion: v1
46+
kind: ServiceAccount
47+
metadata:
48+
name: paymentservice
49+
---
50+
apiVersion: v1
51+
kind: ServiceAccount
52+
metadata:
53+
name: productcatalogservice
54+
---
55+
apiVersion: v1
56+
kind: ServiceAccount
57+
metadata:
58+
name: recommendationservice
59+
---
60+
apiVersion: v1
61+
kind: ServiceAccount
62+
metadata:
63+
name: shippingservice
64+
EOF
65+
```
66+
67+
Replace the `default` `ServiceAccount` per app:
68+
```Bash
69+
services="adservice cartservice checkoutservice currencyservice emailservice frontend loadgenerator paymentservice productcatalogservice recommendationservice shippingservice"
70+
for s in $services; do sed -i "s/serviceAccountName: default/serviceAccountName: $s/g" ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/deployment_$s.yaml; done
71+
```
72+
73+
Re-deploy the updated Kubernetes manifests updated:
74+
```Bash
75+
kubectl apply -f ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/ -n $ONLINEBOUTIQUE_NAMESPACE
76+
```
77+
78+
Ensure that all deployments are still up and running:
79+
```Bash
80+
kubectl wait --for=condition=available --timeout=600s deployment --all -n $ONLINEBOUTIQUE_NAMESPACE
81+
curl -s http://${INGRESS_GATEWAY_PUBLIC_IP}
82+
```
83+
784
Deploy fine granular `AuthorizationPolicy` per app:
885
```Bash
986
cat <<EOF | kubectl apply -n $ONLINEBOUTIQUE_NAMESPACE -f -
@@ -192,4 +269,9 @@ spec:
192269
methods: ["POST"]
193270
ports: ["50051"]
194271
EOF
272+
```
273+
274+
Test that the solution is still working properly:
275+
```Bash
276+
curl -s http://${INGRESS_GATEWAY_PUBLIC_IP}
195277
```

content/deploy-workloads/ingress-gateway.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ spec:
3535
ports:
3636
- port: 80
3737
name: http
38-
- port: 443
39-
name: https
4038
---
4139
apiVersion: apps/v1
4240
kind: Deployment
@@ -53,6 +51,7 @@ spec:
5351
inject.istio.io/templates: gateway
5452
labels:
5553
${INGRESS_GATEWAY_LABEL}
54+
app: ${INGRESS_GATEWAY_NAME}
5655
spec:
5756
containers:
5857
- name: istio-proxy

content/deploy-workloads/onlineboutique.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ weight: 2
44
---
55
In this section, you will deploy the [OnlineBoutique](https://github.com/GoogleCloudPlatform/microservices-demo) apps as-is, without any notion of Istio nor ASM, not yet.
66

7+
Create the OnlineBoutique namespace:
78
```Bash
89
export ONLINEBOUTIQUE_NAMESPACE=onlineboutique
910
cat <<EOF | kubectl apply -n $ONLINEBOUTIQUE_NAMESPACE -f -
@@ -14,8 +15,15 @@ metadata:
1415
labels:
1516
name: ${ONLINEBOUTIQUE_NAMESPACE}
1617
EOF
17-
curl -LO https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/release/kubernetes-manifests.yaml > ~/$WORKING_DIRECTORY/onlineboutique.yaml
18-
kubectl apply -f ~/$WORKING_DIRECTORY/onlineboutique.yaml -n $ONLINEBOUTIQUE_NAMESPACE
18+
```
19+
20+
Retrieve and deploy the Kubernetes manifests of the OnlineBoutique apps:
21+
```Bash
22+
mkdir ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE
23+
curl https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/main/release/kubernetes-manifests.yaml > ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/tmp.yaml
24+
nomos hydrate --path ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/ --output ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE --no-api-server-check --source-format unstructured
25+
rm ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/tmp.yaml
26+
kubectl apply -f ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/ -n $ONLINEBOUTIQUE_NAMESPACE
1927
```
2028

2129
Ensure that all deployments are up and running:
@@ -25,13 +33,13 @@ ONLINEBOUTIQUE_PUBLIC_IP=$(kubectl get svc frontend-external -n $ONLINEBOUTIQUE_
2533
curl -s http://${ONLINEBOUTIQUE_PUBLIC_IP}
2634
```
2735

28-
In order to be more secure and have more resilience with the data stored in `redis`, we will instead leverage Memorystore (redis) instead:
36+
In order to be more secure and have more resilience with the data stored in `redis`, we will leverage Memorystore (redis) instead:
2937
```Bash
3038
gcloud services enable redis.googleapis.com
31-
gcloud redis instances create cart --size=1 --region=$REGION --zone=$ZONE --redis-version=redis_6_X
39+
gcloud redis instances create cart --size=1 --region=$REGION --zone=$ZONE --redis-version=redis_6_x
3240
REDIS_IP=$(gcloud redis instances describe cart --region=$REGION --format='get(host)')
33-
sed -i "s/value: \"redis-cart:6379\"/value: \"$REDIS_IP\"/g" ~/$WORKING_DIRECTORY/onlineboutique.yaml
34-
kubectl apply -f ~/$WORKING_DIRECTORY/onlineboutique.yaml -n $ONLINEBOUTIQUE_NAMESPACE
41+
sed -i "s/redis-cart:6379/$REDIS_IP/g" ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/deployment_cartservice.yaml
42+
kubectl apply -f ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/deployment_cartservice.yaml -n $ONLINEBOUTIQUE_NAMESPACE
3543
```
3644

3745
Ensure that the solution is still working correctly with Memorystore (redis):
@@ -43,6 +51,8 @@ From there, the `redis` container originally deployed could now be deleted:
4351
```Bash
4452
kubectl delete deployment redis -n $ONLINEBOUTIQUE_NAMESPACE
4553
kubectl delete service redis -n $ONLINEBOUTIQUE_NAMESPACE
54+
rm ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/deployment_redis-cart.yaml
55+
rm ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/service_redis-cart.yaml
4656
```
4757
{{% notice note %}}
4858
You can connect to a Memorystore (redis) instance only from GKE clusters that are in the same region and use the same network as your instance. You cannot connect to a Memorystore (redis) instance from a GKE cluster without VPC-native/IP aliasing enabled. For this you should create a GKE cluster with this option `--enable-ip-alias`.

content/enable-asm/onlineboutique.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ curl -s http://${INGRESS_GATEWAY_PUBLIC_IP}
5858

5959
You could remove the `LoadBalancer` service `frontend-external` (not used moving forward) deployed earlier in this workshop:
6060
```Bash
61-
kubectl delete service frontend-external -n -n $ONLINEBOUTIQUE_NAMESPACE
61+
kubectl delete service frontend-external -n $ONLINEBOUTIQUE_NAMESPACE
62+
rm ~/$WORKING_DIRECTORY/$ONLINEBOUTIQUE_NAMESPACE/service_frontend-external.yaml
6263
```
6364

6465
Resources:

content/install-asm/install-asm.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ metadata:
4040
apiVersion: v1
4141
data:
4242
mesh: |-
43+
enableTracing: true
4344
defaultConfig:
4445
image:
4546
imageType: distroless
@@ -57,6 +58,7 @@ kubectl get controlplanerevision -n istio-system
5758
kubectl get dataplanecontrols
5859
kubectl get daemonset istio-cni-node -n kube-system
5960
kubectl wait --for=condition=available --timeout=600s deployment --all -n asm-system
61+
kubectl describe configmap env-$ASM_VERSION -n istio-system
6062
```
6163

6264
Resources:

content/monitor-asm/_index.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "Monitor ASM"
3+
chapter: true
4+
weight: 3
5+
---
6+
In this section you will monitor Anthos Service Mesh (ASM).
7+
8+
{{% notice warning %}}
9+
This section is still under construction... stay tuned!
10+
{{% /notice %}}
11+
12+
{{% children showhidden="false" %}}
13+
14+
_Note: For each Google / Kubernetes SA, mounted via Workload Identity, grant them this `roles/cloudtrace.agent` role in order to leverage ASM's option: Cloud Tracing._

content/overview/before-you-begin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Install the required tools:
1717
- [`gcloud`](https://cloud.google.com/sdk/docs/install)
1818
- [`kubectl`](https://kubernetes.io/docs/tasks/tools/#kubectl)
1919
- `istioctl`
20+
- [`nomos`](https://cloud.google.com/anthos-config-management/docs/how-to/nomos-command#installing)
2021
- `curl`
2122

2223
Get the _Folder Id_ and _Billing Account Id_ you will use to create your GCP project:

content/troubleshoot-asm/troubleshoot-istio.md renamed to content/troubleshoot-asm/troubleshoot-asm.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: "Troubleshoot Istio/ASM"
33
weight: 2
44
---
55

6+
_Note: Managed ASM doesn't support `istioctl proxy-status`._
7+
68
```Bash
79
kubectl get events
810
```
@@ -11,10 +13,6 @@ kubectl get events
1113
istioctl analyze -A
1214
```
1315

14-
```Bash
15-
istioctl proxy-status
16-
```
17-
1816
```Bash
1917
NAMESPACE=your-namespace
2018
DEPLOYMENT_NAME=your-deployment-name
@@ -25,7 +23,9 @@ kubectl logs deployment/$DEPLOYMENT_NAME -c istio-proxy -n $NAMESPACE
2523
NAMESPACE=your-namespace
2624
DEPLOYMENT_NAME=your-deployment-name
2725
APP_LABEL=your-pod-app-label
28-
istioctl proxy-config log -l app=$APP_LABEL --level none -n $NAMESPACE
26+
istioctl proxy-config log $(kubectl -n $NAMESPACE get pod -l app=$APP_LABEL -o jsonpath={.items..metadata.name}) \
27+
--level debug \
28+
-n $NAMESPACE
2929
kubectl logs deployment/$DEPLOYMENT_NAME -c istio-proxy -n $NAMESPACE
3030
```
3131

@@ -44,9 +44,10 @@ istioctl proxy-config listeners $(kubectl -n $NAMESPACE get pod -l app=$APP_LABE
4444
```
4545

4646
```Bash
47-
ASM_VERSION=$(kubectl get deploy -n istio-system -l app=istiod -o jsonpath={.items[*].metadata.labels.'istio\.io\/rev'}'{"\n"}')
48-
kubectl describe configmap istio-$ASM_VERSION -n istio-system
47+
kubectl describe configmap -n istio-system
4948
```
5049

5150
Resources:
52-
- [Troubleshooting ASM](https://cloud.google.com/service-mesh/docs/troubleshooting/troubleshoot-intro)
51+
- [Resolving managed Anthos Service Mesh issues](https://cloud.google.com/service-mesh/docs/managed/troubleshoot)
52+
- [Troubleshooting ASM](https://cloud.google.com/service-mesh/docs/troubleshooting/troubleshoot-intro)
53+
- [Managed Anthos Service Mesh supported features](https://cloud.google.com/service-mesh/docs/managed/supported-features-mcp)

0 commit comments

Comments
 (0)