Skip to content

Commit

Permalink
Added the eyal accounts (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
athiruma authored Oct 16, 2024
1 parent 25d4d4e commit 80ec6cc
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ pipeline {
for (account in accounts_list.keySet()) {
echo "Running for account ${account.toUpperCase()}"
withCredentials([string(credentialsId: "${account}-aws-access-key-id", variable: 'access_key'),
string(credentialsId: "${account}-aws-secret-key-id", variable: 'secret_key')]) {
string(credentialsId: "${account}-aws-secret-key-id", variable: 'secret_key'),
string(credentialsId: "${account}-s3-bucket", variable: 's3_bucket')
]) {
env.account_name = "${account}"
env.ES_INDEX = "cloud-governance-cost-explorer-global-index-tenant-qe"
sh 'python3 jenkins/tenant/aws/common/run_cost_policies.py'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
### ecoeng_02 - dry_run=no
### qe_01 - dry_run=no

**POLICIES_IN_ACTION
** = '[]'

ES_HOST:

- Currently using intlab
- Currently, using haim elasticsearch

Accounts:

Expand Down
91 changes: 91 additions & 0 deletions jenkins/tenant/aws/qe/qe_02/PolicyJenkinsfileDaily
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
accounts_list = ['konflux-fedora': '[email protected], [email protected], [email protected], [email protected], [email protected], [email protected]',
'external-staging-multi-platform': '[email protected], [email protected], [email protected], [email protected], [email protected], [email protected]',
'internal-staging-multi-platform': '[email protected], [email protected], [email protected], [email protected], [email protected], [email protected]',
'external-staging-konflux': '[email protected], [email protected], [email protected], [email protected], [email protected], [email protected]',
'internal-staging-konflux': '[email protected], [email protected], [email protected], [email protected], [email protected], [email protected]']
pipeline {
options {
disableConcurrentBuilds()
}
agent {
docker {
label 'cloud-governance-worker'
image 'quay.io/athiru/fedora38-podman:latest'
args '-u root -v /etc/postfix/main.cf:/etc/postfix/main.cf --privileged'
}
}
environment {
QUAY_CLOUD_GOVERNANCE_REPOSITORY = credentials('QUAY_CLOUD_GOVERNANCE_REPOSITORY')
AWS_IAM_USER_SPREADSHEET_ID = credentials('cloud-governance-aws-iam-user-spreadsheet-id')
GOOGLE_APPLICATION_CREDENTIALS = credentials('cloud-governance-google-application-credentials')
LDAP_HOST_NAME = credentials('cloud-governance-ldap-host-name')
ES_HOST = credentials('cloud-governance-es-host')
ES_PORT = credentials('cloud-governance-es-port')
ALERT_DRY_RUN = true
contact1 = "[email protected]"
contact2 = "[email protected]"
// Find the all available policies: https://github.com/redhat-performance/cloud-governance/tree/main/cloud_governance/policy
// By default, all policies are running in dry_run="yes" mode and the whole list can be found in run_policies.py
// POLICIES_IN_ACTION: Policies that run in the dry_run="no" mode
POLICIES_IN_ACTION = '[]'
}
stages {
stage('Checkout') { // Checkout (git clone ...) the projects repository
steps {
checkout scm
}
}
stage('Initial Cleanup') {
steps {
sh '''if [[ "$(podman images -q ${QUAY_CLOUD_GOVERNANCE_REPOSITORY} 2> /dev/null)" != "" ]]; then podman rmi -f $(podman images -q ${QUAY_CLOUD_GOVERNANCE_REPOSITORY} 2> /dev/null); fi'''
}
}
stage('Run Cost Policies') {
steps {
script {
for (account in accounts_list.keySet()) {
echo "Running for account ${account.toUpperCase()}"
withCredentials([string(credentialsId: "${account}-aws-access-key-id", variable: 'access_key'),
string(credentialsId: "${account}-aws-secret-key-id", variable: 'secret_key')]) {
env.account_name = "${account}"
env.ES_INDEX = "cloud-governance-cost-explorer-global-index-tenant-qe"
sh 'python3 jenkins/tenant/aws/common/run_cost_policies.py'
}
}
}
}
}
stage('Run Daily Policies') {
steps {
script {
for (account in accounts_list.keySet()) {
echo "Running for account ${account.toUpperCase()}"
withCredentials([string(credentialsId: "${account}-aws-access-key-id", variable: 'access_key'),
string(credentialsId: "${account}-aws-secret-key-id", variable: 'secret_key')]) {
env.account_name = "${account}"
env.ADMIN_MAIL_LIST = "${accounts_list[account]}"
env.ES_INDEX = "cloud-governance-cost-policy-es-index-tenant-qe"
sh 'python3 jenkins/tenant/aws/common/run_policies.py'
}
}
}
}
}
stage('Finalize Cleanup') {
steps {
sh '''if [[ "$(podman images -q ${QUAY_CLOUD_GOVERNANCE_REPOSITORY} 2> /dev/null)" != "" ]]; then podman rmi -f $(podman images -q ${QUAY_CLOUD_GOVERNANCE_REPOSITORY} 2> /dev/null); fi'''
deleteDir()
}
}
}
post {
failure {
script {
msg = "Build error for ${env.JOB_NAME} ${env.BUILD_NUMBER} (${env.BUILD_URL})"
emailext body: """\
Jenkins job: ${env.BUILD_URL}\nSee the console output for more details: ${env.BUILD_URL}consoleFull\n\n
""",subject: msg, to: "${contact1}, ${contact2}"
}
}
}
}
21 changes: 21 additions & 0 deletions jenkins/tenant/aws/qe/qe_02/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### qe_02 - dry_run=yes

**POLICIES_IN_ACTION
** = '[]'

ES_HOST:

- Currently, using haim elasticsearch

Accounts:

1. **konflux-fedora**: [email protected], [email protected], [email protected], [email protected], [email protected],
[email protected]
2. **external-staging-multi-platform**: [email protected], [email protected], [email protected], [email protected],
[email protected], [email protected]
3. **internal-staging-multi-platform**: [email protected], [email protected], [email protected], [email protected],
[email protected], [email protected]
4. **external-staging-konflux**: [email protected], [email protected], [email protected], [email protected],
[email protected], [email protected]
5. **internal-staging-konflux**: [email protected], [email protected], [email protected], [email protected],
[email protected], [email protected]
61 changes: 61 additions & 0 deletions jenkins/tenant/aws/qe/qe_02/TaggingJenkinsfileHourly
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
account = ['konflux-fedora', 'external-staging-multi-platform', 'internal-staging-multi-platform', 'external-staging-konflux', 'internal-staging-konflux']
pipeline {
options {
disableConcurrentBuilds()
}
agent {
docker {
label 'cloud-governance-worker'
image 'quay.io/athiru/fedora38-podman:latest'
args '-u root -v /etc/postfix/main.cf:/etc/postfix/main.cf --privileged'
}
}
environment {
QUAY_CLOUD_GOVERNANCE_REPOSITORY = credentials('QUAY_CLOUD_GOVERNANCE_REPOSITORY')
LDAP_HOST_NAME = credentials('cloud-governance-ldap-host-name')
contact1 = "[email protected]"
contact2 = "[email protected]"
}
stages {
stage('Checkout') { // Checkout (git clone ...) the projects repository
steps {
checkout scm
}
}
stage('Initial Cleanup') {
steps {
sh '''if [[ "$(podman images -q ${QUAY_CLOUD_GOVERNANCE_REPOSITORY} 2> /dev/null)" != "" ]]; then podman rmi -f $(podman images -q ${QUAY_CLOUD_GOVERNANCE_REPOSITORY} 2> /dev/null); fi'''
}
}
stage('Run Tagging Cluster & Non-Cluster') {
steps {
script {
for (int i = 0; i < account.size(); ++i) {
echo "Running for account ${account[i].toUpperCase()}"
withCredentials([string(credentialsId: "${account[i]}-aws-access-key-id", variable: 'access_key'),
string(credentialsId: "${account[i]}-aws-secret-key-id", variable: 'secret_key')]) {
env.account_name = "${account[i]}"
sh 'python3 jenkins/tenant/aws/common/run_tagging.py'
}
}
}
}
}
stage('Finalize Cleanup') {
steps {
sh '''if [[ "$(podman images -q ${QUAY_CLOUD_GOVERNANCE_REPOSITORY} 2> /dev/null)" != "" ]]; then podman rmi -f $(podman images -q ${QUAY_CLOUD_GOVERNANCE_REPOSITORY} 2> /dev/null); fi'''
deleteDir()
}
}
}
post {
failure {
script {
msg = "Build error for ${env.JOB_NAME} ${env.BUILD_NUMBER} (${env.BUILD_URL})"
emailext body: """\
Jenkins job: ${env.BUILD_URL}\nSee the console output for more details: ${env.BUILD_URL}consoleFull\n\n
""",subject: msg, to: "${contact1}, ${contact2}"
}
}
}
}

0 comments on commit 80ec6cc

Please sign in to comment.