Skip to content
user

GitHub Action

Create Kubernetes Status Badge

v1.1.4 Latest version

Create Kubernetes Status Badge

user

Create Kubernetes Status Badge

Create a status badge for your Kubernetes cluster

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Create Kubernetes Status Badge

uses: walnuts1018/[email protected]

Learn more about this action in walnuts1018/k8s-badge

Choose a version

k8s badge

Last Build k8s Status Pod Status Node Status

Kubernetes ステータスのバッジを作成し、Pages にデプロイする Action です。

Inputs

name required description
kubeconfig * kubeconfig の中身相当の文字列
github_token * GitHub の Token ( secrets.GITHUB_TOKEN)
k8sStatus-SVG-text k8s Status のラベル部分の文字列
podStatus-SVG-text Pod Status のラベル部分の文字列
nodeStatus-SVG-text Node Status のラベル部分の文字列

完成 SVG

k8s Status

k8s Status

k8s Status

Kubernetes の API サーバーにアクセスできるかどうかを示します。

Pod Status

Pod Status

Pod Status

Pod Status

Node Status

Node Status

Node Status

Node Status

Getting Started

用意するもの

  • バッジの svg を置くリポジトリ
    • これは svg を置くリポジトリなので、必ずしも badge を使うリポジトリと同じである必要はありません。
    • gh-pagesブランチで Pages を有効にしてください。
    • 初回の workflow を動かすとブランチができるのでそのあとで設定するのがおすすめです。
  • kubeconfig
    • 適切な role を設定した、Actions 専用の user を使ってください。
    • 必要な role は(たぶん)pod, nodeget, listです
  • Actions からクラスタへの接続方法
    • Tailscale などを使用すると楽だと思います。

Workflow を書く

サンプル

name: k8s badge build
on:
  workflow_dispatch:
  schedule:
    - cron: '0/10 * * * *'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  k8s-badge-build:
    name: k8s badge build
    runs-on: ubuntu-latest
    steps:
      - name: setup tailscale
        uses: tailscale/github-action@v2
        with:
          oauth-client-id: ${{secrets.TAILSCALE_CLIENT_ID}}
          oauth-secret: ${{secrets.TAILSCALE_SECRET}}
          tags: "tag:github"
          args: "--accept-routes"

      - name: gen svg
        uses: walnuts1018/k8s-badge@v1
        with:
          kubeconfig: ${{ secrets.Kubeconfig }}
          github_token: ${{ secrets.GITHUB_TOKEN }}