Skip to content

Commit b31da3d

Browse files
committed
docs: Improve documentation about flags, env var and config file
Signed-off-by: Jose Blanquicet <[email protected]>
1 parent eac9f38 commit b31da3d

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ against the cluster nodes, regardless of the control plane's state.
1010
It's important to note that this plugin does not replace the Azure CLI,
1111
[az](https://learn.microsoft.com/en-us/cli/azure/?view=azure-cli-latest).
1212
Instead, it complements it by offering additional commands and providing users
13-
with a kubectl-like experience. In practice, users will use az to create and
14-
delete their AKS cluster, and then use kubectl and kubectl-aks to interact with
15-
and debug it.
13+
with a kubectl-like experience. In practice, users will use `az` to create and
14+
delete their AKS cluster, and then use `kubectl` and `kubectl-aks` to interact
15+
with and debug it.
1616

1717
Going through the following documentation will help you to understand each
1818
available command and which one is the most suitable for your case:
@@ -21,17 +21,17 @@ available command and which one is the most suitable for your case:
2121
- [check-apiserver-connectivity](docs/check-apiserver-connectivity.md)
2222
- [config](docs/config.md)
2323

24-
Consider `kubectl-aks` expects the cluster to use virtual machine scale sets,
25-
which is the case of an AKS cluster. And, the use of the `--node` flag requires
26-
the Kubernetes control plane to up and running, because the VMSS instance
27-
information of the node will be retrieved from the Kubernetes API server.
28-
29-
However, in case of issues with the Kubernetes control plane, you can reuse the
30-
already stored VMSS instance information, see [config](docs/config.md) command.
31-
Or, if it is a cluster you have never used before on that host, you can retrieve
32-
such information from the [Azure portal](https://portal.azure.com/) and pass it
33-
to the commands using the `--id` flag or separately with the `--subscription`,
34-
`--node-resource-group`, `--vmss` and `--instance-id` flags.
24+
Take into account that `kubectl-aks` expects the cluster to use virtual machine
25+
scale sets, which is the case of an AKS cluster.
26+
27+
You can get the node information needed to execute the commands directly from
28+
the [Azure portal](https://portal.azure.com/) or you can let `kubectl-aks` get
29+
that information for you. If you already have such a information, you can pass
30+
it using the flags or environment variables. If you don't have it, `kubectl-aks`
31+
can retrieve it either from the Azure API or the Kubernetes API server. If you
32+
expect to use the same node multiple times, it is recommended to import the node
33+
information in the configuration file and set it as the default node, see the
34+
[config](docs/config.md) command for further details.
3535

3636
## Install
3737

cmd/utils/vmss.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func VirtualMachineScaleSetVMFromConfig() (*VirtualMachineScaleSetVM, error) {
8585
// the VMSS information of that node is already in the config file.
8686
config := config.New()
8787
if cc, ok := config.GetNodeConfig(node); ok {
88-
log.Warnf("Using VMSS information from config for node %s", node)
88+
log.Debugf("Using VMSS information from config for node %s", node)
8989

9090
vm.SubscriptionID = cc.GetString(SubscriptionIDKey)
9191
vm.NodeResourceGroup = cc.GetString(NodeResourceGroupKey)

docs/config.md

+17-12
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
We can use the `config` command to configure node information for `kubectl-aks` commands.
44
This allows ease of switching between different nodes and persisting the configuration. Nodes can be configured
5-
either specifying the `--node` or `--resource-id` or VMSS instance information(`--subscription`, `--node-resource-group`, `--vmss`, `--instance-id`).
6-
All three options are mutually exclusive:
5+
either specifying the `--node` or `--id` or VMSS instance information (`--subscription`, `--node-resource-group`, `--vmss`, `--instance-id`). All three options are mutually exclusive:
76

87
```bash
98
$ kubectl aks config --help
@@ -31,7 +30,7 @@ As an example, we set a couple of nodes in the configuration (using VMSS instanc
3130

3231
```bash
3332
$ kubectl aks config set-node node1 --subscription mySubID --node-resource-group myRG --vmss myVMSS --instance-id myInstanceID1
34-
$ kubectl aks config set-node node2 --subscription mySubID --node-resource-group myRG --vmss myVMSS --instance-id myInstanceID2
33+
$ kubectl aks config set-node node2 --id "/subscriptions/mySubID/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSS/virtualmachines/myInstanceID2"
3534
$ kubectl aks show
3635
nodes:
3736
node1:
@@ -57,6 +56,12 @@ the `unset-node`/`unset-all`/`unset-current-node` commands.
5756

5857
## Importing configuration
5958

59+
`kubectl-aks` can also import the node information from the Kubernetes API
60+
server or Azure API using the `config import` command. By default, if no flags
61+
are passed, `kubectl-aks` will try to retrieve the node information from the
62+
Kubernetes API server:
63+
64+
```bash
6065
We can also import the node information using the AKS cluster credentials already available in the `kubeconfig` file:
6166

6267
```bash
@@ -87,16 +92,16 @@ nodes:
8792
$ kubectl aks use-node aks-agentpool-12345678-vmss000000
8893
```
8994

90-
Or in case Kubernetes API is not available, we can also import the node information using Azure API by specifying the cluster information:
95+
If the Kubernetes API server is not available or we can't rely on it for some
96+
reason (e.g. we are investigating connectivity issues between nodes and the API
97+
server), we can use the `--subscription`, `--resource-group` and
98+
`--cluster-name` flags to retrieve the node information from the Azure API:
9199
92100
```bash
93-
$ kubectl aks config import --subscription mySubID --resource-group myRG --cluster-name myCluster
94-
$ kubectl aks config show
101+
kubectl aks config import --subscription mySubID --resource-group myRG --cluster-name myCluster
102+
kubectl aks config show
95103
```
96104
97-
The information is stored with node name as key and VMSS instance information as value to avoid talking to be able
98-
to continue talking with the node, even if the API server is not working correctly.
99-
100105
## Precedence of configuration
101106
102107
Apart from the configuration file, we can also use the flags and environment variables to
@@ -109,7 +114,7 @@ pass the node information to the commands. The precedence of the configuration i
109114
Using the flags:
110115
111116
```bash
112-
$ kubectl aks check-apiserver-connectivity --node aks-agentpool-77471288-vmss000013
117+
kubectl aks check-apiserver-connectivity --node aks-agentpool-77471288-vmss000013
113118
```
114119
115120
or using the environment variables:
@@ -119,5 +124,5 @@ or using the environment variables:
119124
- `KUBECTL_AKS_SUBSCRIPTION`, `KUBECTL_AKS_NODE_RESOURCE_GROUP`, `KUBECTL_AKS_VMSS` and `KUBECTL_AKS_INSTANCE_ID`
120125
121126
```bash
122-
$ KUBECTL_AKS_NODE=aks-agentpool-77471288-vmss000013 kubectl aks check-apiserver-connectivity
123-
```
127+
KUBECTL_AKS_NODE=aks-agentpool-77471288-vmss000013 kubectl aks check-apiserver-connectivity
128+
```

0 commit comments

Comments
 (0)