File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
deployment/terraform/modules/openstack-kubernetes-infra Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ resource "null_resource" "copy_kubeconfig" {
2+ depends_on = [openstack_compute_instance_v2 . kubernetes_server ]
3+
4+ provisioner "local-exec" {
5+ # Copy the kubeconfig file from the host to a local file using SCP.
6+ # Use ssh-keyscan to prevent interactive prompt on unknown host
7+ # Use sed to replace the localhost address in the KUBECONFIG file with the actual IP adddress of the created VM.
8+ command = << EOT
9+ mkdir -p ${ path . root } /.build/ && \
10+ ssh-keyscan -H ${ openstack_compute_instance_v2 . kubernetes_server . access_ip_v4 } >> ${ path . root } /.build/.known_hosts_cogstack && \
11+ scp -o UserKnownHostsFile=${ path . root } /.build/.known_hosts_cogstack -o StrictHostKeyChecking=yes \
12+ -i ${ local . ssh_keys . private_key_file } \
13+ ubuntu@${ openstack_compute_instance_v2 . kubernetes_server . access_ip_v4 } :/etc/rancher/k3s/k3s.yaml \
14+ ${ local . kubeconfig_file } && \
15+ sed -i "s/127.0.0.1/${ openstack_compute_instance_v2 . kubernetes_server . access_ip_v4 } /" ${ local . kubeconfig_file }
16+ EOT
17+ }
18+ }
19+
20+ data "local_file" "kube_config_raw_file" {
21+ filename = local. kubeconfig_file
22+ depends_on = [ null_resource. copy_kubeconfig ]
23+ }
24+
25+ output "kube_config_raw" {
26+ value = data. local_file . kube_config_raw_file
27+ description = " Kubeconfig for this cluster"
28+ }
You can’t perform that action at this time.
0 commit comments