1- version : ' 3 '
1+ version : " 3 "
22
33tasks :
44 up :
55 desc : " Start Talos cluster"
6+ vars :
7+ TRAEFIK_IP :
8+ sh : task talos:get-traefik-ip
9+ cmds :
10+ - cp .talos/patch_host.yaml.tpl .talos/patch_host.yaml && sed -i 's/TRAEFIK_IP/{{ .TRAEFIK_IP }}/g' .talos/patch_host.yaml
11+ - task talos:up:cert
12+ - talosctl cluster create --workers 1 --config-patch-control-plane @.talos/patch_auth.yaml --config-patch @.talos/patch_host.yaml
13+ - task talos:kubeconfig
14+ - task talos:crd
15+ - task talos:k -- apply -f ./deploy/exemple/min-local-talos.crd.yaml
16+ - task talos:create-kubeconfig-proxy
17+ - task talos:create-kubeconfig-oidc
18+ up:cert :
619 cmds :
7- - talosctl cluster create --workers 1 --config-patch-control-plane @.talos/patch_auth.yaml
20+ - cp .talos/patch_auth.yaml.tpl .talos/patch_auth.yaml
21+ - |
22+ awk '/CERTIFICATE/ {
23+ while ((getline line < ".compose/traefik/certs/cert.pem") > 0) {
24+ print " " line
25+ }
26+ close(".compose/traefik/certs/cert.pem")
27+ next
28+ }
29+ { print }' .talos/patch_auth.yaml > .talos/patch_auth.yaml.tmp
30+ - mv .talos/patch_auth.yaml.tmp .talos/patch_auth.yaml
831 down :
932 desc : " Destroy Talos cluster"
1033 cmds :
1134 - talosctl cluster destroy
1235 kubeconfig :
1336 desc : " Get kubeconfig for Talos cluster"
1437 cmds :
38+ - rm -f kubeconfig.local.yaml
1539 - talosctl kubeconfig 'kubeconfig.local.yaml' -n 10.5.0.2
1640 dashboard :
1741 desc : " Open Talos dashboard"
1842 cmds :
1943 - talosctl dashboard -n 10.5.0.2
2044 k :
2145 desc : " Shortcut for kubectl"
46+ silent : true
2247 env :
2348 KUBECONFIG : kubeconfig.local.yaml
2449 cmds :
2550 - kubectl {{ .CLI_ARGS }}
51+ k-proxy :
52+ desc : " Shortcut for kubectl using ProxyauthK8s"
53+ silent : true
54+ env :
55+ KUBECONFIG : kubeconfig.local-proxy.yaml
56+ cmds :
57+ - kubectl {{ .CLI_ARGS }}
58+ k-oidc :
59+ desc : " Shortcut for kubectl using OIDC"
60+ silent : true
61+ env :
62+ KUBECONFIG : kubeconfig.local-oidc.yaml
63+ cmds :
64+ - kubectl {{ .CLI_ARGS }}
2665 k9s :
2766 desc : " Shortcut for k9s"
2867 env :
@@ -36,12 +75,30 @@ tasks:
3675 cmds :
3776 - kubectl apply -f ./deploy/crds.yaml
3877 create-kubeconfig-oidc :
78+ desc : " Create kubeconfig to use with OIDC and ProxyauthK8s"
79+ silent : true
80+ vars :
81+ server_url : " https://localhost:5437/clusters/default/local"
82+ cmds :
83+ - cp kubeconfig-template.oidc.yaml kubeconfig.local-oidc.yaml
84+ - yq e -i '.clusters[0].cluster.server = "{{ .server_url }}"' kubeconfig.local-oidc.yaml
85+ create-kubeconfig-proxy :
86+ desc : " Create kubeconfig to use with ProxyauthK8s"
87+ silent : true
3988 vars :
40- server_url :
41- sh : cat kubeconfig.local.yaml | yq .clusters[0].cluster.server
42- server_ca :
43- sh : cat kubeconfig.local.yaml | yq .clusters[0].cluster."certificate-authority-data"
44- cmds :
45- - cp kubeconfig-template.oidc.yaml kubeconfig.local-oidc.yaml
46- - yq e -i '.clusters[0].cluster.server = "{{ .server_url }}"' kubeconfig.local-oidc.yaml
47- - yq e -i '.clusters[0].cluster."certificate-authority-data" = "{{ .server_ca }}"' kubeconfig.local-oidc.yaml
89+ server_url : " https://localhost:5437/clusters/default/local"
90+ token :
91+ sh : task talos:k -- create token default
92+ cmds :
93+ - cp kubeconfig.local.yaml kubeconfig.local-proxy.yaml
94+ - yq e -i '.clusters[0].cluster.server = "{{ .server_url }}"' kubeconfig.local-proxy.yaml
95+ - yq e -i 'del(.clusters[0].cluster."certificate-authority-data")' kubeconfig.local-proxy.yaml
96+ - yq e -i '.users[0].user.token = "{{ .token }}"' kubeconfig.local-proxy.yaml
97+ - yq e -i 'del(.users[0].user."client-certificate-data")' kubeconfig.local-proxy.yaml
98+ - yq e -i 'del(.users[0].user."client-key-data")' kubeconfig.local-proxy.yaml
99+ get-traefik-ip :
100+ desc : " Get Traefik Docker IP"
101+ silent : true
102+ cmds :
103+ - docker inspect traefik | jq -r '.[0].NetworkSettings.Networks["talos-default"].IPAddress'
104+ # https://docs.siderolabs.com/talos/v1.6/reference/configuration/v1alpha1/config#extrahostentries%5B%5D
0 commit comments