Skip to content

Commit

Permalink
Merge pull request #18 from Azure/jose/krew
Browse files Browse the repository at this point in the history
ci: Add krew plugin manifest and release job
  • Loading branch information
blanquicet authored Apr 5, 2023
2 parents 2f74ca8 + b4b7040 commit f73caa5
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 17 deletions.
40 changes: 38 additions & 2 deletions .github/workflows/kubectl-az.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
push:
branches:
- main
tags:
- 'v*'

jobs:
build:
Expand Down Expand Up @@ -60,7 +62,7 @@ jobs:
- name: Add kubectl-az-${{ matrix.os }}-${{ matrix.arch }}.tar.gz as artifact
uses: actions/upload-artifact@v3
with:
name: kubectl-az-${{ matrix.os }}-${{ matrix.arch }}
name: kubectl-az-${{ matrix.os }}-${{ matrix.arch }}-tar-gz
path: kubectl-az-${{ matrix.os }}-${{ matrix.arch }}.tar.gz

unit-tests:
Expand Down Expand Up @@ -171,7 +173,7 @@ jobs:
- name: Get kubectl-az from artifact
uses: actions/download-artifact@v3
with:
name: kubectl-az-${{ env.os }}-${{ matrix.arch }}
name: kubectl-az-${{ env.os }}-${{ matrix.arch }}-tar-gz
- name: Prepare kubectl-az binary
shell: bash
run: |
Expand All @@ -195,3 +197,37 @@ jobs:
shell: bash
run: |
make integration-test -o kubectl-az
release:
name: Release
needs: [ integration-tests ]
runs-on: ubuntu-latest
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
# Checkout the repo to get the .krew.yaml file
- uses: actions/checkout@v3
- name: Get all artifacts.
uses: actions/download-artifact@v3
- name: Rename all artifacts to kubectl-az-${{ github.ref_name }}.tar.gz
shell: bash
run: |
for i in kubectl-az-*-*-tar-gz/kubectl-az-*-*.tar.gz; do
mv $i $(dirname $i)/$(basename $i .tar.gz)-${{ github.ref_name }}.tar.gz
done
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Release ${{ github.ref }}
- name: Upload kubectl-az binaries to the release
uses: csexton/release-asset-action@v2
with:
pattern: "kubectl-az-*-*-tar-gz/kubectl-az-*-*.tar.gz"
github-token: ${{ secrets.GITHUB_TOKEN }}
release-url: ${{ steps.create_release.outputs.upload_url }}
- name: Update new version in krew-index
if: github.repository == 'azure/kubectl-az'
uses: rajatjindal/[email protected]
35 changes: 35 additions & 0 deletions .krew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: az
spec:
version: {{ .TagName }}
homepage: https://github.com/Azure/kubectl-az
shortDescription: Interact with an AKS cluster
description: |
This plugin provides a set of commands that can be used to debug an AKS
cluster even when the cluster's control plane is not working correctly. For
instance, when the API server is having problems.
This plugin is not meant to replace az, but to complement it by providing
additional commands and, mainly, allowing users to have a kubectl-like
experience when working with an AKS cluster.
platforms:
- selector:
matchLabels:
os: linux
arch: amd64
{{addURIAndSha "https://github.com/Azure/kubectl-az/releases/download/{{ .TagName }}/kubectl-az-linux-amd64-{{ .TagName }}.tar.gz" .TagName }}
bin: kubectl-az
- selector:
matchLabels:
os: darwin
arch: amd64
{{addURIAndSha "https://github.com/Azure/kubectl-az/releases/download/{{ .TagName }}/kubectl-az-darwin-amd64-{{ .TagName }}.tar.gz" .TagName }}
bin: kubectl-az
- selector:
matchLabels:
os: windows
arch: amd64
{{addURIAndSha "https://github.com/Azure/kubectl-az/releases/download/{{ .TagName }}/kubectl-az-windows-amd64-{{ .TagName }}.tar.gz" .TagName }}
bin: kubectl-az
56 changes: 41 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Microsoft Azure CLI kubectl plugin

`kubectl-az` is a set of commands used to troubleshoot Kubernetes clusters in
Azure.
`kubectl-az` is a `kubectl` plugin that provides a set of commands that can be
used to debug an AKS cluster even when the cluster's control plane is not
working correctly. For instance, when the API server is having problems.

This plugin is not meant to replace
[az](https://learn.microsoft.com/en-us/cli/azure/?view=azure-cli-latest), but
to complement it by providing additional commands and, mainly, allowing users to
have a kubectl-like experience when working with an AKS cluster.

Going through the following documentation will help you to understand each
available command and which one is the most suitable for your case:
Expand All @@ -10,26 +16,46 @@ available command and which one is the most suitable for your case:
- [check-apiserver-connectivity](docs/check-apiserver-connectivity.md)
- [config](docs/config.md)

Consider `kubectl-az` expects the cluster to use virtual machine scale sets.
And, commands that allow using `--node` flag requires the Kubernetes API server
to up and running because it is used to retrieve the VMSS instance information
of nodes.
Consider `kubectl-az` expects the cluster to use virtual machine scale sets,
which is the case of an AKS cluster. And, the use of the `--node` flag requires
the Kubernetes control plane to up and running, because the VMSS instance
information of the node will be retrieved from the Kubernetes API server.

However, in case of issues with the Kubernetes API server, we can retrieve the
VMSS instance information from the [Azure portal](https://portal.azure.com/) and
pass it to the commands using the `--id` flag or separately with the
`--subscription`, `--node-resource-group`, `--vmss` and `--instance-id` flags.
However, in case of issues with the Kubernetes control plane, you can reuse the
already stored VMSS instance information, see [config](docs/config.md) command.
Or, if it is a cluster you have never used before on that host, you can retrieve
such information from the [Azure portal](https://portal.azure.com/) and pass it
to the commands using the `--id` flag or separately with the `--subscription`,
`--node-resource-group`, `--vmss` and `--instance-id` flags.

## Install

There is multiple ways to install the `kubectl-az`.

### Install a specific release

It is possible to download the asset for a given release and platform from the
[releases page](https://github.com/azure/kubectl-az/releases/), uncompress and
move the `kubectl-az` executable to any folder in your `$PATH`.

```bash
$ git clone https://github.com/Azure/kubectl-az.git
$ cd kubectl-az
# Build and copy the resulting binary in $HOME/.local/bin/
$ make install
VERSION=v0.1.0
curl -sL https://github.com/azure/kubectl-az/releases/latest/download/kubectl-az-linux-amd64-${VERSION}.tar.gz | sudo tar -C /usr/local/bin -xzf - kubectl-az
kubectl az version
```

Notice it requires Go version 1.17.
### Compile from source

To build `kubectl-az` from source, you'll need to have a Golang version 1.17
or higher installed:

```bash
git clone https://github.com/Azure/kubectl-az.git
cd kubectl-az
# Build and copy the resulting binary in $HOME/.local/bin/
make install
kubectl az version
```

## Usage

Expand Down

0 comments on commit f73caa5

Please sign in to comment.