Skip to content

Commit 8dbc7d4

Browse files
Renatojpetazzo
Renato
authored andcommitted
Fix powershell script
1 parent 7a115ae commit 8dbc7d4

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ That's it!
3030
At the end of the `terraform apply`, a `kubeconfig` file is generated
3131
in this directory. To use your new cluster, you can do:
3232

33+
Linux
3334
```bash
3435
export KUBECONFIG=$PWD/kubeconfig
3536
kubectl get nodes
3637
```
3738

39+
40+
Windows
41+
```powershell
42+
$env:KUBECONFIG="$pwd\kubeconfig"
43+
kubectl get nodes
44+
```
45+
46+
3847
The command above should show you 4 nodes, named `node1` to `node4`.
3948

4049
You can also log into the VMs. At the end of the Terraform output

kubeconfig.tf

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ locals {
33
}
44
locals {
55
bash = "while ! curl -k https://${oci_core_instance._[1].public_ip}:6443; do sleep 1; done"
6-
powershell = "powershell -file .\\winInsecureCurl.ps1"
6+
powershell = "powershell .\\winInsecureCurl.ps1 ${oci_core_instance._[1].public_ip}"
77
}
88

99
resource "null_resource" "wait_for_kube_apiserver" {
@@ -18,8 +18,7 @@ data "external" "kubeconfig" {
1818
program = local.is_windows ? [
1919
"powershell",
2020
<<EOT
21-
$Content1 = ssh -o StrictHostKeyChecking=no -l k8s -i ${local_file.ssh_private_key.filename} ${oci_core_instance._[1].public_ip} sudo base64 -w0 /etc/kubernetes/admin.conf
22-
write-host "{`"base64`": `"$($Content1)`"}"
21+
write-host "{`"base64`": `"$(ssh -o StrictHostKeyChecking=no -l k8s -i ${local_file.ssh_private_key.filename} ${oci_core_instance._[1].public_ip} sudo base64 -w0 /etc/kubernetes/admin.conf)`"}"
2322
EOT
2423
] : [
2524
"sh",

winInsecureCurl.ps1

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
param(
2+
[Parameter()]
3+
[String]$address
4+
)
5+
$url = "https://$($address):6443"
6+
17
add-type @"
28
using System.Net;
39
using System.Security.Cryptography.X509Certificates;
@@ -10,4 +16,6 @@ add-type @"
1016
}
1117
"@
1218
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
13-
while ( -not (Invoke-WebRequest -uri https://${oci_core_instance._[1].public_ip}:6443)){ Start-Sleep 1 }
19+
Start-Sleep -Seconds 5
20+
while ( -not (Invoke-WebRequest $url)){ Start-Sleep -Seconds 1 }
21+
Start-Sleep -Seconds 5

0 commit comments

Comments
 (0)