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

rename demo app services #298

Merged
merged 2 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/content/concepts/policies/policy-blueprints.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ local k = import "github.com/jsonnet-libs/k8s-libsonnet/1.24/main.libsonnet";
local latencyGradientPolicy = import "github.com/fluxninja/aperture-blueprints/lib/1.0/policies/latency-gradient.libsonnet";

local policy = latencyGradientPolicy({
fluxmeterName: "demo1-demo-app",
fluxmeterName: "service1-demo-app",
serviceSelector+: {
service: "demo1-demo-app.demoapp.svc.cluster.local"
service: "service1-demo-app.demoapp.svc.cluster.local"
},
}).policy;

Expand Down
16 changes: 8 additions & 8 deletions manifests/k8s/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -260,24 +260,24 @@ DEP_TREE = {
],
"child_resources": [
{
"workload": "demo1-demo-app",
"workload": "service1-demo-app",
"resource_deps": ["cluster-bootstrap", "istiod"],
"extra_objects": [
"demo1-demo-app:serviceaccount"
"service1-demo-app:serviceaccount"
]
},
{
"workload": "demo2-demo-app",
"workload": "service2-demo-app",
"resource_deps": ["cluster-bootstrap", "istiod"],
"extra_objects": [
"demo2-demo-app:serviceaccount"
"service2-demo-app:serviceaccount"
]
},
{
"workload": "demo3-demo-app",
"workload": "service3-demo-app",
"resource_deps": ["cluster-bootstrap", "istiod"],
"extra_objects": [
"demo3-demo-app:serviceaccount"
"service3-demo-app:serviceaccount"
]
},
{
Expand Down Expand Up @@ -900,7 +900,7 @@ kubectl create configmap load-test --from-file=../../tools/load_generator/scenar
kubectl apply -f ../../tools/load_generator/scenarios/demoapp-load-test-cr.yaml
'''
cmd_button('demoapp-load-test-run',
resource='demo1-demo-app',
resource='k6-operator-controller-manager',
icon_name='content_paste_go',
text='Run load test',
argv=['sh', '-c', run_load_generator],
Expand All @@ -912,7 +912,7 @@ kubectl delete -f ../../tools/load_generator/scenarios/demoapp-load-test-cr.yaml
kubectl delete configmap load-test
'''
cmd_button('demoapp-load-test-del',
resource='demo1-demo-app',
resource='k6-operator-controller-manager',
icon_name='content_paste_off',
text='Delete load test',
argv=['sh', '-c', delete_load_generator],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ local demoappMixin =
};

local policy = latencyGradientPolicy({
policyName: 'demo1-demo-app',
policyName: 'service1-demo-app',
serviceSelector+: {
service: 'demo1-demo-app.demoapp.svc.cluster.local',
service: 'service1-demo-app.demoapp.svc.cluster.local',
},
}).policy;

Expand All @@ -40,7 +40,7 @@ local policy = latencyGradientPolicy({
+ k.core.v1.configMap.metadata.withLabels({ 'fluxninja.com/validate': 'true' })
+ k.core.v1.configMap.metadata.withNamespace('aperture-system')
+ k.core.v1.configMap.withData({
'demo1-demo-app.yaml': std.manifestYamlDoc(policy, quote_keys=false),
'service1-demo-app.yaml': std.manifestYamlDoc(policy, quote_keys=false),
}),
demoapp: demoappMixin,
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local dashboards =
dashboard.new('example-dashboard') +
dashboard.metadata.withLabels({ 'fluxninja.com/grafana-instance': 'aperture-grafana' }) +
dashboard.spec.withJson(std.manifestJsonEx(decisionDashboard({
policyName: 'demo1-demo-app',
policyName: 'service1-demo-app',
}).dashboard, indent=' ')) +
dashboard.spec.withDatasources({
inputName: 'DS_APERTURE-PROMETHEUS',
Expand Down
12 changes: 6 additions & 6 deletions manifests/k8s/tanka/lib/apps/demoapp/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ local helm = tanka.helm.new(helpers.helmChartsRoot);
},
values:: {
},
demo1:
helm.template('demo1', 'charts/demo-app', {
service1:
helm.template('service1', 'charts/demo-app', {
namespace: $.environment.namespace,
values: $.values,
}),
demo2:
helm.template('demo2', 'charts/demo-app', {
service2:
helm.template('service2', 'charts/demo-app', {
namespace: $.environment.namespace,
values: $.values,
}),
demo3:
helm.template('demo3', 'charts/demo-app', {
service3:
helm.template('service3', 'charts/demo-app', {
namespace: $.environment.namespace,
values: $.values,
}),
Expand Down
72 changes: 36 additions & 36 deletions manifests/k8s/tilt/portforward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
set -euo pipefail

check_var_set() {
local -r var_name="${1?}"
if [ -z "${!var_name:-}" ]; then
printf 'Required variable %s is not set!\n' "${var_name}" >&2
return 1
fi
local -r var_name="${1?}"
if [ -z "${!var_name:-}" ]; then
printf 'Required variable %s is not set!\n' "${var_name}" >&2
return 1
fi
}

check_var_set RESOURCE_NAME
Expand All @@ -25,40 +25,40 @@ check_var_set REMOTE_PORT

port_forward_args=()
if [ -n "${NAMESPACE:-}" ]; then
port_forward_args+=( --namespace "${NAMESPACE}" )
port_forward_args+=(--namespace "${NAMESPACE}")
fi
port_forward_args+=( "${RESOURCE_TYPE}/${RESOURCE_NAME}" "${LOCAL_PORT}:${REMOTE_PORT}" )
port_forward_args+=("${RESOURCE_TYPE}/${RESOURCE_NAME}" "${LOCAL_PORT}:${REMOTE_PORT}")
curl_args=(
--head # Just retrieve headers - ignore body
--silent # Don't show stuff on stdout
--show-error # But still show errors
--max-time "${TIMEOUT}" # Make curl exit if it can't finish the operation on time
"localhost:${LOCAL_PORT}${REQUEST_PATH}"
--head # Just retrieve headers - ignore body
--silent # Don't show stuff on stdout
--show-error # But still show errors
--max-time "${TIMEOUT}" # Make curl exit if it can't finish the operation on time
"localhost:${LOCAL_PORT}${REQUEST_PATH}"
)

while sleep 1; do
kubectl port-forward "${port_forward_args[@]}" &
process_id="${!}"
trap 'kill "${process_id}"' EXIT
sleep "${INITIAL_DELAY}" || break
failures=0
while :; do
if curl "${curl_args[@]}" | head -n1; then
failures=0
else
exit_code="${?}"
if [ "${exit_code}" -eq 124 ]; then
printf 'Timed out waiting for response\n' >&2
else
printf 'Curl failed with exit code %s\n' "${exit_code}" >&2
fi
if (( ++failures >= FAILURE_THRESHOLD )); then
printf 'Restarting port-forwarding\n' >&2
kill "${process_id}"
wait "${process_id}" || true # Ignore exit code
break
fi
fi
sleep "${PERIOD}" || break
done
kubectl port-forward "${port_forward_args[@]}" &
process_id="${!}"
trap 'kill "${process_id}"' EXIT
sleep "${INITIAL_DELAY}" || break
failures=0
while :; do
if curl "${curl_args[@]}" | head -n1; then
failures=0
else
exit_code="${?}"
if [ "${exit_code}" -eq 124 ]; then
printf 'Timed out waiting for response\n' >&2
else
printf 'Curl failed with exit code %s\n' "${exit_code}" >&2
fi
if ((++failures >= FAILURE_THRESHOLD)); then
printf 'Restarting port-forwarding\n' >&2
kill "${process_id}"
wait "${process_id}" || true # Ignore exit code
break
fi
fi
sleep "${PERIOD}" || break
done
done
6 changes: 3 additions & 3 deletions pkg/flowcontrol/envoy/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ var _ = Describe("Authorization handler", func() {
})
})

var demo1Selector = selectorv1.Selector{
Service: "demo1-demo-app.demoapp.svc.cluster.local",
var service1Selector = selectorv1.Selector{
Service: "service1-demo-app.demoapp.svc.cluster.local",
ControlPoint: &selectorv1.ControlPoint{
Controlpoint: &selectorv1.ControlPoint_Traffic{
Traffic: "ingress",
Expand All @@ -92,7 +92,7 @@ var demo1Selector = selectorv1.Selector{
}

var hardcodedRegoRules = classificationv1.Classifier{
Selector: &demo1Selector,
Selector: &service1Selector,
Rules: map[string]*classificationv1.Rule{
"destination": {
Source: &classificationv1.Rule_Rego_{
Expand Down
8 changes: 4 additions & 4 deletions pkg/policies/controlplane/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ data:
flux_meters:
"service_latency":
selector:
service: "demo1-demo-app.demoapp.svc.cluster.local"
service: "service1-demo-app.demoapp.svc.cluster.local"
control_point:
traffic: "ingress"
classifiers:
- selector:
service: demo1-demo-app.demoapp.svc.cluster.local
service: service1-demo-app.demoapp.svc.cluster.local
control_point: { traffic: ingress }
rules:
# An example rule using extractor.
Expand Down Expand Up @@ -167,7 +167,7 @@ data:
- concurrency_limiter:
scheduler:
selector:
service: "demo1-demo-app.demoapp.svc.cluster.local"
service: "service1-demo-app.demoapp.svc.cluster.local"
control_point:
traffic: "ingress"
auto_tokens: true
Expand Down Expand Up @@ -331,7 +331,7 @@ const rateLimitPolicy = `
limit:
signal_name: "RATE_LIMIT"
selector:
service: "demo1-demo-app.demoapp.svc.cluster.local"
service: "service1-demo-app.demoapp.svc.cluster.local"
control_point:
traffic: "ingress"
label_key: "request_header_user-type"
Expand Down
4 changes: 2 additions & 2 deletions tools/load_generator/scenarios/load_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export let vuStages = [
{ duration: "2m", target: 15 }, // ramp-up to 10 users over 1 minutes
{ duration: "2m", target: 15 }, // stay at 10 users for 2 minutes (peak hour)
{ duration: "10s", target: 5 }, // ramp-down to 5 users in 10 seconds
{ duration: "30s", target: 5 }, // stay at to 5 users in 30 seconds
{ duration: "2m", target: 5 }, // stay at to 5 users in 30 seconds
];

export let options = {
Expand All @@ -28,7 +28,7 @@ export let options = {

export default function () {
let userType = __ENV.USER_TYPE;
const url = "http://demo1-demo-app.demoapp.svc.cluster.local/request";
const url = "http://service1-demo-app.demoapp.svc.cluster.local/request";
const headers = {
"Content-Type": "application/json",
Cookie:
Expand Down