This repository was archived by the owner on Oct 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
[JCasC] google cloud engine local setup #979
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2f1fb73
[JCasC] google cloud engine local setup
v1v 91e45a6
Changed cloud compute entry
v1v 2672713
Merge remote-tracking branch 'upstream/master' into poc/google-engine
v1v 4119954
change images
v1v 460ae68
Merge remote-tracking branch 'upstream/master' into poc/google-engine
v1v 347ac19
Merge remote-tracking branch 'upstream/master' into poc/google-engine
v1v e619b29
ci(jenkins): test scenarios for analysis the GCE
v1v ae670c4
Test pipelines: in batches of 10 workers, in batches of 10*i workers,…
v1v 356fb49
Enable less delay when provisioining and a longer timeout
v1v 78040dc
Merge remote-tracking branch 'upstream/master' into poc/google-engine
v1v 040bf04
Merge remote-tracking branch 'upstream/master' into poc/google-engine
v1v 818a6a2
Merge remote-tracking branch 'upstream/master' into poc/google-engine
v1v 31e13a8
Use latest available jenkins docker image
v1v d257576
Add Docs
v1v 50350d1
Merge branch 'master' into poc/google-engine
v1v 61f030c
Merge branch 'master' into poc/google-engine
v1v 0e089cd
Merge branch 'master' into poc/google-engine
mergify[bot] 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 hidden or 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 @@ | ||
| # Cloud | ||
|
|
||
| We are using the Google Compute Jenkins plugins. | ||
|
|
||
| See https://github.com/jenkinsci/google-compute-engine-plugin/#configuration-as-code-support for further examples. | ||
|
|
||
| ## How to | ||
|
|
||
| ### Add a new AMI | ||
|
|
||
| You can add new VMs, for such you need to: | ||
|
|
||
| 1. Create a new template in the [Google Cloud](https://console.cloud.google.com/compute/instanceTemplates/list?project=elastic-observability) | ||
| 1. Add a new entry in `local/configs/google.yaml`, that's the JCasC for the cloud provider. | ||
| 1. If you prefer you can use the Jenkins UI. Go to the [configureClouds](http://localhost:18080/configureClouds/) menu. | ||
|
|
||
| Once you are happy with the configuration then you can export to a JCasC format, for such you just need to go to | ||
| [JCasC](http://localhost:18080/configuration-as-code/) and click on the `View Configuration` button. | ||
|
|
||
|
|
||
| ### Modify the existing credentials for the google service account | ||
|
|
||
| If for any reason you'd like to update the existing credentials then you need to follow the below steps: | ||
|
|
||
| 1. Go to [Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts?project=elastic-observability) | ||
| 1. Select the `jenkins-gce` one. | ||
| 1. Create a new JSON key type. | ||
| 1. Transform to base64 and update the existing vault entry | ||
|
|
||
| ```bash | ||
| $ base64 -i elastic-observability-*********.json -o base64.json | ||
| $ vault write secret/observability-team/ci/service-account/jenkins-gce-elastic-observability google_cloud_secret=@base64.json ticket=https://github.com/elastic/apm-pipeline-library/pull/356 | ||
| ``` | ||
This file contains hidden or 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,4 +1,4 @@ | ||
| FROM docker.elastic.co/infra/jenkins:202010021728.bc28cd532cad | ||
| FROM docker.elastic.co/infra/jenkins:202102102240.c37e3f69e293 | ||
|
|
||
| COPY configs/plugins.txt /usr/share/jenkins/ref/plugins.txt | ||
| RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt |
This file contains hidden or 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,45 @@ | ||
| credentials: | ||
| system: | ||
| domainCredentials: | ||
| - credentials: | ||
| ## See https://github.com/jenkinsci/google-oauth-plugin/blob/google-oauth-plugin-1.0.0/src/test/resources/com/google/jenkins/plugins/credentials/oauth/json-service-account-config.yml | ||
| - googleRobotPrivateKey: | ||
| projectId: 'elastic-observability' | ||
| serviceAccountConfig: | ||
| json: | ||
| secretJsonKey: ${google_cloud_secret} | ||
|
|
||
| jenkins: | ||
| clouds: | ||
| - computeEngine: | ||
| cloudName: "elastic-observability" | ||
| configurations: | ||
| - bootDiskAutoDelete: true | ||
| bootDiskSizeGb: 50 | ||
| bootDiskSourceImageProject: "elastic-observability" | ||
| bootDiskType: "https://www.googleapis.com/compute/v1/projects/elastic-observability/zones/us-central1-f/diskTypes/pd-ssd" | ||
| description: "obs11 workers" | ||
| externalAddress: true | ||
| javaExecPath: "java" | ||
| labels: "linux immutable obs11" | ||
| launchTimeoutSeconds: 600 | ||
| machineType: "https://www.googleapis.com/compute/v1/projects/elastic-observability/zones/us-central1-f/machineTypes/g1-small" | ||
| mode: NORMAL | ||
| namePrefix: "obs11-linux" | ||
| networkConfiguration: | ||
| autofilled: | ||
| network: "https://www.googleapis.com/compute/v1/projects/elastic-observability/global/networks/default" | ||
| subnetwork: "https://www.googleapis.com/compute/v1/projects/elastic-observability/regions/us-central1/subnetworks/default" | ||
| numExecutors: 1 | ||
| oneShot: true | ||
| preemptible: true | ||
| region: "https://www.googleapis.com/compute/v1/projects/elastic-observability/regions/us-central1" | ||
| retentionTimeMinutes: 10 | ||
| runAsUser: "jenkins-gce" | ||
| serviceAccountEmail: "jenkins-gce@elastic-observability.iam.gserviceaccount.com" | ||
| template: "https://www.googleapis.com/compute/v1/projects/elastic-observability/global/instanceTemplates/elastic-apm-ci-ubuntu-1804-lts-20210201222928" | ||
| zone: "https://www.googleapis.com/compute/v1/projects/elastic-observability/zones/us-central1-f" | ||
| credentialsId: "elastic-observability" | ||
| instanceCapStr: "300" | ||
| instanceId: "20d4387f-26d5-470f-8455-d8e4c15de6df" | ||
| projectId: "elastic-observability" |
This file contains hidden or 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 hidden or 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,5 +1,9 @@ | ||
| disable-github-multibranch-status | ||
| filesystem_scm | ||
| google-compute-engine | ||
| job-dsl | ||
| metrics | ||
| monitoring | ||
| opentelemetry::https://storage.googleapis.com/apm-ci-temp/plugins/opentelemetry.hpi | ||
| plot | ||
| ssh-agent |
This file contains hidden or 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 hidden or 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,49 @@ | ||
| NAME = 'it/gce-test-orchestrator' | ||
| DSL = ''' | ||
| pipeline { | ||
| agent none | ||
| stages { | ||
| /*stage('Test for a while') { | ||
| steps { | ||
| parallelStepsForAWhile() | ||
| } | ||
| }*/ | ||
| stage('Test in batches') { | ||
| steps { | ||
| buildCall(10, 10) | ||
| } | ||
| } | ||
| stage('Test in massive requests') { | ||
| steps { | ||
| buildCall(3, 100) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def buildCall(num, factor) { | ||
| for (i = 1; i < num; i++) { | ||
| buildRun(i * factor, false) | ||
| } | ||
| } | ||
|
|
||
| def buildRun(i, wait) { | ||
| build(job: 'gce-test', propagate: false, quietPeriod: 0, wait: wait, | ||
| parameters: [string(name: 'num', value: "${i}")]) | ||
| } | ||
|
|
||
| // It runs in batches of 10 node requests | ||
| def parallelStepsForAWhile(){ | ||
| for (i = 0; i < 100; i++) { | ||
| buildRun(10, false) | ||
| } | ||
| } | ||
| ''' | ||
|
|
||
| pipelineJob(NAME) { | ||
| definition { | ||
| cps { | ||
| script(DSL.stripIndent()) | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,68 @@ | ||
| NAME = 'it/gce-test' | ||
| DSL = ''' | ||
| import groovy.time.* | ||
| pipeline { | ||
| agent none | ||
| environment { | ||
| PIPELINE_LOG_LEVEL = 'INFO' | ||
| HOME = "${WORKSPACE}" | ||
| } | ||
| parameters { | ||
| string defaultValue: '1', description: '', name: 'num', trim: false | ||
| } | ||
| options { | ||
| timeout(time: 2, unit: 'HOURS') | ||
| timestamps() | ||
| disableResume() | ||
| durabilityHint('PERFORMANCE_OPTIMIZED') | ||
| disableConcurrentBuilds() | ||
| } | ||
| stages { | ||
| stage('Test') { | ||
| steps { | ||
| script { | ||
| currentBuild.description = "With ${params.num} nodes" | ||
| } | ||
| parallelSteps("${params.num}".toString().toInteger()) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def parallelSteps(max){ | ||
| def num = (max < 1) ? 1 : max | ||
| def parallelSteps = [:] | ||
| for (i = 0; i < num; i++) { | ||
| parallelSteps["step-${i}"] = { | ||
| echo 'parallelSteps|started' | ||
| TimeDuration timeDuration = elapsedTime { | ||
| node('linux && immutable'){ | ||
| echo 'hey!' | ||
| } | ||
| } | ||
| echo "parallelSteps|finished|${timeDuration.toString()}" | ||
| } | ||
| } | ||
| parallel parallelSteps | ||
| } | ||
|
|
||
| def elapsedTime(Closure closure){ | ||
| def timeStart = new Date() | ||
| closure() | ||
| def timeStop = new Date() | ||
| TimeCategory.minus(timeStop, timeStart) | ||
| } | ||
|
|
||
| ''' | ||
|
|
||
| pipelineJob(NAME) { | ||
| parameters { | ||
| stringParam('num', '1') | ||
| } | ||
| concurrentBuild(false) | ||
| definition { | ||
| cps { | ||
| script(DSL.stripIndent()) | ||
| } | ||
| } | ||
| } |
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.
IMHO we need to add a section here explaining what exactly this is and why somebody would want to configure it. The purpose of setting up GCE locally is not clear from reading this documentation.
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.
I added the why in the description of this PR, how do you foresee we can improve this?