Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cloud Armor in front of this deployed demo #689

Merged
merged 9 commits into from
Jan 28, 2022

Conversation

mathieu-benoit
Copy link
Contributor

@mathieu-benoit mathieu-benoit commented Jan 14, 2022

Document the way to setup Cloud Armor in front of the public endpoint of this demo onlineboutique.dev.

What's in this PR:

  • Document the steps do deploy the release-cluster part with more automation with gcloud
  • Add BackendConfig to bind Cloud Armor to the Ingress
  • Add FrontendConfig to bind the SSL Policy and redirect http to https
  • Update Ingress's apiVersion from apiVersion: networking.k8s.io/v1beta1 to networking.k8s.io/v1 to avoid future breaking change because deprecation with GKE 1.22
  • Remove the frontend-nodeport.yaml because it's not anymore a requirement, the default ClusterIP one is sufficient/working now.
  • To avoid to have another Public IP, do a kubectl delete svc frontend-external in the process too
  • Not related, fix a typo in the Memorystore (redis) doc.

Next steps:

  • Test on a personal GKE cluster (see comment below with details information about the tests)
  • Validate with the team about their thoughts and feedback
  • If validated, apply this to onlineboutique.dev
  • Eventually, port this to BoA too, to be consistent

@mathieu-benoit mathieu-benoit requested a review from a team as a code owner January 14, 2022 16:19
@mathieu-benoit mathieu-benoit marked this pull request as draft January 14, 2022 16:19
@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

2 similar comments
@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

@mathieu-benoit
Copy link
Contributor Author

mathieu-benoit commented Jan 15, 2022

Tests conducted:

Bash commands to test this PR...

PROJECT_ID=FIXME
gcloud config set project $PROJECT_ID
kubectl create ns onlineboutique
kubectl apply -f release/kubernetes-manifests.yaml -n onlineboutique
gcloud compute addresses create online-boutique-ip --global
PUBLIC_IP=$(gcloud compute addresses describe online-boutique-ip \
    --global \
    --format "value(address)")
HOST_NAME="onlineboutique.endpoints.${PROJECT_ID}.cloud.goog"
cat <<EOF > dns-spec.yaml
swagger: "2.0"
info:
  description: "Cloud Endpoints DNS"
  title: "Cloud Endpoints DNS"
  version: "1.0.0"
paths: {}
host: "${HOST_NAME}"
x-google-endpoints:
- name: "${HOST_NAME}"
  target: "${PUBLIC_IP}"
EOF
gcloud endpoints services deploy dns-spec.yaml
SECURITY_POLICY_NAME=online-boutique-security-policy
gcloud compute security-policies create $SECURITY_POLICY_NAME \
    --description "Block XSS attacks"
gcloud compute security-policies rules create 1000 \
    --security-policy $SECURITY_POLICY_NAME \
    --expression "evaluatePreconfiguredExpr('xss-stable')" \
    --action "deny-403" \
    --description "XSS attack filtering"
gcloud compute security-policies rules create 12345 \
    --security-policy $SECURITY_POLICY_NAME \
    --expression "evaluatePreconfiguredExpr('cve-canary')" \
    --action "deny-403" \
    --description "CVE-2021-44228 and CVE-2021-45046"
gcloud compute security-policies update $SECURITY_POLICY_NAME \
    --enable-layer7-ddos-defense
gcloud compute security-policies update $SECURITY_POLICY_NAME \
    --log-level=VERBOSE
SSL_POLICY_NAME=online-boutique-ssl-policy
gcloud compute ssl-policies create $SSL_POLICY_NAME \
    --profile COMPATIBLE  \
    --min-tls-version 1.0
sed -i "s,onlineboutique.dev,${HOST_NAME},g" .github/release-cluster/managed-cert.yaml
kubectl apply -f .github/release-cluster/ -n onlineboutique

@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

@mathieu-benoit mathieu-benoit marked this pull request as ready for review January 17, 2022 13:55
@mathieu-benoit
Copy link
Contributor Author

Ready for your review and comments, thanks.

@NimJay NimJay self-requested a review January 27, 2022 15:34
@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

@NimJay
Copy link
Collaborator

NimJay commented Jan 27, 2022

Thanks so much for creating this pull-request. And apologies for the late review.
I think using Cloud Armor is a good idea — we would be dog-fooding yet another GCP product! :)

Warning: I have added a commit to the mathieu-benoit/cloud-armor-release-cluster branch, with some wording changes.
So you may want to git pull from your end.

Question:
See hack/README.md where we've documented the release process.
Step 10 consists of applying ./release/kubernetes-manifests.yaml to our deployment GKE cluster.
Do you think we should add a step between step 10 and step 11 similar to:

  1. Delete unused resources.
kubectl delete service frontend-external
kubectl delete deployment loadgenerator

I am currently testing everything out in my own GCP project (i.e., still reviewing).

@mathieu-benoit
Copy link
Contributor Author

mathieu-benoit commented Jan 27, 2022

Thanks for the wording changes @NimJay.
For your suggestion, I think that's a good idea. Why not making a disclaimer/note at the beginning to point/mention this release process page/doc by saying "assumption that the release process has been applied" or something like this? So without duplicating any steps/commands, just pointing to the existing one?
I can do the commit/change about that, but just making sure with you about the approach.

@NimJay
Copy link
Collaborator

NimJay commented Jan 27, 2022

Ah, that's a good idea.
I like the idea of not duplicating instructions.
Go for it. :)

Copy link
Collaborator

@NimJay NimJay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just finished testing this on my own cluster and domain.
See deletemenow.peachytools.com (which I'll take down once this PR is merged).
Cloud Armor was applied:
Screen Shot 2022-01-27 at 2 00 07 PM

I didn't test Cloud Armor itself — but I trust that it works.
I left 2 comments.
They're minor so I'll approve this.

Thanks again for doing this, @mathieu-benoit! And thanks for the very details PR description. It made the changes easy to review. 👏

I'll apply the changes (set up Cloud Armor) to onlineboutique.dev as soon as this is merge. :)

.github/release-cluster/README.md Outdated Show resolved Hide resolved
.github/release-cluster/README.md Outdated Show resolved Hide resolved
@github-actions
Copy link

🚲 PR staged at http://104.154.87.241

@mathieu-benoit
Copy link
Contributor Author

Thanks for the review and comments @NimJay, let me know if there is anything else.

@NimJay NimJay merged commit 1594dc2 into main Jan 28, 2022
@NimJay NimJay deleted the mathieu-benoit/cloud-armor-release-cluster branch January 28, 2022 15:21
@NimJay
Copy link
Collaborator

NimJay commented Jan 28, 2022

I just applied the changes to the onlineboutique.dev cluster (online-boutique-release).
For some reason, the online-boutique-security-policy has "0 targets".
I'll give it some time and check back in a bit.

@NimJay
Copy link
Collaborator

NimJay commented Jan 28, 2022

Update on Investigation

@mathieu-benoit and I just investigated a bit.

The frontend-ingress is still connected to the old frontend-nodeport:

kubectl describe ingress
Name:             frontend-ingress
Labels:           <none>
Namespace:        default
Address:          35.244.250.164
Default backend:  frontend-nodeport:80 (<error: endpoints "frontend-nodeport" not found>)

which I had deleted using:

kubectl delete Service frontend-nodeport

after I applied the new manifests from the ./github/release-cluster/ folder.

But we just reapplied the old frontend-nodeport.yaml file.
And now we see that the Cloud Armor online-boutique-security-policy has "1 target".

@mathieu-benoit
Copy link
Contributor Author

Found out the issue: because of the update of the ingress to v1, I haven't set the defaultBakend field. The issue was not there on a brand new GKE cluster we tested, but because the Ingress of the live cluster of onlineboutique.dev was pointing to the deleted frontendservice-nodeport, it raised that issue.

All good now, #698 is fixing the issue.

sitaramkm pushed a commit to sitaramkm/microservices-demo that referenced this pull request Mar 27, 2022
* 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 <nimjay@google.com>
D-Mwanth pushed a commit to D-Mwanth/microservices-demo that referenced this pull request Mar 6, 2024
* 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 <nimjay@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants