-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate kind into local deployment to no longer require minikube fo…
…r development (#1171) * Checking in files for kind deployment * Using kind for deployment * Black formatting * Cannot view kubernetes cluster before deployment now * arm64 -> amd64 typo * use decoupled docker image new registry As the original docker build pipeline was moved to a separate repo, those changes need to be reflected in the workflow as well: - Update docker image labels and registry (hardcoded to main) - Remove docker build stage, added docker pull in place use bash loop for docker pull fix looping bash syntax * add kind cluster create there is no kind config yet switch image tags to test kind load Run test Run test fix formating issue fix formating issue * fix error from merge * Fix pre-commit error with yaml-check * Update Ingress IP match on hosts * rm kubectl check status * rm not used steps * Add existing deployment mode Co-authored-by: Vinicius D. Cerutti <51954708+viniciusdc@users.noreply.github.com> Co-authored-by: viniciusdc <vinivdc2009@hotmail.com>
- Loading branch information
1 parent
ee41b5e
commit 0c88503
Showing
14 changed files
with
692 additions
and
56 deletions.
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
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 |
---|---|---|
|
@@ -46,6 +46,7 @@ jobs: | |
- do | ||
- gcp | ||
- local | ||
- existing | ||
cicd: | ||
- none | ||
- github-actions | ||
|
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
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
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
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
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
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
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,17 @@ | ||
variable "kube_context" { | ||
description = "Optional kubernetes context to use to connect to kubernetes cluster" | ||
type = string | ||
} | ||
|
||
output "kubernetes_credentials" { | ||
description = "Parameters needed to connect to kubernetes cluster locally" | ||
value = { | ||
config_path = pathexpand("~/.kube/config") | ||
config_context = var.kube_context | ||
} | ||
} | ||
|
||
output "kubeconfig_filename" { | ||
description = "filename for qhub kubeconfig" | ||
value = pathexpand("~/.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 |
---|---|---|
@@ -1,17 +1,111 @@ | ||
variable "kube_context" { | ||
description = "Optional kubernetes context to use to connect to kubernetes cluster" | ||
type = string | ||
terraform { | ||
required_providers { | ||
kind = { | ||
source = "kyma-incubator/kind" | ||
version = "0.0.11" | ||
} | ||
docker = { | ||
source = "kreuzwerker/docker" | ||
version = "2.16.0" | ||
} | ||
kubectl = { | ||
source = "gavinbunney/kubectl" | ||
version = ">= 1.7.0" | ||
} | ||
} | ||
} | ||
|
||
provider "kind" { | ||
|
||
} | ||
|
||
provider "docker" { | ||
|
||
} | ||
|
||
output "kubernetes_credentials" { | ||
description = "Parameters needed to connect to kubernetes cluster locally" | ||
value = { | ||
config_path = pathexpand("~/.kube/config") | ||
config_context = var.kube_context | ||
provider "kubernetes" { | ||
host = kind_cluster.default.endpoint | ||
cluster_ca_certificate = kind_cluster.default.cluster_ca_certificate | ||
client_key = kind_cluster.default.client_key | ||
client_certificate = kind_cluster.default.client_certificate | ||
} | ||
|
||
provider "kubectl" { | ||
load_config_file = false | ||
host = kind_cluster.default.endpoint | ||
cluster_ca_certificate = kind_cluster.default.cluster_ca_certificate | ||
client_key = kind_cluster.default.client_key | ||
client_certificate = kind_cluster.default.client_certificate | ||
} | ||
|
||
resource "kind_cluster" "default" { | ||
name = "test-cluster" | ||
wait_for_ready = true | ||
|
||
kind_config { | ||
kind = "Cluster" | ||
api_version = "kind.x-k8s.io/v1alpha4" | ||
|
||
node { | ||
role = "general" | ||
image = "kindest/node:v1.21.10" | ||
} | ||
} | ||
} | ||
|
||
output "kubeconfig_filename" { | ||
description = "filename for qhub kubeconfig" | ||
value = pathexpand("~/.kube/config") | ||
resource "kubernetes_namespace" "metallb" { | ||
metadata { | ||
name = "metallb-system" | ||
} | ||
} | ||
|
||
data "kubectl_path_documents" "metallb" { | ||
pattern = "${path.module}/metallb.yaml" | ||
} | ||
|
||
resource "kubectl_manifest" "metallb" { | ||
for_each = toset(data.kubectl_path_documents.metallb.documents) | ||
yaml_body = each.value | ||
wait = true | ||
depends_on = [kubernetes_namespace.metallb] | ||
} | ||
|
||
resource "kubectl_manifest" "load-balancer" { | ||
yaml_body = yamlencode({ | ||
apiVersion = "v1" | ||
kind = "ConfigMap" | ||
metadata = { | ||
namespace = kubernetes_namespace.metallb.metadata.0.name | ||
name = "config" | ||
} | ||
data = { | ||
config = yamlencode({ | ||
address-pools = [{ | ||
name = "default" | ||
protocol = "layer2" | ||
addresses = [ | ||
"${local.metallb_ip_min}-${local.metallb_ip_max}" | ||
] | ||
}] | ||
}) | ||
} | ||
}) | ||
|
||
depends_on = [kubectl_manifest.metallb] | ||
} | ||
|
||
data "docker_network" "kind" { | ||
name = "kind" | ||
|
||
depends_on = [kind_cluster.default] | ||
} | ||
|
||
locals { | ||
metallb_ip_min = cidrhost([ | ||
for network in data.docker_network.kind.ipam_config : network if network.gateway != "" | ||
][0].subnet, 356) | ||
|
||
metallb_ip_max = cidrhost([ | ||
for network in data.docker_network.kind.ipam_config : network if network.gateway != "" | ||
][0].subnet, 406) | ||
} |
Oops, something went wrong.