Skip to content

Commit c2e9a93

Browse files
committed
increase vault max_lease_ttl_seconds 2h
1 parent 680326d commit c2e9a93

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

infrastructure-as-code/k8s-cluster-openshift-aws/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ While the original repository required the user to manually run ansible-playbook
1010
* [ansible-playbook](https://docs.ansible.com/ansible/2.4/ansible-playbook.html): the actual ansible tool used to deploy the OpenShift cluster. This is used in the install-from-bastion.sh script.
1111

1212
## Estimated Time to Complete
13-
60 minutes
13+
120 minutes
1414

1515
## Personas
1616
Our target persona is a developer or operations engineer who wants to provision an OpenShift cluster into AWS.
@@ -47,7 +47,7 @@ vault write aws-tf/config/root \
4747
access_key=<your_aws_access_key> \
4848
secret_key=<your_aws_secret_key> \
4949
region=us-east-1
50-
50+
5151
vault write aws-tf/roles/deploy policy_document=-<<EOF
5252
{
5353
"Version": "2012-10-17",
@@ -84,7 +84,9 @@ If you want to use open source Terraform instead of TFE, you can create a copy o
8484
1. On the Latest Run tab, you should see a new run. If the plan succeeds, you can view the plan and verify that the AWS infrastructure will be created and that various remote-exec and local-exec provisioners will run when you apply your plan.
8585
1. Click the "Confirm and Apply" button to actually provision your OpenShift cluster.
8686

87-
You will see outputs providing the IPs and DNS addresses needed to access your OpenShift cluster in the AWS Console, TLS certs/keys for your cluster, the Vault Kubernetes auth method path, the Vault server address, and your Vault username. You will need these when using Terraform's Kubernetes Provider to provision Kubernetes pods and services in other workspaces that use your OpenShift cluster. You can also validate that the cluster was created in the AWS Console.
87+
Unfortunately, the Ansible playbook that provisions the OpenShift cluster takes 80-90 minutes to do it. To accomodate this, we have set the `max_lease_ttl_seconds` attribute on the Vault provider to 7200 seconds (2 hours).
88+
89+
When the Ansible playbook finally deploys the OpenShift cluster and a few other null resources are run by Terraform, you will see outputs providing the IPs and DNS addresses needed to access your OpenShift cluster in the AWS Console, TLS certs/keys for your cluster, the Vault Kubernetes auth method path, the Vault server address, and your Vault username. You will need these when using Terraform's Kubernetes Provider to provision Kubernetes pods and services in other workspaces that use your OpenShift cluster. You can also validate that the cluster was created in the AWS Console.
8890

8991
You will be able to login to the OpenShift Console with username "admin" and password "123" at the URL contained in the k8s_endpoint output of the apply.log. To use the OpenShift `oc` CLI utility, you may SSH into the bastion host using `bastion_public_ip` output, then to the OpenShift master server using `master_private_ip` output from the apply log.
9092

infrastructure-as-code/k8s-cluster-openshift-aws/main.tf

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ terraform {
66
# Set VAULT_TOKEN environment variable
77
provider "vault" {
88
address = "${var.vault_addr}"
9-
max_lease_ttl_seconds = 3600
9+
max_lease_ttl_seconds = 7200
1010
}
1111

1212
# AWS credentials from Vault
@@ -177,44 +177,14 @@ resource "null_resource" "get_vault_reviewer_token" {
177177
depends_on = ["null_resource.configure_k8s"]
178178
}
179179

180-
# Get certs again in case Ansible script takes too long to run
181-
# and Vault token is no longer valid.
182-
# We need the certs in Terraform worker container in second run
183-
# This resource can be tainted before doing new run if first fails
184-
resource "null_resource" "get_config_2" {
185-
186-
provisioner "local-exec" {
187-
command = "echo \"${var.private_key_data}\" > private-key.pem"
188-
}
189-
190-
provisioner "local-exec" {
191-
command = "chmod 400 private-key.pem"
192-
}
193-
194-
provisioner "local-exec" {
195-
command = "scp -o StrictHostKeyChecking=no -i private-key.pem ec2-user@${module.openshift.bastion_public_dns}:~/config config"
196-
}
197-
provisioner "local-exec" {
198-
command = "sed -n 4,4p config | cut -d ':' -f 2 | sed 's/ //' > ca_certificate"
199-
}
200-
provisioner "local-exec" {
201-
command = "sed -n 28,28p config | cut -d ':' -f 2 | sed 's/ //' > client_certificate"
202-
}
203-
provisioner "local-exec" {
204-
command = "sed -n 29,29p config | cut -d ':' -f 2 | sed 's/ //' > client_key"
205-
}
206-
207-
depends_on = ["null_resource.get_vault_reviewer_token"]
208-
}
209-
210180
data "null_data_source" "get_certs" {
211181
inputs = {
212182
client_certificate = "${file("client_certificate")}"
213183
client_key = "${file("client_key")}"
214184
ca_certificate = "${file("ca_certificate")}"
215185
vault_reviewer_token = "${file("vault-reviewer-token")}"
216186
}
217-
depends_on = ["null_resource.get_config_2"]
187+
depends_on = ["null_resource.get_vault_reviewer_token"]
218188
}
219189

220190
# Use the vault_kubernetes_auth_backend_config resource

0 commit comments

Comments
 (0)