Skip to content

Commit

Permalink
Merge pull request #94 from equinix/kubeconfigfile-output
Browse files Browse the repository at this point in the history
include kubeconfig filename in outputs, make content sensitive
  • Loading branch information
displague authored Dec 9, 2021
2 parents ad8554c + b2fe6f1 commit f489a57
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jobs:
name: Integration Tests
runs-on: ${{ matrix.os }}
env:
TF_VAR_secrets_encryption: false
TF_VAR_metro: "sv"
TF_VAR_ccm_enabled: true
TF_VAR_loadbalancer_type: "kube-vip"
TF_IN_AUTOMATION: 1
TF_VERSION: ${{ matrix.tf }}
TF_VAR_control_plane_node_count: 0
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
*.tfvars
examples/inventory.yaml
examples/main.retry
kubeconfig
metal-key
metal-key.pub
2 changes: 1 addition & 1 deletion modules/controller_pool/assets/kubeconfig_copy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
/usr/bin/ssh -i $ssh_private_key_path -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$controller "while true; do if ! type kubeadm > /dev/null; then sleep 20; else break; fi; done"
sleep 360
sleep 520
/usr/bin/scp -i $ssh_private_key_path -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q root@$controller:/etc/kubernetes/admin.conf $local_path/kubeconfig;

10 changes: 3 additions & 7 deletions modules/controller_pool/controller-primary.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,13 @@ EOF
}

function kube_vip {
kubectl apply -f https://kube-vip.io/manifests/rbac.yaml
GATEWAY_IP=$(curl https://metadata.platformequinix.com/metadata | jq -r ".network.addresses[] | select(.public == false) | .gateway");
ip route add 169.254.255.1 via $GATEWAY_IP
ip route add 169.254.255.2 via $GATEWAY_IP
alias kube-vip="docker run --network host --rm ghcr.io/kube-vip/kube-vip:v0.3.8"
kube-vip manifest daemonset \
kubectl --kubeconfig=/etc/kubernetes/admin.conf apply -f https://kube-vip.io/manifests/rbac.yaml
docker run --network host --rm ghcr.io/kube-vip/kube-vip:v0.4.0 manifest daemonset \
--interface lo \
--services \
--bgp \
--annotations metal.equinix.com \
--inCluster | kubectl apply -f -
--inCluster | kubectl --kubeconfig=/etc/kubernetes/admin.conf apply -f -
}

function ceph_pre_check {
Expand Down
2 changes: 1 addition & 1 deletion modules/controller_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ resource "null_resource" "kubeconfig" {
}

data "local_file" "kubeconfig" {
filename = "${path.root}/kubeconfig"
filename = abspath("${path.root}/kubeconfig")

depends_on = [
null_resource.kubeconfig
Expand Down
12 changes: 9 additions & 3 deletions modules/controller_pool/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ output "controller_addresses" {
# }

output "kubeconfig" {
description = "Kubeconfig for the newly created cluster"
value = data.local_file.kubeconfig
}
description = "Kubeconfig content for the newly created cluster"
value = data.local_file.kubeconfig.content
sensitive = true
}

output "kubeconfig_filename" {
description = "Kubeconfig file for the newly created cluster"
value = data.local_file.kubeconfig.filename
}
8 changes: 7 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ output "kubernetes_api_address" {
output "kubernetes_kubeconfig" {
description = "Kubeconfig for the newly created cluster"
value = module.controllers.kubeconfig
}
sensitive = true
}

output "kubernetes_kubeconfig_file" {
description = "Kubecobnfig file for the newly created cluster"
value = module.controllers.kubeconfig_filename
}

0 comments on commit f489a57

Please sign in to comment.