Skip to content

Commit f73caa5

Browse files
authored
Merge pull request #18 from Azure/jose/krew
ci: Add krew plugin manifest and release job
2 parents 2f74ca8 + b4b7040 commit f73caa5

File tree

3 files changed

+114
-17
lines changed

3 files changed

+114
-17
lines changed

.github/workflows/kubectl-az.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
push:
1313
branches:
1414
- main
15+
tags:
16+
- 'v*'
1517

1618
jobs:
1719
build:
@@ -60,7 +62,7 @@ jobs:
6062
- name: Add kubectl-az-${{ matrix.os }}-${{ matrix.arch }}.tar.gz as artifact
6163
uses: actions/upload-artifact@v3
6264
with:
63-
name: kubectl-az-${{ matrix.os }}-${{ matrix.arch }}
65+
name: kubectl-az-${{ matrix.os }}-${{ matrix.arch }}-tar-gz
6466
path: kubectl-az-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
6567

6668
unit-tests:
@@ -171,7 +173,7 @@ jobs:
171173
- name: Get kubectl-az from artifact
172174
uses: actions/download-artifact@v3
173175
with:
174-
name: kubectl-az-${{ env.os }}-${{ matrix.arch }}
176+
name: kubectl-az-${{ env.os }}-${{ matrix.arch }}-tar-gz
175177
- name: Prepare kubectl-az binary
176178
shell: bash
177179
run: |
@@ -195,3 +197,37 @@ jobs:
195197
shell: bash
196198
run: |
197199
make integration-test -o kubectl-az
200+
201+
release:
202+
name: Release
203+
needs: [ integration-tests ]
204+
runs-on: ubuntu-latest
205+
permissions:
206+
contents: write
207+
if: startsWith(github.ref, 'refs/tags/v')
208+
steps:
209+
# Checkout the repo to get the .krew.yaml file
210+
- uses: actions/checkout@v3
211+
- name: Get all artifacts.
212+
uses: actions/download-artifact@v3
213+
- name: Rename all artifacts to kubectl-az-${{ github.ref_name }}.tar.gz
214+
shell: bash
215+
run: |
216+
for i in kubectl-az-*-*-tar-gz/kubectl-az-*-*.tar.gz; do
217+
mv $i $(dirname $i)/$(basename $i .tar.gz)-${{ github.ref_name }}.tar.gz
218+
done
219+
- name: Create Release
220+
id: create_release
221+
uses: softprops/action-gh-release@v1
222+
with:
223+
token: ${{ secrets.GITHUB_TOKEN }}
224+
name: Release ${{ github.ref }}
225+
- name: Upload kubectl-az binaries to the release
226+
uses: csexton/release-asset-action@v2
227+
with:
228+
pattern: "kubectl-az-*-*-tar-gz/kubectl-az-*-*.tar.gz"
229+
github-token: ${{ secrets.GITHUB_TOKEN }}
230+
release-url: ${{ steps.create_release.outputs.upload_url }}
231+
- name: Update new version in krew-index
232+
if: github.repository == 'azure/kubectl-az'
233+
uses: rajatjindal/krew-release-bot@v0.0.46

.krew.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: krew.googlecontainertools.github.com/v1alpha2
2+
kind: Plugin
3+
metadata:
4+
name: az
5+
spec:
6+
version: {{ .TagName }}
7+
homepage: https://github.com/Azure/kubectl-az
8+
shortDescription: Interact with an AKS cluster
9+
description: |
10+
This plugin provides a set of commands that can be used to debug an AKS
11+
cluster even when the cluster's control plane is not working correctly. For
12+
instance, when the API server is having problems.
13+
14+
This plugin is not meant to replace az, but to complement it by providing
15+
additional commands and, mainly, allowing users to have a kubectl-like
16+
experience when working with an AKS cluster.
17+
platforms:
18+
- selector:
19+
matchLabels:
20+
os: linux
21+
arch: amd64
22+
{{addURIAndSha "https://github.com/Azure/kubectl-az/releases/download/{{ .TagName }}/kubectl-az-linux-amd64-{{ .TagName }}.tar.gz" .TagName }}
23+
bin: kubectl-az
24+
- selector:
25+
matchLabels:
26+
os: darwin
27+
arch: amd64
28+
{{addURIAndSha "https://github.com/Azure/kubectl-az/releases/download/{{ .TagName }}/kubectl-az-darwin-amd64-{{ .TagName }}.tar.gz" .TagName }}
29+
bin: kubectl-az
30+
- selector:
31+
matchLabels:
32+
os: windows
33+
arch: amd64
34+
{{addURIAndSha "https://github.com/Azure/kubectl-az/releases/download/{{ .TagName }}/kubectl-az-windows-amd64-{{ .TagName }}.tar.gz" .TagName }}
35+
bin: kubectl-az

README.md

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Microsoft Azure CLI kubectl plugin
22

3-
`kubectl-az` is a set of commands used to troubleshoot Kubernetes clusters in
4-
Azure.
3+
`kubectl-az` is a `kubectl` plugin that provides a set of commands that can be
4+
used to debug an AKS cluster even when the cluster's control plane is not
5+
working correctly. For instance, when the API server is having problems.
6+
7+
This plugin is not meant to replace
8+
[az](https://learn.microsoft.com/en-us/cli/azure/?view=azure-cli-latest), but
9+
to complement it by providing additional commands and, mainly, allowing users to
10+
have a kubectl-like experience when working with an AKS cluster.
511

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

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

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

2331
## Install
2432

33+
There is multiple ways to install the `kubectl-az`.
34+
35+
### Install a specific release
36+
37+
It is possible to download the asset for a given release and platform from the
38+
[releases page](https://github.com/azure/kubectl-az/releases/), uncompress and
39+
move the `kubectl-az` executable to any folder in your `$PATH`.
40+
2541
```bash
26-
$ git clone https://github.com/Azure/kubectl-az.git
27-
$ cd kubectl-az
28-
# Build and copy the resulting binary in $HOME/.local/bin/
29-
$ make install
42+
VERSION=v0.1.0
43+
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
44+
kubectl az version
3045
```
3146

32-
Notice it requires Go version 1.17.
47+
### Compile from source
48+
49+
To build `kubectl-az` from source, you'll need to have a Golang version 1.17
50+
or higher installed:
51+
52+
```bash
53+
git clone https://github.com/Azure/kubectl-az.git
54+
cd kubectl-az
55+
# Build and copy the resulting binary in $HOME/.local/bin/
56+
make install
57+
kubectl az version
58+
```
3359

3460
## Usage
3561

0 commit comments

Comments
 (0)