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

add: test k8s #34

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions .github/workflows/k8s-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Get Kubernetes Pods via Service Token

on:
push:
branches:
- '**' # すべてのブランチが対象

permissions:
contents: read # リポジトリのコンテンツの読み取り権限

jobs:
get-pods:
runs-on: ubuntu-latest

env:
CLOUDFLARE_TUNNEL_URL: "https://k8s.b0xp.io" # Kubernetes APIのURL
K8S_NAMESPACE: "argocd" # KubernetesのNamespace
CLOUDFLARE_SERVICE_TOKEN_ID: ${{ secrets.CLOUDFLARE_SERVICE_TOKEN_ID }} # Service TokenのID
CLOUDFLARE_SERVICE_TOKEN_SECRET: ${{ secrets.CLOUDFLARE_SERVICE_TOKEN_SECRET }} # Service TokenのSecret

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Get Kubernetes Pods from API
run: |
echo "Fetching pods from Kubernetes API at $CLOUDFLARE_TUNNEL_URL..."

# Kubernetes APIのGETリクエスト
API_URL="$CLOUDFLARE_TUNNEL_URL/api/v1/namespaces/$K8S_NAMESPACE/pods"

RESPONSE=$(curl -s -X GET $API_URL \
-H "CF-Access-Client-Id: ${{ secrets.CLOUDFLARE_SERVICE_TOKEN_ID }}" \
-H "CF-Access-Client-Secret: ${{ secrets.CLOUDFLARE_SERVICE_TOKEN_SECRET }}" \
-H "Accept: application/json")

echo "Response from API:"
echo $RESPONSE
echo $RESPONSE | jq
Loading