add installKubectlAndTools
parent
73a40498a0
commit
1493977672
@ -0,0 +1,17 @@
|
||||
function main() {
|
||||
local cluster_name="${1}"; shift
|
||||
|
||||
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.meissa-gmbh.de \
|
||||
"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
|
||||
}
|
||||
|
||||
main $1
|
@ -0,0 +1,18 @@
|
||||
# Set the default kube context if present
|
||||
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"
|
@ -0,0 +1,39 @@
|
||||
package org.domaindrivenarchitecture.provs.workplace.infrastructure
|
||||
|
||||
import org.domaindrivenarchitecture.provs.core.getResourceAsText
|
||||
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createDir
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createDirs
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.fileContainsText
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class DevOpsKtTest {
|
||||
|
||||
@Test
|
||||
fun installKubectlAndTools() {
|
||||
// given
|
||||
defaultTestContainer().def {
|
||||
createDirs("/etc/bash_completion.d", sudo = true)
|
||||
createDir(".bashrc.d")
|
||||
}
|
||||
|
||||
//when
|
||||
val res = defaultTestContainer().installKubectlAndTools()
|
||||
|
||||
// then
|
||||
assertTrue(res.success)
|
||||
assertTrue(
|
||||
defaultTestContainer().fileContainsText(
|
||||
"~/.bashrc.d/kubectl.sh",
|
||||
getResourceAsText("workplace/infrastructure/kubectl.sh")
|
||||
)
|
||||
)
|
||||
assertTrue(
|
||||
defaultTestContainer().fileContainsText(
|
||||
"/etc/bash_completion.d/kubernetes",
|
||||
"\nkubectl completion bash\n"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue