Loading data/.gitignore 0 → 100644 +1 −0 Original line number Diff line number Diff line *.xml deploy_in_kubernetes.sh +23 −14 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ REGISTRY_IMAGE="" #REGISTRY_IMAGE="http://my-container-registry.local/" # Set the list of components you want to build images for, and deploy. COMPONENTS="context device service compute monitoring centralizedattackdetector" COMPONENTS="context device automation policy service compute monitoring centralizedattackdetector" # Set the tag you want to use for your images. IMAGE_TAG="tf-dev" Loading @@ -18,7 +18,6 @@ IMAGE_TAG="tf-dev" # Set the name of the Kubernetes namespace to deploy to. K8S_NAMESPACE="tf-dev" ######################################################################################################################## # Automated steps start here ######################################################################################################################## Loading @@ -34,10 +33,10 @@ mkdir -p $TMP_MANIFESTS_FOLDER TMP_LOGS_FOLDER="$TMP_FOLDER/logs" mkdir -p $TMP_LOGS_FOLDER # Re-create the namespace to prevent being affected by garbage on it kubectl delete namespace $K8S_NAMESPACE kubectl create namespace $K8S_NAMESPACE printf "\n" for COMPONENT in $COMPONENTS; do echo "Processing '$COMPONENT' component..." Loading @@ -46,32 +45,42 @@ for COMPONENT in $COMPONENTS; do echo " Building Docker image..." BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log" docker build -t "$IMAGE_NAME" -f ./src/$COMPONENT/Dockerfile ./src/ > $BUILD_LOG 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" fi if [ -n "$REGISTRY_IMAGE" ]; then echo "Pushing Docker image to '$REGISTRY_IMAGE'..." TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}.log" docker tag "$IMAGE_NAME" "$IMAGE_URL" > $TAG_LOG docker tag "$IMAGE_NAME" "$IMAGE_URL" > "$TAG_LOG" PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}.log" docker push "$IMAGE_URL" > "$PUSH_LOG" fi echo " Adapting manifest file..." echo " Adapting '$COMPONENT' manifest file..." MANIFEST="$TMP_MANIFESTS_FOLDER/${COMPONENT}service.yaml" cp ./manifests/${COMPONENT}service.yaml $MANIFEST cp ./manifests/"${COMPONENT}"service.yaml "$MANIFEST" VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) if [ -n "$REGISTRY_IMAGE" ]; then sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:latest#image: $IMAGE_URL#g" $MANIFEST sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" $MANIFEST sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST" else sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:latest#image: $IMAGE_NAME#g" $MANIFEST sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" $MANIFEST sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_NAME#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" "$MANIFEST" fi echo " Deploying to Kubernetes..." echo " Deploying '$COMPONENT' component to Kubernetes..." DEPLOY_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}.log" kubectl --namespace $K8S_NAMESPACE apply -f $MANIFEST > $DEPLOY_LOG kubectl --namespace $K8S_NAMESPACE apply -f "$MANIFEST" > "$DEPLOY_LOG" printf "\n" done kubectl --namespace $K8S_NAMESPACE get all Loading manifests/contextservice.yaml +0 −4 Original line number Diff line number Diff line Loading @@ -81,10 +81,6 @@ spec: selector: app: contextservice ports: - name: grpc protocol: TCP port: 1010 targetPort: 1010 - name: http protocol: TCP port: 8080 Loading manifests/deviceservice.yaml +0 −4 Original line number Diff line number Diff line Loading @@ -19,10 +19,6 @@ spec: ports: - containerPort: 2020 env: - name: DB_ENGINE value: "redis" - name: REDIS_DATABASE_ID value: "0" - name: LOG_LEVEL value: "DEBUG" readinessProbe: Loading manifests/l3_attackmitigatorservice.yaml 0 → 100644 +49 −0 Original line number Diff line number Diff line apiVersion: apps/v1 kind: Deployment metadata: name: attackmitigatorservice spec: selector: matchLabels: app: attackmitigatorservice template: metadata: labels: app: attackmitigatorservice spec: terminationGracePeriodSeconds: 5 containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/attackmitigator:latest imagePullPolicy: Always ports: - containerPort: 10002 env: - name: LOG_LEVEL value: "DEBUG" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10002"] livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10002"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service metadata: name: attackmitigatorservice spec: type: ClusterIP selector: app: attackmitigatorservice ports: - name: grpc port: 10002 targetPort: 10002 Loading
deploy_in_kubernetes.sh +23 −14 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ REGISTRY_IMAGE="" #REGISTRY_IMAGE="http://my-container-registry.local/" # Set the list of components you want to build images for, and deploy. COMPONENTS="context device service compute monitoring centralizedattackdetector" COMPONENTS="context device automation policy service compute monitoring centralizedattackdetector" # Set the tag you want to use for your images. IMAGE_TAG="tf-dev" Loading @@ -18,7 +18,6 @@ IMAGE_TAG="tf-dev" # Set the name of the Kubernetes namespace to deploy to. K8S_NAMESPACE="tf-dev" ######################################################################################################################## # Automated steps start here ######################################################################################################################## Loading @@ -34,10 +33,10 @@ mkdir -p $TMP_MANIFESTS_FOLDER TMP_LOGS_FOLDER="$TMP_FOLDER/logs" mkdir -p $TMP_LOGS_FOLDER # Re-create the namespace to prevent being affected by garbage on it kubectl delete namespace $K8S_NAMESPACE kubectl create namespace $K8S_NAMESPACE printf "\n" for COMPONENT in $COMPONENTS; do echo "Processing '$COMPONENT' component..." Loading @@ -46,32 +45,42 @@ for COMPONENT in $COMPONENTS; do echo " Building Docker image..." BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log" docker build -t "$IMAGE_NAME" -f ./src/$COMPONENT/Dockerfile ./src/ > $BUILD_LOG 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" fi if [ -n "$REGISTRY_IMAGE" ]; then echo "Pushing Docker image to '$REGISTRY_IMAGE'..." TAG_LOG="$TMP_LOGS_FOLDER/tag_${COMPONENT}.log" docker tag "$IMAGE_NAME" "$IMAGE_URL" > $TAG_LOG docker tag "$IMAGE_NAME" "$IMAGE_URL" > "$TAG_LOG" PUSH_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}.log" docker push "$IMAGE_URL" > "$PUSH_LOG" fi echo " Adapting manifest file..." echo " Adapting '$COMPONENT' manifest file..." MANIFEST="$TMP_MANIFESTS_FOLDER/${COMPONENT}service.yaml" cp ./manifests/${COMPONENT}service.yaml $MANIFEST cp ./manifests/"${COMPONENT}"service.yaml "$MANIFEST" VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3) if [ -n "$REGISTRY_IMAGE" ]; then sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:latest#image: $IMAGE_URL#g" $MANIFEST sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" $MANIFEST sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST" else sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:latest#image: $IMAGE_NAME#g" $MANIFEST sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" $MANIFEST sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_NAME#g" "$MANIFEST" sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" "$MANIFEST" fi echo " Deploying to Kubernetes..." echo " Deploying '$COMPONENT' component to Kubernetes..." DEPLOY_LOG="$TMP_LOGS_FOLDER/push_${COMPONENT}.log" kubectl --namespace $K8S_NAMESPACE apply -f $MANIFEST > $DEPLOY_LOG kubectl --namespace $K8S_NAMESPACE apply -f "$MANIFEST" > "$DEPLOY_LOG" printf "\n" done kubectl --namespace $K8S_NAMESPACE get all Loading
manifests/contextservice.yaml +0 −4 Original line number Diff line number Diff line Loading @@ -81,10 +81,6 @@ spec: selector: app: contextservice ports: - name: grpc protocol: TCP port: 1010 targetPort: 1010 - name: http protocol: TCP port: 8080 Loading
manifests/deviceservice.yaml +0 −4 Original line number Diff line number Diff line Loading @@ -19,10 +19,6 @@ spec: ports: - containerPort: 2020 env: - name: DB_ENGINE value: "redis" - name: REDIS_DATABASE_ID value: "0" - name: LOG_LEVEL value: "DEBUG" readinessProbe: Loading
manifests/l3_attackmitigatorservice.yaml 0 → 100644 +49 −0 Original line number Diff line number Diff line apiVersion: apps/v1 kind: Deployment metadata: name: attackmitigatorservice spec: selector: matchLabels: app: attackmitigatorservice template: metadata: labels: app: attackmitigatorservice spec: terminationGracePeriodSeconds: 5 containers: - name: server image: registry.gitlab.com/teraflow-h2020/controller/attackmitigator:latest imagePullPolicy: Always ports: - containerPort: 10002 env: - name: LOG_LEVEL value: "DEBUG" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10002"] livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10002"] resources: requests: cpu: 250m memory: 512Mi limits: cpu: 700m memory: 1024Mi --- apiVersion: v1 kind: Service metadata: name: attackmitigatorservice spec: type: ClusterIP selector: app: attackmitigatorservice ports: - name: grpc port: 10002 targetPort: 10002