Skip to content

Commit

Permalink
Add support for Calico networking on GCE
Browse files Browse the repository at this point in the history
* Calico on GCE with IP-in-IP encapsulation and MTU 1440
* Calico on DO with IP-in-IP encapsulation and MTU 1440
* Digital Ocean firewalls don't support IPIP protocol yet
  • Loading branch information
dghubble committed Sep 6, 2017
1 parent d48f88c commit ec46bc1
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 2 deletions.
4 changes: 3 additions & 1 deletion digital-ocean/container-linux/kubernetes/bootkube.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Self-hosted Kubernetes assets (kubeconfig, manifests)
module "bootkube" {
source = "git::https://github.com/poseidon/bootkube-terraform.git?ref=v0.6.1"
source = "git::https://github.com/poseidon/bootkube-terraform.git?ref=5ffbfec46dc05721eaf9d15c3c9bbedefaead1bc"

cluster_name = "${var.cluster_name}"
api_servers = ["${format("%s.%s", var.cluster_name, var.dns_zone)}"]
etcd_servers = ["http://127.0.0.1:2379"]
asset_dir = "${var.asset_dir}"
networking = "${var.networking}"
network_mtu = 1440
pod_cidr = "${var.pod_cidr}"
service_cidr = "${var.service_cidr}"
experimental_self_hosted_etcd = "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ storage:
# Wrapper for bootkube start
set -e
# Move experimental manifests
[ -d /opt/bootkube/assets/manifests-* ] && mv /opt/bootkube/assets/manifests-*/* /opt/bootkube/assets/manifests && rm -rf /opt/bootkube/assets/manifests-*
[ -d /opt/bootkube/assets/experimental/manifests ] && mv /opt/bootkube/assets/experimental/manifests/* /opt/bootkube/assets/manifests && rm -r /opt/bootkube/assets/experimental/manifests
[ -d /opt/bootkube/assets/experimental/bootstrap-manifests ] && mv /opt/bootkube/assets/experimental/bootstrap-manifests/* /opt/bootkube/assets/bootstrap-manifests && rm -r /opt/bootkube/assets/experimental/bootstrap-manifests
BOOTKUBE_ACI="$${BOOTKUBE_ACI:-quay.io/coreos/bootkube}"
Expand Down
6 changes: 6 additions & 0 deletions digital-ocean/container-linux/kubernetes/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ variable "asset_dir" {
type = "string"
}

variable "networking" {
description = "Choice of networking provider (flannel or calico)"
type = "string"
default = "flannel"
}

variable "pod_cidr" {
description = "CIDR IP range to assign Kubernetes pods"
type = "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ storage:
# Wrapper for bootkube start
set -e
# Move experimental manifests
[ -d /opt/bootkube/assets/manifests-* ] && mv /opt/bootkube/assets/manifests-*/* /opt/bootkube/assets/manifests && rm -rf /opt/bootkube/assets/manifests-*
[ -d /opt/bootkube/assets/experimental/manifests ] && mv /opt/bootkube/assets/experimental/manifests/* /opt/bootkube/assets/manifests && rm -r /opt/bootkube/assets/experimental/manifests
[ -d /opt/bootkube/assets/experimental/bootstrap-manifests ] && mv /opt/bootkube/assets/experimental/bootstrap-manifests/* /opt/bootkube/assets/bootstrap-manifests && rm -r /opt/bootkube/assets/experimental/bootstrap-manifests
BOOTKUBE_ACI="$${BOOTKUBE_ACI:-quay.io/coreos/bootkube}"
Expand Down
6 changes: 6 additions & 0 deletions google-cloud/container-linux/controllers/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ variable "preemptible" {

// configuration

variable "networking" {
description = "Choice of networking provider (flannel or calico)"
type = "string"
default = "flannel"
}

variable "service_cidr" {
description = <<EOD
CIDR IP range to assign Kubernetes services.
Expand Down
4 changes: 3 additions & 1 deletion google-cloud/container-linux/kubernetes/bootkube.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Self-hosted Kubernetes assets (kubeconfig, manifests)
module "bootkube" {
source = "git::https://github.com/poseidon/bootkube-terraform.git?ref=v0.6.1"
source = "git::https://github.com/poseidon/bootkube-terraform.git?ref=5ffbfec46dc05721eaf9d15c3c9bbedefaead1bc"

cluster_name = "${var.cluster_name}"
api_servers = ["${format("%s.%s", var.cluster_name, var.dns_zone)}"]
etcd_servers = ["http://127.0.0.1:2379"]
asset_dir = "${var.asset_dir}"
networking = "${var.networking}"
network_mtu = 1440
pod_cidr = "${var.pod_cidr}"
service_cidr = "${var.service_cidr}"
experimental_self_hosted_etcd = "true"
Expand Down
1 change: 1 addition & 0 deletions google-cloud/container-linux/kubernetes/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module "controllers" {
preemptible = "${var.controller_preemptible}"

# configuration
networking = "${var.networking}"
service_cidr = "${var.service_cidr}"
kubeconfig_ca_cert = "${module.bootkube.ca_cert}"
kubeconfig_kubelet_cert = "${module.bootkube.kubelet_cert}"
Expand Down
20 changes: 20 additions & 0 deletions google-cloud/container-linux/kubernetes/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,23 @@ resource "google_compute_firewall" "allow-internal" {

source_ranges = ["10.0.0.0/8"]
}

# Calico BGP and IPIP
# https://docs.projectcalico.org/v2.5/reference/public-cloud/gce
resource "google_compute_firewall" "allow-calico" {
count = "${var.networking == "calico" ? 1 : 0}"

name = "${var.cluster_name}-allow-calico"
network = "${google_compute_network.network.name}"

allow {
protocol = "tcp"
ports = ["179"]
}

allow {
protocol = "ipip"
}

source_ranges = ["10.0.0.0/8"]
}
6 changes: 6 additions & 0 deletions google-cloud/container-linux/kubernetes/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ variable "asset_dir" {
type = "string"
}

variable "networking" {
description = "Choice of networking provider (flannel or calico)"
type = "string"
default = "flannel"
}

variable "pod_cidr" {
description = "CIDR IP range to assign Kubernetes pods"
type = "string"
Expand Down

0 comments on commit ec46bc1

Please sign in to comment.