Fixed a potential bug coming from hardcoded interface names, now it should detect it automatically

This commit is contained in:
Karim Naufal 2021-09-25 15:12:37 +02:00
parent bb8afc8c30
commit d25acf5439
4 changed files with 15 additions and 7 deletions

View File

@ -83,7 +83,15 @@ terraform init
terraform apply -auto-approve
```
It will take a few minutes to complete, and then you should see a green output with the IP addresses of the nodes. Then you can immediately kubectl into it without any further action.
It will take a few minutes to complete, and then you should see a green output with the IP addresses of the nodes. Then you can immediately kubectl into it (using the kubeconfig.yaml saved to the project's directory after the install).
Just using the command `kubectl --kubeconfig kubeconfig.yaml` would work, but for more convenience, either create a symlink from `~/.kube/config` to `kubeconfig.yaml`, or add an export statement to your `~/.bashrc` or `~/.zshrc` file, as follows:
```sh
export KUBECONFIG=/<path-to>/kubeconfig.yaml
```
To get the path, of course, you could use the `pwd` command.
<!-- USAGE EXAMPLES -->

View File

@ -84,7 +84,7 @@ data "hcloud_image" "linux" {
}
data "template_file" "init_cfg" {
template = file("init.cfg")
template = file("${path.module}/init.cfg")
}
# Render a multi-part cloud-init config making use of the part

View File

@ -49,15 +49,15 @@ resource "hcloud_server" "first_control_plane" {
}
provisioner "local-exec" {
command = "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${var.private_key} root@${self.ipv4_address}:/etc/rancher/k3s/k3s.yaml ./kubeconfig.yaml"
command = "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${var.private_key} root@${self.ipv4_address}:/etc/rancher/k3s/k3s.yaml ${path.module}/kubeconfig.yaml"
}
provisioner "local-exec" {
command = "sed -i -e 's/127.0.0.1/${self.ipv4_address}/g' ./kubeconfig.yaml"
command = "sed -i -e 's/127.0.0.1/${self.ipv4_address}/g' ${path.module}/kubeconfig.yaml"
}
provisioner "local-exec" {
command = "helm install --values=manifests/helm/cilium/values.yaml cilium cilium/cilium -n kube-system"
command = "helm repo add cilium https://helm.cilium.io/ --kubeconfig ${path.module}/kubeconfig.yaml; helm install --values=manifests/helm/cilium/values.yaml cilium cilium/cilium -n kube-system --kubeconfig ${path.module}/kubeconfig.yaml"
}
network {

View File

@ -46,12 +46,12 @@ variable "agent_server_type" {
variable "k3s_server_flags" {
description = "Important flags to make our setup work"
default = "--disable-cloud-controller --disable-network-policy --disable=traefik --disable=servicelb --disable='local-storage' --kubelet-arg='cloud-provider=external' --flannel-backend=none --flannel-iface=ens10"
default = "--disable-cloud-controller --disable-network-policy --disable=traefik --disable=servicelb --disable='local-storage' --kubelet-arg='cloud-provider=external' --flannel-backend=none"
}
variable "k3s_agent_flags" {
description = "Important flags to make our setup work"
default = "--kubelet-arg='cloud-provider=external' --flannel-iface=ens10"
default = "--kubelet-arg='cloud-provider=external'"
}
variable "initial_commands" {