[k8s] S01E02 Control Plane: bootkube-render

This commit is contained in:
Nemo 2019-01-13 00:39:08 +05:30
parent 9b40bfd341
commit 86c0613d28
4 changed files with 76 additions and 0 deletions

View File

@ -7,3 +7,19 @@ module "etcd" {
docker = "docker.sydney"
}
}
# module "kubelet" {
# source = "modules/kubelet"
# listen_ip = "${var.ips["dovpn"]}"
# }
module "bootkube-render" {
source = "modules/bootkube"
mode = "render"
host_ip = "${var.ips["dovpn"]}"
k8s_host = "k8s.${var.root-domain}"
providers = {
docker = "docker.sydney"
}
}

1
modules/bootkube/data.tf Normal file
View File

@ -0,0 +1 @@

30
modules/bootkube/main.tf Normal file
View File

@ -0,0 +1,30 @@
resource "docker_container" "bootkube" {
image = "${docker_image.image.latest}"
name = "bootkube-render"
volumes {
container_path = "/home/.bootkube"
volume_name = "${var.asset_dir_volume_name}"
}
command = [
"bootkube",
"${var.mode}",
"--asset-dir=/home/.bootkube",
"--api-servers=https://kubernetes.default:${var.host_port},https://${var.k8s_host},https://${var.host_ip}:${var.host_port}",
"--pod-cidr=${var.pod_cidr}",
]
# "--service-cidr=${var.service_cidr}",
restart = "on-failure"
max_retry_count = 5
}
data "docker_registry_image" "image" {
name = "captn3m0/bootkube:v${var.version}"
}
resource "docker_image" "image" {
name = "${data.docker_registry_image.image.name}"
pull_triggers = ["${data.docker_registry_image.image.sha256_digest}"]
}

View File

@ -0,0 +1,29 @@
// Based on https://github.com/v1k0d3n/dockerfiles/tree/master/bootkube
variable "asset_dir_volume_name" {
default = "k8s-assets"
}
variable "k8s_host" {
description = "kubenetes hostname"
}
variable "host_port" {
default = "8443"
}
variable "host_ip" {}
variable "pod_cidr" {
default = "10.25.0.0/16"
}
variable "service_cidr" {
default = "10.96.0.0/16"
}
variable "mode" {}
variable "version" {
default = "0.14.0"
}