diff --git a/.editorconfig b/.editorconfig index 322ae390af7788fe50f207263d7fb9ec5c2247e4..4818cdace44342f60ada3cc6bdc6058f03ea6276 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,7 @@ insert_final_newline = true [*.yml] indent_style = space indent_size = 2 + +[*.yaml] +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore index c55852de03810de5500ec3677d25fdd273001491..bceeebe4ccb229632d6193778c0af6088f406b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,6 @@ test/appsettings.* *lock.json docker-compose-*.yml + +deployment/services/ +deployment/config.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e9c7ad1bda25389ba82fa8f5689052721c46d016..7d7e1d6f8c00760fed9994ccea6b6ba7b0e36580 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -148,3 +148,14 @@ release-debian: - debian/build/* tags: - docker + +release-deployment: + stage: release + image: dbogatov/docker-images:alpine-extras-latest + script: + - ./build.sh -f build-deployment + artifacts: + paths: + - deployment/config.yaml + tags: + - docker diff --git a/api.yml b/api.yml index 25cb68afd1ca12c5de389458dc1eb35656443abb..ade0a617e5d50950fb15906d3d54211a06bb4358 100644 --- a/api.yml +++ b/api.yml @@ -6,7 +6,7 @@ info: Collects, processes and provides various data regarding the status of the services. version: "1.0.0" -host: status.makerchip.com +host: status.dbogatov.org securityDefinitions: apiauth: type: apiKey diff --git a/build.sh b/build.sh index d508775eeb92e893015aad74bfd6a12e3f6705ac..53b75a0c3b85fb061c059a294a93f379c758c15f 100755 --- a/build.sh +++ b/build.sh @@ -290,6 +290,25 @@ build-for-compose () { build-docker-images } +## Deployment + +build-deployment () { + + cd $CWD/deployment + + echo "Building deploy configs..." + + if [ -z "$DOTNET_TAG" ]; then + DOTNET_TAG="local" + fi + + ./build-services.sh $DOTNET_TAG + + mv services/namespace.yaml config.yaml + cat services/**/*.yaml >> config.yaml + +} + ## DEBIAN PACKAGE build-debian-package () { diff --git a/deployment/build-services.sh b/deployment/build-services.sh new file mode 100755 index 0000000000000000000000000000000000000000..5dcd6ae17c331aff05bf7b999b1f24a74c55007d --- /dev/null +++ b/deployment/build-services.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -e + +shopt -s globstar + +SERVICES=("ping" "nginx" "docs" "daemons" "web" "database") + +if [ $# -eq 0 ] +then + TAG="master" +else + TAG=$1 +fi + +# "49-move-to-kubernetes-deployment" + +rm -rf services/ +mkdir -p services + +cp sources/namespace.yaml services/ + +for service in ${SERVICES[@]} +do + echo "Generating $service configs..." + + mkdir -p services/$service + + cp sources/service/{service,deployment}.yaml services/$service + + if [ "$service" != "database" ] + then + IMAGE="dbogatov/status-site:$service-$TAG" + PORT="80" + else + IMAGE="postgres:9.6.3-alpine" + PORT="5432" + fi + + sed -i '' -e "s#__NAME__#$service#g" services/$service/{service,deployment}.yaml + sed -i '' -e "s#__IMAGE__#$IMAGE#g" services/$service/{service,deployment}.yaml + sed -i '' -e "s#__PORT__#$PORT#g" services/$service/{service,deployment}.yaml + +done + +echo "Done!" diff --git a/deployment/sources/namespace.yaml b/deployment/sources/namespace.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6b0e9f82acc903bfbf1f124a30329dbedc9d1755 --- /dev/null +++ b/deployment/sources/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: status-site diff --git a/deployment/sources/service/deployment.yaml b/deployment/sources/service/deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..69f9091f60e5c41ea34677c05765df1400c7c4e0 --- /dev/null +++ b/deployment/sources/service/deployment.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: __NAME__ + namespace: status-site + labels: + application: __NAME__ +spec: + replicas: 1 + selector: + matchLabels: + application: __NAME__ + template: + metadata: + labels: + application: __NAME__ + spec: + containers: + - name: __NAME__ + image: __IMAGE__ + imagePullPolicy: Always + volumeMounts: + - name: appsettings + mountPath: "/run/secrets/" + # readOnly: true + env: + - name: POSTGRES_DB + value: "statussite" + - name: POSTGRES_USER + value: "statususer" + - name: POSTGRES_PASSWORD + value: "relyOn1InternalSwarmNetwork" + - name: ASPNETCORE_ENVIRONMENT + value: "Production" + volumes: + - name: appsettings + secret: + secretName: appsettings.production.yml diff --git a/deployment/sources/service/service.yaml b/deployment/sources/service/service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3b36d3cd7ee84b3f7446e3a5ae55884e5ce8a6a4 --- /dev/null +++ b/deployment/sources/service/service.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: __NAME__ + namespace: status-site + labels: + application: __NAME__ +spec: + selector: + application: __NAME__ + ports: + - port: __PORT__ + targetPort: __PORT__