Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add documentation-test for run-command.md #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mqasimsarfraz
Copy link
Member

@mqasimsarfraz mqasimsarfraz commented Oct 27, 2023

Add test for run-command.md. In order to test it locally you need to write an INI file at docs/run-command.ini with sample:

→ cat docs/run-command.ini.sample 
mySubID = mySubID
myRG = myRG
myCluster = myCluster
myNode = myNode

Then use following to run the tests:

make documentation-test-commands

@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 16:25 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 16:28 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 16:33 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 16:33 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 16:33 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 16:40 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:14 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:20 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:20 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:20 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:26 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:48 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:53 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:53 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 17:53 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 18:00 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 22:01 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 22:06 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 22:06 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 22:06 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 22:18 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 22:22 — with GitHub Actions Inactive
@mqasimsarfraz mqasimsarfraz temporarily deployed to aks October 27, 2023 22:23 — with GitHub Actions Inactive
Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
Comment on lines -296 to +359
run: make documentation-test -o kubectl-aks
run: make documentation-test-readme
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the -o kubectl-aks?

kubectl aks config unset-all
```

Import the nodes information with the cluster information:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Import the nodes information with the cluster information:
Import the nodes information with the cluster information:
> [!NOTE]
> Passing the cluster information to the `config import` command is optional. However, in this specific case, it will force the command to retrieve the nodes information from the Azure API server instead of the Kubernetes API server, making this approach more resilient to issues on the Kubernetes control plane.

Comment on lines +24 to +28
In case we want to print the imported information, we can use the `show` command:

```bash
kubectl aks config show
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you check, we always execute config show after a config import. I started thinking that we should automatically print the imported data in the config import (maybe with a --quiet flag). Also for the documentation, it makes things more consistent. For instance:

Import node info:

kubectl aks config import

Run command against one of the nodes (Folks will take the node name from the previous output):

kubectk aks run-command --node <myNode>

WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#60

Comment on lines +56 to +63
```bash
kubectl aks run-command "ip route"
```

# Execute the run-command, and it will be automatically executed in aks-agentpool-12345678-vmss000000
$ kubectl aks run-command "ip route"
The output should be similar to this:

<!--expected_similarity=0.8-->
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should use another command that provides a more deterministic output so that we can use <!--expected_similarity=1--> or some regex to match an expected string.

Of course, this is something we can do later, not for this PR.

Comment on lines +90 to +94
Unset the current node to avoid conflict with flags or environment variables:

```bash
kubectl aks config unset-current-node
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#55 should solve this issue. It shouldn't be necessary anymore. In the documentation we said that the precedence is flags, env variables, config file. So, using the flag --id should simply have the precedence and don't go in conflict with the config file.

AZURE_NODE_COUNT: 3 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster
AZURE_NODE_COUNT: 4 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AZURE_NODE_COUNT: 3 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster
AZURE_NODE_COUNT: 4 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster
AZURE_NODE_COUNT: 4 # multiple nodes are needed to allow running parallel 'run-command' against the same cluster. See create-aks-cluster.nodes job.

On the other side, if we already have the node (VMSS instance) information and we don't want/need to save it locally, we could pass it directly as following:

```bash
kubectl aks run-command "ip route" --id "/subscriptions/$SUBSCRIPTION/resourceGroups/$NODERESOURCEGROUP/providers/Microsoft.Compute/virtualMachineScaleSets/$VMSS/virtualmachines/$INSTANCEID"
<!-- TODO: Test following when we have a simple way to get instance information -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do it with az in the CI and store that info in the ini file.

Comment on lines 312 to 336
echo "mySubID = ${{ secrets.AZURE_AKS_SUBSCRIPTION_ID }}" >> $f
echo "myRG = ${{ env.AZURE_PREFIX }}-rg" >> $f
echo "myCluster = ${{ env.AZURE_PREFIX }}-amd64-cluster" >> $f
echo "myNode = $(echo '${{ needs.create-aks-cluster.outputs.documentation-nodes }}' | jq -r ".[0]")" >> $f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to continue with the ini file approach.

```

```bash
kubectl aks run-command "ip route" --subscription $SUBSCRIPTION --node-resource-group $NODERESOURCEGROUP --vmss $VMSS --instance-id $INSTANCEID
Or using the flags:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Or using the flags:
Or using the individual flags:

BTW, please add also the same TODO comment here.

Comment on lines 113 to 115
```bash
kubectl aks run-command "ip route" --node aks-agentpool-12345678-vmss000000
kubectl aks run-command "ip route" --node $myNode
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #52, we should need to clean up the config file. I think it is fine. We could add the unset-all here and explain that otherwise, the info already available in the config file will be re-used.

Comment on lines +121 to 139
```

Start using one of the nodes e.g `aks-agentpool-12345678-vmss000000` we call it `$myNode` here:

```bash
kubectl aks config use-node $myNode
```

# Start using one of the nodes
kubectl aks use-node aks-agentpool-12345678-vmss000000
Execute the run-command, and it will be automatically executed in `aks-agentpool-12345678-vmss000000`:

# Execute the run-command, and it will be automatically executed in aks-agentpool-12345678-vmss000000
```bash
kubectl aks run-command "ip route"
```

If we run another command, it will again be executed in `aks-agentpool-12345678-vmss000000`:

# Another command that will be still executed in aks-agentpool-12345678-vmss000000
```bash
kubectl aks run-command "hostname"
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, it doesn't make sense to repeat everything here again. Probably, we should change the structure of this file:

  • The two mechanisms to retrieve the info (and we verify the output from both using ExecDocs).
  • Show the example (only once and no matter how we retrieve the info as we already tested that both are fine).

It's fine to manage this comment in later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants