fix merge leftovers

pull/300/head
iwilltry42 4 years ago
parent 84d6063e4b
commit c83ac0afd4
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 2
      README.md
  2. 2
      docs/index.md
  3. 31
      docs/usage/kubeconfig.md
  4. 10
      tests/common.sh

@ -74,7 +74,7 @@ Check out what you can do via `k3d help` or check the docs @ [k3d.io](https://k3
Example Workflow: Create a new cluster and use it with `kubectl`
1. `k3d cluster create CLUSTER_NAME` to create a new single-node cluster (= 1 container running k3s + 1 loadbalancer container)
2. `k3d kubeconfig merge CLUSTER_NAME --switch` to update your default kubeconfig and switch the current-context to the new one
2. `k3d kubeconfig merge CLUSTER_NAME --switch-context` to update your default kubeconfig and switch the current-context to the new one
3. execute some commands like `kubectl get pods --all-namespaces`
4. `k3d cluster delete CLUSTER_NAME` to delete the default cluster

@ -56,7 +56,7 @@ k3d cluster create mycluster
Get the new cluster's connection details merged into your default kubeconfig (usually specified using the `KUBECONFIG` environment variable or the default path `#!bash $HOME/.kube/config`) and directly switch to the new context:
```bash
k3d kubeconfig merge mycluster --switch
k3d kubeconfig merge mycluster --switch-context
```
Use the new cluster with [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/), e.g.:

@ -11,16 +11,6 @@ To get a kubeconfig set up for you to connect to a k3d cluster, you can go diffe
## Getting the kubeconfig for a newly created cluster
<<<<<<< HEAD
1. Update your default kubeconfig **upon** cluster creation
- `#!bash k3d cluster create mycluster --update-kubeconfig`
- *Note:* this won't switch the current-context
2. Update your default kubeconfig **after** cluster creation
- `#!bash k3d kubeconfig merge mycluster`
- *Note:* this won't switch the current-context
3. Update a different kubeconfig **after** cluster creation
- `#!bash k3d kubeconfig merge mycluster --output some/other/file.yaml`
=======
1. Create a new kubeconfig file **after** cluster creation
- `#!bash k3d kubeconfig get mycluster`
- *Note:* this will create (or update) the file `$HOME/.k3d/kubeconfig-mycluster.yaml`
@ -32,38 +22,23 @@ To get a kubeconfig set up for you to connect to a k3d cluster, you can go diffe
- `#!bash k3d kubeconfig merge mycluster --merge-default-kubeconfig`
- *Note:* this won't switch the current-context (append `--switch-context` to do so)
4. Update a different kubeconfig **after** cluster creation
- `#!bash k3d get kubeconfig mycluster --output some/other/file.yaml`
>>>>>>> master
- `#!bash k3d kubeconfig merge mycluster --output some/other/file.yaml`
- *Note:* this won't switch the current-context
- The file will be created if it doesn't exist
!!! info "Switching the current context"
None of the above options switch the current-context by default.
This is intended to be least intrusive, since the current-context has a global effect.
<<<<<<< HEAD
You can switch the current-context directly with the `kubeconfig merge` command by adding the `--switch` flag.
You can switch the current-context directly with the `kubeconfig merge` command by adding the `--switch-context` flag.
## Removing cluster details from the kubeconfig
`#!bash k3d cluster delete mycluster` will always remove the details for `mycluster` from the default kubeconfig.
## Handling multiple clusters
`k3s kubeconfig merge` let's you specify one or more clusters via arguments _or_ all via `--all`.
All kubeconfigs will then be merged into a single file, which is either the default kubeconfig or the kubeconfig specified via `--output FILE`.
Note, that with multiple cluster specified, the `--switch` flag will change the current context to the cluster which was last in the list.
=======
You can switch the current-context directly with the `get kubeconfig` command by adding the `--switch-context` flag.
## Removing cluster details from the kubeconfig
`#!bash k3d delete cluster mycluster` will always remove the details for `mycluster` from the default kubeconfig.
It will also delete the respective kubeconfig file in `$HOME/.k3d/` if it exists.
## Handling multiple clusters
`k3d get kubeconfig` let's you specify one or more clusters via arguments _or_ all via `--all`.
`k3d kubeconfig merge` let's you specify one or more clusters via arguments _or_ all via `--all`.
All kubeconfigs will then be merged into a single file if `--merge-default-kubeconfig` or `--output` is specified.
If none of those two flags was specified, a new file will be created per cluster and the merged path (e.g. `$HOME/.k3d/kubeconfig-cluster1.yaml:$HOME/.k3d/cluster2.yaml`) will be returned.
Note, that with multiple cluster specified, the `--switch-context` flag will change the current context to the cluster which was last in the list.
>>>>>>> master

@ -61,7 +61,7 @@ check_url() {
check_clusters() {
[ -n "$EXE" ] || abort "EXE is not defined"
for c in "$@" ; do
$EXE kubeconfig merge "$c" --switch
$EXE kubeconfig merge "$c" --switch-context
if kubectl cluster-info ; then
passed "cluster $c is reachable"
else
@ -87,11 +87,7 @@ check_cluster_count() {
check_multi_node() {
cluster=$1
expectedNodeCount=$2
<<<<<<< HEAD
$EXE kubeconfig merge "$cluster" --switch
=======
$EXE get kubeconfig "$cluster" --merge-default-kubeconfig --switch-context
>>>>>>> master
$EXE kubeconfig merge "$cluster" --switch-context
nodeCount=$(kubectl get nodes -o=custom-columns=NAME:.metadata.name --no-headers | wc -l)
if [[ $nodeCount == $expectedNodeCount ]]; then
passed "cluster $cluster has $expectedNodeCount nodes, as expected"
@ -114,5 +110,5 @@ check_volume_exists() {
check_cluster_token_exist() {
[ -n "$EXE" ] || abort "EXE is not defined"
$EXE cluster list "$1" --token | grep "TOKEN" >/dev/null 2>&1
$EXE cluster get "$1" --token | grep "TOKEN" >/dev/null 2>&1
}

Loading…
Cancel
Save