Public/Kubernetes.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function New-KubeConfig {
    param (
        [string]$outputFolder,
        [string]$k8sUrl,
        [string]$k8sToken
    )

    Set-Content -Path "$outputFolder/kubeconfig" -Value @"
    {
        "apiVersion": "v1",
        "clusters": [
            {
                "cluster": {
                    "server": "$k8sUrl",
                    "insecure-skip-tls-verify": true
                },
                "name": "kubernetes-cluster"
            }
        ],
        "contexts": [
            {
                "context": {
                    "cluster": "kubernetes-cluster",
                    "user": "kubernetes-admin"
                },
                "name": "kubernetes-cluster"
            }
        ],
        "current-context": "kubernetes-cluster",
        "kind": "Config",
        "users": [
            {
                "name": "kubernetes-admin",
                "user": {
                    "token": "$k8sToken"
                }
            }
        ]
    }
"@

}