Skip to content
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

[Blueprints, 02-at-scale]: Use Secrets to pass terraform variables to Casc (part II) #144

Closed
wants to merge 87 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
406ca44
CI: same values as main
carlosrodlop May 8, 2024
4f939ca
Minor copy edits to recently revised docs.
kellie-freeman May 13, 2024
e59c816
terraform-docs: automated action
github-actions[bot] May 13, 2024
283a9c1
Fixing admonitions in lists and minor copy edits
kellie-freeman May 13, 2024
5e06ffa
Minor edits.
kellie-freeman May 13, 2024
b55e6f5
Merge pull request #139 from cloudbees/copy-edits
kellie-freeman May 14, 2024
fe17ca1
Addressing #72
carlosrodlop May 15, 2024
90e32d3
Merge branch 'develop' of github.com:cloudbees/terraform-aws-cloudbee…
carlosrodlop May 15, 2024
2461d52
Addressing #72
carlosrodlop May 15, 2024
81d56f5
Adding main for ci
carlosrodlop May 15, 2024
5b75d88
Adding comments from Kelly
carlosrodlop May 15, 2024
7b03742
fix line
carlosrodlop May 15, 2024
152f194
terraform-docs: automated action
github-actions[bot] May 15, 2024
87acb13
Update blueprints/02-at-scale/README.md
carlosrodlop May 15, 2024
812eb76
Update blueprints/02-at-scale/README.md
carlosrodlop May 15, 2024
2057eb3
terraform-docs: automated action
github-actions[bot] May 15, 2024
f507f8b
Update blueprints/02-at-scale/outputs.tf
carlosrodlop May 15, 2024
a8f8311
Update blueprints/02-at-scale/outputs.tf
carlosrodlop May 15, 2024
b0ccb68
Update blueprints/02-at-scale/outputs.tf
carlosrodlop May 15, 2024
3094544
Update blueprints/02-at-scale/outputs.tf
carlosrodlop May 15, 2024
643bcfc
terraform-docs: automated action
github-actions[bot] May 15, 2024
3c5d134
Update blueprints/02-at-scale/main.tf
carlosrodlop May 15, 2024
0072ba3
Preparing bundle
carlosrodlop May 15, 2024
44d2178
Removing old secret hardcoded in the file
carlosrodlop May 15, 2024
8da46a7
Replacing osixia-openldap by openldap-stack
carlosrodlop May 15, 2024
4457a03
Merge branch 'ldap' of github.com:cloudbees/terraform-aws-cloudbees-c…
carlosrodlop May 15, 2024
ea28c16
Removing osixia-ldap
carlosrodlop May 19, 2024
2112e4b
Casc. Test ldap password
carlosrodlop May 19, 2024
b3670a0
casc test
carlosrodlop May 19, 2024
2956470
Casc: Adding Ldap configuration for Example Org
carlosrodlop May 20, 2024
26061e0
Casc - refactor names
carlosrodlop May 20, 2024
7f54859
Adding notes on users and groups configuration
carlosrodlop May 20, 2024
929d7c2
Reformat names on secrets
carlosrodlop May 20, 2024
34933e0
Prepare secrets to be templating
carlosrodlop May 20, 2024
4eb885d
Template secrets
carlosrodlop May 20, 2024
59713f4
Casc: enabling Rbac configuraion
carlosrodlop May 20, 2024
ed31b61
Setting ldap branch
carlosrodlop May 20, 2024
5f42e79
Secrets passed as String not as file path
carlosrodlop May 20, 2024
08234dd
Update blueprints/02-at-scale/k8s/openldap-stack-values.yml
carlosrodlop May 20, 2024
fea0242
Update variables.tf
carlosrodlop May 20, 2024
4c563f2
Update blueprints/02-at-scale/k8s/openldap-stack-values.yml
carlosrodlop May 20, 2024
179df16
Replace to ACME Coorporation
carlosrodlop May 21, 2024
f71506a
Merge branch 'ldap' of github.com:cloudbees/terraform-aws-cloudbees-c…
carlosrodlop May 21, 2024
6814aac
Replacing by global password
carlosrodlop May 21, 2024
3397e61
typo and disabling phpldapadmin
carlosrodlop May 21, 2024
fe66954
typo
carlosrodlop May 21, 2024
bc021d3
Moving to local.global_pass_jsonpath
carlosrodlop May 21, 2024
3a19d22
Using Global Password for validation
carlosrodlop May 21, 2024
ff8388c
Merge branch 'develop' into ldap
carlosrodlop May 21, 2024
e092815
terraform-docs: automated action
github-actions[bot] May 21, 2024
e9bbc45
terraform-docs: automated action
github-actions[bot] May 21, 2024
4a7dc29
Merge pull request #140 from cloudbees/ldap
carlosrodlop May 21, 2024
9761d51
Docs: Amending Documentation for LDAP authetication
carlosrodlop May 21, 2024
0ffcd96
Merge branch 'ldap' of github.com:cloudbees/terraform-aws-cloudbees-c…
carlosrodlop May 21, 2024
80329c3
pre-commit checks update
carlosrodlop May 21, 2024
f7381ea
Adding tflint-ignore k8s/secrets-values.yml
carlosrodlop May 21, 2024
6e03ac2
try with ignore all for K8s secrets file
carlosrodlop May 21, 2024
95529fe
Adding in the same line the ignore
carlosrodlop May 21, 2024
4c5784b
increasing version of tf-lini
carlosrodlop May 21, 2024
9be23c7
Adding secrets file path as variable
carlosrodlop May 21, 2024
d4a54d3
Merge pull request #141 from cloudbees/ldap
carlosrodlop May 21, 2024
ad134cf
CI: Fi to only run on main
carlosrodlop May 21, 2024
bf467c6
Domains autovar replacing example by acme for clarity
carlosrodlop May 21, 2024
9caf9c5
Merge pull request #142 from cloudbees/domains
carlosrodlop May 21, 2024
f2caa59
Casc: using s3 name as secret
carlosrodlop May 21, 2024
d7919a7
casc: fix s3 variable
carlosrodlop May 21, 2024
be7997b
Secrets file are parametrized
carlosrodlop May 21, 2024
b2b4b84
terraform-docs: automated action
github-actions[bot] May 21, 2024
eda6e90
Casc: quoting secrets
carlosrodlop May 21, 2024
f25e77f
Merge branch 's3' of github.com:cloudbees/terraform-aws-cloudbees-ci-…
carlosrodlop May 21, 2024
68ac891
set s3 as branch values
carlosrodlop May 21, 2024
4daeff8
update CascBranch replacement
carlosrodlop May 21, 2024
a7575fc
passing pre-commit
carlosrodlop May 21, 2024
6702c87
adding ths for debugging
carlosrodlop May 21, 2024
8f98121
Adding mount configuration for secret
carlosrodlop May 21, 2024
f2aaaa2
Enable cascItemsConfiguration
carlosrodlop May 21, 2024
f6eafc3
solving typo
carlosrodlop May 21, 2024
939ad23
Mounting secrets for all controllers
carlosrodlop May 21, 2024
9e1b8ac
indenting yaml correctly
carlosrodlop May 21, 2024
771c4ec
Going back to deployment approach
carlosrodlop May 21, 2024
eb88292
fix indentation
carlosrodlop May 21, 2024
1b913bd
Fixing indentation
carlosrodlop May 21, 2024
4f89360
The secret mount is only valid for the OC
carlosrodlop May 21, 2024
fa3e100
terraform-docs: automated action
github-actions[bot] May 21, 2024
a683b69
Adapting docs to the new way of deployment
carlosrodlop May 21, 2024
16164fb
Merge branch 's3' of github.com:cloudbees/terraform-aws-cloudbees-ci-…
carlosrodlop May 21, 2024
0b5f98b
Merge pull request #143 from cloudbees/s3
carlosrodlop May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .cloudbees/workflows/bp-tf-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:
- 'main'

env:
AWS_REGION: "us-west-1"
AWS_REGION: "us-east-1"
BUCKET_NAME_TF_STATE: "cbci-eks-addon-tf-state"
AWS_ROLE_TO_ASSUME: "infra-admin-ci"
REPLAY_STR: "2"
REPLAY_STR: "1"
TF_AUTO_VARS_FILE: |
tags = {
"cb-owner" : "professional-services"
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

bp01:
env:
CLEAN_UP: "true"
CLEAN_UP: "false"
needs:
- init
steps:
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:

bp02:
env:
CLEAN_UP: "true"
CLEAN_UP: "false"
needs:
- init
steps:
Expand Down
40 changes: 0 additions & 40 deletions .cloudbees/workflows/ldap-dh.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions .cloudbees/workflows/ldap-gh.yaml

This file was deleted.

90 changes: 0 additions & 90 deletions .docker/ldap/data.ldif

This file was deleted.

10 changes: 0 additions & 10 deletions .docker/ldap/openldap.Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions: read-all

env:
TERRAFORM_DOCS_VERSION: v0.16.0
TFLINT_VERSION: v0.50.3
TFLINT_VERSION: v0.51.1

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ terraform.rc
terraform*.output
kubeconfig*.yaml

# Secrets file
*secrets*
!secrets*example

# Bankend file
backend*.tf

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ The CloudBees CI add-on uses `helms release` for its resources definition, makin
| cert_arn | AWS Certificate Manager (ACM) certificate for Amazon Resource Names (ARN). | `string` | n/a | yes |
| hosted_zone | Amazon Route 53 hosted zone name. | `string` | n/a | yes |
| trial_license | CloudBees CI trial license details for evaluation. | `map(string)` | n/a | yes |
| create_k8s_secrets | Create the Kubernetes secret cbci-secrets. It can be consumed by CloudBees CasC. | `bool` | `false` | no |
| create_k8s_secrets | Create the Kubernetes secret cbci-secrets. It can be consumed by CloudBees CasC at Operation Center level. | `bool` | `false` | no |
| helm_config | CloudBees CI Helm chart configuration. | `any` | <pre>{<br> "values": [<br> ""<br> ]<br>}</pre> | no |
| k8s_secrets_file | Secrets file .yml path containing the secrets names:values for cbci-secrets. | `string` | `"secrets-values.yml"` | no |
| k8s_secrets | Secrets file .yml as a string containing the secrets names:values. It is required when create_k8s_secrets is enabled. | `string` | `"secrets-values.yml"` | no |
| prometheus_target | Creates a service monitor to discover the CloudBees CI Prometheus target dynamically. It is designed to be enabled with the AWS EKS Terraform Addon Kube Prometheus Stack. | `bool` | `false` | no |

### Outputs
Expand Down
2 changes: 1 addition & 1 deletion blueprints/01-getting-started/.auto.tfvars.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hosted_zone = "example.domain.com" # Required. Route 53 Hosted Zone to host CloudBees CI subdomains records.
hosted_zone = "acme.domain.com" # Required. Route 53 Hosted Zone to host CloudBees CI subdomains records.

trial_license = { # Required. CloudBees CI Trial license details for evaluation.
first_name = "Foo"
Expand Down
7 changes: 5 additions & 2 deletions blueprints/02-at-scale/.auto.tfvars.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
hosted_zone = "example.domain.com" # Required. Route 53 Hosted Zone to host CloudBees CI subdomains records.
hosted_zone = "acme.domain.com" # Required. Route 53 Hosted Zone to host CloudBees CI subdomains records. Replace Default values by your own.

trial_license = { # Required. CloudBees CI Trial license details for evaluation.
trial_license = { # Required. CloudBees CI Trial license details for evaluation. Replace Default values by your own.
first_name = "Foo"
last_name = "Bar"
email = "foo.bar@acme.com"
company = "Acme Inc."
}

gh_user = "exampleUser" # Required. Default values can be used for demo.
gh_token = "ExampleToken1234" # Required. Default values can be used for demo.

# tags = { # Optional. Tags for the resources created. Default set to empty. Shared among all.
# "cb-owner" : "team-services"
# "cb-user" : "demo-user"
Expand Down
52 changes: 8 additions & 44 deletions blueprints/02-at-scale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ Once you have familiarized yourself with [CloudBees CI blueprint add-on: Get sta
|------|-------------|------|---------|:--------:|
| hosted_zone | Amazon Route 53 hosted zone. CloudBees CI applications are configured to use subdomains in this hosted zone. | `string` | n/a | yes |
| trial_license | CloudBees CI trial license details for evaluation. | `map(string)` | n/a | yes |
| grafana_admin_password | Grafana admin password. | `string` | `"change.me"` | no |
| gh_token | GitHub Token for CloudBees Operation Center credential GH-User-token that is created via Casc. | `string` | `"ExampleToken1234"` | no |
| gh_user | GitHub User for CloudBees Operation Center credential GH-User-token that is created via Casc. | `string` | `"exampleUser"` | no |
| suffix | Unique suffix to assign to all resources. When adding the suffix, changes are required in CloudBees CI for the validation phase. | `string` | `""` | no |
| tags | Tags to apply to resources. | `map(string)` | `{}` | no |

Expand Down Expand Up @@ -87,6 +88,7 @@ Once you have familiarized yourself with [CloudBees CI blueprint add-on: Get sta
| efs_access_points | Amazon EFS access points. |
| efs_arn | Amazon EFS ARN. |
| eks_cluster_arn | Amazon EKS cluster ARN. |
| global_password | Random string that is used as the global password. |
| grafana_dashboard | Provides access to Grafana dashboards. |
| kubeconfig_add | Add kubeconfig to the local configuration to access the Kubernetes API. |
| kubeconfig_export | Export the KUBECONFIG environment variable to access the Kubernetes API. |
Expand All @@ -95,9 +97,9 @@ Once you have familiarized yourself with [CloudBees CI blueprint add-on: Get sta
| prometheus_dashboard | Provides access to Prometheus dashboards. |
| s3_cbci_arn | CloudBees CI Amazon S3 bucket ARN. |
| s3_cbci_name | CloudBees CI Amazon S3 bucket name. It is required by CloudBees CI for workspace caching and artifact management. |
| velero_backup_on_demand | Takes an on-demand Velero backup from the schedule for selected controller using Block Storage. |
| velero_backup_schedule | Creates a Velero backup schedule for selected controller using Block Storage and deletes the existing schedulle, if it exists. |
| velero_restore | Restores selected controller using Block Storage from a backup. |
| velero_backup_on_demand | Takes an on-demand Velero backup from the schedule for the selected controller that is using block storage. |
| velero_backup_schedule | Creates a Velero backup schedule for the selected controller that is using block storage, and then deletes the existing schedule, if it exists. |
| velero_restore | Restores the selected controller that is using block storage from a backup. |
| vpc_arn | VPC ID. |
<!-- END_TF_DOCS -->

Expand All @@ -108,44 +110,6 @@ In addition to the minimum required settings explained in [Get started - Deploy]
> [!TIP]
> The `deploy` phase can be orchestrated via the companion [Makefile](../../Makefile).

### Create the secrets file

You must create your secrets file by copying the contents of [secrets-values.yml.example](k8s/secrets-values.yml.example) to `secrets-values.yml`. This provides [Kubernetes secrets](https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/docs/features/secrets.adoc#kubernetes-secrets) that can be consumed by CasC.

### Update Amazon S3 bucket settings

Since the optional Terraform variable `suffix` is used for this blueprint, you must update the Amazon S3 bucket name for CloudBees CI controllers and the Amazon S3 bucket for the backup controller cluster operations. To update the Amazon S3 bucket name, you have the following options:

- [Option 1: Update Amazon S3 bucket name using CasC](#option-1-update-amazon-s3-bucket-name-using-casc)
- [Option 2: Update Amazon S3 bucket name using the CloudBees CI UI](#option-2-update-amazon-s3-bucket-name-using-the-cloudbees-ci-ui)

#### Option 1: Update Amazon S3 bucket name using CasC

>[!IMPORTANT]
> This option can only be used before the blueprint has been deployed.

1. Create a fork of the [cloudbees/terraform-aws-cloudbees-ci-eks-addon](https://github.com/cloudbees/casc-cloudbees-ci-eks-addon) GitHub repository to your GitHub organization and make any necessary edits to the controller CasC bundle.
- Update `cbci_s3` in the [casc/mc/parent/variables/variables.yaml](casc/mc/parent/variables/variables.yaml) file, including your custom prefix.
- Update `scm_casc_mc_store` in the [casc/oc/variables/variables.yaml](casc/oc/variables/variables.yaml) file and `bucketName` in the [casc/oc/items/items-admin-jobs-folder.yaml](casc/oc/items/items-admin-jobs-folder.yaml) file.
2. Commit and push your changes to the forked repository in your organization.
3. In the [k8s/cbci-values.yml](k8s/cbci-values.yml) Helm file, update the `OperationsCenter.CasC.Retriever.scmRepo` field based on the files in this blueprint.
4. Save the file and issue the `terraform apply` command.

#### Option 2: Update Amazon S3 bucket name using the CloudBees CI UI

> [!IMPORTANT]
> - This option can only be used after the blueprint is deployed.
> - If using CasC, the declarative definition overrides any configuration updates that are made in the UI the next time the controller is restarted.

1. Sign in to the CloudBees CI controller UI as a user with **Administer** privileges.
2. Navigate to **Manage Jenkins > AWS > Amazon S3 Bucket Access settings**, update the **S3 Bucket Name**, and select **Save**.
3. Sign in to the CloudBees CI operations center UI as a user with **Administer** privileges.
Note that access to back up jobs is restricted to admin users via role-based access control (RBAC).
4. From the operations center dashboard, select **All** to view all folders on the operations center.
5. Navigate to the **admin** folder, and then select the **backup-all-controllers** Cluster Operations job.
6. From the left pane, select **Configure**.
7. Update the **S3 Bucket Name**, and then select **Save**.

## Validate

Once the blueprint has been deployed, you can validate it.
Expand All @@ -164,10 +128,10 @@ Once the resources have been created, a `kubeconfig` file is created in the [/k8

1. Complete the steps to [validate CloudBees CI](../01-getting-started/README.md#cloudbees-ci), if you have not done so already.

2. Authentication in this blueprint is based on LDAP and uses two types of personas (Admin and Developer), each with a different authorization level. Each persona uses a different username (cn); you can find the password in [.docker/ldap/data.ldif](./../../.docker/ldap/data.ldif). The authorization level defines a set of permissions configured using [RBAC](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-secure-guide/rbac). Additionally, the operations center and controller use [single sign-on (SS0)](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-secure-guide/using-sso). Issue the following command to retrieve the password of the `admin_cbci_a` user
2. Authentication in this blueprint is based on LDAP using user cn (available in [k8s/openldap-stack-values.yml](./k8s/openldap-stack-values.yml)) and the global password. The authorization level defines a set of permissions configured using [RBAC](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-secure-guide/rbac). Additionally, the operations center and controller use [single sign-on (SS0)](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-secure-guide/using-sso). Issue the following command to retrieve the global password:

```sh
eval $(terraform output --raw ldap_admin_password)
eval $(terraform output --raw global_password)
```

3. CasC is enabled for the [operations center](https://docs.cloudbees.com/docs/cloudbees-ci/latest/casc-oc/) (`cjoc`) and [controllers](https://docs.cloudbees.com/docs/cloudbees-ci/latest/casc-controller/) (`team-b` and `team-c-ha`). `team-a` is not using CasC, to illustrate the difference between the two approaches. Issue the following command to verify that all controllers are in a `Running` state:
Expand Down
2 changes: 1 addition & 1 deletion blueprints/02-at-scale/casc/mc/parent/jcasc/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ unclassified:
endpoint: ${ot_endpoint}
aws:
s3:
container: ${cbci_s3}
container: "${sec_s3bucketName}"
disableSessionToken: false
prefix: "cbci/"
useHttp: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
variables:
- ot_endpoint: "http://tempo.kube-prometheus-stack.svc.cluster.local:4317"
# You must update the variable in case a variable suffix is provided in the .tf files (for example, cbci-bp02-<YOUR-SUFFIX>-s3).
- cbci_s3: cbci-bp02-s3
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ items:
safeDelaySeconds: 0
store:
s3Store:
#TODO: Use variables
#bucketName: ${cbci_s3}
bucketName: "cbci-bp02-s3"
bucketName: "${sec_s3bucketName}"
bucketFolder: cbci/backup
region: us-east-1
itemSource:
Expand Down
Loading
Loading