-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deployment configurations #6
Merged
Merged
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ef20ca7
WIP: deployment configurations
petertrr b1bdd0f
WIP: deployment configurations
petertrr 7b3b56e
WIP: deployment configurations
petertrr 7104a39
Update save-stack.yaml
petertrr 8125a3a
Update save-stack.yaml
petertrr aeb2e83
WIP: deployment configs
petertrr 1fb2d95
WIP: deployment configs
petertrr ca67316
Deployment configs
petertrr fd8a34e
WIP: initialized save agent
petertrr 2173b85
Merge branch 'master' into infra/deploy-configs
petertrr a1822a9
Deployment configs
petertrr 84cb22a
Deployment configs
petertrr 573498d
Deployment configs
petertrr c214d7d
Deployment configs
petertrr ca99f77
Deployment configs
petertrr ceb1ea2
Deployment configs
petertrr 9e78d2e
Deployment configs
petertrr b15c0af
Deployment configs
petertrr c5576c1
Deployment configs
petertrr 962b38d
Deployment configs
petertrr 14c5bb6
Deployment configs
petertrr b862c49
Deployment configs
petertrr 7811767
Deployment configs
petertrr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
buildSrc/src/main/kotlin/org/cqfn/save/buildutils/DockerStackConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.cqfn.save.buildutils | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.Exec | ||
import org.gradle.kotlin.dsl.register | ||
import org.gradle.kotlin.dsl.withType | ||
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage | ||
|
||
fun Project.createStackDeployTask() { | ||
tasks.register<Exec>("startLocalDockerRegistry") { | ||
enabled = false | ||
description = "Start local docker registry for spring boot images. Disabled, see comment in deployDockerStack task." | ||
commandLine("docker", "service", "create", "--name", "registry", "--publish", "published=6000,target=5000", "registry:2") | ||
} | ||
|
||
tasks.register<Exec>("deployDockerStack") { | ||
dependsOn(subprojects.flatMap { it.tasks.withType<BootBuildImage>() }) | ||
doFirst { | ||
copy { | ||
description = "Copy configuration files from repo to actual locations" | ||
from("save-deploy") | ||
into("${System.getProperty("user.home")}/configs") | ||
} | ||
} | ||
description = "Deploy to docker swarm. If swarm contains more than one node, some registry for built images is requried." | ||
commandLine("docker", "stack", "deploy", "--compose-file", "docker-compose.yaml", "save") | ||
// doLast { | ||
// exec { | ||
// description = "Stop local docker registry" | ||
// commandLine("docker", "service", "rm", "registry") | ||
// } | ||
// } | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
buildSrc/src/main/kotlin/org/cqfn/save/buildutils/SpringBootConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.cqfn.save.buildutils | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.named | ||
import org.springframework.boot.gradle.dsl.SpringBootExtension | ||
import org.springframework.boot.gradle.plugin.SpringBootPlugin | ||
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage | ||
|
||
fun Project.configureSpringBoot() { | ||
apply<SpringBootPlugin>() | ||
|
||
dependencies { | ||
add("implementation", "org.springframework.boot:spring-boot-starter-webflux:${Versions.springBoot}") | ||
add("implementation", "org.springframework.boot:spring-boot-starter-actuator:${Versions.springBoot}") | ||
add("implementation", "io.micrometer:micrometer-registry-prometheus:${Versions.micrometer}") // expose prometheus metrics in actuator | ||
add("implementation", "org.springframework.security:spring-security-core:${Versions.springSecurity}") | ||
add("testImplementation", "org.springframework.boot:spring-boot-starter-test:${Versions.springBoot}") | ||
} | ||
|
||
configure<SpringBootExtension> { | ||
buildInfo() // configures `bootBuildInfo` task, which creates META-INF/build-info.properties file | ||
} | ||
|
||
tasks.named<BootBuildImage>("bootBuildImage") { | ||
dependsOn(rootProject.tasks.getByName("startLocalDockerRegistry")) | ||
// `host.docker.internal` for win 10? | ||
imageName = "127.0.0.1:6000/${project.name}:${project.version}" | ||
environment = mapOf("BP_JVM_VERSION" to Versions.BP_JVM_VERSION) | ||
isPublish = false | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
buildSrc/src/main/kotlin/org/cqfn/save/buildutils/VersioningConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.cqfn.save.buildutils | ||
|
||
import org.ajoberstar.reckon.gradle.ReckonExtension | ||
import org.ajoberstar.reckon.gradle.ReckonPlugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
fun Project.configureVersioning() { | ||
apply<ReckonPlugin>() | ||
|
||
configure<ReckonExtension> { | ||
scopeFromProp() | ||
snapshotFromProp() // use -Preckon.stage=final to build a version without `SNAPSHOT` modifier | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# https://docs.docker.com/engine/swarm/stack-deploy/ | ||
# $ ./gradlew deployDockerStack | ||
version: '3.9' | ||
|
||
services: | ||
orchestrator: | ||
image: 127.0.0.1:6000/save-orchestrator:0.1.0-SNAPSHOT | ||
ports: | ||
- "5100:5100" | ||
volumes: | ||
- "/var/run/docker.sock:/var/run/docker.sock" | ||
deploy: | ||
labels: | ||
- "prometheus-job=save-orchestrator" | ||
backend: | ||
image: 127.0.0.1:6000/save-backend:0.1.0-SNAPSHOT | ||
ports: | ||
- "5000:5000" | ||
deploy: | ||
labels: | ||
- "prometheus-job=save-backend" | ||
prometheus: | ||
image: prom/prometheus | ||
user: root # to access host's docker socket for service discovery, see https://groups.google.com/g/prometheus-users/c/EuEW0qRzXvg/m/0aqKh_ZABQAJ | ||
ports: | ||
- "9090:9090" | ||
volumes: | ||
- "~/configs/prometheus.yml:/etc/prometheus/prometheus.yml" | ||
- "/var/run/docker.sock:/var/run/docker.sock" | ||
grafana: | ||
image: grafana/grafana | ||
ports: | ||
- "9100:3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
server.port = 5000 | ||
server.port = 5000 | ||
management.endpoints.web.exposure.include=health,info,prometheus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
scrape_configs: | ||
# Make Prometheus scrape itself for metrics. | ||
- job_name: 'prometheus' | ||
static_configs: | ||
- targets: ['localhost:9090'] | ||
|
||
# Create a job for Docker Swarm containers. | ||
- job_name: 'dockerswarm' | ||
metrics_path: '/actuator/prometheus' | ||
dockerswarm_sd_configs: | ||
- host: unix:///var/run/docker.sock | ||
role: tasks | ||
relabel_configs: | ||
# Only keep containers that should be running. | ||
- source_labels: [__meta_dockerswarm_task_desired_state] | ||
regex: running | ||
action: keep | ||
# Only keep containers that have a `prometheus-job` label. | ||
- source_labels: [__meta_dockerswarm_service_label_prometheus_job] | ||
regex: .+ | ||
action: keep | ||
# Use the prometheus-job Swarm label as Prometheus job label. | ||
- source_labels: [__meta_dockerswarm_service_label_prometheus_job] | ||
target_label: job | ||
# Adding docker_node label to the targets | ||
- source_labels: [ __meta_dockerswarm_node_hostname ] | ||
target_label: docker_node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
server.port = 5100 | ||
server.port = 5100 | ||
management.endpoints.web.exposure.include=health,info,prometheus |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a table with ports