Commit 3cfe485c authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'l3_scalability' into 'develop'

Updated L3 components + scalability

See merge request !93
parents 71df8f8a 66135558
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}

# If not already set, set the list of components you want to build images for, and deploy.
export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device automation policy service compute monitoring dbscanserving opticalattackmitigator opticalcentralizedattackdetector webui"}
export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device automation policy service compute monitoring dbscanserving opticalattackmitigator opticalcentralizedattackdetector l3_attackmitigator l3_centralizedattackdetector webui"}

########################################################################################################################
# Automated steps start here
+59 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ spec:
        imagePullPolicy: Always
        ports:
        - containerPort: 10002
        - containerPort: 9192
        env:
        - name: LOG_LEVEL
          value: "DEBUG"
@@ -53,11 +54,69 @@ apiVersion: v1
kind: Service
metadata:
  name: l3-attackmitigatorservice
  labels:
    app: l3-attackmitigatorservice
spec:
  type: ClusterIP
  selector:
    app: l3-attackmitigatorservice
  ports:
  - name: metrics
    protocol: TCP
    port: 9192
    targetPort: 9192
  - name: grpc
    port: 10002
    targetPort: 10002

---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: l3-attackmitigatorservice-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: l3-attackmitigatorservice
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 80
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 120

---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: tfs-l3-attackmitigatorservice-metric
  labels:
    app: l3-attackmitigatorservice
    #release: prometheus
    #release: prom  # name of the release 
    # ( VERY IMPORTANT: You need to know the correct release name by viewing 
    #   the servicemonitor of Prometheus itself: Without the correct name, 
    #   Prometheus cannot identify the metrics of the Flask app as the target.)
spec:
  selector:
    matchLabels:
      # Target app service
      #namespace: tfs
      app: l3-attackmitigatorservice # same as above
      #release: prometheus # same as above
  endpoints:
  - port: metrics # named port in target app
    scheme: http
    path: /metrics # path to scrape
    interval: 5s # scrape interval
  namespaceSelector:
    any: false
    matchNames:
    - tfs # namespace where the app is running
+58 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ spec:
        imagePullPolicy: Always
        ports:
        - containerPort: 10001
        - containerPort: 9192
        env:
        - name: LOG_LEVEL
          value: "DEBUG"
@@ -53,11 +54,68 @@ apiVersion: v1
kind: Service
metadata:
  name: l3-centralizedattackdetectorservice
  labels:
    app: l3-centralizedattackdetectorservice
spec:
  type: ClusterIP
  selector:
    app: l3-centralizedattackdetectorservice
  ports:
  - name: metrics
    protocol: TCP
    port: 9192
    targetPort: 9192
  - name: grpc
    port: 10001
    targetPort: 10001

---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: l3-centralizedattackdetectorservice-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: l3-centralizedattackdetectorservice
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 80
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 120
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: tfs-l3-centralizedattackdetectorservice-metric
  labels:
    app: l3-centralizedattackdetectorservice
    #release: prometheus
    #release: prom  # name of the release 
    # ( VERY IMPORTANT: You need to know the correct release name by viewing 
    #   the servicemonitor of Prometheus itself: Without the correct name, 
    #   Prometheus cannot identify the metrics of the Flask app as the target.)
spec:
  selector:
    matchLabels:
      # Target app service
      #namespace: tfs
      app: l3-centralizedattackdetectorservice # same as above
      #release: prometheus # same as above
  endpoints:
  - port: metrics # named port in target app
    scheme: http
    path: /metrics # path to scrape
    interval: 5s # scrape interval
  namespaceSelector:
    any: false
    matchNames:
    - tfs # namespace where the app is running
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"

# Set the list of components, separated by spaces, you want to build images for, and deploy.
export TFS_COMPONENTS="context device automation monitoring pathcomp service slice compute webui load_generator"
export TFS_COMPONENTS="context device automation monitoring pathcomp service slice compute webui load_generator l3_attackmitigator l3_centralizedattackdetector"

# Set the tag you want to use for your images.
export TFS_IMAGE_TAG="dev"
+22 −12
Original line number Diff line number Diff line
@@ -17,10 +17,12 @@ syntax = "proto3";
import "context.proto";

service L3Attackmitigator{
  // Sends a greeting
  rpc SendOutput (L3AttackmitigatorOutput) returns (context.Empty) {}
  // Sends another greeting
  // Perform Mitigation
  rpc PerformMitigation (L3AttackmitigatorOutput) returns (context.Empty) {}
  // Get Mitigation
  rpc GetMitigation (context.Empty) returns (context.Empty) {}
  // Get Configured ACL Rules
  rpc GetConfiguredACLRules (context.Empty) returns (ACLRules) {}
}


@@ -28,12 +30,20 @@ message L3AttackmitigatorOutput {
	float confidence = 1;
	string timestamp = 2;
	string ip_o = 3;
	string tag_name = 4;
	int32 tag = 5;
	string flow_id = 6;
	string protocol = 7;
	string port_d = 8;
	string ml_id = 9;
	float time_start = 10;
	float time_end = 11;
	string ip_d = 4;	
	string tag_name = 5;
	int32 tag = 6;
	string flow_id = 7;
	string protocol = 8;
	string port_o = 9;
	string port_d = 10;
	string ml_id = 11;
	context.ServiceId service_id = 12;
	context.EndPointId endpoint_id = 13; 
	float time_start = 14;
	float time_end = 15;
}

message ACLRules {
	repeated context.ConfigRule acl_rules = 1;
}
Loading