Skip to content

vbem/k8s-port-forward

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k8s-port-forward

Testing Super Linter GitHub release (latest SemVer) Marketplace

About

This action can be used to forward local ports on GitHub runners to workloads in your Kubernetes cluster.

Current implementation is to setup a kubectl port-forward daemon in background and immune to hangups, which make local ports on runner available to subsequent steps.

Note that this action follow official kubeconfig authentication methods and you need to sign in your K8s cluster via other actions such as kubeconfig4sa, or manually set KUBECONFIG environment variable for this action in your workflows file.

Example usage

- name: Setup KUBECONFIG
  uses: vbem/kubeconfig4sa@v1
  with:
    server:     https://your-kubeapi-server:6443
    ca-base64:  ${{ secrets.K8S_CA_BASE64 }}
    token:      ${{ secrets.K8S_SA_TOKEN }}
    namespace:  my-namespace

# This action will forward port 8080 on runner to port 80 of your service in Kubernetes!
- name: Setup Kubernetes port-forward daemon
  uses: vbem/k8s-port-forward@v1
  with:
    workload: 'svc/mysvc'

- name: Request a service in Kubernetes
  run: curl localhost:8080

Example

Inputs

ID Type Default Description
workload String Required input Kubernetes workload type/name such as deploy/mydeploy, svc/mysvc or po/mypod
mappings String 8080:80 Ports mappings [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N]
options String <empty> Other command-line options, such as --namespace=myns
sleep String 3 Seconds to wait before action finished

Outputs

ID Type Description
pid String Process ID of port-forward daemon
log String Path to port-forward log file