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

Fix/build publish workflow #38

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
JobBuild:
name: release
runs-on: ubuntu-latest
# Expose step outputs as job outputs
# Expose step outputs as job outputs
outputs:
currentversion: ${{ steps.package_version.outputs.current-version }}
changelog_reader_changes: ${{ steps.changelog_reader.outputs.changes }}
Expand Down Expand Up @@ -59,7 +59,19 @@ jobs:
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit

# Checkout the code again for release
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Use Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
# Run install dependencies
- name: Install dependencies
run: npm run install:all
# Ensure project builds successfully before creating release
- name: Build
run: npm run webpack
- name: Create a Release
id: create_release
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## [1.4.3]

* Retina integration with VsCode.
* In-house download replacement implementation.
* Show-properties page k8s version is now available with deprecated warning.
* Dependabot updates and bumps.

Thank you so much @sprab for continued effort for Retina User-Sceanrios testing changes, thanks you so much to @hsubramanianaks for Retina help and U/X changes, thanks to, @sprab, @hsubramanianaks, & @peterbom for comments and testing. Thank you @rbtr and @vakalapa for async Retina Fixes and for `0.0.7` release. Thanks all for our other BAU contributors.

## [1.4.2]

* Show Properties page new feature for help information with k8s version deprecated available .
Expand Down
1 change: 1 addition & 0 deletions docs/book/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Azure Kubernetes Service (AKS) Extension for Visual Studio Code helps enable AKS
* [Collect TCP Dumps](./features/tcp-dumps.md)
* [Compare AKS Cluster](./features/aks-compare-cluster.md)
* [Run Image Cleaner Eraser Tool](./features/image-cleaner-eraser-tool.md)
* [Run Retina Capture](./features/retina-capture.md)

## Development and Release

Expand Down
1 change: 1 addition & 0 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- [Collect TCP Dump](./features/tcp-dumps.md)
- [Compare AKS Cluster](./features/aks-compare-cluster.md)
- [Run Image Cleaner Eraser Tool](./features/image-cleaner-eraser-tool.md)
- [Run Retina Capture](./features/retina-capture.md)
- [Release](./release.md)
- [Releasing Information](./release/releasing.md)
- [Contributing](./contributing.md)
Expand Down
4 changes: 3 additions & 1 deletion docs/book/src/features/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ Once you successfully log in with your Azure Account, you can view all AKS clust

![AKS Show Properties webview](../resources/show-properties-reconcile.png)

![Cloud Explorer Compare AKS Cluster](../resources/aks-compare-cluster-result.png)
![Cloud Explorer Compare AKS Cluster](../resources/aks-compare-cluster-result.png)

![Cloud Explorer Run Retina Capture on AKS Cluster](../resources/retina-success-run-download.png)
2 changes: 1 addition & 1 deletion docs/book/src/features/inspektor-gadget.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Deploy and Undeploy InspektorGadget

Right click on your AKS cluster and click on **Show Inspektor Gadget** to easily deploy gadget into your cluster. User can easily one-click deploy and undeploy gadget from this feature.
Right click on your AKS cluster and select **Troubleshoot Network Health** and then click on **Show Inspektor Gadget** to easily deploy gadget into your cluster. User can easily one-click deploy and undeploy gadget from this feature.

### Profile, Top, Trace and Snapshot Inspektor Gadget Commands

Expand Down
11 changes: 11 additions & 0 deletions docs/book/src/features/retina-capture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Run Retina Distributed Capture from AKS Cluster Linux Nodes

### Run Retina Capture

Right click on your AKS cluster and select **Troubleshoot Network Health** and then click on **Run Retina Capture** to capture logs like iptables-rules, [ip-resrouces.txt and other key distributed captures form this azure networking tool](https://retina.sh/docs/captures/cli#file-and-directory-structure-inside-the-tarball) for any Linux node and download them to your local machine with ease.

![Step 1: Menu](../resources/right-click-retina-capture.png)

![Step 2: Select Nodes to Run Retina](../resources/retina-select-nodes.png)

![Step 3: Retina Ran Successfully](../resources/retina-success-run-download.png)
2 changes: 1 addition & 1 deletion docs/book/src/features/tcp-dumps.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Collect TCP Dumps

Right click on your AKS cluster and select **Collect TCP Dumps** to capture TCP dumps for any Linux node and download them to your local machine with ease.
Right click on your AKS cluster and select **Troubleshoot Network Health** and then select **Collect TCP Dumps** to capture TCP dumps for any Linux node and download them to your local machine with ease.

Added filters to the TCP Dump functionality, so that you can target traffic capture to specific network interfaces, ports or protocols, to or from specific pods, or craft custom [pcap filter strings](https://www.tcpdump.org/manpages/pcap-filter.7.html).

Expand Down
Binary file added docs/book/src/resources/retina-select-nodes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 34 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-aks-tools",
"displayName": "Azure Kubernetes Service",
"description": "Display Azure Kubernetes Services within VS Code",
"version": "1.4.2",
"version": "1.4.3",
"aiKey": "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255",
"publisher": "ms-kubernetes-tools",
"icon": "resources/aks-tools.png",
Expand Down Expand Up @@ -144,6 +144,12 @@
"default": "v0.0.30",
"title": "Draft repository release tag",
"description": "Release tag for the stable Draft tool release."
},
"aks.retinatool.releaseTag": {
"type": "string",
"default": "v0.0.7",
"title": "Retina repository release tag",
"description": "Release tag for the stable Retina tool release."
}
}
},
Expand Down Expand Up @@ -259,6 +265,10 @@
{
"command": "aks.compareCluster",
"title": "Compare AKS Cluster"
},
{
"command": "aks.aksRetinaCapture",
"title": "Run Retina Capture"
}
],
"menus": {
Expand Down Expand Up @@ -331,19 +341,14 @@
"when": "view == kubernetes.cloudExplorer && viewItem =~ /aks\\.cluster/i || view == extension.vsKubernetesExplorer && viewItem =~ /vsKubernetes\\.\\w*cluster$/i",
"group": "9@3"
},
{
"command": "aks.aksInspektorGadgetShow",
"when": "view == kubernetes.cloudExplorer && viewItem =~ /aks\\.cluster/i || view == extension.vsKubernetesExplorer && viewItem =~ /vsKubernetes\\.\\w*cluster$/i",
"group": "9@4"
},
{
"command": "aks.aksTCPDump",
"when": "view == kubernetes.cloudExplorer && viewItem =~ /aks\\.cluster/i || view == extension.vsKubernetesExplorer && viewItem =~ /vsKubernetes\\.\\w*cluster$/i",
"group": "9@5"
},
{
"command": "aks.compareCluster",
"when": "view == kubernetes.cloudExplorer && viewItem =~ /aks\\.subscription/i"
},
{
"submenu": "aks.networkTroubleshootingSubMenu",
"when": "view == kubernetes.cloudExplorer && viewItem =~ /aks\\.cluster/i",
"group": "9@3"
}
],
"aks.createClusterSubMenu": [
Expand Down Expand Up @@ -400,6 +405,20 @@
"group": "navigation"
}
],
"aks.networkTroubleshootingSubMenu": [
{
"command": "aks.aksTCPDump",
"group": "navigation"
},
{
"command": "aks.aksInspektorGadgetShow",
"group": "navigation"
},
{
"command": "aks.aksRetinaCapture",
"group": "navigation"
}
],
"aks.managedClusterOperationSubMenu": [
{
"command": "aks.aksDeleteCluster",
Expand Down Expand Up @@ -435,6 +454,10 @@
{
"id": "aks.tcpDataCollectionSubMenu",
"label": "Collect TCP Dump"
},
{
"id": "aks.networkTroubleshootingSubMenu",
"label": "Troubleshoot Network Health"
}
]
},
Expand Down
135 changes: 135 additions & 0 deletions src/commands/aksRetinaCapture/aksRetinaCapture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import * as vscode from "vscode";
import * as k8s from "vscode-kubernetes-tools-api";
import { IActionContext } from "@microsoft/vscode-azext-utils";
import { getKubernetesClusterInfo } from "../utils/clusters";
import { getExtension, longRunning } from "../utils/host";
import * as tmpfile from "../utils/tempfile";
import path from "path";
import { ensureDirectoryInPath } from "../utils/env";
import { getRetinaBinaryPath } from "../utils/helper/retinaBinaryDownload";
import { getVersion, invokeKubectlCommand } from "../utils/kubectl";
import { RetinaCapturePanel, RetinaCaptureProvider } from "../../panels/RetinaCapturePanel";
import { failed } from "../utils/errorable";
import { getLinuxNodes } from "../../panels/utilities/KubectlNetworkHelper";

export async function aksRetinaCapture(_context: IActionContext, target: unknown): Promise<void> {
const kubectl = await k8s.extension.kubectl.v1;
const cloudExplorer = await k8s.extension.cloudExplorer.v1;
const clusterExplorer = await k8s.extension.clusterExplorer.v1;

if (!kubectl.available) {
vscode.window.showWarningMessage(`Kubectl is unavailable.`);
return;
}

if (!cloudExplorer.available) {
vscode.window.showWarningMessage(`Cloud explorer is unavailable.`);
return;
}

if (!clusterExplorer.available) {
vscode.window.showWarningMessage(`Cluster explorer is unavailable.`);
return;
}

const clusterInfo = await getKubernetesClusterInfo(target, cloudExplorer, clusterExplorer);
if (failed(clusterInfo)) {
vscode.window.showErrorMessage(clusterInfo.error);
return;
}

const kubectlRetinaPath = await getRetinaBinaryPath();
if (failed(kubectlRetinaPath)) {
vscode.window.showWarningMessage(`kubectl retina path was not found ${kubectlRetinaPath.error}`);
return;
}

ensureDirectoryInPath(path.dirname(kubectlRetinaPath.result));

const extension = getExtension();
if (failed(extension)) {
vscode.window.showErrorMessage(extension.error);
return;
}

// Get all Linux Nodes For this Cluster
const kubeConfigFile = await tmpfile.createTempFile(clusterInfo.result.kubeconfigYaml, "yaml");
const linuxNodesList = await getLinuxNodes(kubectl, kubeConfigFile.filePath);
if (failed(linuxNodesList)) {
vscode.window.showErrorMessage(linuxNodesList.error);
return;
}

// Pick a Node to Capture Traffic From
const nodeNamesSelected = await vscode.window.showQuickPick(linuxNodesList.result, {
canPickMany: true,
placeHolder: "Please select all the Nodes you want Retina to capture traffic from.",
title: "Select Nodes to Capture Traffic From",
});

if (!nodeNamesSelected) {
vscode.window.showErrorMessage('No nodes were selected to capture traffic.');
return;
}

const selectedNodes = nodeNamesSelected.map((item) => item).join(",");

if (!selectedNodes) {
return;
}

// Retina Run Capture
const capturename = `retina-capture-${clusterInfo.result.name.toLowerCase()}`;
const retinaCaptureResult = await longRunning(`Retina Distributed Capture running for cluster ${clusterInfo.result.name}.`, async () => {
return await invokeKubectlCommand(
kubectl,
kubeConfigFile.filePath,
`retina capture create --namespace default --name ${capturename} --host-path /mnt/capture --node-selectors "kubernetes.io/os=linux" --node-names "${selectedNodes}" --no-wait=false`,
)
});

if (failed(retinaCaptureResult)) {
vscode.window.showErrorMessage(`Failed to capture the cluster: ${retinaCaptureResult.error}`);
return;
}

if (retinaCaptureResult.result.stdout && retinaCaptureResult.result.code === 0) {
vscode.window.showInformationMessage(`Retina distributed capture is successfully completed for the cluster ${clusterInfo.result.name}`);
}

const kubectlVersion = await getVersion(kubectl, kubeConfigFile.filePath);
if (failed(kubectlVersion)) {
vscode.window.showErrorMessage(kubectlVersion.error);
return;
}

const foldername = `${capturename}_${(new Date().toJSON().replaceAll(":", ""))}`;

// find if node explorer pod is already exists
let nodeExplorerPodExists = false;
const nodeExplorerPod = await invokeKubectlCommand(
kubectl,
kubeConfigFile.filePath,
`get pods -n default -l app=node-explorer`,
);


if (nodeExplorerPod.succeeded && nodeExplorerPod.result.stdout && nodeExplorerPod.result.stdout.includes("node-explorer")) {
nodeExplorerPodExists = true;
}


const dataProvider = new RetinaCaptureProvider(
kubectl,
kubectlVersion.result,
kubeConfigFile.filePath,
clusterInfo.result.name,
retinaCaptureResult.result.stdout,
selectedNodes.split(","),
`${foldername}`,
nodeExplorerPodExists,
);

const panel = new RetinaCapturePanel(extension.result.extensionUri);
panel.show(dataProvider, kubeConfigFile);
}
14 changes: 3 additions & 11 deletions src/commands/aksTCPCollection/tcpDumpCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import * as k8s from "vscode-kubernetes-tools-api";
import { IActionContext } from "@microsoft/vscode-azext-utils";
import { getKubernetesClusterInfo } from "../utils/clusters";
import { getExtension } from "../utils/host";
import { Errorable, failed, map as errmap } from "../utils/errorable";
import { failed } from "../utils/errorable";
import * as tmpfile from "../utils/tempfile";
import { TcpDumpDataProvider, TcpDumpPanel } from "../../panels/TcpDumpPanel";
import { getVersion, invokeKubectlCommand } from "../utils/kubectl";
import { getVersion } from "../utils/kubectl";
import { getLinuxNodes } from "../../panels/utilities/KubectlNetworkHelper";

export async function aksTCPDump(_context: IActionContext, target: unknown) {
const kubectl = await k8s.extension.kubectl.v1;
Expand Down Expand Up @@ -64,12 +65,3 @@ export async function aksTCPDump(_context: IActionContext, target: unknown) {

panel.show(dataProvider, kubeConfigFile);
}

async function getLinuxNodes(
kubectl: k8s.APIAvailable<k8s.KubectlV1>,
kubeConfigFile: string,
): Promise<Errorable<string[]>> {
const command = `get node -l kubernetes.io/os=linux --no-headers -o custom-columns=":metadata.name"`;
const commandResult = await invokeKubectlCommand(kubectl, kubeConfigFile, command);
return errmap(commandResult, (sr) => sr.stdout.trim().split("\n"));
}
3 changes: 0 additions & 3 deletions src/commands/periscope/models/DraftConfig.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/commands/periscope/models/RetinaDownloadConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface RetinaDownloadConfig {
releaseTag: string;
}
Loading
Loading