diff --git a/Makefile b/Makefile index 6999687..3b1ab68 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ +SHELL:=/bin/bash MAKEFLAGS += --no-print-directory -COMPONENTS = community-controller system-controller edge-scheduler function-deployment-webhook dispatcher +COMPONENTS = community-controller cpu-monitoring simple-dispatcher simple-dispatcher-of system-controller dispatcher ifeq (,$(shell go env GOBIN)) GOBIN=$(shell go env GOPATH)/bin diff --git a/config/crd/bases/edgeautoscaler.polimi.it_communityconfigurations.yaml b/config/crd/bases/edgeautoscaler.polimi.it_communityconfigurations.yaml index 87ab944..a36a723 100644 --- a/config/crd/bases/edgeautoscaler.polimi.it_communityconfigurations.yaml +++ b/config/crd/bases/edgeautoscaler.polimi.it_communityconfigurations.yaml @@ -52,7 +52,7 @@ spec: description: MaximumDelay is the upper bound for the delay inside a community measured in milliseconds format: int32 - maximum: 100 + maximum: 10000 minimum: 0 type: integer probability-threshold: diff --git a/config/deploy/simple-dispatcher.yaml b/config/deploy/simple-dispatcher.yaml new file mode 100644 index 0000000..4932a2c --- /dev/null +++ b/config/deploy/simple-dispatcher.yaml @@ -0,0 +1,45 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: simple-dispatcher + namespace: default + labels: + app: dispatcher +spec: + selector: + matchLabels: + app: dispatcher + template: + metadata: + labels: + app: dispatcher + spec: + automountServiceAccountToken: true + nodeSelector: + kubernetes.io/kind: worker + serviceAccountName: dispatcher + containers: + - name: dispatcher + image: systemautoscaler/simple-dispatcher:dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName +--- +apiVersion: v1 +kind: Service +metadata: + name: dispatcher + labels: + app: dispatcher +spec: + ports: + - port: 80 + targetPort: 8080 + selector: + app: dispatcher + diff --git a/config/metric-db/002_init.sql b/config/metric-db/002_init.sql index 128e52b..f0596fd 100644 --- a/config/metric-db/002_init.sql +++ b/config/metric-db/002_init.sql @@ -24,9 +24,9 @@ CREATE TABLE IF NOT EXISTS ping timestamp TIMESTAMP, from_node VARCHAR(50), to_node VARCHAR(50), - avg_latency INTEGER, - max_latency INTEGER, - min_latency INTEGER, + avg_latency DOUBLE PRECISION, + max_latency DOUBLE PRECISION, + min_latency DOUBLE PRECISION, PRIMARY KEY (timestamp, from_node) ); @@ -47,3 +47,19 @@ CREATE TABLE IF NOT EXISTS resource ); SELECT create_hypertable('resource', 'timestamp', chunk_time_interval => INTERVAL '5 minutes'); + +CREATE TABLE IF NOT EXISTS proxy_metric +( + timestamp TIMESTAMP, + node VARCHAR(50), + function VARCHAR(50), + namespace VARCHAR(50), + community VARCHAR(50), + latency INTEGER, + gpu BOOLEAN, + PRIMARY KEY (timestamp, node, function, namespace, community) + ); + +SELECT create_hypertable('proxy_metric', 'timestamp', chunk_time_interval => INTERVAL '30 seconds'); +SELECT add_dimension('proxy_metric', 'community', number_partitions => 4); +SELECT add_dimension('proxy_metric', 'namespace', number_partitions => 4); diff --git a/example/sla-2/carts-delete-sla.yaml b/example/sla-2/carts-delete-sla.yaml index 4d51fa0..3eebcf8 100644 --- a/example/sla-2/carts-delete-sla.yaml +++ b/example/sla-2/carts-delete-sla.yaml @@ -4,16 +4,18 @@ metadata: name: carts-delete namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: - responseTime: 50m + responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "600m" + memory: 1500Mi minResources: - memory: 1000Mi - cpu: 300m + memory: 1500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 1500Mi cpu: 20000m service: container: carts-delete diff --git a/example/sla-2/carts-post-sla.yaml b/example/sla-2/carts-post-sla.yaml index f10ea78..7987dbf 100644 --- a/example/sla-2/carts-post-sla.yaml +++ b/example/sla-2/carts-post-sla.yaml @@ -4,16 +4,18 @@ metadata: name: carts-post namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: - responseTime: 150m + responseTime: 200m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "600m" + memory: 1500Mi minResources: - memory: 1000Mi - cpu: 300m + memory: 1500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 1500Mi cpu: 20000m service: container: carts-post diff --git a/example/sla-2/carts-sla.yaml b/example/sla-2/carts-sla.yaml index 2f5f33d..bada1d9 100644 --- a/example/sla-2/carts-sla.yaml +++ b/example/sla-2/carts-sla.yaml @@ -4,16 +4,18 @@ metadata: name: carts namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: - responseTime: 50m + responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "600m" + memory: 1500Mi minResources: - memory: 1000Mi - cpu: 300m + memory: 1500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 1500Mi cpu: 20000m service: container: carts diff --git a/example/sla-2/catalogue-sla.yaml b/example/sla-2/catalogue-sla.yaml index da1e217..bc7ded5 100644 --- a/example/sla-2/catalogue-sla.yaml +++ b/example/sla-2/catalogue-sla.yaml @@ -4,16 +4,18 @@ metadata: name: catalogue namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: - responseTime: 50m + responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "50m" + memory: 250Mi minResources: - memory: 1000Mi - cpu: 50m + memory: 250Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 250Mi cpu: 20000m service: container: catalogue diff --git a/example/sla-2/front-end-sla.yaml b/example/sla-2/front-end-sla.yaml deleted file mode 100644 index f917115..0000000 --- a/example/sla-2/front-end-sla.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: systemautoscaler.polimi.it/v1beta1 -kind: ServiceLevelAgreement -metadata: - name: front-end - namespace: openfaas-fn -spec: - metric: - responseTime: 100m - defaultResources: - cpu: "1000m" - memory: 1000Mi - minResources: - memory: 1000Mi - cpu: 100m - maxResources: - memory: 1000Mi - cpu: 20000m - service: - container: front-end - selector: - matchLabels: - name: front-end \ No newline at end of file diff --git a/example/sla-2/orders-sla.yaml b/example/sla-2/orders-sla.yaml index d506ffb..b523228 100644 --- a/example/sla-2/orders-sla.yaml +++ b/example/sla-2/orders-sla.yaml @@ -4,16 +4,18 @@ metadata: name: orders namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: responseTime: 300m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "600m" + memory: 1500Mi minResources: - memory: 1000Mi - cpu: 300m + memory: 1500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 1500Mi cpu: 20000m service: container: orders diff --git a/example/sla-2/payment-sla.yaml b/example/sla-2/payment-sla.yaml index fd6b95c..aeb86c6 100644 --- a/example/sla-2/payment-sla.yaml +++ b/example/sla-2/payment-sla.yaml @@ -4,16 +4,18 @@ metadata: name: payment namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: - responseTime: 50m + responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "50" + memory: 250Mi minResources: - memory: 1000Mi - cpu: 50m + memory: 250Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 250Mi cpu: 20000m service: container: payment diff --git a/example/sla-2/queue-master-sla.yaml b/example/sla-2/queue-master-sla.yaml index f0d039d..7ade240 100644 --- a/example/sla-2/queue-master-sla.yaml +++ b/example/sla-2/queue-master-sla.yaml @@ -4,19 +4,21 @@ metadata: name: queue-master namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "600m" + memory: 1500Mi minResources: - memory: 1000Mi - cpu: 300m + memory: 1500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 1500Mi cpu: 20000m service: container: queue-master selector: matchLabels: - name: queue-master \ No newline at end of file + name: queue-master diff --git a/example/sla-2/shipping-sla.yaml b/example/sla-2/shipping-sla.yaml index e4f608f..dbdf9cd 100644 --- a/example/sla-2/shipping-sla.yaml +++ b/example/sla-2/shipping-sla.yaml @@ -4,16 +4,18 @@ metadata: name: shipping namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: - responseTime: 50m + responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "600m" + memory: 1500Mi minResources: - memory: 1000Mi - cpu: 300m + memory: 1500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 1500Mi cpu: 20000m service: container: shipping diff --git a/example/sla-2/user-login-sla.yaml b/example/sla-2/user-login-sla.yaml index 962db5d..2b1d7ea 100644 --- a/example/sla-2/user-login-sla.yaml +++ b/example/sla-2/user-login-sla.yaml @@ -4,16 +4,18 @@ metadata: name: user-login namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: - responseTime: 50m + responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "50m" + memory: 500Mi minResources: - memory: 1000Mi - cpu: 50m + memory: 500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 500Mi cpu: 20000m service: container: user-login diff --git a/example/sla-2/user-register-sla.yaml b/example/sla-2/user-register-sla.yaml index 8072a63..45598de 100644 --- a/example/sla-2/user-register-sla.yaml +++ b/example/sla-2/user-register-sla.yaml @@ -4,16 +4,18 @@ metadata: name: user-register namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: - responseTime: 50m + responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "50m" + memory: 500Mi minResources: - memory: 1000Mi - cpu: 50m + memory: 500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 500Mi cpu: 20000m service: container: user-register diff --git a/example/sla-2/user-sla.yaml b/example/sla-2/user-sla.yaml index d331e74..d187877 100644 --- a/example/sla-2/user-sla.yaml +++ b/example/sla-2/user-sla.yaml @@ -4,19 +4,21 @@ metadata: name: user namespace: openfaas-fn spec: + integralGain: 3 + proportionalGain: 6 metric: responseTime: 100m defaultResources: - cpu: "1000m" - memory: 1000Mi + cpu: "50m" + memory: 500Mi minResources: - memory: 1000Mi - cpu: 50m + memory: 500Mi + cpu: 30m maxResources: - memory: 1000Mi + memory: 500Mi cpu: 20000m service: container: user selector: matchLabels: - name: user \ No newline at end of file + name: user diff --git a/example/sock-shop-2/carts-db-dep.yaml b/example/sock-shop-2/carts-db-dep.yaml index cde6399..57dbfc4 100644 --- a/example/sock-shop-2/carts-db-dep.yaml +++ b/example/sock-shop-2/carts-db-dep.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: carts-db - image: mongo + image: systemautoscaler/mongo-carts:dev ports: - name: mongo containerPort: 27017 diff --git a/example/sock-shop-2/carts-fn-delete.yaml b/example/sock-shop-2/carts-fn-delete.yaml index bc49aec..3d20301 100644 --- a/example/sock-shop-2/carts-fn-delete.yaml +++ b/example/sock-shop-2/carts-fn-delete.yaml @@ -8,14 +8,17 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: carts-delete image: weaveworksdemos/carts:0.4.8 environment: JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: cpu: "600m" - memory: "1000Mi" + memory: "1500Mi" requests: cpu: "600m" - memory: "1000Mi" + memory: "1500Mi" diff --git a/example/sock-shop-2/carts-fn-get.yaml b/example/sock-shop-2/carts-fn-get.yaml index 99fe1f7..1b63a29 100644 --- a/example/sock-shop-2/carts-fn-get.yaml +++ b/example/sock-shop-2/carts-fn-get.yaml @@ -8,14 +8,17 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: carts-get image: weaveworksdemos/carts:0.4.8 environment: JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: cpu: "600m" - memory: "1000Mi" + memory: "1500Mi" requests: cpu: "600m" - memory: "1000Mi" + memory: "1500Mi" diff --git a/example/sock-shop-2/carts-fn-post.yaml b/example/sock-shop-2/carts-fn-post.yaml index 45b6b56..758af9a 100644 --- a/example/sock-shop-2/carts-fn-post.yaml +++ b/example/sock-shop-2/carts-fn-post.yaml @@ -8,14 +8,17 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: carts-post image: weaveworksdemos/carts:0.4.8 environment: JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: cpu: "600m" - memory: "1000Mi" + memory: "1500Mi" requests: cpu: "600m" - memory: "1000Mi" + memory: "1500Mi" diff --git a/example/sock-shop-2/carts-fn.yaml b/example/sock-shop-2/carts-fn.yaml index b7cc87f..02fd1b0 100644 --- a/example/sock-shop-2/carts-fn.yaml +++ b/example/sock-shop-2/carts-fn.yaml @@ -8,14 +8,17 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: carts image: weaveworksdemos/carts:0.4.8 environment: JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: cpu: "600m" - memory: "1000Mi" + memory: "1500Mi" requests: cpu: "600m" - memory: "1000Mi" + memory: "1500Mi" diff --git a/example/sock-shop-2/catalogue-fn.yaml b/example/sock-shop-2/catalogue-fn.yaml index 060b5dd..1a8d7e3 100644 --- a/example/sock-shop-2/catalogue-fn.yaml +++ b/example/sock-shop-2/catalogue-fn.yaml @@ -8,12 +8,15 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: catalogue image: systemautoscaler/catalogue:dev limits: cpu: "50m" - memory: "100Mi" + memory: "250Mi" requests: cpu: "50m" - memory: "100Mi" + memory: "250Mi" diff --git a/example/sock-shop-2/front-end-fn.yaml b/example/sock-shop-2/front-end-fn.yaml deleted file mode 100644 index 95b8124..0000000 --- a/example/sock-shop-2/front-end-fn.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: apps/v1 -kind: DaemonSet -metadata: - name: front-end - namespace: openfaas-fn - labels: - app: front-end -spec: - selector: - matchLabels: - app: front-end - template: - metadata: - labels: - app: front-end - spec: - containers: - - name: front-end - image: systemautoscaler/front-end:dev - imagePullPolicy: Always - resources: - limits: - cpu: 1 - memory: 150Mi - requests: - cpu: 1 - memory: 150Mi diff --git a/example/sock-shop-2/front-end-svc.yaml b/example/sock-shop-2/front-end-svc.yaml deleted file mode 100644 index 0d40eeb..0000000 --- a/example/sock-shop-2/front-end-svc.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -apiVersion: v1 -kind: Service -metadata: - name: front-end - labels: - name: front-end - namespace: openfaas-fn -spec: - selector: - app: front-end -# edgeautoscaler.polimi.it/function-name: "front-end" -# edgeautoscaler.polimi.it/function-namespace: "openfaas-fn" - ports: - # the port that this service should serve on - - port: 80 - targetPort: 8080 - topologyKeys: - - "kubernetes.io/hostname" - - "*" diff --git a/example/sock-shop-2/orders-fn.yaml b/example/sock-shop-2/orders-fn.yaml index 10ed8b4..f57f98d 100644 --- a/example/sock-shop-2/orders-fn.yaml +++ b/example/sock-shop-2/orders-fn.yaml @@ -8,13 +8,16 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: orders image: systemautoscaler/orders:dev environment: JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: - cpu: "300m" - memory: "1000Mi" + cpu: "600m" + memory: "1500Mi" requests: - cpu: "300m" - memory: "1000Mi" + cpu: "600m" + memory: "1500Mi" diff --git a/example/sock-shop-2/payment-fn.yaml b/example/sock-shop-2/payment-fn.yaml index 49648b9..66ebe4f 100644 --- a/example/sock-shop-2/payment-fn.yaml +++ b/example/sock-shop-2/payment-fn.yaml @@ -8,13 +8,14 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: payment image: systemautoscaler/payment:dev - environment: - JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: cpu: "50m" - memory: "100Mi" + memory: "250Mi" requests: cpu: "50m" - memory: "100Mi" + memory: "250Mi" diff --git a/example/sock-shop-2/queue-master-fn.yaml b/example/sock-shop-2/queue-master-fn.yaml index 6b25faa..e6ca85a 100644 --- a/example/sock-shop-2/queue-master-fn.yaml +++ b/example/sock-shop-2/queue-master-fn.yaml @@ -8,13 +8,16 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: queue-master image: weaveworksdemos/queue-master:0.3.1 environment: JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: - cpu: "300m" + cpu: "600m" memory: "1000Mi" requests: - cpu: "300m" + cpu: "600m" memory: "1000Mi" diff --git a/example/sock-shop-2/shipping-fn.yaml b/example/sock-shop-2/shipping-fn.yaml index 457b5b6..9feac52 100644 --- a/example/sock-shop-2/shipping-fn.yaml +++ b/example/sock-shop-2/shipping-fn.yaml @@ -8,13 +8,16 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: shipping image: weaveworksdemos/shipping:0.4.8 environment: JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: - cpu: "300m" - memory: "1000Mi" + cpu: "600m" + memory: "1500Mi" requests: - cpu: "300m" - memory: "1000Mi" + cpu: "600m" + memory: "1500Mi" diff --git a/example/sock-shop-2/user-fn-login.yaml b/example/sock-shop-2/user-fn-login.yaml index 62938d2..20efeaf 100644 --- a/example/sock-shop-2/user-fn-login.yaml +++ b/example/sock-shop-2/user-fn-login.yaml @@ -8,13 +8,14 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: user-login image: systemautoscaler/user:dev - environment: - JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: cpu: "50m" - memory: "100Mi" + memory: "500Mi" requests: cpu: "50m" - memory: "100Mi" + memory: "500Mi" diff --git a/example/sock-shop-2/user-fn-register.yaml b/example/sock-shop-2/user-fn-register.yaml index 3c26edf..40bb0d9 100644 --- a/example/sock-shop-2/user-fn-register.yaml +++ b/example/sock-shop-2/user-fn-register.yaml @@ -8,13 +8,14 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: user-register image: systemautoscaler/user:dev - environment: - JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: cpu: "50m" - memory: "100Mi" + memory: "500Mi" requests: cpu: "50m" - memory: "100Mi" + memory: "500Mi" diff --git a/example/sock-shop-2/user-fn.yaml b/example/sock-shop-2/user-fn.yaml index 24da0af..6b325ad 100644 --- a/example/sock-shop-2/user-fn.yaml +++ b/example/sock-shop-2/user-fn.yaml @@ -8,13 +8,14 @@ spec: com.openfaas.scale.max: "0" com.openfaas.scale.min: "0" com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" name: user image: systemautoscaler/user:dev - environment: - JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" limits: cpu: "50m" - memory: "100Mi" + memory: "500Mi" requests: cpu: "50m" - memory: "100Mi" + memory: "500Mi" diff --git a/example/sock-shop-openfaas/db/carts-db-dep.yaml b/example/sock-shop-openfaas/db/carts-db-dep.yaml new file mode 100644 index 0000000..57dbfc4 --- /dev/null +++ b/example/sock-shop-openfaas/db/carts-db-dep.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: carts-db + labels: + name: carts-db + namespace: openfaas-fn +spec: + replicas: 1 + selector: + matchLabels: + name: carts-db + template: + metadata: + labels: + name: carts-db + spec: + containers: + - name: carts-db + image: systemautoscaler/mongo-carts:dev + ports: + - name: mongo + containerPort: 27017 + securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + volumeMounts: + - mountPath: /tmp + name: tmp-volume + - mountPath: /data/db + name: cache-volume + volumes: + - name: tmp-volume + emptyDir: + medium: Memory + - name: cache-volume + emptyDir: { } + nodeSelector: + beta.kubernetes.io/os: linux diff --git a/example/sock-shop-openfaas/db/carts-db-svc.yaml b/example/sock-shop-openfaas/db/carts-db-svc.yaml new file mode 100644 index 0000000..2fdb6e0 --- /dev/null +++ b/example/sock-shop-openfaas/db/carts-db-svc.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: carts-db + labels: + name: carts-db + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 27017 + targetPort: 27017 + selector: + name: carts-db diff --git a/example/sock-shop-openfaas/db/catalogue-db-dep.yaml b/example/sock-shop-openfaas/db/catalogue-db-dep.yaml new file mode 100644 index 0000000..b5d8cd8 --- /dev/null +++ b/example/sock-shop-openfaas/db/catalogue-db-dep.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: catalogue-db + labels: + name: catalogue-db + namespace: openfaas-fn +spec: + replicas: 1 + selector: + matchLabels: + name: catalogue-db + template: + metadata: + labels: + name: catalogue-db + spec: + containers: + - name: catalogue-db + image: weaveworksdemos/catalogue-db:0.3.0 + env: + - name: MYSQL_ROOT_PASSWORD + value: fake_password + - name: MYSQL_DATABASE + value: socksdb + ports: + - name: mysql + containerPort: 3306 + nodeSelector: + beta.kubernetes.io/os: linux diff --git a/example/sock-shop-openfaas/db/catalogue-db-svc.yaml b/example/sock-shop-openfaas/db/catalogue-db-svc.yaml new file mode 100644 index 0000000..cd55755 --- /dev/null +++ b/example/sock-shop-openfaas/db/catalogue-db-svc.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: catalogue-db + labels: + name: catalogue-db + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 3306 + targetPort: 3306 + selector: + name: catalogue-db diff --git a/example/sock-shop-openfaas/db/orders-db-dep.yaml b/example/sock-shop-openfaas/db/orders-db-dep.yaml new file mode 100644 index 0000000..b8272f8 --- /dev/null +++ b/example/sock-shop-openfaas/db/orders-db-dep.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: orders-db + labels: + name: orders-db + namespace: openfaas-fn +spec: + replicas: 1 + selector: + matchLabels: + name: orders-db + template: + metadata: + labels: + name: orders-db + spec: + containers: + - name: orders-db + image: mongo + ports: + - name: mongo + containerPort: 27017 + securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + readOnlyRootFilesystem: true + volumeMounts: + - mountPath: /tmp + name: tmp-volume + volumes: + - name: tmp-volume + emptyDir: + medium: Memory + nodeSelector: + beta.kubernetes.io/os: linux diff --git a/example/sock-shop-openfaas/db/orders-db-svc.yaml b/example/sock-shop-openfaas/db/orders-db-svc.yaml new file mode 100644 index 0000000..4e00f83 --- /dev/null +++ b/example/sock-shop-openfaas/db/orders-db-svc.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: orders-db + labels: + name: orders-db + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 27017 + targetPort: 27017 + selector: + name: orders-db diff --git a/example/sock-shop-openfaas/db/rabbitmq-dep.yaml b/example/sock-shop-openfaas/db/rabbitmq-dep.yaml new file mode 100644 index 0000000..f3db289 --- /dev/null +++ b/example/sock-shop-openfaas/db/rabbitmq-dep.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rabbitmq + labels: + name: rabbitmq + namespace: openfaas-fn +spec: + replicas: 1 + selector: + matchLabels: + name: rabbitmq + template: + metadata: + labels: + name: rabbitmq + annotations: + prometheus.io/scrape: "false" + spec: + containers: + - name: rabbitmq + image: rabbitmq:3.6.8-management + ports: + - containerPort: 15672 + name: management + - containerPort: 5672 + name: rabbitmq + securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + - DAC_OVERRIDE + readOnlyRootFilesystem: true + - name: rabbitmq-exporter + image: kbudde/rabbitmq-exporter + ports: + - containerPort: 9090 + name: exporter + nodeSelector: + beta.kubernetes.io/os: linux diff --git a/example/sock-shop-openfaas/db/rabbitmq-svc.yaml b/example/sock-shop-openfaas/db/rabbitmq-svc.yaml new file mode 100644 index 0000000..5b32f33 --- /dev/null +++ b/example/sock-shop-openfaas/db/rabbitmq-svc.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: rabbitmq + labels: + name: rabbitmq + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 5672 + name: rabbitmq + targetPort: 5672 + - port: 9090 + name: exporter + targetPort: exporter + protocol: TCP + selector: + name: rabbitmq diff --git a/example/sock-shop-openfaas/db/session-db-dep.yaml b/example/sock-shop-openfaas/db/session-db-dep.yaml new file mode 100644 index 0000000..a0b577e --- /dev/null +++ b/example/sock-shop-openfaas/db/session-db-dep.yaml @@ -0,0 +1,37 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: session-db + labels: + name: session-db + namespace: openfaas-fn +spec: + replicas: 1 + selector: + matchLabels: + name: session-db + template: + metadata: + labels: + name: session-db + annotations: + prometheus.io.scrape: "false" + spec: + containers: + - name: session-db + image: redis:alpine + ports: + - name: redis + containerPort: 6379 + securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + readOnlyRootFilesystem: true + nodeSelector: + beta.kubernetes.io/os: linux diff --git a/example/sock-shop-openfaas/db/session-db-svc.yaml b/example/sock-shop-openfaas/db/session-db-svc.yaml new file mode 100644 index 0000000..1534c4f --- /dev/null +++ b/example/sock-shop-openfaas/db/session-db-svc.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: session-db + labels: + name: session-db + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 6379 + targetPort: 6379 + selector: + name: session-db diff --git a/example/sock-shop-openfaas/db/user-db-dep.yaml b/example/sock-shop-openfaas/db/user-db-dep.yaml new file mode 100644 index 0000000..71e068c --- /dev/null +++ b/example/sock-shop-openfaas/db/user-db-dep.yaml @@ -0,0 +1,46 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: user-db + labels: + name: user-db + namespace: openfaas-fn +spec: + replicas: 1 + selector: + matchLabels: + name: user-db + template: + metadata: + labels: + name: user-db + spec: + containers: + - name: user-db + image: weaveworksdemos/user-db:0.3.0 + ports: + - name: mongo + containerPort: 27017 + securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + readOnlyRootFilesystem: true + volumeMounts: + - mountPath: /tmp + name: tmp-volume + - mountPath: /data/db-users + name: cache-volume + volumes: + - name: tmp-volume + emptyDir: + medium: Memory + - name: cache-volume + emptyDir: { } + nodeSelector: + beta.kubernetes.io/os: linux diff --git a/example/sock-shop-openfaas/db/user-db-svc.yaml b/example/sock-shop-openfaas/db/user-db-svc.yaml new file mode 100644 index 0000000..b8f10cb --- /dev/null +++ b/example/sock-shop-openfaas/db/user-db-svc.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: user-db + labels: + name: user-db + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 27017 + targetPort: 27017 + selector: + name: user-db + diff --git a/example/sock-shop-openfaas/deployment/carts-dp-delete.yaml b/example/sock-shop-openfaas/deployment/carts-dp-delete.yaml new file mode 100644 index 0000000..15ab233 --- /dev/null +++ b/example/sock-shop-openfaas/deployment/carts-dp-delete.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"carts-delete","image":"weaveworksdemos/carts:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"1"},"requests":{"memory":"1000Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: carts-delete + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/carts-delete +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: carts-delete + controller: carts-delete + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"carts-delete","image":"weaveworksdemos/carts:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"1"},"requests":{"memory":"1000Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: carts-delete + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: carts-delete + faas_function: carts-delete + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: weaveworksdemos/carts:0.4.8 + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: carts-delete + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: "600m" + memory: 1000Mi + requests: + cpu: "600m" + memory: 1000Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "carts-delete" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/carts-dp-get.yaml b/example/sock-shop-openfaas/deployment/carts-dp-get.yaml new file mode 100644 index 0000000..0399e81 --- /dev/null +++ b/example/sock-shop-openfaas/deployment/carts-dp-get.yaml @@ -0,0 +1,123 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"carts-get","image":"weaveworksdemos/carts:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"1"},"requests":{"memory":"1000Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: carts-get + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/carts-get +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 5 + selector: + matchLabels: + app: carts-get + controller: carts-get + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"carts-get","image":"weaveworksdemos/carts:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"1"},"requests":{"memory":"1000Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: carts-get + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: carts-get + faas_function: carts-get + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: weaveworksdemos/carts:0.4.8 + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: carts-get + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: "600m" + memory: 1000Mi + requests: + cpu: "600m" + memory: 1000Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "carts-get" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/carts-dp-post.yaml b/example/sock-shop-openfaas/deployment/carts-dp-post.yaml new file mode 100644 index 0000000..499c038 --- /dev/null +++ b/example/sock-shop-openfaas/deployment/carts-dp-post.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"carts-post","image":"weaveworksdemos/carts:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"1"},"requests":{"memory":"1000Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: carts-post + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/carts-post +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: carts-post + controller: carts-post + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"carts-post","image":"weaveworksdemos/carts:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"1"},"requests":{"memory":"1000Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: carts-post + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: carts-post + faas_function: carts-post + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: weaveworksdemos/carts:0.4.8 + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: carts-post + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: "600m" + memory: 1000Mi + requests: + cpu: "600m" + memory: 1000Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "carts-post" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/carts-dp.yaml b/example/sock-shop-openfaas/deployment/carts-dp.yaml new file mode 100644 index 0000000..d1c6c1e --- /dev/null +++ b/example/sock-shop-openfaas/deployment/carts-dp.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"carts","image":"weaveworksdemos/carts:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"1"},"requests":{"memory":"1000Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: carts + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/carts +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: carts + controller: carts + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"carts","image":"weaveworksdemos/carts:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"1"},"requests":{"memory":"1000Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: carts + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: carts + faas_function: carts + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: weaveworksdemos/carts:0.4.8 + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: carts + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: "600m" + memory: 1000Mi + requests: + cpu: "600m" + memory: 1000Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "carts" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/catalogue-dp.yaml b/example/sock-shop-openfaas/deployment/catalogue-dp.yaml new file mode 100644 index 0000000..5aa7c5e --- /dev/null +++ b/example/sock-shop-openfaas/deployment/catalogue-dp.yaml @@ -0,0 +1,114 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"catalogue","image":"systemautoscaler/catalogue:dev","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"limits":{"memory":"500Mi","cpu":"50m"},"requests":{"memory":"500Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: catalogue + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/catalogue +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: catalogue + controller: catalogue + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"catalogue","image":"systemautoscaler/catalogue:dev","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"limits":{"memory":"500Mi","cpu":"50m"},"requests":{"memory":"500Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: catalogue + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: catalogue + faas_function: catalogue + spec: + containers: + - image: systemautoscaler/catalogue:openfaas-dev + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: catalogue + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: 50m + memory: 100Mi + requests: + cpu: 50m + memory: 100Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "catalogue" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/orders-dp.yaml b/example/sock-shop-openfaas/deployment/orders-dp.yaml new file mode 100644 index 0000000..884b994 --- /dev/null +++ b/example/sock-shop-openfaas/deployment/orders-dp.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"orders","image":"systemautoscaler/orders:dev","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1024Mi","cpu":"2"},"requests":{"memory":"1024Mi","cpu":"2"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: orders + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/orders +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: orders + controller: orders + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"orders","image":"systemautoscaler/orders:dev","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1024Mi","cpu":"2"},"requests":{"memory":"1024Mi","cpu":"2"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: orders + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: orders + faas_function: orders + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: systemautoscaler/orders:dev + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 120 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: orders + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: "600m" + memory: 1000Mi + requests: + cpu: "600m" + memory: 1000Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "orders" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/payment-dp.yaml b/example/sock-shop-openfaas/deployment/payment-dp.yaml new file mode 100644 index 0000000..a53d9f7 --- /dev/null +++ b/example/sock-shop-openfaas/deployment/payment-dp.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"payment","image":"systemautoscaler/payment:dev","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1024Mi","cpu":"50m"},"requests":{"memory":"1024Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: payment + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/payment +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: payment + controller: payment + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"payment","image":"systemautoscaler/payment:dev","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1024Mi","cpu":"50m"},"requests":{"memory":"1024Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: payment + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: payment + faas_function: payment + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: systemautoscaler/payment:openfaas-dev + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: payment + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: 50m + memory: 100Mi + requests: + cpu: 50m + memory: 100Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "payment" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/queue-master-dp.yaml b/example/sock-shop-openfaas/deployment/queue-master-dp.yaml new file mode 100644 index 0000000..d4ed7da --- /dev/null +++ b/example/sock-shop-openfaas/deployment/queue-master-dp.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"queue-master","image":"weaveworksdemos/queue-master:0.3.1","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1024Mi","cpu":"1"},"requests":{"memory":"1024Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: queue-master + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/queue-master +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: queue-master + controller: queue-master + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"queue-master","image":"weaveworksdemos/queue-master:0.3.1","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1024Mi","cpu":"1"},"requests":{"memory":"1024Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: queue-master + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: queue-master + faas_function: queue-master + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: weaveworksdemos/queue-master:0.3.1 + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: queue-master + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: "600m" + memory: 1000Mi + requests: + cpu: "600m" + memory: 1000Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "queue-master" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/shipping-dp.yaml b/example/sock-shop-openfaas/deployment/shipping-dp.yaml new file mode 100644 index 0000000..1125af1 --- /dev/null +++ b/example/sock-shop-openfaas/deployment/shipping-dp.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"shipping","image":"weaveworksdemos/shipping:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1024Mi","cpu":"1"},"requests":{"memory":"1024Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: shipping + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/shipping +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: shipping + controller: shipping + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"shipping","image":"weaveworksdemos/shipping:0.4.8","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1024Mi","cpu":"1"},"requests":{"memory":"1024Mi","cpu":"1"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: shipping + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: shipping + faas_function: shipping + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: weaveworksdemos/shipping:0.4.8 + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: shipping + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: "600m" + memory: 1000Mi + requests: + cpu: "600m" + memory: 1000Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "shipping" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/user-dp-login.yaml b/example/sock-shop-openfaas/deployment/user-dp-login.yaml new file mode 100644 index 0000000..e69d65f --- /dev/null +++ b/example/sock-shop-openfaas/deployment/user-dp-login.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"user-login","image":"systemautoscaler/user:dev","annotations":{"com.openfaas.health.http.initialDelay":"30s","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"50m"},"requests":{"memory":"1000Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 30s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: user-login + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/user-login +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: user-login + controller: user-login + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"user-login","image":"systemautoscaler/user:dev","annotations":{"com.openfaas.health.http.initialDelay":"30s","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"50m"},"requests":{"memory":"1000Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 30s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: user-login + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: user-login + faas_function: user-login + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: systemautoscaler/user:openfaas-dev + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: user-login + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: 50m + memory: 100Mi + requests: + cpu: 50m + memory: 100Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "user-login" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/user-dp-register.yaml b/example/sock-shop-openfaas/deployment/user-dp-register.yaml new file mode 100644 index 0000000..12cdf81 --- /dev/null +++ b/example/sock-shop-openfaas/deployment/user-dp-register.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"user-register","image":"systemautoscaler/user:dev","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"50m"},"requests":{"memory":"1000Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: user-register + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/user-register +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: user-register + controller: user-register + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"user-register","image":"systemautoscaler/user:dev","annotations":{"com.openfaas.health.http.initialDelay":"5m","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"50m"},"requests":{"memory":"1000Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 5s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: user-register + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: user-register + faas_function: user-register + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: systemautoscaler/user:openfaas-dev + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: user-register + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: 50m + memory: 100Mi + requests: + cpu: 50m + memory: 100Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "user-register" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/deployment/user-dp.yaml b/example/sock-shop-openfaas/deployment/user-dp.yaml new file mode 100644 index 0000000..5f7b676 --- /dev/null +++ b/example/sock-shop-openfaas/deployment/user-dp.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + com.openfaas.function.spec: '{"name":"user","image":"systemautoscaler/user:dev","annotations":{"com.openfaas.health.http.initialDelay":"30s","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"50m"},"requests":{"memory":"1000Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 30s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "true" + name: user + namespace: openfaas-fn + selfLink: /apis/apps/v1/namespaces/openfaas-fn/deployments/user +spec: + progressDeadlineSeconds: 600 + replicas: 1 + selector: + matchLabels: + app: user + controller: user + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + com.openfaas.function.spec: '{"name":"user","image":"systemautoscaler/user:dev","annotations":{"com.openfaas.health.http.initialDelay":"30s","com.openfaas.health.http.path":"/health"},"labels":{"com.openfaas.scale.max":"10","com.openfaas.scale.min":"0","com.openfaas.scale.zero":"true"},"environment":{"JAVA_OPTS":"-Xms64m + -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + -Dserver.port=8080"},"limits":{"memory":"1000Mi","cpu":"50m"},"requests":{"memory":"1000Mi","cpu":"50m"},"readOnlyRootFilesystem":false}' + com.openfaas.health.http.initialDelay: 30s + com.openfaas.health.http.path: /health + prometheus.io.scrape: "false" + creationTimestamp: null + labels: + app: user + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + controller: user + faas_function: user + spec: + containers: + - env: + - name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom + -Dspring.zipkin.enabled=false -Dserver.port=7777 + image: systemautoscaler/user:openfaas-dev + imagePullPolicy: Always + livenessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + name: user + ports: + - containerPort: 7777 + protocol: TCP + readinessProbe: + failureThreshold: 1000 + httpGet: + path: /health + port: 7777 + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 60 + resources: + limits: + cpu: 50m + memory: 100Mi + requests: + cpu: 50m + memory: 100Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + - name: http-metrics + image: systemautoscaler/http-metrics:openfaas-dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + env: + - name: ADDRESS + value: "localhost" + - name: APP_PORT + value: "7777" + - name: WINDOW_SIZE + value: "30s" + - name: WINDOW_GRANULARITY + value: "1ms" + - name: NODE + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: FUNCTION + value: "user" + - name: COMMUNITY + value: "none" + - name: NAMESPACE + value: "openfaas-fn" + resources: + requests: + memory: 128Mi + cpu: 50m + limits: + memory: 128Mi + cpu: 50m + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 10 diff --git a/example/sock-shop-openfaas/front-end-svc.yaml b/example/sock-shop-openfaas/front-end-svc.yaml new file mode 100644 index 0000000..53add80 --- /dev/null +++ b/example/sock-shop-openfaas/front-end-svc.yaml @@ -0,0 +1,51 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: front-end + labels: + name: front-end + namespace: openfaas-fn +spec: + selector: + app: front-end +# edgeautoscaler.polimi.it/function-name: "front-end" +# edgeautoscaler.polimi.it/function-namespace: "openfaas-fn" + ports: + # the port that this service should serve on + - port: 80 + targetPort: 8080 + topologyKeys: + - "kubernetes.io/hostname" + - "*" +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: front-end + namespace: openfaas-fn + labels: + app: front-end +spec: + selector: + matchLabels: + app: front-end + template: + metadata: + labels: + app: front-end + spec: + automountServiceAccountToken: true + containers: + - name: front-end + image: systemautoscaler/front-end:dev + imagePullPolicy: Always + ports: + - containerPort: 8080 + resources: + requests: + memory: 128Mi + cpu: 1 + limits: + memory: 128Mi + cpu: 1 diff --git a/example/sock-shop-openfaas/function/carts-fn-delete.yaml b/example/sock-shop-openfaas/function/carts-fn-delete.yaml new file mode 100644 index 0000000..a8ab5e3 --- /dev/null +++ b/example/sock-shop-openfaas/function/carts-fn-delete.yaml @@ -0,0 +1,23 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: carts-delete + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: carts-delete + image: weaveworksdemos/carts:0.4.8 + environment: + JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" + limits: + cpu: "600m" + memory: "1000Mi" + requests: + cpu: "600m" + memory: "1000Mi" diff --git a/example/sock-shop-openfaas/function/carts-fn-get.yaml b/example/sock-shop-openfaas/function/carts-fn-get.yaml new file mode 100644 index 0000000..b18916a --- /dev/null +++ b/example/sock-shop-openfaas/function/carts-fn-get.yaml @@ -0,0 +1,23 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: carts-get + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: carts-get + image: weaveworksdemos/carts:0.4.8 + environment: + JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" + limits: + cpu: "600m" + memory: "1000Mi" + requests: + cpu: "600m" + memory: "1000Mi" diff --git a/example/sock-shop-openfaas/function/carts-fn-post.yaml b/example/sock-shop-openfaas/function/carts-fn-post.yaml new file mode 100644 index 0000000..348db9c --- /dev/null +++ b/example/sock-shop-openfaas/function/carts-fn-post.yaml @@ -0,0 +1,23 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: carts-post + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: carts-post + image: weaveworksdemos/carts:0.4.8 + environment: + JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" + limits: + cpu: "600m" + memory: "1000Mi" + requests: + cpu: "600m" + memory: "1000Mi" diff --git a/example/sock-shop-openfaas/function/carts-fn.yaml b/example/sock-shop-openfaas/function/carts-fn.yaml new file mode 100644 index 0000000..3134461 --- /dev/null +++ b/example/sock-shop-openfaas/function/carts-fn.yaml @@ -0,0 +1,23 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: carts + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: carts + image: weaveworksdemos/carts:0.4.8 + environment: + JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" + limits: + cpu: "600m" + memory: "1000Mi" + requests: + cpu: "600m" + memory: "1000Mi" diff --git a/example/sock-shop-openfaas/function/catalogue-fn.yaml b/example/sock-shop-openfaas/function/catalogue-fn.yaml new file mode 100644 index 0000000..adc00d7 --- /dev/null +++ b/example/sock-shop-openfaas/function/catalogue-fn.yaml @@ -0,0 +1,21 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: catalogue + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: catalogue + image: systemautoscaler/catalogue:dev + limits: + cpu: "50m" + memory: "100Mi" + requests: + cpu: "50m" + memory: "100Mi" diff --git a/example/sock-shop-openfaas/function/orders-fn.yaml b/example/sock-shop-openfaas/function/orders-fn.yaml new file mode 100644 index 0000000..96fb126 --- /dev/null +++ b/example/sock-shop-openfaas/function/orders-fn.yaml @@ -0,0 +1,23 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: orders + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: orders + image: systemautoscaler/orders:dev + environment: + JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" + limits: + cpu: "600m" + memory: "1000Mi" + requests: + cpu: "600m" + memory: "1000Mi" diff --git a/example/sock-shop-openfaas/function/payment-fn.yaml b/example/sock-shop-openfaas/function/payment-fn.yaml new file mode 100644 index 0000000..a3e0ac3 --- /dev/null +++ b/example/sock-shop-openfaas/function/payment-fn.yaml @@ -0,0 +1,21 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: payment + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: payment + image: systemautoscaler/payment:dev + limits: + cpu: "50m" + memory: "100Mi" + requests: + cpu: "50m" + memory: "100Mi" diff --git a/example/sock-shop-openfaas/function/queue-master-fn.yaml b/example/sock-shop-openfaas/function/queue-master-fn.yaml new file mode 100644 index 0000000..dc36793 --- /dev/null +++ b/example/sock-shop-openfaas/function/queue-master-fn.yaml @@ -0,0 +1,23 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: queue-master + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: queue-master + image: weaveworksdemos/queue-master:0.3.1 + environment: + JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" + limits: + cpu: "600m" + memory: "1000Mi" + requests: + cpu: "600m" + memory: "1000Mi" diff --git a/example/sock-shop-openfaas/function/shipping-fn.yaml b/example/sock-shop-openfaas/function/shipping-fn.yaml new file mode 100644 index 0000000..2e08471 --- /dev/null +++ b/example/sock-shop-openfaas/function/shipping-fn.yaml @@ -0,0 +1,23 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: shipping + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: shipping + image: weaveworksdemos/shipping:0.4.8 + environment: + JAVA_OPTS: "-Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false -Dserver.port=8080" + limits: + cpu: "600m" + memory: "1000Mi" + requests: + cpu: "600m" + memory: "1000Mi" diff --git a/example/sock-shop-openfaas/function/user-fn-login.yaml b/example/sock-shop-openfaas/function/user-fn-login.yaml new file mode 100644 index 0000000..eed1507 --- /dev/null +++ b/example/sock-shop-openfaas/function/user-fn-login.yaml @@ -0,0 +1,21 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: user-login + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: user-login + image: systemautoscaler/user:dev + limits: + cpu: "50m" + memory: "100Mi" + requests: + cpu: "50m" + memory: "100Mi" diff --git a/example/sock-shop-openfaas/function/user-fn-register.yaml b/example/sock-shop-openfaas/function/user-fn-register.yaml new file mode 100644 index 0000000..f57df5f --- /dev/null +++ b/example/sock-shop-openfaas/function/user-fn-register.yaml @@ -0,0 +1,21 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: user-register + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: user-register + image: systemautoscaler/user:dev + limits: + cpu: "50m" + memory: "100Mi" + requests: + cpu: "50m" + memory: "100Mi" diff --git a/example/sock-shop-openfaas/function/user-fn.yaml b/example/sock-shop-openfaas/function/user-fn.yaml new file mode 100644 index 0000000..6d9050b --- /dev/null +++ b/example/sock-shop-openfaas/function/user-fn.yaml @@ -0,0 +1,21 @@ +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: user + namespace: openfaas-fn +spec: + labels: + com.openfaas.scale.max: "10" + com.openfaas.scale.min: "1" + com.openfaas.scale.zero: "true" + annotations: + com.openfaas.health.http.path: "/health" + com.openfaas.health.http.initialDelay: "30s" + name: user + image: systemautoscaler/user:dev + limits: + cpu: "50m" + memory: "100Mi" + requests: + cpu: "50m" + memory: "100Mi" diff --git a/example/sock-shop-openfaas/hpa/carts-sla-delete.yml b/example/sock-shop-openfaas/hpa/carts-sla-delete.yml new file mode 100644 index 0000000..3fa13a6 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/carts-sla-delete.yml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: carts-delete + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: carts-delete + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa/carts-sla.yml b/example/sock-shop-openfaas/hpa/carts-sla.yml new file mode 100644 index 0000000..a52a084 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/carts-sla.yml @@ -0,0 +1,32 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: carts + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: carts + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 diff --git a/example/sock-shop-openfaas/hpa/carts-svc-get.yml b/example/sock-shop-openfaas/hpa/carts-svc-get.yml new file mode 100644 index 0000000..16c2f18 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/carts-svc-get.yml @@ -0,0 +1,32 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: carts-get + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: carts-get + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 diff --git a/example/sock-shop-openfaas/hpa/carts-svc-post.yml b/example/sock-shop-openfaas/hpa/carts-svc-post.yml new file mode 100644 index 0000000..b86fe89 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/carts-svc-post.yml @@ -0,0 +1,32 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: carts-post + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: carts-post + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 diff --git a/example/sock-shop-openfaas/hpa/catalogue-svc.yaml b/example/sock-shop-openfaas/hpa/catalogue-svc.yaml new file mode 100644 index 0000000..372d1dd --- /dev/null +++ b/example/sock-shop-openfaas/hpa/catalogue-svc.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: catalogue + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: catalogue + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa/orders-svc.yaml b/example/sock-shop-openfaas/hpa/orders-svc.yaml new file mode 100644 index 0000000..a47febe --- /dev/null +++ b/example/sock-shop-openfaas/hpa/orders-svc.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: orders + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: orders + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa/payment-svc.yaml b/example/sock-shop-openfaas/hpa/payment-svc.yaml new file mode 100644 index 0000000..ad9ed03 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/payment-svc.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: payment + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: payment + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa/queue-master-svc.yaml b/example/sock-shop-openfaas/hpa/queue-master-svc.yaml new file mode 100644 index 0000000..2686de6 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/queue-master-svc.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: queue-master + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: queue-master + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa/shipping-svc.yaml b/example/sock-shop-openfaas/hpa/shipping-svc.yaml new file mode 100644 index 0000000..60c9410 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/shipping-svc.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: shipping + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: shipping + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa/user-svc-login.yaml b/example/sock-shop-openfaas/hpa/user-svc-login.yaml new file mode 100644 index 0000000..0cf09f8 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/user-svc-login.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: user-login + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: user-login + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa/user-svc-register.yaml b/example/sock-shop-openfaas/hpa/user-svc-register.yaml new file mode 100644 index 0000000..c7334f4 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/user-svc-register.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: user-register + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: user-register + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa/user-svc.yaml b/example/sock-shop-openfaas/hpa/user-svc.yaml new file mode 100644 index 0000000..69f30d8 --- /dev/null +++ b/example/sock-shop-openfaas/hpa/user-svc.yaml @@ -0,0 +1,33 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: user + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: user + minReplicas: 1 + maxReplicas: 20 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + behavior: + scaleDown: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/carts-sla-delete.yml b/example/sock-shop-openfaas/hpa_rt/carts-sla-delete.yml new file mode 100644 index 0000000..8a13abb --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/carts-sla-delete.yml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: carts-delete + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: carts-delete + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: carts-delete + target: + type: Value + value: 25m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/carts-sla.yml b/example/sock-shop-openfaas/hpa_rt/carts-sla.yml new file mode 100644 index 0000000..fae2956 --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/carts-sla.yml @@ -0,0 +1,37 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: carts + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: carts + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: carts + target: + type: Value + value: 50m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 diff --git a/example/sock-shop-openfaas/hpa_rt/carts-svc-get.yml b/example/sock-shop-openfaas/hpa_rt/carts-svc-get.yml new file mode 100644 index 0000000..6115f11 --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/carts-svc-get.yml @@ -0,0 +1,37 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: carts-get + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: carts-get + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: carts-get + target: + type: Value + value: 50m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 diff --git a/example/sock-shop-openfaas/hpa_rt/carts-svc-post.yml b/example/sock-shop-openfaas/hpa_rt/carts-svc-post.yml new file mode 100644 index 0000000..c1b65b1 --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/carts-svc-post.yml @@ -0,0 +1,37 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: carts-post + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: carts-post + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: carts-post + target: + type: Value + value: 150m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 diff --git a/example/sock-shop-openfaas/hpa_rt/catalogue-svc.yaml b/example/sock-shop-openfaas/hpa_rt/catalogue-svc.yaml new file mode 100644 index 0000000..1beb3ad --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/catalogue-svc.yaml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: catalogue + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: catalogue + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: catalogue + target: + type: Value + value: 25m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/orders-svc.yaml b/example/sock-shop-openfaas/hpa_rt/orders-svc.yaml new file mode 100644 index 0000000..87c5ecf --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/orders-svc.yaml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: orders + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: orders + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: orders + target: + type: Value + value: 300m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/payment-svc.yaml b/example/sock-shop-openfaas/hpa_rt/payment-svc.yaml new file mode 100644 index 0000000..bcb5c31 --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/payment-svc.yaml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: payment + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: payment + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: payment + target: + type: Value + value: 10m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/queue-master-svc.yaml b/example/sock-shop-openfaas/hpa_rt/queue-master-svc.yaml new file mode 100644 index 0000000..4dbb63f --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/queue-master-svc.yaml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: queue-master + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: queue-master + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: queue-master + target: + type: Value + value: 100m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/shipping-svc.yaml b/example/sock-shop-openfaas/hpa_rt/shipping-svc.yaml new file mode 100644 index 0000000..8fc6781 --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/shipping-svc.yaml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: shipping + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: shipping + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: shipping + target: + type: Value + value: 10m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/user-svc-login.yaml b/example/sock-shop-openfaas/hpa_rt/user-svc-login.yaml new file mode 100644 index 0000000..4d374c7 --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/user-svc-login.yaml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: user-login + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: user-login + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: user-login + target: + type: Value + value: 50m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/user-svc-register.yaml b/example/sock-shop-openfaas/hpa_rt/user-svc-register.yaml new file mode 100644 index 0000000..1ec1169 --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/user-svc-register.yaml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: user-register + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: user-register + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: user-register + target: + type: Value + value: 25m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/hpa_rt/user-svc.yaml b/example/sock-shop-openfaas/hpa_rt/user-svc.yaml new file mode 100644 index 0000000..0a9c5ec --- /dev/null +++ b/example/sock-shop-openfaas/hpa_rt/user-svc.yaml @@ -0,0 +1,38 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: user + namespace: openfaas-fn +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: user + minReplicas: 1 + maxReplicas: 50 + metrics: + - type: Object + object: + metric: + name: response_time + describedObject: + apiVersion: /v1 + kind: Service + name: user + target: + type: Value + value: 25m + behavior: + scaleDown: + stabilizationWindowSeconds: 30 + policies: + - type: Pods + value: 5 + periodSeconds: 15 + scaleUp: + stabilizationWindowSeconds: 15 + policies: + - type: Pods + value: 1 + periodSeconds: 15 + diff --git a/example/sock-shop-openfaas/service/carts-svc-delete.yml b/example/sock-shop-openfaas/service/carts-svc-delete.yml new file mode 100644 index 0000000..ee53705 --- /dev/null +++ b/example/sock-shop-openfaas/service/carts-svc-delete.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: carts-delete + labels: + app: carts-delete + namespace: openfaas-fn +spec: + ports: + - port: 80 + targetPort: 8080 + selector: + app: carts-delete + topologyKeys: + - "kubernetes.io/hostname" + - "*" + diff --git a/example/sock-shop-openfaas/service/carts-svc-get.yml b/example/sock-shop-openfaas/service/carts-svc-get.yml new file mode 100644 index 0000000..4dff3f9 --- /dev/null +++ b/example/sock-shop-openfaas/service/carts-svc-get.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: carts-get + labels: + app: carts-get + namespace: openfaas-fn +spec: + ports: + - port: 80 + targetPort: 8080 + selector: + app: carts-get + topologyKeys: + - "kubernetes.io/hostname" + - "*" + diff --git a/example/sock-shop-openfaas/service/carts-svc-post.yml b/example/sock-shop-openfaas/service/carts-svc-post.yml new file mode 100644 index 0000000..b1b5115 --- /dev/null +++ b/example/sock-shop-openfaas/service/carts-svc-post.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: carts-post + labels: + app: carts-post + namespace: openfaas-fn +spec: + ports: + - port: 80 + targetPort: 8080 + selector: + app: carts-post + topologyKeys: + - "kubernetes.io/hostname" + - "*" + diff --git a/example/sock-shop-openfaas/service/carts-svc.yml b/example/sock-shop-openfaas/service/carts-svc.yml new file mode 100644 index 0000000..cbffc50 --- /dev/null +++ b/example/sock-shop-openfaas/service/carts-svc.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: carts + labels: + app: carts + namespace: openfaas-fn +spec: + ports: + - port: 80 + targetPort: 8080 + selector: + app: carts + topologyKeys: + - "kubernetes.io/hostname" + - "*" + diff --git a/example/sock-shop-openfaas/service/catalogue-svc.yaml b/example/sock-shop-openfaas/service/catalogue-svc.yaml new file mode 100644 index 0000000..f80eaa2 --- /dev/null +++ b/example/sock-shop-openfaas/service/catalogue-svc.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: catalogue + labels: + app: catalogue + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 8080 + selector: + app: catalogue + topologyKeys: + - "kubernetes.io/hostname" + - "*" + diff --git a/example/sock-shop-openfaas/service/orders-svc.yaml b/example/sock-shop-openfaas/service/orders-svc.yaml new file mode 100644 index 0000000..91822fc --- /dev/null +++ b/example/sock-shop-openfaas/service/orders-svc.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: orders + labels: + app: orders + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 8080 + selector: + app: orders + topologyKeys: + - "kubernetes.io/hostname" + - "*" + diff --git a/example/sock-shop-openfaas/service/payment-svc.yaml b/example/sock-shop-openfaas/service/payment-svc.yaml new file mode 100644 index 0000000..de54aa8 --- /dev/null +++ b/example/sock-shop-openfaas/service/payment-svc.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: payment + labels: + app: payment + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 8080 + selector: + app: payment + topologyKeys: + - "kubernetes.io/hostname" + - "*" diff --git a/example/sock-shop-openfaas/service/queue-master-svc.yaml b/example/sock-shop-openfaas/service/queue-master-svc.yaml new file mode 100644 index 0000000..f83d9d7 --- /dev/null +++ b/example/sock-shop-openfaas/service/queue-master-svc.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: queue-master + labels: + app: queue-master + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 80 + selector: + app: queue-master diff --git a/example/sock-shop-openfaas/service/shipping-svc.yaml b/example/sock-shop-openfaas/service/shipping-svc.yaml new file mode 100644 index 0000000..9885034 --- /dev/null +++ b/example/sock-shop-openfaas/service/shipping-svc.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: shipping + labels: + app: shipping + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 8080 + selector: + app: shipping + topologyKeys: + - "kubernetes.io/hostname" + - "*" + + diff --git a/example/sock-shop-openfaas/service/user-svc-login.yaml b/example/sock-shop-openfaas/service/user-svc-login.yaml new file mode 100644 index 0000000..bd298ae --- /dev/null +++ b/example/sock-shop-openfaas/service/user-svc-login.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: user-login + labels: + app: user-login + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 8080 + selector: + app: user-login + topologyKeys: + - "kubernetes.io/hostname" + - "*" + + diff --git a/example/sock-shop-openfaas/service/user-svc-register.yaml b/example/sock-shop-openfaas/service/user-svc-register.yaml new file mode 100644 index 0000000..658deec --- /dev/null +++ b/example/sock-shop-openfaas/service/user-svc-register.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: user-register + labels: + app: user-register + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 8080 + selector: + app: user-register + topologyKeys: + - "kubernetes.io/hostname" + - "*" + + diff --git a/example/sock-shop-openfaas/service/user-svc.yaml b/example/sock-shop-openfaas/service/user-svc.yaml new file mode 100644 index 0000000..1415234 --- /dev/null +++ b/example/sock-shop-openfaas/service/user-svc.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: user + labels: + app: user + namespace: openfaas-fn +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 8080 + selector: + app: user + topologyKeys: + - "kubernetes.io/hostname" + - "*" + + diff --git a/example/sock-shop-openfaas/sock-shop-ns.yaml b/example/sock-shop-openfaas/sock-shop-ns.yaml new file mode 100644 index 0000000..00787e3 --- /dev/null +++ b/example/sock-shop-openfaas/sock-shop-ns.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: sock-shop diff --git a/example/sock-shop/carts-db-dep.yaml b/example/sock-shop/carts-db-dep.yaml index dba3f27..c5aee33 100644 --- a/example/sock-shop/carts-db-dep.yaml +++ b/example/sock-shop/carts-db-dep.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: carts-db - image: mongo + image: systemautoscaler/mongo-carts:dev ports: - name: mongo containerPort: 27017 diff --git a/pkg/apis/edgeautoscaler/v1alpha1/types.go b/pkg/apis/edgeautoscaler/v1alpha1/types.go index f078ccf..b557587 100644 --- a/pkg/apis/edgeautoscaler/v1alpha1/types.go +++ b/pkg/apis/edgeautoscaler/v1alpha1/types.go @@ -44,7 +44,7 @@ type CommunityConfigurationSpec struct { // CommunitySize is the upper bound on the community size CommunitySize int64 `json:"community-size"` // +kubebuilder:validation:Required - // +kubebuilder:validation:Maximum=100 + // +kubebuilder:validation:Maximum=10000 // +kubebuilder:validation:Minimum=0 // MaximumDelay is the upper bound for the delay inside a community measured in milliseconds MaximumDelay int32 `json:"maximum-delay"` diff --git a/pkg/community-controller/pkg/controller/community-controller.go b/pkg/community-controller/pkg/controller/community-controller.go index 23bb98b..da0a1c8 100644 --- a/pkg/community-controller/pkg/controller/community-controller.go +++ b/pkg/community-controller/pkg/controller/community-controller.go @@ -143,17 +143,20 @@ func (c *CommunityController) Run(threadiness int, stopCh <-chan struct{}) error klog.Info("Starting system controller workers") for i := 0; i < threadiness; i++ { - // TODO: Currently the scheduler reschedules pods every 30 seconds. It should be change to be triggered by event or as cron jobs - go wait.Until(c.runPeriodicScheduleWorker, 180*time.Second, stopCh) + // TODO: Currently the scheduler reschedules pods every 180 seconds. It should be change to be triggered by event or as cron jobs go wait.Until(c.runSyncCommunitySchedule, time.Second, stopCh) } + go wait.Until(c.runPeriodicScheduleWorker, 300*time.Second, stopCh) return nil } // runPeriodicScheduleWorker is a worker which runs the scheduling algorithm func (c *CommunityController) runPeriodicScheduleWorker() { - _ = c.runScheduler("") + err := c.runScheduler("") + if err != nil { + klog.Info(err) + } } // runSyncCommunitySchedule is a worker which looks for inconsistencies between diff --git a/pkg/community-controller/pkg/controller/sync.go b/pkg/community-controller/pkg/controller/sync.go index 44fe5f7..983d272 100644 --- a/pkg/community-controller/pkg/controller/sync.go +++ b/pkg/community-controller/pkg/controller/sync.go @@ -6,7 +6,11 @@ import ( rand "math/rand" "strings" + "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/pointer" + "github.com/lterrac/edge-autoscaler/pkg/apis/edgeautoscaler/v1alpha1" + dispatcher "github.com/lterrac/edge-autoscaler/pkg/dispatcher/pkg/controller" ealabels "github.com/lterrac/edge-autoscaler/pkg/labels" openfaasv1 "github.com/openfaas/faas-netes/pkg/apis/openfaas/v1" corev1 "k8s.io/api/core/v1" @@ -27,6 +31,11 @@ const ( HttpMetricsCpu = 100 HttpMetricsMemory = 200000000 DefaultAppPort = "8080" + SchedulerName = "edge-autoscaler" +) + +var ( + DefaultTerminationGracePeriodSeconds = pointer.Int64(20) ) func (c *CommunityController) runScheduler(_ string) error { @@ -160,8 +169,10 @@ func (c *CommunityController) sync(cs *v1alpha1.CommunitySchedule, pods []*corev var err error // used to delete duplicated pods - deleteSet := make([]*corev1.Pod, 0) - createSet := make([]*corev1.Pod, 0) + deleteMap := make(map[string][]*corev1.Pod) + createMap := make(map[string][]*corev1.Pod) + actualPods := make(map[string][]*corev1.Pod) + outOfCPUPods := make([]*corev1.Pod, 0) // Find the pods that are correctly deployed // Pods which are not correctly deployed are appended in the deleteSet @@ -176,26 +187,32 @@ func (c *CommunityController) sync(cs *v1alpha1.CommunitySchedule, pods []*corev podsMap[fKey] = make(map[string]*corev1.Pod) } + if _, ok := deleteMap[fKey]; !ok { + deleteMap[fKey] = make([]*corev1.Pod, 0) + } + if _, ok := podsMap[fKey][pod.Spec.NodeName]; ok { - deleteSet = append(deleteSet, pod) + deleteMap[fKey] = append(deleteMap[fKey], pod) } else { podsMap[fKey][pod.Spec.NodeName] = pod } } } } - } - for _, pod := range createSet { - klog.Infof("creating pod %s", pod.Name) + + if pod.Status.Phase == corev1.PodFailed && pod.Status.Reason == "OutOfcpu" { + outOfCPUPods = append(outOfCPUPods, pod) + } + } // Compute the pod creation set // Pods which are correctly deployed are deleted from podsMap, in this way podsMap will contain only pods // which should be deleted - for functionKey, nodes := range functionKeys { - fNamespace, fName, err := cache.SplitMetaNamespaceKey(functionKey) + for fKey, nodes := range functionKeys { + fNamespace, fName, err := cache.SplitMetaNamespaceKey(fKey) if err != nil { - klog.Errorf("invalid resource key: %s", functionKey) + klog.Errorf("invalid resource key: %s", fKey) return err } function, err := c.listers.Functions(fNamespace).Get(fName) @@ -205,8 +222,13 @@ func (c *CommunityController) sync(cs *v1alpha1.CommunitySchedule, pods []*corev } for nodeName, ok := range nodes { if ok { - if _, ok := podsMap[functionKey][nodeName]; ok { - delete(podsMap[functionKey], nodeName) + if _, ok := podsMap[fKey][nodeName]; ok { + if _, ok := actualPods[fKey]; !ok { + actualPods[fKey] = make([]*corev1.Pod, 0) + } + + actualPods[fKey] = append(actualPods[fKey], podsMap[fKey][nodeName]) + delete(podsMap[fKey], nodeName) continue } @@ -225,33 +247,85 @@ func (c *CommunityController) sync(cs *v1alpha1.CommunitySchedule, pods []*corev pod = newCPUPod(function, cs, node) } - createSet = append(createSet, pod) + if _, ok := createMap[fKey]; !ok { + createMap[fKey] = make([]*corev1.Pod, 0) + } + createMap[fKey] = append(createMap[fKey], pod) } } } - for _, nodes := range podsMap { + for fKey, nodes := range podsMap { for _, pod := range nodes { - deleteSet = append(deleteSet, pod) + deleteMap[fKey] = append(deleteMap[fKey], pod) } } - for _, pod := range createSet { - node := pod.Labels[ealabels.NodeLabel] - pod, err = c.kubernetesClientset.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{}) - if err != nil { - klog.Errorf("failed to create pod %s/%s, with error %v", pod.Namespace, pod.Name, err) - return err + for fKey, pods := range createMap { + for _, pod := range pods { + node := pod.Labels[ealabels.NodeLabel] + pod, err = c.kubernetesClientset.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{}) + if err != nil { + klog.Errorf("failed to create pod %s/%s, with error %v", pod.Namespace, pod.Name, err) + return err + } + err = c.bind(pod, node) + if err != nil { + klog.Errorf("failed to bind pod %s/%s to node %s, with error %v", pod.Namespace, pod.Name, node, err) + return err + } + klog.Infof("created function %s pod %s", fKey, pod.Name) } - err = c.bind(pod, node) - if err != nil { - klog.Errorf("failed to bind pod %s/%s to node %s, with error %v", pod.Namespace, pod.Name, node, err) - return err + } + + for fKey, pods := range createMap { + for _, pod := range pods { + pod, err = c.kubernetesClientset.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{}) + if err != nil { + klog.Errorf("failed to get pod %s/%s, with error %v", pod.Namespace, pod.Name, err) + return err + } + + // do not delete old pods if all the new ones are not ready + if !dispatcher.IsPodReady(pod) { + klog.Infof("function %s is not ready, skipping delete set", fKey) + deleteMap[fKey] = nil + break + } } } - for _, pod := range deleteSet { + for fKey, pods := range actualPods { + for _, pod := range pods { + pod, err = c.kubernetesClientset.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{}) + if err != nil { + klog.Errorf("failed to get pod %s/%s, with error %v", pod.Namespace, pod.Name, err) + return err + } + + // do not delete old pods if all the new ones are not ready + if !dispatcher.IsPodReady(pod) { + klog.Infof("function %s is not ready, skipping delete set", fKey) + deleteMap[fKey] = nil + break + } + } + } + + for fKey, pods := range deleteMap { + for _, pod := range pods { + err = c.kubernetesClientset.CoreV1().Pods(pod.Namespace).Delete(context.TODO(), pod.Name, metav1.DeleteOptions{}) + if err != nil { + klog.Errorf("failed to delete pod %s/%s, with error %v", pod.Namespace, pod.Name, err) + return err + } + klog.Infof("delete function %s pod %s", fKey, pod.Name) + + } + } + + for _, pod := range outOfCPUPods { err = c.kubernetesClientset.CoreV1().Pods(pod.Namespace).Delete(context.TODO(), pod.Name, metav1.DeleteOptions{}) if err != nil { klog.Errorf("failed to delete pod %s/%s, with error %v", pod.Namespace, pod.Name, err) @@ -303,7 +377,8 @@ func newCPUPod(function *openfaasv1.Function, cs *v1alpha1.CommunitySchedule, no }, }, Spec: corev1.PodSpec{ - SchedulerName: "edge-autoscaler", + SchedulerName: SchedulerName, + TerminationGracePeriodSeconds: DefaultTerminationGracePeriodSeconds, Containers: []corev1.Container{ { Name: function.Spec.Name, @@ -373,6 +448,32 @@ func newCPUPod(function *openfaasv1.Function, cs *v1alpha1.CommunitySchedule, no corev1.ResourceMemory: *resource.NewQuantity(HttpMetricsMemory, resource.BinarySI), }, }, + LivenessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/health", + Port: intstr.FromInt(8080), + }, + }, + InitialDelaySeconds: 5, + TimeoutSeconds: 60, + PeriodSeconds: 5, + SuccessThreshold: 1, + FailureThreshold: 1000, + }, + ReadinessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/health", + Port: intstr.FromInt(8080), + }, + }, + InitialDelaySeconds: 5, + TimeoutSeconds: 60, + PeriodSeconds: 5, + SuccessThreshold: 1, + FailureThreshold: 1000, + }, }, }, }, @@ -438,7 +539,6 @@ func newGPUPod(function *openfaasv1.Function, cs *v1alpha1.CommunitySchedule, no ealabels.CommunityLabel.WithNamespace(cs.Namespace).String(): cs.Name, ealabels.NodeLabel: node.Name, ealabels.GpuFunctionLabel: "", - "autoscaling": "vertical", }, OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(function, schema.GroupVersionKind{ @@ -449,8 +549,9 @@ func newGPUPod(function *openfaasv1.Function, cs *v1alpha1.CommunitySchedule, no }, }, Spec: corev1.PodSpec{ - SchedulerName: "edge-autoscaler", - HostIPC: true, + SchedulerName: "edge-autoscaler", + HostIPC: true, + TerminationGracePeriodSeconds: DefaultTerminationGracePeriodSeconds, Volumes: []corev1.Volume{ { Name: "nvidia-mps", @@ -538,6 +639,32 @@ func newGPUPod(function *openfaasv1.Function, cs *v1alpha1.CommunitySchedule, no corev1.ResourceMemory: *resource.NewQuantity(HttpMetricsMemory, resource.BinarySI), }, }, + LivenessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/health", + Port: intstr.FromInt(8080), + }, + }, + InitialDelaySeconds: 5, + TimeoutSeconds: 60, + PeriodSeconds: 5, + SuccessThreshold: 1, + FailureThreshold: 1000, + }, + ReadinessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/health", + Port: intstr.FromInt(8080), + }, + }, + InitialDelaySeconds: 5, + TimeoutSeconds: 60, + PeriodSeconds: 5, + SuccessThreshold: 1, + FailureThreshold: 1000, + }, }, }, }, diff --git a/pkg/cpu-monitoring/pkg/scraper/scraper.go b/pkg/cpu-monitoring/pkg/scraper/scraper.go index d1819bf..4fd4e6b 100644 --- a/pkg/cpu-monitoring/pkg/scraper/scraper.go +++ b/pkg/cpu-monitoring/pkg/scraper/scraper.go @@ -38,7 +38,7 @@ type defaultScraper struct { // DefaultScraper scrapes all pods running on the node func DefaultScraper(pods func(selector labels.Selector) ([]*corev1.Pod, error), metricsClient v1beta1.MetricsV1beta1Interface) (Scraper, error) { - resourceChan := make(chan metrics.RawResourceData, 1000) + resourceChan := make(chan metrics.RawResourceData, 10000) persistor := persistor.NewResourcePersistor(db.NewDBOptions(), resourceChan) err := persistor.SetupDBConnection() @@ -94,6 +94,10 @@ func (s *defaultScraper) scrape() { for _, p := range pods { + if p.Spec.NodeName == "" { + continue + } + totalCores = 0 totalRequests = 0 totalLimits = 0 diff --git a/pkg/dispatcher/pkg/balancer/load-balancer.go b/pkg/dispatcher/pkg/balancer/load-balancer.go index 0056df7..431cc90 100644 --- a/pkg/dispatcher/pkg/balancer/load-balancer.go +++ b/pkg/dispatcher/pkg/balancer/load-balancer.go @@ -180,8 +180,7 @@ func (lb *LoadBalancer) DeleteServer(serverURL *url.URL) error { return fmt.Errorf(ServerNotFoundError, serverURL.Host) } - lb.serverPool.RemoveBackend(b) - return nil + return lb.serverPool.RemoveBackend(b) } // ServerExists checks if a backend exists in the pool diff --git a/pkg/dispatcher/pkg/balancer/pool/serverpool.go b/pkg/dispatcher/pkg/balancer/pool/serverpool.go index 5331aee..a86704d 100644 --- a/pkg/dispatcher/pkg/balancer/pool/serverpool.go +++ b/pkg/dispatcher/pkg/balancer/pool/serverpool.go @@ -52,10 +52,15 @@ func (s *ServerPool) SetBackend(b Backend, weigth int) { s.backends = append(s.backends, ru.Choice{Weight: weigth, Item: b}) } -// RemoveBackend removes a backend from the pool -func (s *ServerPool) RemoveBackend(b Backend) { +// RemoveBackend removes a backend from the pool. returns an error if the backend list would be empty with the last removal +func (s *ServerPool) RemoveBackend(b Backend) error { s.lock.Lock() defer s.lock.Unlock() + + if len(s.backends) == 1 { + return fmt.Errorf("cannot remove the last backend") + } + for i, choice := range s.backends { if choice.Item == b { s.backends[i] = s.backends[len(s.backends)-1] @@ -64,9 +69,7 @@ func (s *ServerPool) RemoveBackend(b Backend) { } } - if len(s.backends) == 0 { - klog.Errorf("Empty backends. Last backend removed is: %v", b) - } + return nil } // GetBackend returns a backend given its URL. It returns the backend and bool diff --git a/pkg/dispatcher/pkg/balancer/pool/serverpool_test.go b/pkg/dispatcher/pkg/balancer/pool/serverpool_test.go index e4e4c4c..aca48d0 100644 --- a/pkg/dispatcher/pkg/balancer/pool/serverpool_test.go +++ b/pkg/dispatcher/pkg/balancer/pool/serverpool_test.go @@ -49,7 +49,7 @@ func TestPool(t *testing.T) { verifyFunc: func(t *testing.T, p *ServerPool) { expectedLength := len(backends) - for _, b := range backends { + for _, b := range backends[0 : len(backends)-1] { p.RemoveBackend(b) actual, found := p.GetBackend(b.URL) require.False(t, found) diff --git a/pkg/dispatcher/pkg/controller/sync.go b/pkg/dispatcher/pkg/controller/sync.go index 12d58b4..c91ad85 100644 --- a/pkg/dispatcher/pkg/controller/sync.go +++ b/pkg/dispatcher/pkg/controller/sync.go @@ -70,101 +70,118 @@ func (c *LoadBalancerController) syncCommunitySchedule(key string) error { } func (c *LoadBalancerController) syncRoutingRules(sourceRules v1alpha1.CommunitySourceRoutingRule, nodeName, community string, gpu bool) { - for source, functionRules := range sourceRules { - if source != nodeName { - continue + + source := "" + var functionRules v1alpha1.CommunityFunctionRoutingRule + + for source, functionRules = range sourceRules { + if source == nodeName { + break } + } - klog.Infof("source node %s\n", source) + if source == "" { + return + } - for functionNamespaceName, destinationRules := range functionRules { + skipForNotReadyPods := false - funcNamespace, funcName, err := cache.SplitMetaNamespaceKey(functionNamespaceName) + for functionNamespaceName, destinationRules := range functionRules { - if err != nil { - utilruntime.HandleError(fmt.Errorf("invalid resource key: %s", functionNamespaceName)) - continue - } + funcNamespace, funcName, err := cache.SplitMetaNamespaceKey(functionNamespaceName) + + if err != nil { + utilruntime.HandleError(fmt.Errorf("invalid resource key: %s", functionNamespaceName)) + continue + } - function, err := c.listers.FunctionLister.Functions(funcNamespace).Get(funcName) + function, err := c.listers.FunctionLister.Functions(funcNamespace).Get(funcName) - if err != nil { - utilruntime.HandleError(fmt.Errorf("couldn't find function %s: %v", funcName, err)) - continue - } - klog.Infof("route to function %s\n", functionNamespaceName) + if err != nil { + utilruntime.HandleError(fmt.Errorf("couldn't find function %s: %v", funcName, err)) + continue + } + + var lb *balancer.LoadBalancer + + value, _ := c.balancers.LoadOrStore(functionNamespaceName, balancer.NewLoadBalancer( + balancer.NodeInfo{ + Node: source, + Function: funcName, + Namespace: funcNamespace, + Community: community, + }, + c.metricChan, + )) - var lb *balancer.LoadBalancer + lb = value.(*balancer.LoadBalancer) - value, _ := c.balancers.LoadOrStore(functionNamespaceName, balancer.NewLoadBalancer( - balancer.NodeInfo{ - Node: source, - Function: funcName, - Namespace: funcNamespace, - Community: community, - }, - c.metricChan, - )) + actualBackends := []*url.URL{} - lb = value.(*balancer.LoadBalancer) + for destination, workload := range destinationRules { - actualBackends := []*url.URL{} - klog.Infof("backend in routing rules for function: %v in node: %v", functionNamespaceName, source) + pods, err := c.resGetter.GetPodsOfFunctionInNode(function, destination, gpu) - for destination := range destinationRules { - klog.Infof("destination: %v", destination) + if err != nil { + utilruntime.HandleError(fmt.Errorf("error parsing function url: %s", err)) + continue } - for destination, workload := range destinationRules { - pods, err := c.resGetter.GetPodsOfFunctionInNode(function, destination, gpu) + if !ArePodsReady(pods) { + skipForNotReadyPods = true + break + } - klog.Info("pods of function") + for _, pod := range pods { - for _, pod := range pods { - klog.Infof("pod: %v in node: %v", pod.Name, pod.Spec.NodeName) - } + destinationURL, err := url.Parse(fmt.Sprintf("http://%s:%d", pod.Status.PodIP, 8000)) if err != nil { utilruntime.HandleError(fmt.Errorf("error parsing function url: %s", err)) continue } - klog.Info("destination nodes\n") - - for _, pod := range pods { - if !isPodReady(pod) { - continue - } + // sync load balancer backends with the new weights + if !lb.ServerExists(destinationURL) { + klog.Infof("load balancer %s add server %s", functionNamespaceName, destination) + lb.AddServer(destinationURL, destination, gpu, &workload, func(req *queue.HTTPRequest) {}) + } else { + lb.UpdateWorkload(destinationURL, &workload) + } - destinationURL, err := url.Parse(fmt.Sprintf("http://%s:%d", pod.Status.PodIP, 8000)) + actualBackends = append(actualBackends, destinationURL) + } + } - if err != nil { - utilruntime.HandleError(fmt.Errorf("error parsing function url: %s", err)) - continue - } + if skipForNotReadyPods { + continue + } - // sync load balancer backends with the new weights - if !lb.ServerExists(destinationURL) { - lb.AddServer(destinationURL, destination, gpu, &workload, func(req *queue.HTTPRequest) {}) - } else { - lb.UpdateWorkload(destinationURL, &workload) - } + // clean old backends + deleteSet := lb.ServerPoolDiff(actualBackends) - actualBackends = append(actualBackends, destinationURL) - } - } + for _, b := range deleteSet { + klog.Infof("load balancer %s delete server %s", functionNamespaceName) - // clean old backends - deleteSet := lb.ServerPoolDiff(actualBackends) + err := lb.DeleteServer(b) - for _, b := range deleteSet { - lb.DeleteServer(b) + if err != nil { + utilruntime.HandleError(fmt.Errorf("error deleting server %s: %v", b, err)) } } } } -func isPodReady(pod *corev1.Pod) bool { +func ArePodsReady(pods []*corev1.Pod) bool { + for _, p := range pods { + if !IsPodReady(p) { + return false + } + } + return true +} + +func IsPodReady(pod *corev1.Pod) bool { for _, c := range pod.Status.Conditions { if c.Type == corev1.PodReady && c.Status == corev1.ConditionTrue { return true diff --git a/pkg/dispatcher/pkg/persistor/persistor.go b/pkg/dispatcher/pkg/persistor/persistor.go index 3789324..9d43634 100644 --- a/pkg/dispatcher/pkg/persistor/persistor.go +++ b/pkg/dispatcher/pkg/persistor/persistor.go @@ -29,7 +29,6 @@ var ( ) const ( - // InsertMetricQuery is the prepare statement for inserting metrics. batchSize = 1000 table = "metric" ) diff --git a/pkg/simple-dispatcher-of/Dockerfile b/pkg/simple-dispatcher-of/Dockerfile new file mode 100644 index 0000000..3edad9c --- /dev/null +++ b/pkg/simple-dispatcher-of/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:3.14.0 + +LABEL name="Simple Dispatcher" + +COPY simple-dispatcher /usr/local/bin/ + +CMD ["simple-dispatcher"] diff --git a/pkg/simple-dispatcher-of/Makefile b/pkg/simple-dispatcher-of/Makefile new file mode 100644 index 0000000..65efbdf --- /dev/null +++ b/pkg/simple-dispatcher-of/Makefile @@ -0,0 +1,48 @@ +BUILD_SETTINGS = CGO_ENABLED=0 GOOS=linux GOARCH=amd64 +IMAGE = simple-dispatcher +IMAGE_VERSION = $(shell git tag --points-at HEAD | sed '/$(IMAGE)\/.*/!s/.*//' | sed 's/\//:/') +REPO = systemautoscaler + + +.PHONY: all build coverage clean e2e fmt release test vet + +all: build test coverage clean + +build: fmt vet test + $(BUILD_SETTINGS) go build -trimpath -o "$(IMAGE)" ./main.go + +fmt: + @go fmt ./... + +test: + @go test -race $(shell go list ./... | grep -v e2e) --coverprofile=coverage.out + +e2e: + @go test -race $(shell go list ./... | grep e2e) + +coverage: test + @go tool cover -func=coverage.out + +release: + @if [ -n "$(IMAGE_VERSION)" ]; then \ + echo "Building $(IMAGE_VERSION)" ;\ + docker build -t $(REPO)/$(IMAGE_VERSION) . ;\ + docker push $(REPO)/$(IMAGE_VERSION) ;\ + else \ + echo "$(IMAGE) unchanged: no version tag on HEAD commit" ;\ + fi + +vet: + @go vet ./... + +clean: + @rm -rf ./$(IMAGE) + @go clean -cache + @rm -rf *.out + +dev: + echo "Building dev release"; \ + $(BUILD_SETTINGS) go build -trimpath -o "$(IMAGE)" ./main.go; \ + docker build -t $(REPO)/$(IMAGE):openfaas-dev . ;\ + docker push $(REPO)/$(IMAGE):openfaas-dev ; \ + echo "Dev release built and pushed"; \ diff --git a/pkg/simple-dispatcher-of/main.go b/pkg/simple-dispatcher-of/main.go new file mode 100644 index 0000000..8c510b8 --- /dev/null +++ b/pkg/simple-dispatcher-of/main.go @@ -0,0 +1,190 @@ +package main + +import ( + "fmt" + "github.com/lterrac/edge-autoscaler/pkg/db" + "github.com/lterrac/edge-autoscaler/pkg/dispatcher/pkg/persistor" + "github.com/lterrac/edge-autoscaler/pkg/metrics" + "io" + "k8s.io/klog/v2" + "log" + "net" + "net/http" + "net/url" + "os" + "strconv" + "strings" + "time" + + "github.com/asecurityteam/rolling" +) + +var target = &url.URL{} +var window = &rolling.TimePolicy{} + +// Environment +var address string +var port string +var windowSize time.Duration +var windowGranularity time.Duration + +// MetricsDB +var database *persistor.MetricsPersistor +var metricChan chan metrics.RawResponseTime + +// Useful information +var node string +var function string +var community string +var namespace string +var gpu bool + +// Proxy client +var client *http.Client + +func main() { + + var err error + + node = getenv("NODE", "") + function = getenv("FUNCTION", "") + community = getenv("COMMUNITY", "") + namespace = getenv("NAMESPACE", "") + gpu, err = strconv.ParseBool(getenv("GPU", "false")) + + mux := http.NewServeMux() + + mux.Handle("/", http.HandlerFunc(ForwardRequest)) + + address = getenv("ADDRESS", "localhost") + port = getenv("APP_PORT", "8080") + + if err != nil { + klog.Fatal("failed to parse GPU environment variable. It should be a boolean") + } + + client = &http.Client{ + Transport: &http.Transport{ + DialContext: (&net.Dialer{ + KeepAlive: 5 * time.Minute, + Timeout: 90 * time.Second, + }).DialContext, + IdleConnTimeout: 90 * time.Second, + ExpectContinueTimeout: 5 * time.Second, + }, + Timeout: time.Second * 30, + } + + metricChan = make(chan metrics.RawResponseTime, 10000) + + database = persistor.NewMetricsPersistor(db.NewDBOptions(), metricChan) + err = database.SetupDBConnection() + if err != nil { + klog.Fatal(err) + } + go database.PollMetrics() + + srv := &http.Server{ + Addr: ":8080", + Handler: mux, + } + + // output error and quit if ListenAndServe fails + log.Fatal(srv.ListenAndServe()) + +} + +// ForwardRequest send all the request the the pod except for the ones having metrics/ in the path +func ForwardRequest(w http.ResponseWriter, req *http.Request) { + requestTime := time.Now() + + klog.Infof("Received request : %v", req) + + paths := strings.SplitN(req.URL.Path, "/", 5) + functionNamespace := paths[2] + functionName := paths[3] + functionPath := paths[4] + klog.Infof("Request for Function %s in namespace %s with path %s", functionName, functionNamespace, functionPath) + + targetString := fmt.Sprintf("http://gateway.openfaas.svc.cluster.local:8080/function/%s/%s", functionName, functionPath) + target, _ := url.Parse(targetString) + newRequest := newRequest(req, target) + klog.Infof("Forwarding to target %s", target) + klog.Infof("Forwarded request is %v", newRequest) + + res, err := client.Do(newRequest) + if err != nil { + klog.Error(err) + } + klog.Info(res) + + if res.Body != nil { + defer res.Body.Close() + } + + copyHeaders(w.Header(), &res.Header) + + w.WriteHeader(res.StatusCode) + + if res.Body != nil { + // Copy the body over + _, err = io.CopyBuffer(w, res.Body, nil) + } + + responseTime := time.Now() + delta := responseTime.Sub(requestTime) + metricChan <- metrics.RawResponseTime{ + Timestamp: time.Now(), + Function: functionName, + Source: node, + Destination: "not-defined", + Namespace: functionNamespace, + Community: community, + Gpu: gpu, + Latency: int(delta.Milliseconds()), + } + +} + +func getenv(key, fallback string) string { + value := os.Getenv(key) + if len(value) == 0 { + klog.Warningf("failed parsing environment variable %s, setting it to default value %s", key, fallback) + return fallback + } + klog.Infof("parsed environment variable %s with value %s", key, value) + return value +} + +func newRequest(old *http.Request, target *url.URL) *http.Request { + + req, err := http.NewRequest(old.Method, target.String(), old.Body) + + if err != nil { + klog.Error(err) + } + + copyHeaders(req.Header, &old.Header) + + if len(old.Host) > 0 && req.Header.Get("X-Forwarded-Host") == "" { + req.Header["X-Forwarded-Host"] = []string{old.Host} + } + + if req.Header.Get("X-Forwarded-For") == "" { + req.Header["X-Forwarded-For"] = []string{old.RemoteAddr} + } + + if old.Body != nil { + req.Body = old.Body + } + + return req +} + +func copyHeaders(destination http.Header, source *http.Header) { + for k, v := range *source { + vClone := make([]string, len(v)) + copy(vClone, v) + (destination)[k] = vClone + } +} diff --git a/pkg/simple-dispatcher/main.go b/pkg/simple-dispatcher/main.go index 28a304f..2d5dd5d 100644 --- a/pkg/simple-dispatcher/main.go +++ b/pkg/simple-dispatcher/main.go @@ -97,11 +97,13 @@ func ForwardRequest(w http.ResponseWriter, req *http.Request) { functionNamespace := paths[2] functionName := paths[3] functionPath := paths[4] - klog.Info(functionPath) + klog.Infof("Request for Function %s in namespace %s with path %s", functionName, functionNamespace, functionPath) targetString := fmt.Sprintf("http://%s.%s.svc.cluster.local/%s", functionName, functionNamespace, functionPath) target, _ := url.Parse(targetString) newRequest := newRequest(req, target) + klog.Infof("Forwarding to target %s", target) + klog.Infof("Forwarded request is %v", newRequest) res, err := client.Do(newRequest) if err != nil { @@ -129,10 +131,10 @@ func ForwardRequest(w http.ResponseWriter, req *http.Request) { delta := responseTime.Sub(requestTime) metricChan <- metrics.RawResponseTime{ Timestamp: time.Now(), - Function: function, + Function: functionName, Source: node, Destination: "not-defined", - Namespace: namespace, + Namespace: functionNamespace, Community: community, Gpu: gpu, Latency: int(delta.Milliseconds()), diff --git a/pkg/system-controller/pkg/delayclient/client.go b/pkg/system-controller/pkg/delayclient/client.go index fd116d5..8af791b 100644 --- a/pkg/system-controller/pkg/delayclient/client.go +++ b/pkg/system-controller/pkg/delayclient/client.go @@ -11,7 +11,7 @@ import ( type NodeDelay struct { FromNode string ToNode string - Latency int + Latency float64 } const (