-
Notifications
You must be signed in to change notification settings - Fork 10
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
add kind for local setup #6
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
af22864
WIP: add kind for local setup
MChorfa 62ad06c
Update variables.tf
MChorfa 9140556
Update README.md
MChorfa ab4908d
Merge branch 'add-kind' of ssh://github.com/MChorfa/multi-cloud-kuber…
MChorfa 51531f1
Update README.md
MChorfa 82694fa
Update README.md
MChorfa c49b608
Update clusters/kind/main.tf
ksatirli 5ebd76f
Apply suggestions from code review
ksatirli 242182c
Update clusters/kind/terraform.tfvars.sample
ksatirli 429c89d
Update main.tf
ksatirli 198af3d
Update clusters/kind/outputs.tf
ksatirli 61db0f5
Update clusters/kind/outputs.tf
ksatirli 8cee720
Update variables.tf
ksatirli a7934db
Apply code review
MChorfa 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,27 @@ | ||
# Workspace `kind` | ||
|
||
> This directory contains [kind Provider](https://registry.terraform.io/providers/kyma-incubator/kind/latest) Resources. | ||
|
||
## Requirements | ||
|
||
* Terraform CLI `1.0.9` or newer | ||
* ``` | ||
|
||
## Downstream Consumption | ||
|
||
The Kubernetes Cluster can be consumed via the [kind_cluster](https://kind.sigs.k8s.io/docs/user/quick-start/) data source: | ||
|
||
```hcl | ||
# see https://registry.terraform.io/providers/kyma-incubator/kind/latest/docs/resources/cluster#attributes-reference | ||
data "kind_cluster" "cluster" { | ||
name = "multi-cloud-k8s" | ||
} | ||
``` | ||
|
||
## Execution Mode | ||
|
||
Upon terraform initialization, make sure to: | ||
|
||
1. YOUR_ORGANIZATION_NAME > Workspaces >YOUR_WORKSPACE_NAME > Settings > General | ||
1. Switch `Execution Mode`from `Remote` to `Local` | ||
1. Save the settings |
This file contains 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 @@ | ||
# see https://registry.terraform.io/providers/kyma-incubator/kind/latest | ||
resource "kind_cluster" "cluster" { | ||
name = var.tfe_workspaces_prefix | ||
kubeconfig_path = pathexpand(var.kind_cluster_config_path) | ||
wait_for_ready = true | ||
|
||
# see https://github.com/kubernetes-sigs/kind/releases | ||
node_image = "kindest/node:${var.kind_kubernetes_version}" | ||
ksatirli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# see https://github.com/kyma-incubator/terraform-provider-kind/blob/master/kind/structure_kind_config.go | ||
kind_config { | ||
kind = "Cluster" | ||
api_version = "kind.x-k8s.io/v1alpha4" | ||
|
||
node { | ||
role = "control-plane" | ||
|
||
kubeadm_config_patches = [ | ||
"kind: InitConfiguration\nnodeRegistration:\n kubeletExtraArgs:\n node-labels: \"ingress-ready=true\"\n" | ||
] | ||
|
||
extra_port_mappings { | ||
container_port = 80 | ||
host_port = 80 | ||
} | ||
|
||
extra_port_mappings { | ||
container_port = 443 | ||
host_port = 443 | ||
} | ||
} | ||
|
||
node { | ||
ksatirli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
role = "worker" | ||
} | ||
|
||
node { | ||
ksatirli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
role = "worker" | ||
} | ||
|
||
node { | ||
ksatirli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
role = "worker" | ||
} | ||
} | ||
} |
This file contains 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,36 @@ | ||
# see https://www.terraform.io/docs/language/values/outputs.html | ||
output "cluster_config" { | ||
description = "Kind Cluster Config." | ||
value = kind_cluster.cluster.kubeconfig | ||
} | ||
|
||
# see https://www.terraform.io/docs/language/values/outputs.html | ||
output "cluster_client_certificate" { | ||
description = "Kind Cluster Client Certificate." | ||
value = kind_cluster.cluster.client_certificate | ||
} | ||
|
||
# see https://www.terraform.io/docs/language/values/outputs.html | ||
output "cluster_client_key" { | ||
description = "Kind Cluster Client Key." | ||
ksatirli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
value = kind_cluster.cluster.client_key | ||
ksatirli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sensitive = true | ||
} | ||
|
||
# see https://www.terraform.io/docs/language/values/outputs.html | ||
output "cluster_ca_certificate" { | ||
description = "Kind Cluster CA Certificate." | ||
value = kind_cluster.cluster.cluster_ca_certificate | ||
} | ||
|
||
# see https://www.terraform.io/docs/language/values/outputs.html | ||
output "cluster_endpoint" { | ||
description = "Kind Cluseter Endpoint." | ||
value = kind_cluster.cluster.endpoint | ||
} | ||
|
||
# this variable is used for testing purposes and has no bearing on the demo | ||
# see https://www.terraform.io/docs/language/values/outputs.html | ||
output "workspace_url" { | ||
value = "https://app.terraform.io/app/a-demo-organization/workspaces/${var.tfe_workspaces_prefix}-kind" | ||
} |
This file contains 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,2 @@ | ||
# see https://registry.terraform.io/providers/kyma-incubator/kind/latest | ||
provider "kind" {} |
This file contains 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,23 @@ | ||
terraform { | ||
# see https://www.terraform.io/docs/language/settings/backends/remote.html | ||
backend "remote" { | ||
hostname = "app.terraform.io" | ||
organization = "a-demo-organization" | ||
|
||
workspaces { | ||
name = "multi-cloud-k8s-kind" | ||
} | ||
} | ||
|
||
# see https://www.terraform.io/docs/language/settings/index.html#specifying-provider-requirements | ||
required_providers { | ||
# see https://registry.terraform.io/providers/kyma-incubator/kind/0.0.9 | ||
kind = { | ||
source = "kyma-incubator/kind" | ||
version = "0.0.9" | ||
} | ||
} | ||
|
||
# see https://www.terraform.io/docs/language/settings/index.html#specifying-a-required-terraform-version | ||
required_version = "1.0.9" | ||
} |
This file contains 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,2 @@ | ||
kind_kubernetes_version = "v1.21.1" | ||
kind_cluster_config_path = "~/.kube/config" |
This file contains 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,18 @@ | ||
variable "tfe_workspaces_prefix" { | ||
type = string | ||
description = "Prefix for TFE Workspaces." | ||
default = "multi-cloud-k8s" | ||
} | ||
|
||
# see https://github.com/kubernetes-sigs/kind/releases | ||
variable "kind_kubernetes_version" { | ||
type = string | ||
description = "Kubernetes version to use with Kind Cluster." | ||
default = "v1.21.1" | ||
} | ||
|
||
variable "kind_cluster_config_path" { | ||
type = string | ||
description = "The location where this cluster's kubeconfig will be saved to." | ||
default = "~/.kube/config" | ||
} |
This file contains 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 |
---|---|---|
|
@@ -7,7 +7,8 @@ variable "tfe_workspaces" { | |
"aks", | ||
"eks", | ||
"doks", | ||
"gke" | ||
"gke", | ||
"kind" | ||
] | ||
} | ||
|
||
|
This file contains 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
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.
So this line is interesting, because a data source would be the right approach, but there currently is none for
kind_cluster
specifically (looking at https://github.com/kyma-incubator/terraform-provider-kind/tree/master/kind).That being said, this and lines #13-18 might need an update to reflect the consumption through a normal resource (vs. a data source).
Does that make sense?
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.
@MChorfa
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.
Yep you are right there is no data-source . Sorry for the confusion