Skip to content

Commit 1594dc2

Browse files
Add Cloud Armor to onlineboutique.dev (#689)
* Update README with instruction * Delete frontend-nodeport.yaml * Update frontend-ingress.yaml * Update README.md * add backend-config and frontend-config * update according to the tests conducted * fix typo in --redis-version=redis_6_x * Alter wording/casing in release-cluster/README.md * Taking into consideration comments Co-authored-by: Nim Jayawardena <[email protected]>
1 parent 0d5c2f3 commit 1594dc2

File tree

7 files changed

+109
-18
lines changed

7 files changed

+109
-18
lines changed

.github/release-cluster/README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,67 @@
11
# onlineboutique.dev manifests
22

3-
This directory contains extra deploy manifests for configuring a domain name/static IP to point to an Online Boutique deployment running in GKE.
3+
This directory contains extra deploy manifests for configuring a domain name/static IP to point to an Online Boutique deployment running in GKE and for setting up Cloud Armor.
4+
5+
_Note: before moving forward, the OnlineBoutique apps should already be deployed [on the online-boutique-release GKE cluster](../../hack#10-deploy-releasekubernetes-manifestsyaml-to-our-online-boutique-release-gke-cluster)._
6+
7+
Create the static public IP address:
8+
```
9+
STATIC_IP_NAME=online-boutique-ip # name hard-coded in: frontend-ingress.yaml
10+
gcloud compute addresses create $STATIC_IP_NAME --global
11+
```
12+
13+
When ready to do so, you could grab this public IP address and update your DNS:
14+
```
15+
gcloud compute addresses describe $STATIC_IP_NAME \
16+
--global \
17+
--format "value(address)"
18+
```
19+
20+
Set up Cloud Armor:
21+
```
22+
SECURITY_POLICY_NAME=online-boutique-security-policy # Name hard-coded in: backendconfig.yaml
23+
gcloud compute security-policies create $SECURITY_POLICY_NAME \
24+
--description "Block various attacks"
25+
gcloud compute security-policies rules create 1000 \
26+
--security-policy $SECURITY_POLICY_NAME \
27+
--expression "evaluatePreconfiguredExpr('xss-stable')" \
28+
--action "deny-403" \
29+
--description "XSS attack filtering"
30+
gcloud compute security-policies rules create 12345 \
31+
--security-policy $SECURITY_POLICY_NAME \
32+
--expression "evaluatePreconfiguredExpr('cve-canary')" \
33+
--action "deny-403" \
34+
--description "CVE-2021-44228 and CVE-2021-45046"
35+
gcloud compute security-policies update $SECURITY_POLICY_NAME \
36+
--enable-layer7-ddos-defense
37+
gcloud compute security-policies update $SECURITY_POLICY_NAME \
38+
--log-level=VERBOSE
39+
```
40+
41+
Set up an SSL policy in order to later set up a redirect from HTTP to HTTPs:
42+
```
43+
SSL_POLICY_NAME=online-boutique-ssl-policy # Name hard-coded in: frontendconfig.yaml
44+
gcloud compute ssl-policies create $SSL_POLICY_NAME \
45+
--profile COMPATIBLE \
46+
--min-tls-version 1.0
47+
```
48+
49+
Deploy the Kubernetes manifests in this current folder:
50+
```
51+
kubectl apply -f .
52+
```
53+
54+
Wait for the `ManagedCertificate` to be provisioned. This usually takes about 30 minutes.
55+
```
56+
kubectl get managedcertificates
57+
```
58+
59+
Remove the default `LoadBalancer` `Service` not used at this point:
60+
```
61+
kubectl delete service frontend-external
62+
```
63+
64+
Remove the `loadgenerator` `Deployment` not used at this point:
65+
```
66+
kubectl delete deployment loadgenerator
67+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: cloud.google.com/v1
2+
kind: BackendConfig
3+
metadata:
4+
name: frontend-backend-config
5+
spec:
6+
securityPolicy:
7+
name: online-boutique-security-policy
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: networking.gke.io/v1beta1
2+
kind: FrontendConfig
3+
metadata:
4+
name: frontend-frontend-config
5+
spec:
6+
sslPolicy: online-boutique-ssl-policy
7+
redirectToHttps:
8+
enabled: true
9+
responseCodeName: MOVED_PERMANENTLY_DEFAULT
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
apiVersion: networking.k8s.io/v1beta1
1+
apiVersion: networking.k8s.io/v1
22
kind: Ingress
33
metadata:
44
name: frontend-ingress
55
annotations:
66
kubernetes.io/ingress.global-static-ip-name: online-boutique-ip
77
networking.gke.io/managed-certificates: online-boutique-certificate
8+
networking.gke.io/v1beta1.FrontendConfig: frontend-frontend-config
89
spec:
9-
backend:
10-
serviceName: frontend-nodeport
11-
servicePort: 80
10+
rules:
11+
- http:
12+
paths:
13+
- path: /*
14+
pathType: ImplementationSpecific
15+
backend:
16+
service:
17+
name: frontend
18+
port:
19+
number: 80

.github/release-cluster/frontend-nodeport.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: frontend
5+
annotations:
6+
cloud.google.com/neg: '{"ingress": true}'
7+
cloud.google.com/backend-config: '{"default": "frontend-backend-config"}'
8+
spec:
9+
type: ClusterIP
10+
selector:
11+
app: frontend
12+
ports:
13+
- name: http
14+
port: 80
15+
targetPort: 8080

docs/memorystore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ gcloud services enable redis.googleapis.com --project=${PROJECT_ID}
3333
3. Create the Memorystore (redis) instance.
3434

3535
```sh
36-
gcloud redis instances create redis-cart --size=1 --region=${REGION} --zone=${ZONE} --redis-version=redis_6_X --project=${PROJECT_ID}
36+
gcloud redis instances create redis-cart --size=1 --region=${REGION} --zone=${ZONE} --redis-version=redis_6_x --project=${PROJECT_ID}
3737
```
3838

3939
After a few minutes, you will see the `STATUS` as `READY` when your Memorystore instance will be successfully provisioned:

0 commit comments

Comments
 (0)