add additional tunel to connect
This commit is contained in:
parent
ed33c1b0c2
commit
cf6d2cb885
5 changed files with 24 additions and 81 deletions
|
@ -82,29 +82,6 @@ fun Prov.installDevopsScripts() {
|
|||
)
|
||||
}
|
||||
|
||||
task("install k8sCreateContext") {
|
||||
val k8sContextFile = "/usr/local/bin/k8s-create-context.sh"
|
||||
createFileFromResource(
|
||||
k8sContextFile,
|
||||
"k8s-create-context.sh",
|
||||
resourcePath,
|
||||
"555",
|
||||
sudo = true
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
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(
|
||||
|
|
|
@ -12,7 +12,10 @@ function main() {
|
|||
|
||||
/usr/local/bin/k3s-create-context.sh ${cluster_name} ${domain_name}
|
||||
kubectl config use-context ${cluster_name}
|
||||
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.${domain_name} -L 8002:localhost:8002 -L 6443:192.168.5.1:6443
|
||||
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.${domain_name} \
|
||||
-L 8002:localhost:8002 \
|
||||
-L 6443:192.168.5.1:6443 \
|
||||
-L 9000:192.168.5.1:9000
|
||||
}
|
||||
|
||||
if [ $# -gt 0 ]
|
||||
|
|
|
@ -6,6 +6,25 @@ function usage() {
|
|||
echo "Requires argument cluster_name and domain_name in server fqdn {cluster_name}.{domain_name}"
|
||||
}
|
||||
|
||||
function sourceNewContext() {
|
||||
DEFAULT_KUBE_CONTEXTS="$HOME/.kube/config"
|
||||
if test -f "${DEFAULT_KUBE_CONTEXTS}"
|
||||
then
|
||||
export KUBECONFIG="$DEFAULT_KUBE_CONTEXTS"
|
||||
fi
|
||||
|
||||
# Additional contexts should be in ~/.kube/custom-contexts/
|
||||
CUSTOM_KUBE_CONTEXTS="$HOME/.kube/custom-contexts"
|
||||
mkdir -p "${CUSTOM_KUBE_CONTEXTS}"
|
||||
|
||||
OIFS="$IFS"
|
||||
IFS=$'\n'
|
||||
for contextFile in `find "${CUSTOM_KUBE_CONTEXTS}" -type f -name "*.yml"`
|
||||
do
|
||||
export KUBECONFIG="$contextFile:$KUBECONFIG"
|
||||
done
|
||||
IFS="$OIFS"
|
||||
}
|
||||
|
||||
function main() {
|
||||
local cluster_name="${1}";
|
||||
|
@ -22,6 +41,7 @@ function main() {
|
|||
| del(.preferences) \
|
||||
| .users[0].name=\"${cluster_name}\"" - \
|
||||
> ~/.kube/custom-contexts/${cluster_name}.yml
|
||||
sourceNewContext
|
||||
}
|
||||
|
||||
if [ $# -gt 0 ]
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
set -o noglob
|
||||
|
||||
function usage() {
|
||||
echo "Requires argument cluster_name and domain_name in server fqdn {cluster_name}.{domain_name}"
|
||||
}
|
||||
|
||||
function main() {
|
||||
local cluster_name="${1}"; shift
|
||||
local domain_name="${1:-meissa-gmbh.de}"; 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}.${domain_name} -L 8002:localhost:8002 -L 6443:192.168.5.1:6443
|
||||
}
|
||||
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
main $1
|
||||
else
|
||||
usage
|
||||
exit -1
|
||||
fi
|
|
@ -1,33 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
set -o noglob
|
||||
|
||||
function usage() {
|
||||
echo "Requires argument cluster_name and domain_name in server fqdn {cluster_name}.{domain_name}"
|
||||
}
|
||||
|
||||
|
||||
function main() {
|
||||
local cluster_name="${1}"; shift
|
||||
local domain_name="${1:-meissa-gmbh.de}"; shift
|
||||
|
||||
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.${domain_name} \
|
||||
"cat /etc/kubernetes/admin.conf" | \
|
||||
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 [ $# -gt 0 ]
|
||||
then
|
||||
main $1
|
||||
else
|
||||
usage
|
||||
exit -1
|
||||
fi
|
Loading…
Reference in a new issue