added context creation and connect scripts
k8s-connect.sh works on clusters set up with the old infrastructure k3s-connect.sh works with the new infrastructure
This commit is contained in:
parent
89ffbca01f
commit
64511aa491
5 changed files with 105 additions and 1 deletions
|
@ -86,6 +86,39 @@ fun Prov.installKubectlAndTools(): ProvResult = task {
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task("install k8sConnect") {
|
||||||
|
val k8sConnectFile = "/usr/local/bin/k8s-connect.sh"
|
||||||
|
createFileFromResource(
|
||||||
|
k8sConnectFile,
|
||||||
|
"k8s-connect.sh",
|
||||||
|
resourcePath,
|
||||||
|
"555",
|
||||||
|
sudo = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
task("install k3sCreateContext") {
|
||||||
|
val k3sContextFile = "/usr/local/bin/k3s-create-context.sh"
|
||||||
|
createFileFromResource(
|
||||||
|
k3sContextFile,
|
||||||
|
"k3s-create-context.sh",
|
||||||
|
resourcePath,
|
||||||
|
"555",
|
||||||
|
sudo = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
task("install k3sConnect") {
|
||||||
|
val k3sConnectFile = "/usr/local/bin/k3s-connect.sh"
|
||||||
|
createFileFromResource(
|
||||||
|
k3sConnectFile,
|
||||||
|
"k3s-connect.sh",
|
||||||
|
resourcePath,
|
||||||
|
"555",
|
||||||
|
sudo = true
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Prov.installTerraform(): ProvResult = task {
|
fun Prov.installTerraform(): ProvResult = task {
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set -o noglob
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
local cluster_name="${1}"; shift
|
||||||
|
|
||||||
|
/usr/local/bin/k3s-create-context.sh ${cluster_name}
|
||||||
|
kubectl config use-context ${cluster_name}
|
||||||
|
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.meissa-gmbh.de -L 8002:localhost:8002 -L 6443:192.168.5.1:6443
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 1 ]
|
||||||
|
then
|
||||||
|
main $1
|
||||||
|
else
|
||||||
|
echo "Requires argument cluster_name in server fqdn {cluster_name}.meissa-gmbh.de"
|
||||||
|
exit -1
|
||||||
|
fi
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set -o noglob
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
local cluster_name="${1}"; shift
|
||||||
|
|
||||||
|
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.meissa-gmbh.de \
|
||||||
|
"cat /etc/rancher/k3s/k3s.yaml" | \
|
||||||
|
yq e ".clusters[0].name=\"${cluster_name}\" \
|
||||||
|
| .clusters[0].cluster.server=\"https://kubernetes:6443\" \
|
||||||
|
| .contexts[0].context.cluster=\"${cluster_name}\" \
|
||||||
|
| .contexts[0].context.user=\"${cluster_name}\" \
|
||||||
|
| .contexts[0].name=\"${cluster_name}\" \
|
||||||
|
| del(.current-context) \
|
||||||
|
| del(.preferences) \
|
||||||
|
| .users[0].name=\"${cluster_name}\"" - \
|
||||||
|
> ~/.kube/custom-contexts/${cluster_name}.yml
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 1 ]
|
||||||
|
then
|
||||||
|
main $1
|
||||||
|
else
|
||||||
|
echo "Requires argument cluster_name in server fqdn {cluster_name}.meissa-gmbh.de"
|
||||||
|
exit -1
|
||||||
|
fi
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set -o noglob
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
local cluster_name="${1}"; shift
|
||||||
|
|
||||||
|
/usr/local/bin/k8s-create-context.sh ${cluster_name}
|
||||||
|
kubectl config use-context ${cluster_name}
|
||||||
|
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.meissa-gmbh.de -L 8002:localhost:8002 -L 6443:192.168.5.1:6443
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 1 ]
|
||||||
|
then
|
||||||
|
main $1
|
||||||
|
else
|
||||||
|
echo "Requires argument cluster_name in server fqdn {cluster_name}.meissa-gmbh.de"
|
||||||
|
exit -1
|
||||||
|
fi
|
|
@ -18,4 +18,10 @@ function main() {
|
||||||
> ~/.kube/custom-contexts/${cluster_name}.yml
|
> ~/.kube/custom-contexts/${cluster_name}.yml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 1 ]
|
||||||
|
then
|
||||||
main $1
|
main $1
|
||||||
|
else
|
||||||
|
echo "Requires argument cluster_name in server fqdn {cluster_name}.meissa-gmbh.de"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue