This repository was archived by the owner on Dec 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Tiller module #25
Merged
Merged
Tiller module #25
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
aea4bf7
Working protoype
yorinasub17 d7a768b
Working protoype
yorinasub17 8b0b936
Clean up
yorinasub17 5fd0b86
Use alpha version of kubergrunt
yorinasub17 0404a45
Remove unnecessary vars
yorinasub17 3e005c1
Update modules/k8s-tiller/README.md
rileykarson 7ea0f43
Address PR comments
yorinasub17 ba9d9c5
Use released kubergrunt in test
yorinasub17 31a14b2
dependency_getter => wait_for
yorinasub17 067a608
Revert input to be dependencies as opposed to wait_for
yorinasub17 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
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
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 |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ provider "kubernetes" { | |
| module "tiller_namespace" { | ||
| # When using these modules in your own templates, you will need to use a Git URL with a ref attribute that pins you | ||
| # to a specific version of the modules, such as the following example: | ||
| # source = "git::git@github.com:gruntwork-io/terraform-kubernetes-helm.git//modules/k8s-namespace?ref=v0.1.0" | ||
| # source = "git::git@github.com:gruntwork-io/terraform-kubernetes-helm.git//modules/k8s-namespace?ref=v0.3.0" | ||
| source = "./modules/k8s-namespace" | ||
|
|
||
| name = "${var.tiller_namespace}" | ||
|
|
@@ -31,7 +31,7 @@ module "tiller_namespace" { | |
| module "resource_namespace" { | ||
| # When using these modules in your own templates, you will need to use a Git URL with a ref attribute that pins you | ||
| # to a specific version of the modules, such as the following example: | ||
| # source = "git::git@github.com:gruntwork-io/terraform-kubernetes-helm.git//modules/k8s-namespace?ref=v0.1.0" | ||
| # source = "git::git@github.com:gruntwork-io/terraform-kubernetes-helm.git//modules/k8s-namespace?ref=v0.3.0" | ||
| source = "./modules/k8s-namespace" | ||
|
|
||
| name = "${var.resource_namespace}" | ||
|
|
@@ -40,7 +40,7 @@ module "resource_namespace" { | |
| module "tiller_service_account" { | ||
| # When using these modules in your own templates, you will need to use a Git URL with a ref attribute that pins you | ||
| # to a specific version of the modules, such as the following example: | ||
| # source = "git::git@github.com:gruntwork-io/terraform-kubernetes-helm.git//modules/k8s-service-account?ref=v0.1.0" | ||
| # source = "git::git@github.com:gruntwork-io/terraform-kubernetes-helm.git//modules/k8s-service-account?ref=v0.3.0" | ||
| source = "./modules/k8s-service-account" | ||
|
|
||
| name = "${var.service_account_name}" | ||
|
|
@@ -63,17 +63,88 @@ module "tiller_service_account" { | |
| } | ||
| } | ||
|
|
||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| # GENERATE TLS CERTIFICATES FOR USE WITH TILLER | ||
| # This will use kubergrunt to generate TLS certificates, and upload them as Kubernetes Secrets that can then be used by | ||
| # Tiller. | ||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| resource "null_resource" "tiller_tls_certs" { | ||
| provisioner "local-exec" { | ||
| command = <<-EOF | ||
| # Generate CA TLS certs | ||
| kubergrunt tls gen --ca --namespace kube-system --secret-name ${local.tls_ca_secret_name} --secret-label gruntwork.io/tiller-namespace=${var.tiller_namespace} --secret-label gruntwork.io/tiller-credentials=true --secret-label gruntwork.io/tiller-credentials-type=ca --tls-subject-json '${jsonencode(var.tls_subject)}' --tls-private-key-algorithm ${var.private_key_algorithm} ${local.tls_algorithm_config} ${local.kubectl_config_options} | ||
|
|
||
| # Then use that CA to generate server TLS certs | ||
| kubergrunt tls gen --namespace ${module.tiller_namespace.name} --ca-secret-name ${local.tls_ca_secret_name} --ca-namespace kube-system --secret-name ${local.tls_secret_name} --secret-label gruntwork.io/tiller-namespace=${var.tiller_namespace} --secret-label gruntwork.io/tiller-credentials=true --secret-label gruntwork.io/tiller-credentials-type=server --tls-subject-json '${jsonencode(var.tls_subject)}' --tls-private-key-algorithm ${var.private_key_algorithm} ${local.tls_algorithm_config} ${local.kubectl_config_options} | ||
| EOF | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These long string |
||
| } | ||
|
|
||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| # DEPLOY TILLER | ||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| module "tiller" { | ||
| # When using these modules in your own templates, you will need to use a Git URL with a ref attribute that pins you | ||
| # to a specific version of the modules, such as the following example: | ||
| # source = "git::git@github.com:gruntwork-io/terraform-kubernetes-helm.git//modules/k8s-tiller?ref=v0.3.0" | ||
| source = "./modules/k8s-tiller" | ||
|
|
||
| tiller_service_account_name = "${module.tiller_service_account.name}" | ||
| tiller_service_account_token_secret_name = "${module.tiller_service_account.token_secret_name}" | ||
| tiller_tls_secret_name = "${local.tls_secret_name}" | ||
| namespace = "${module.tiller_namespace.name}" | ||
| tiller_image_version = "${var.tiller_version}" | ||
|
|
||
| # Kubergrunt will store the private key under the key "tls.pem" in the corresponding Secret resource, which will be | ||
| # accessed as a file when mounted into the container. | ||
| tiller_tls_key_file_name = "tls.pem" | ||
|
|
||
| dependencies = ["${null_resource.tiller_tls_certs.id}"] | ||
| } | ||
|
|
||
| # The Deployment resources created in the module call to `k8s-tiller` will be complete creation before the rollout is | ||
| # complete. We use kubergrunt here to wait for the deployment to complete, so that when this resource is done creating, | ||
| # any resources that depend on this can assume Tiller is successfully deployed and up at that point. | ||
| resource "null_resource" "wait_for_tiller" { | ||
| provisioner "local-exec" { | ||
| command = "kubergrunt helm wait-for-tiller --tiller-namespace ${module.tiller_namespace.name} --tiller-deployment-name ${module.tiller.deployment_name} --expected-tiller-version ${var.tiller_version}" | ||
| } | ||
| } | ||
|
|
||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| # CONFIGURE OPERATOR HELM CLIENT | ||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| resource "null_resource" "grant_and_configure_helm" { | ||
| count = "${var.configure_helm}" | ||
|
|
||
| provisioner "local-exec" { | ||
| command = <<-EOF | ||
| kubergrunt helm grant --tiller-namespace ${module.tiller_namespace.name} ${local.kubectl_config_options} --tls-subject-json '${jsonencode(var.client_tls_subject)}' ${local.configure_args} | ||
|
|
||
| kubergrunt helm configure --helm-home ${local.helm_home_with_default} --tiller-namespace ${module.tiller_namespace.name} --resource-namespace ${module.resource_namespace.name} ${local.kubectl_config_options} ${local.configure_args} | ||
| EOF | ||
| } | ||
|
|
||
| depends_on = ["null_resource.wait_for_tiller"] | ||
| } | ||
|
|
||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| # COMPUTATIONS | ||
| # These locals compute various useful information used throughout this Terraform module. | ||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| locals { | ||
| helm_home_with_default = "${var.helm_home == "" ? pathexpand("~/.helm") : var.helm_home}" | ||
| kubectl_config_options = "${var.kubectl_config_context_name != "" ? "--kubectl-context-name ${var.kubectl_config_context_name}" : ""} ${var.kubectl_config_path != "" ? "--kubeconfig ${var.kubectl_config_path}" : ""}" | ||
|
|
||
| tls_ca_secret_name = "${var.tiller_namespace}-namespace-tiller-ca-certs" | ||
| tls_secret_name = "tiller-certs" | ||
|
|
||
| tls_algorithm_config = "${var.private_key_algorithm == "ECDSA" ? "--tls-private-key-ecdsa-curve ${var.private_key_ecdsa_curve}" : "--tls-private-key-rsa-bits ${var.private_key_rsa_bits}"}" | ||
|
|
||
| undeploy_args = "${var.force_undeploy ? "--force" : ""} ${var.undeploy_releases ? "--undeploy-releases" : ""}" | ||
| helm_home_with_default = "${var.helm_home == "" ? pathexpand("~/.helm") : var.helm_home}" | ||
|
|
||
| configure_args = "${ | ||
| var.helm_client_rbac_user != "" ? "--rbac-user ${var.helm_client_rbac_user}" | ||
|
|
@@ -82,14 +153,3 @@ locals { | |
| : "" | ||
| }" | ||
| } | ||
|
|
||
| resource "null_resource" "tiller" { | ||
| provisioner "local-exec" { | ||
| command = "kubergrunt helm deploy ${local.kubectl_config_options} --service-account ${module.tiller_service_account.name} --resource-namespace ${module.resource_namespace.name} --tiller-namespace ${module.tiller_namespace.name} --tls-private-key-algorithm ${var.private_key_algorithm} ${local.tls_algorithm_config} --tls-subject-json '${jsonencode(var.tls_subject)}' --client-tls-subject-json '${jsonencode(var.client_tls_subject)}' --helm-home ${local.helm_home_with_default} ${local.configure_args} --tiller-version ${var.tiller_version}" | ||
| } | ||
|
|
||
| provisioner "local-exec" { | ||
| command = "kubergrunt helm undeploy ${local.kubectl_config_options} --helm-home ${local.helm_home_with_default} --tiller-namespace ${module.tiller_namespace.name} ${local.undeploy_args}" | ||
| when = "destroy" | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
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.
This is now irrelevant, because upgrades can be done by modifying the vars to the
k8s-tillermodule call.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.
Just curious: This is done by upgrading the
tiller_image_version?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.
Yup that is correct. Updating
tiller_image_versionwill trigger a new rollout of theDeploymentresource and thePodswill be restarted.