Created
January 30, 2023 17:55
-
-
Save fenar/fe160038cc5d7d5228e30abe0482c498 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requirements: | |
1x RHACM HUB | |
2x+ Managed Clusters | |
#Join clusters | |
Go ahead and make sure that all your ManagedClusters joined the RHACM Hub and are in ready state. | |
#ManagedClusters must have labels that will be used for app placement together with the LatencyCheck operator. For example, if we plan to use the label `ddosify` as the one used by the operator when creating the PlacementRule, that label should have the following values: | |
- If using locationMatchingStrategy set to city: NA.US.TX.SA | |
- If using locationMatchingStrategy set to state: NA.US.TX | |
- If using locationMatchingStrategy set to country: NA.US | |
- If using locationMatchingStrategy set to continent: NA | |
#Create the demo namespace | |
1. Create the ddosify namespace in the HUB cluster: | |
oc create namespace ddosify | |
#Run the Fake ddosify api | |
The fake api can be found here https://github.com/RHsyseng/ddosify-tooling/tree/main/tooling/fake-api. | |
For the sake of simplicity, we are running the Fake ddosify API in our Hub cluster. In order to deploy it follow the steps below: | |
1. Create the fake-api deployment: | |
oc -n ddosify apply -f https://raw.githubusercontent.com/RHsyseng/ddosify-tooling/main/tooling/fake-api/ocp_deployment/deployment.yaml | |
2. Create the fake-api service: | |
oc -n ddosify apply -f https://raw.githubusercontent.com/RHsyseng/ddosify-tooling/main/tooling/fake-api/ocp_deployment/service.yaml | |
At this point the fake ddosify api will be running inside a pod, the fake api uses json files inside the templates folder as fake results. For the demo, the important file is the symbolic link named latency-test-result-200.json. By default this link is pointing to the global.json results. If you want it to point to a different file you can access the pod and re-link to another json file. For example, if we wanted to get spain.json results we would run the following commands: | |
oc -n ddosify rsh deployment/ddosify-fakeapi | |
cd templates/ | |
unlink latency-test-result-200.json | |
ln -s spain.json latency-test-result-200.json | |
The idea is that you can edit the json file with the results to make the api return the values you want at any point. | |
Deploy the LatencyCheck Operator | |
1. Deploy the custom catalogsource | |
oc apply -f https://raw.githubusercontent.com/RHsyseng/ddosify-tooling/main/tooling/k8soperator/ocp-operator-deployment/CatalogSource.yaml | |
2.Deploy the latencycheck operator in the ddosify namespace | |
cat <<EOF | oc -n ddosify apply -f - | |
--- | |
apiVersion: operators.coreos.com/v1 | |
kind: OperatorGroup | |
metadata: | |
name: latencycheck-operator-operatorgroup | |
namespace: ddosify | |
spec: | |
targetNamespaces: | |
- ddosify | |
--- | |
apiVersion: operators.coreos.com/v1alpha1 | |
kind: Subscription | |
metadata: | |
name: latencycheck-operator | |
namespace: ddosify | |
spec: | |
channel: "alpha" | |
name: latencycheck-operator | |
source: telcops-catalog | |
sourceNamespace: openshift-marketplace | |
startingCSV: latencycheck-operator.v0.0.1 | |
installPlanApproval: Automatic | |
EOF | |
3. Scale down the operator (this operator doesn’t support querying the ddosify fake api server we will be using for the demo) | |
oc -n ddosify scale deployment latencycheck-controller-manager --replicas 0 | |
4. Deploy the operator with support for ddosify fake api server. Change the FAKE_API_IP var to match your environment. | |
export FAKE_API_IP=$(oc -n ddosify get svc ddosify-fakeapi -o jsonpath='{.spec.clusterIP}') | |
curl -sL https://gist.githubusercontent.com/mvazquezc/2061c971029f070fbf2ac36bea23f375/raw/ba491e1e1c9c9bf84d6929a2475462c74c48e911/operator-deployment-fake-api.yaml | sed "s/FAKEAPI_IP/${FAKE_API_IP}/" | oc apply -f - | |
5. Create the latencycheck | |
curl -sL https://gist.githubusercontent.com/mvazquezc/2061c971029f070fbf2ac36bea23f375/raw/ba491e1e1c9c9bf84d6929a2475462c74c48e911/latencycheck.yaml | sed "s/DEMO_NAMESPACE/ddosify/g" | oc -n ddosify apply -f - | |
6. At this point the latencycheck should exist and a placementrule should have been created | |
oc -n ddosify get placementrule | |
NAME AGE REPLICAS | |
ddosify-demo 1m 1 | |
Create demo app | |
1. Deploy the demo files | |
curl -sL https://gist.githubusercontent.com/mvazquezc/2061c971029f070fbf2ac36bea23f375/raw/6b5ba7955ffbc263c27df284fd8d0c6e7d2346ac/demo-app-files.yaml | sed "s/DEMO_NAMESPACE/ddosify/g" | oc -n ddosify apply -f - | |
2. Get Latency Measurement Objects | |
# Get the object | |
oc -n ddosify get latencycheck redhat-latencycheck -o yaml | |
# Get only the results | |
oc -n ddosify get latencycheck redhat-latencycheck -o jsonpath='{.status.results}' | jq | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment