-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated to Rancher 2.0.2, added floating ip
- Loading branch information
1 parent
2f91ccd
commit 8a30542
Showing
10 changed files
with
95 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
#copy this file to .env file | ||
TF_VAR_hcloud_token=xxx | ||
TF_VAR_docker_version="17.03" | ||
TF_VAR_docker_version="17" | ||
TF_VAR_rancher_version="v2.0.2" | ||
TF_VAR_ssh_key_name="[email protected]" | ||
TF_VAR_ssh_public_key="~/.ssh/id_ed25519.pub" | ||
TF_VAR_ssh_private_key="~/.ssh/id_ed25519" | ||
TF_VAR_rancher_password="admin" | ||
TF_VAR_rancher_cluster_name="playground" | ||
TF_VAR_acme_domain="example.com" |
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,47 @@ | ||
locals { | ||
instance_id = "${hcloud_server.k8s.id}" | ||
instance_ip = "${hcloud_server.k8s.ipv4_address}" | ||
} | ||
|
||
resource "hcloud_floating_ip" "master" { | ||
type = "ipv4" | ||
home_location = "fsn1" | ||
description = "lb" | ||
server_id = "${local.instance_id}" | ||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
} | ||
|
||
resource "null_resource" "add_ip" { | ||
triggers = { | ||
instance_id = "${local.instance_id}" | ||
} | ||
|
||
connection { | ||
user = "root" | ||
host = "${local.instance_ip}" | ||
type = "ssh" | ||
private_key = "${file(var.ssh_private_key)}" | ||
} | ||
|
||
# add floating IP | ||
provisioner "remote-exec" { | ||
inline = [ | ||
"sudo echo 'iface eth0 inet static\n address ${hcloud_floating_ip.master.ip_address}/24\n' >> /etc/network/interfaces", | ||
"sudo ifdown eth0 && sudo ifup eth0", | ||
] | ||
} | ||
} | ||
|
||
resource "null_resource" "assign_server_ip" { | ||
triggers = { | ||
instance_id = "${local.instance_id}" | ||
} | ||
|
||
provisioner "local-exec" { | ||
command = <<CMD | ||
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${var.hcloud_token}" -d '{"server":"${local.instance_id}"}' https://api.hetzner.cloud/v1/floating_ips/${hcloud_floating_ip.master.id}/actions/assign | ||
CMD | ||
} | ||
} |
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,3 +1,3 @@ | ||
output "rancher_ips" { | ||
value = ["${hcloud_server.rancher.*.ipv4_address}"] | ||
value = ["${hcloud_server.k8s.*.ipv4_address}"] | ||
} |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/bash | ||
set -eu | ||
RANCHER_VERSION=${RANCHER_VERSION:-preview} | ||
RANCHER_VERSION=${RANCHER_VERSION:-v2.0.2} | ||
ACME_DOMAIN=${ACME_DOMAIN:-example.com} | ||
|
||
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/server:${RANCHER_VERSION} | ||
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:${RANCHER_VERSION} | ||
# --acme-domain ${ACME_DOMAIN} |
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