Skip to content

Commit

Permalink
Feat: dispatcher (#7)
Browse files Browse the repository at this point in the history
* fix: minor fixes
* doc: add comments to queue package
* feat: add load balancer
* feat: add datastore for metric collection
* feat: partial features
* feat: expose metrics
* feat: deployment webhook automation
* feat: http forwarding working
* fix: fix load balancer bottleneck
* feat: add metric persistence to a timescale-db
* feat: webhook automation (#6)
* feat: deployment webhook automation
* fix: minor fixes
* refactor: move kube api utilites to apiutils package
* fix; minor adjustments
Co-authored-by: DragonBanana <[email protected]>
Co-authored-by: SwagMaster <[email protected]>
Co-authored-by: Luca Terracciano <[email protected]>
  • Loading branch information
lterrac authored Aug 26, 2021
1 parent 7e2eac9 commit 3268f2a
Show file tree
Hide file tree
Showing 47 changed files with 2,920 additions and 224 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ vendor/
pkg/*/community-controller
pkg/*/system-controller
pkg/*/edge-scheduler
pkg/*/function-deployment-webhook

.idea/
pkg/function-deployment-webhook/deploy/server-key.pem
pkg/function-deployment-webhook/deploy/server-cert.pem
pkg/dispatcher/dispatcher
pkg/dispatcher/pkg/controller/loadbalancer-controller.go
pkg/function-deployment-webhook/deploy/admission-registration-subst.yaml
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAKEFLAGS += --no-print-directory
COMPONENTS = community-controller system-controller edge-scheduler function-deployment-webhook
COMPONENTS = community-controller system-controller edge-scheduler function-deployment-webhook dispatcher

ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -41,6 +41,10 @@ e2e: install
$(call action, e2e)
@kubectl delete -f ./config/cluster-conf/e2e-namespace.yaml

metric-db:
@cd ./config/metric-db
@docker build -t systemautoscaler/database .
@docker push -t systemautoscaler/database
# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=edgeautoscaler-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases crd:crdVersions={v1}
Expand Down
2 changes: 2 additions & 0 deletions config/deploy/example-cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ spec:
probability-threshold: 20
iterations: 20
slpa-service: slpa.default.svc.cluster.local:4567
status:
generated-communities: []
41 changes: 41 additions & 0 deletions config/deploy/timescale-db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: metrics-database
namespace: kube-system
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: metrics-database
replicas: 1
template:
metadata:
labels:
app: metrics-database
spec:
containers:
- name: metrics-database
image: systemautoscaler/database:dev
imagePullPolicy: Always
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: "user"
- name: POSTGRES_PASSWORD
value: "password"
---
apiVersion: v1
kind: Service
metadata:
name: metrics-database
namespace: kube-system
labels:
app: metrics-database
spec:
ports:
- port: 5432
selector:
app: metrics-database
24 changes: 24 additions & 0 deletions config/metric-db/002_init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CREATE TABLE IF NOT EXISTS metric
(
timestamp TIMESTAMP,
source VARCHAR(50),
destination VARCHAR(50),
function VARCHAR(50),
namespace VARCHAR(50),
community VARCHAR(50),
latency INTEGER,
gpu BOOLEAN,
PRIMARY KEY (timestamp, source, destination, function, namespace, community)
);

SELECT create_hypertable('metric', 'timestamp', chunk_time_interval => INTERVAL '30 seconds');
SELECT add_dimension('metric', 'community', number_partitions => 4);
SELECT add_dimension('metric', 'namespace', number_partitions => 4);

-- ALTER TABLE candlestick SET (
-- timescaledb.compress,
-- timescaledb.compress_segmentby = 'symbol'
-- );
--
-- SELECT add_compression_policy('candlestick', INTERVAL '12 month');
-- SELECT remove_compression_policy('candlestick');
3 changes: 3 additions & 0 deletions config/metric-db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM timescale/timescaledb:2.0.0-pg12

ADD 002_init.sql docker-entrypoint-initdb.d/
22 changes: 22 additions & 0 deletions figlet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: openfaas.com/v1
kind: Function
metadata:
creationTimestamp: "2021-07-19T21:22:34Z"
generation: 1
name: figlet
namespace: openfaas-fn
resourceVersion: "1689214"
selfLink: /apis/openfaas.com/v1/namespaces/openfaas-fn/functions/figlet
uid: 21b5f4f5-3315-40d6-a900-25b11bca95bb
spec:
image: ghcr.io/openfaas/figlet:latest
labels:
com.openfaas.scale.factor: "20"
com.openfaas.scale.max: "100"
com.openfaas.scale.min: "1"
com.openfaas.scale.zero: "false"
edgeautoscaler.polimi.it/scheduler: edge-autoscaler
name: figlet
readOnlyRootFilesystem: false
requests:
memory: 1M
24 changes: 14 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ go 1.16

require (
github.com/JohnCGriffin/yogofn v0.0.0-20170613212352-43d7b79df9f1
github.com/asecurityteam/rolling v2.0.4+incompatible
github.com/emirpasic/gods v1.12.0
github.com/jackc/pgx/v4 v4.13.0
github.com/kubernetes-sigs/custom-metrics-apiserver v0.0.0-20210723154917-1e5c782a6217
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.13.0
github.com/openfaas/faas-netes v0.0.0-20210708204016-8433edf90f12
github.com/openfaas/faas-netes v0.0.0-20210722152123-f0519195a78b
github.com/stretchr/testify v1.7.0
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect
golang.org/x/tools v0.1.2 // indirect
k8s.io/api v0.21.2
k8s.io/apimachinery v0.21.2
k8s.io/client-go v0.21.2
k8s.io/code-generator v0.21.2
k8s.io/klog/v2 v2.8.0
k8s.io/api v0.21.3
k8s.io/apimachinery v0.21.3
k8s.io/client-go v0.21.3
k8s.io/code-generator v0.21.3
k8s.io/klog/v2 v2.9.0
k8s.io/kube-openapi v0.0.0-20210527164424-3c818078ee3d
k8s.io/utils v0.0.0-20210527160623-6fdb442a123b
sigs.k8s.io/controller-runtime v0.9.2
k8s.io/metrics v0.21.3
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9
sigs.k8s.io/controller-runtime v0.9.3

)
Loading

0 comments on commit 3268f2a

Please sign in to comment.