Loading .gitignore +3 −0 Original line number Diff line number Diff line Loading @@ -162,3 +162,6 @@ cython_debug/ # TeraFlowSDN-generated files tfs_runtime_env_vars.sh delete_local_deployment.sh local_docker_deployment.sh local_k8s_deployment.sh deploy.sh +33 −29 Original line number Diff line number Diff line Loading @@ -58,18 +58,6 @@ kubectl delete namespace $TFS_K8S_NAMESPACE kubectl create namespace $TFS_K8S_NAMESPACE printf "\n" if [[ "$TFS_COMPONENTS" == *"monitoring"* ]]; then echo "Creating secrets for InfluxDB..." #TODO: make sure to change this when having a production deployment kubectl create secret generic influxdb-secrets --namespace=$TFS_K8S_NAMESPACE \ --from-literal=INFLUXDB_DB="monitoring" --from-literal=INFLUXDB_ADMIN_USER="teraflow" \ --from-literal=INFLUXDB_ADMIN_PASSWORD="teraflow" --from-literal=INFLUXDB_HTTP_AUTH_ENABLED="True" kubectl create secret generic monitoring-secrets --namespace=$TFS_K8S_NAMESPACE \ --from-literal=INFLUXDB_DATABASE="monitoring" --from-literal=INFLUXDB_USER="teraflow" \ --from-literal=INFLUXDB_PASSWORD="teraflow" --from-literal=INFLUXDB_HOSTNAME="localhost" printf "\n" fi echo "Deploying components and collecting environment variables..." ENV_VARS_SCRIPT=tfs_runtime_env_vars.sh echo "# Environment variables for TeraFlowSDN deployment" > $ENV_VARS_SCRIPT Loading Loading @@ -158,6 +146,8 @@ for COMPONENT in $TFS_COMPONENTS; do fi fi # TODO: harmonize names of the monitoring component echo " Deploying '$COMPONENT' component to Kubernetes..." DEPLOY_LOG="$TMP_LOGS_FOLDER/deploy_${COMPONENT}.log" kubectl --namespace $TFS_K8S_NAMESPACE apply -f "$MANIFEST" > "$DEPLOY_LOG" Loading Loading @@ -212,12 +202,12 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" echo "Configuring WebUI DataStores and Dashboards..." sleep 3 INFLUXDB_HOST="monitoringservice" INFLUXDB_PORT=$(kubectl --namespace $TFS_K8S_NAMESPACE get service/monitoringservice -o jsonpath='{.spec.ports[?(@.name=="influxdb")].port}') INFLUXDB_URL="http://${INFLUXDB_HOST}:${INFLUXDB_PORT}" INFLUXDB_USER=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_USER}' | base64 --decode) INFLUXDB_PASSWORD=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_PASSWORD}' | base64 --decode) INFLUXDB_DATABASE=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_DB}' | base64 --decode) # INFLUXDB_HOST="monitoringservice" # INFLUXDB_PORT=$(kubectl --namespace $TFS_K8S_NAMESPACE get service/monitoringservice -o jsonpath='{.spec.ports[?(@.name=="influxdb")].port}') # INFLUXDB_URL="http://${INFLUXDB_HOST}:${INFLUXDB_PORT}" # INFLUXDB_USER=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_USER}' | base64 --decode) # INFLUXDB_PASSWORD=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_PASSWORD}' | base64 --decode) # INFLUXDB_DATABASE=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_DB}' | base64 --decode) # Exposed through the ingress controller "tfs-ingress" GRAFANA_HOSTNAME="127.0.0.1" Loading @@ -234,6 +224,8 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" # Updated Grafana API URL GRAFANA_URL_UPDATED="http://${GRAFANA_USERNAME}:${TFS_GRAFANA_PASSWORD}@${GRAFANA_HOSTNAME}:${GRAFANA_PORT}${GRAFANA_BASEURL}" echo "export GRAFANA_URL_UPDATED=${GRAFANA_URL_UPDATED}" >> $ENV_VARS_SCRIPT echo "Connecting to grafana at URL: ${GRAFANA_URL_DEFAULT}..." # Configure Grafana Admin Password Loading @@ -245,18 +237,30 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" }' ${GRAFANA_URL_DEFAULT}/api/user/password echo # Create InfluxDB DataSource # Ref: https://grafana.com/docs/grafana/latest/http_api/data_source/ curl -X POST -H "Content-Type: application/json" -d '{ "type" : "influxdb", "name" : "InfluxDB", "url" : "'"$INFLUXDB_URL"'", # TODO: replace user, password and database by variables to be saved echo "Creating a datasource..." curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{ "access" : "proxy", "type" : "postgres", "name" : "monitoringdb", "url" : "monitoringservice:8812", "database" : "monitoring", "user" : "admin", "password" : "quest", "basicAuth" : false, "user" : "'"$INFLUXDB_USER"'", "password" : "'"$INFLUXDB_PASSWORD"'", "isDefault": true, "database" : "'"$INFLUXDB_DATABASE"'" "jsonData" : { "sslmode" : "disable", "postgresVersion" : 1100, "tlsAuth" : false, "tlsAuthWithCACert": false, "tlsConfigurationMethod": "file-path", "tlsSkipVerify": true }, "secureJsonFields" : { "password" : true } }' ${GRAFANA_URL_UPDATED}/api/datasources echo Loading manifests/monitoringservice.yaml +68 −30 Original line number Diff line number Diff line Loading @@ -13,13 +13,14 @@ # limitations under the License. apiVersion: apps/v1 kind: Deployment kind: StatefulSet metadata: name: monitoringservice name: monitoringdb spec: selector: matchLabels: app: monitoringservice serviceName: "monitoringservice" replicas: 1 template: metadata: Loading @@ -32,35 +33,50 @@ spec: - name: metricsdb image: questdb/questdb ports: - containerPort: 9000 - containerPort: 9009 - containerPort: 9003 - name: http containerPort: 9000 protocol: TCP - name: influxdb containerPort: 9009 protocol: TCP - name: postgre containerPort: 8812 protocol: TCP env: - name: QDB_CAIRO_COMMIT_LAG value: "1000" - name: QDB_CAIRO_MAX_UNCOMMITTED_ROWS value: "100000" readinessProbe: exec: command: ["curl", "-XGET", "localhost:9000"] livenessProbe: exec: command: ["curl", "-XGET", "localhost:9003/metrics"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: apps/v1 kind: Deployment metadata: name: monitoringserver spec: selector: matchLabels: app: monitoringservice replicas: 1 template: metadata: labels: app: monitoringservice spec: terminationGracePeriodSeconds: 5 restartPolicy: Always containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/monitoring:latest imagePullPolicy: Always ports: - containerPort: 7070 - name: grpc containerPort: 7070 protocol: TCP env: - name: LOG_LEVEL value: "INFO" - name: METRICSDB_HOSTNAME value: "localhost" value: "monitoringservice" - name: METRICSDB_ILP_PORT value: "9009" - name: METRICSDB_REST_PORT Loading @@ -73,14 +89,6 @@ spec: livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:7070"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service Loading @@ -95,7 +103,37 @@ spec: protocol: TCP port: 7070 targetPort: 7070 - name: questdb - name: http protocol: TCP port: 9000 targetPort: 9000 - name: influxdb protocol: TCP port: 9009 targetPort: 9009 - name: postgre protocol: TCP port: 8812 targetPort: 8812 --- apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: access-monitoring spec: podSelector: matchLabels: app: monitoringservice ingress: - from: [] ports: - port: 7070 - port: 8812 - from: - podSelector: matchLabels: app: monitoringservice ports: - port: 9009 - port: 9000 manifests/webuiservice.yaml +2 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ spec: - name: LOG_LEVEL value: "DEBUG" - name: WEBUISERVICE_SERVICE_BASEURL_HTTP value: "/webui" value: "/webui/" readinessProbe: httpGet: path: /healthz/ready Loading @@ -61,7 +61,7 @@ spec: cpu: 700m memory: 1024Mi - name: grafana image: grafana/grafana:8.2.6 image: grafana/grafana:8.5.11 imagePullPolicy: IfNotPresent ports: - containerPort: 3000 Loading scripts/old/deploy_in_kubernetes.sh +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ for COMPONENT in $COMPONENTS; do if [ "$COMPONENT" == "automation" ] || [ "$COMPONENT" == "policy" ]; then docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG" else docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/ > "$BUILD_LOG" docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG" fi if [ -n "$REGISTRY_IMAGE" ]; then Loading Loading
.gitignore +3 −0 Original line number Diff line number Diff line Loading @@ -162,3 +162,6 @@ cython_debug/ # TeraFlowSDN-generated files tfs_runtime_env_vars.sh delete_local_deployment.sh local_docker_deployment.sh local_k8s_deployment.sh
deploy.sh +33 −29 Original line number Diff line number Diff line Loading @@ -58,18 +58,6 @@ kubectl delete namespace $TFS_K8S_NAMESPACE kubectl create namespace $TFS_K8S_NAMESPACE printf "\n" if [[ "$TFS_COMPONENTS" == *"monitoring"* ]]; then echo "Creating secrets for InfluxDB..." #TODO: make sure to change this when having a production deployment kubectl create secret generic influxdb-secrets --namespace=$TFS_K8S_NAMESPACE \ --from-literal=INFLUXDB_DB="monitoring" --from-literal=INFLUXDB_ADMIN_USER="teraflow" \ --from-literal=INFLUXDB_ADMIN_PASSWORD="teraflow" --from-literal=INFLUXDB_HTTP_AUTH_ENABLED="True" kubectl create secret generic monitoring-secrets --namespace=$TFS_K8S_NAMESPACE \ --from-literal=INFLUXDB_DATABASE="monitoring" --from-literal=INFLUXDB_USER="teraflow" \ --from-literal=INFLUXDB_PASSWORD="teraflow" --from-literal=INFLUXDB_HOSTNAME="localhost" printf "\n" fi echo "Deploying components and collecting environment variables..." ENV_VARS_SCRIPT=tfs_runtime_env_vars.sh echo "# Environment variables for TeraFlowSDN deployment" > $ENV_VARS_SCRIPT Loading Loading @@ -158,6 +146,8 @@ for COMPONENT in $TFS_COMPONENTS; do fi fi # TODO: harmonize names of the monitoring component echo " Deploying '$COMPONENT' component to Kubernetes..." DEPLOY_LOG="$TMP_LOGS_FOLDER/deploy_${COMPONENT}.log" kubectl --namespace $TFS_K8S_NAMESPACE apply -f "$MANIFEST" > "$DEPLOY_LOG" Loading Loading @@ -212,12 +202,12 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" echo "Configuring WebUI DataStores and Dashboards..." sleep 3 INFLUXDB_HOST="monitoringservice" INFLUXDB_PORT=$(kubectl --namespace $TFS_K8S_NAMESPACE get service/monitoringservice -o jsonpath='{.spec.ports[?(@.name=="influxdb")].port}') INFLUXDB_URL="http://${INFLUXDB_HOST}:${INFLUXDB_PORT}" INFLUXDB_USER=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_USER}' | base64 --decode) INFLUXDB_PASSWORD=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_PASSWORD}' | base64 --decode) INFLUXDB_DATABASE=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_DB}' | base64 --decode) # INFLUXDB_HOST="monitoringservice" # INFLUXDB_PORT=$(kubectl --namespace $TFS_K8S_NAMESPACE get service/monitoringservice -o jsonpath='{.spec.ports[?(@.name=="influxdb")].port}') # INFLUXDB_URL="http://${INFLUXDB_HOST}:${INFLUXDB_PORT}" # INFLUXDB_USER=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_USER}' | base64 --decode) # INFLUXDB_PASSWORD=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_PASSWORD}' | base64 --decode) # INFLUXDB_DATABASE=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_DB}' | base64 --decode) # Exposed through the ingress controller "tfs-ingress" GRAFANA_HOSTNAME="127.0.0.1" Loading @@ -234,6 +224,8 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" # Updated Grafana API URL GRAFANA_URL_UPDATED="http://${GRAFANA_USERNAME}:${TFS_GRAFANA_PASSWORD}@${GRAFANA_HOSTNAME}:${GRAFANA_PORT}${GRAFANA_BASEURL}" echo "export GRAFANA_URL_UPDATED=${GRAFANA_URL_UPDATED}" >> $ENV_VARS_SCRIPT echo "Connecting to grafana at URL: ${GRAFANA_URL_DEFAULT}..." # Configure Grafana Admin Password Loading @@ -245,18 +237,30 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" }' ${GRAFANA_URL_DEFAULT}/api/user/password echo # Create InfluxDB DataSource # Ref: https://grafana.com/docs/grafana/latest/http_api/data_source/ curl -X POST -H "Content-Type: application/json" -d '{ "type" : "influxdb", "name" : "InfluxDB", "url" : "'"$INFLUXDB_URL"'", # TODO: replace user, password and database by variables to be saved echo "Creating a datasource..." curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{ "access" : "proxy", "type" : "postgres", "name" : "monitoringdb", "url" : "monitoringservice:8812", "database" : "monitoring", "user" : "admin", "password" : "quest", "basicAuth" : false, "user" : "'"$INFLUXDB_USER"'", "password" : "'"$INFLUXDB_PASSWORD"'", "isDefault": true, "database" : "'"$INFLUXDB_DATABASE"'" "jsonData" : { "sslmode" : "disable", "postgresVersion" : 1100, "tlsAuth" : false, "tlsAuthWithCACert": false, "tlsConfigurationMethod": "file-path", "tlsSkipVerify": true }, "secureJsonFields" : { "password" : true } }' ${GRAFANA_URL_UPDATED}/api/datasources echo Loading
manifests/monitoringservice.yaml +68 −30 Original line number Diff line number Diff line Loading @@ -13,13 +13,14 @@ # limitations under the License. apiVersion: apps/v1 kind: Deployment kind: StatefulSet metadata: name: monitoringservice name: monitoringdb spec: selector: matchLabels: app: monitoringservice serviceName: "monitoringservice" replicas: 1 template: metadata: Loading @@ -32,35 +33,50 @@ spec: - name: metricsdb image: questdb/questdb ports: - containerPort: 9000 - containerPort: 9009 - containerPort: 9003 - name: http containerPort: 9000 protocol: TCP - name: influxdb containerPort: 9009 protocol: TCP - name: postgre containerPort: 8812 protocol: TCP env: - name: QDB_CAIRO_COMMIT_LAG value: "1000" - name: QDB_CAIRO_MAX_UNCOMMITTED_ROWS value: "100000" readinessProbe: exec: command: ["curl", "-XGET", "localhost:9000"] livenessProbe: exec: command: ["curl", "-XGET", "localhost:9003/metrics"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: apps/v1 kind: Deployment metadata: name: monitoringserver spec: selector: matchLabels: app: monitoringservice replicas: 1 template: metadata: labels: app: monitoringservice spec: terminationGracePeriodSeconds: 5 restartPolicy: Always containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/monitoring:latest imagePullPolicy: Always ports: - containerPort: 7070 - name: grpc containerPort: 7070 protocol: TCP env: - name: LOG_LEVEL value: "INFO" - name: METRICSDB_HOSTNAME value: "localhost" value: "monitoringservice" - name: METRICSDB_ILP_PORT value: "9009" - name: METRICSDB_REST_PORT Loading @@ -73,14 +89,6 @@ spec: livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:7070"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service Loading @@ -95,7 +103,37 @@ spec: protocol: TCP port: 7070 targetPort: 7070 - name: questdb - name: http protocol: TCP port: 9000 targetPort: 9000 - name: influxdb protocol: TCP port: 9009 targetPort: 9009 - name: postgre protocol: TCP port: 8812 targetPort: 8812 --- apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: access-monitoring spec: podSelector: matchLabels: app: monitoringservice ingress: - from: [] ports: - port: 7070 - port: 8812 - from: - podSelector: matchLabels: app: monitoringservice ports: - port: 9009 - port: 9000
manifests/webuiservice.yaml +2 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ spec: - name: LOG_LEVEL value: "DEBUG" - name: WEBUISERVICE_SERVICE_BASEURL_HTTP value: "/webui" value: "/webui/" readinessProbe: httpGet: path: /healthz/ready Loading @@ -61,7 +61,7 @@ spec: cpu: 700m memory: 1024Mi - name: grafana image: grafana/grafana:8.2.6 image: grafana/grafana:8.5.11 imagePullPolicy: IfNotPresent ports: - containerPort: 3000 Loading
scripts/old/deploy_in_kubernetes.sh +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ for COMPONENT in $COMPONENTS; do if [ "$COMPONENT" == "automation" ] || [ "$COMPONENT" == "policy" ]; then docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG" else docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/ > "$BUILD_LOG" docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG" fi if [ -n "$REGISTRY_IMAGE" ]; then Loading