Skip to content

Commit

Permalink
Merge pull request #7 from solidnerd/add-calico-as-default-network
Browse files Browse the repository at this point in the history
Add calico automated install support
  • Loading branch information
solidnerd authored Nov 10, 2018
2 parents abb0800 + 262ea28 commit e3ed7ef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $ KUBECONFIG=secrets/admin.conf kubectl expose deploy nginx --port=80 --type Nod
| `docker_version` | `18.06` | Docker CE version that will be installed | No |
| `kubernetes_version` | `1.12.2` | Kubernetes version that will be installed | No |
| `core_dns` | `false` | Enables CoreDNS as Service Discovery | No |

| `calico_enabled` | `false` | Installs Calico Network Provider after the master comes up | No |
All variables cloud be passed through `environment variables` or a `tfvars` file.

An example for a `tfvars` file would be the following `terraform.tfvars`
Expand Down
18 changes: 18 additions & 0 deletions install-calico.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "null_resource" "calico" {
count = "${var.calico_enabled ? 1 : 0}"

connection {
host = "${hcloud_server.master.*.ipv4_address}"
private_key = "${file(var.ssh_private_key)}"
}

provisioner "remote-exec" {
inline = <<EOF
kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/hosted/etcd.yaml
kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/rbac.yaml
kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/hosted/calico.yaml
EOF
}

depends_on = ["hcloud_server.master"]
}
3 changes: 3 additions & 0 deletions scripts/master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ systemctl enable docker kubelet

# used to join nodes to the cluster
kubeadm token create --print-join-command > /tmp/kubeadm_join

mkdir -p "$HOME/.kube"
cp /etc/kubernetes/admin.conf "$HOME/.kube/config"
6 changes: 5 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ variable "kubernetes_version" {
}

variable "core_dns" {
default = "false"
default = false
}

variable "calico_enabled" {
default = false
}

0 comments on commit e3ed7ef

Please sign in to comment.