• Stars
    star
    177
  • Rank 215,985 (Top 5 %)
  • Language
    Shell
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A GitHub Action to run lightweight ephemeral Kubernetes clusters during workflow. Fundamental advantage of this action is a full customization of embedded k3s clusters. In addition, it provides a private image registry and multi-cluster support.

AbsaOSS/k3d-action

A GitHub Action to run lightweight ephemeral Kubernetes clusters during workflow. Fundamental advantage of this action is a full customization of embedded k3s clusters. In addition, it provides multi-cluster support.

Introduction

Applications running on Kubernetes clusters (microservices, controllers,...) come with their own set of complexities and concerns. In particular, E2E testing k8s based applications requires new approaches to confirm proper operation and continued availability under heavy load or in the face of resource failure. AbsaOSS/k3d-action allows to test the overall application functionality. For instance, the E2E use-case is operator testing in AbsaOSS/k8gb.

The full CI/CD pipeline tutorial with k3d-action by Viktor Farcic.

Getting started

AbsaOSS/k3d-action runs k3d which is a lightweight wrapper to run k3s (Rancher Lab’s minimal Kubernetes distribution) in containers. Thanks to that, we could spin up the test environment quickly with minimal memory requirements, which is especially important in multi-cluster environments.

AbsaOSS/k3d-action defines several input attributes and two outputs:

Inputs

  • cluster-name (Required) Cluster name.

  • args (Optional) list of k3d arguments defined by k3d command tree

  • k3d-version (Optional) version of k3d. If not set, default version will be used from the version mapping table.

Version mapping and override

Implementation of additional features brings complexity and sometimes it may happen that external dependencies get broken. To prevent potential issues, k3d version is fixed according to the mapping below.

k3d-action k3d
v1.1.0 v3.4.0
v1.2.0 v4.2.0
v1.3.0 v4.2.0
v1.4.0 v4.4.1
v1.5.0 v4.4.7
v2.0.0 v5.1.0
v2.1.0 v5.2.2
v2.2.0 v5.3.0
v2.3.0 v5.4.1
v2.4.0 v5.4.6

Users can override the default k3d version with the k3d-version: action parameter

# example
with:
  k3d-version: v5.2.2

Users can also override the default k3s image version, using k3d --image argument

# example
with:
  args: --image docker.io/rancher/k3s:v1.20.4-k3s1

or the image: field in the k3d configuration file.

Recent k3s image versions can be checked on the k3.io project releases page.

Single cluster setup

Although AbsaOSS/k3d-action strongly supports multi-cluster. Single cluster scenarios are very popular. The minimum single-cluster configuration looks like this :

      - uses: AbsaOSS/k3d-action@v2
        name: "Create Single Cluster"
        with:
          cluster-name: "test-cluster-1"
          args: --agents 1

k3d creates a cluster with one worker node (with traefik and metrics services), one agent and one default load-balancer node. In real scenarios you might prefer to do some port mapping and disable default load balancer. Such an action would look like this:

      - uses: AbsaOSS/k3d-action@v2
        name: "Create Single Cluster"
        with:
          cluster-name: "test-cluster-1"
          args: >-
            -p "8083:80@agent:0:direct"
            -p "8443:443@agent:0:direct"
            -p "5053:53/udp@agent:0:direct"
            --agents 3
            --no-lb
            --image docker.io/rancher/k3s:v1.20.4-k3s1
            --k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*"

The created cluster exposes two TCP (:8083,:8443) and one UDP (:5053) ports. The cluster comprises one server, three agents and no load balancers. k3s-server-argument disable default traefik and metrics.

For more details see: Demo, Source

Multi-cluster setup

k3d creates a bridge-network for each separate cluster or attaches the created cluster to an existing network.

When you create a cluster named test-cluster-1, k3d will automatically create a network named k3d-test-cluster-1 with the range 172.18.0.0/16. When you create a second cluster test-cluster-2, k3d automatically creates a network named k3d-test-cluster-2 with a range of 172.19.0.0/16. Other clusters will have ranges 172.20.0.0/16,172.21.0.0/16 etc.

The following example creates a total of four clusters, the first two are created on the network nw01, 172.18.0.0/16, the next two clusters are created on the network nw02, 172.19.0.0/16.

      - uses: AbsaOSS/k3d-action@v2
        name: "Create 1st Cluster in 172.18.0.0/16"
        with:
          cluster-name: "test-cluster-1"
          args: >-
            -p "80:80@agent:0:direct"
            -p "443:443@agent:0:direct"
            -p "5053:53/udp@agent:0:direct"
            --agents 3
            --no-lb
            --k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*"
            --network "nw01"

      - uses: AbsaOSS/k3d-action@v2
        name: "Create 2nd Cluster in 172.18.0.0/16"
        with:
          cluster-name: "test-cluster-2"
          args: >-
            -p "81:80@agent:0:direct"
            -p "444:443@agent:0:direct"
            -p "5054:53/udp@agent:0:direct"
            --agents 3
            --no-lb
            --k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*"
            --network "nw01"

      - uses: AbsaOSS/k3d-action@v2
          name: "Create 1st Cluster in 172.19.0.0/16"
          with:
            cluster-name: "test-cluster-3"
            args: >-
              -p "82:80@agent:0:direct"
              -p "445:443@agent:0:direct"
              -p "5055:53/udp@agent:0:direct"
              --agents 3
              --no-lb
              --k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*"
              --network "nw02"

      - uses: AbsaOSS/k3d-action@v2
        name: "Create 2nd Cluster in 172.19.0.0/16"
        with:
          cluster-name: "test-cluster-4"
          args: >-
            -p "83:80@agent:0:direct"
            -p "446:443@agent:0:direct"
            -p "5056:53/udp@agent:0:direct"
            --agents 3
            --no-lb
            --k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*"
            --network "nw02"

AbsaOSS/k3d-action creates four identical clusters in two different bridge networks.

For more details see: Demo, Source

Config file support

From v1.2.0 you can configure action via config files or mix arguments together with config files. This setup is useful when you want to share the configuration for local testing and testing within k3d-action.

      - uses: ./
        name: "Create single k3d Cluster"
        with:
          cluster-name: "test-cluster-1"
          args: >-
            --agents 1
            --config=<path to config yaml>

All you need to do is to place configuration file somewhere into your project. However, keep in mind, that command line arguments will always take precedence over configuration, so the previous example will result in only one agent, not three as configured.

apiVersion: k3d.io/v1alpha3
kind: Simple
image: docker.io/rancher/k3s:v1.20.5-k3s1
servers: 1
agents: 3 # The action will overwrite this by 1
ports:
  - port: 0.0.0.0:80:80
    nodeFilters:
      - agent:0:direct
  - port: 0.0.0.0:443:443
    nodeFilters:
      - agent:0:direct
  - port: 0.0.0.0:5053:53/udp
    nodeFilters:
      - agent:0:direct
options:
  k3d:
    wait: true
    timeout: "60s"
    disableLoadbalancer: true
  k3s:
    extraArgs:
      - arg: --no-deploy=traefik,servicelb,metrics-server
        nodeFilters:
          - server:*
  kubeconfig:
    updateDefaultKubeconfig: true
    switchCurrentContext: true

For more details see: Demo, Source action, Source config

Private Registry

Before test starts, you need to build your app and install into the cluster. This requires interaction with the image registry. Usually you don't want to push a new image into the remote registry for each test. Instead, you can import the image directly into the created cluster:

docker build . -t <repository>:<semver>
k3d image import <repository>:<semver> -c <cluster-name>

Example below demonstrates how to interact with imported docker registry:

    steps:
      - uses: actions/checkout@v2
      - uses: AbsaOSS/k3d-action@v2
        name: "Create single k3d Cluster with imported Registry"
        with:
          cluster-name: test-cluster-1
          args: >-
            --agents 3
            --no-lb
            --k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*"
      - name: "Docker repo demo"
        run: |
          docker build . -t myproj/demo:v1.0.0
          k3d image import myproj/demo:v1.0.0 -c test-cluster-1 --verbose
          kubectl apply -f pod.yaml

    # pod.yaml
    #
    # apiVersion: v1
    # kind: Pod
    # metadata:
    #   name: test-pod
    # spec:
    #   containers:
    #   - name: demo-app
    #     image: myproj/demo:v1.0.0

For further details see:

More Repositories

1

spline

Data Lineage Tracking And Visualization Solution
Scala
603
star
2

ABRiS

Avro SerDe for Apache Spark structured APIs.
Scala
229
star
3

spline-spark-agent

Spline agent for Apache Spark
Scala
185
star
4

cobrix

A COBOL parser and Mainframe/EBCDIC data source for Apache Spark
Scala
136
star
5

golic

GoLic, injects license into source code files
Go
95
star
6

hyperdrive

Extensible streaming ingestion pipeline on top of Apache Spark
Scala
43
star
7

spark-hats

Nested array transformation helper extensions for Apache Spark
Scala
36
star
8

enceladus

Dynamic Conformance Engine
Scala
31
star
9

atum

A dynamic data completeness and accuracy library at enterprise scale for Apache Spark
Scala
30
star
10

spline-getting-started

Scala
24
star
11

vcxagencynode

NodeJS implementation of Hyperledger Indy LibVCX Agency
JavaScript
24
star
12

pramen

Resilient data pipeline framework running on Apache Spark
Scala
23
star
13

samlet

saml2aws k8s operator
Go
17
star
14

spark-hofs

Scala API for Apache Spark SQL high-order functions
Scala
14
star
15

py2k

A Python to Kafka Serialization Tool
Python
13
star
16

spline-ui

TypeScript
12
star
17

rn-indy-sdk

This code was starting point of https://github.com/hyperledger/indy-sdk-react-native where the work continues.
Java
11
star
18

env-binder

Binding environment variables to GO structures
Makefile
10
star
19

external-dns-infoblox-webhook

Infoblox provider based on in-tree provider for ExternalDNS
Go
10
star
20

hermes

A E2E test tool for Enceladus. Also general dataframe comparison tool
Scala
8
star
21

Jdbc2S

A JDBC streaming source for Spark
Scala
8
star
22

spark-partition-sizing

Sizing partitions in Spark
Scala
8
star
23

commons

Selection of useful reusable components
Scala
8
star
24

spark-commons

Scala
7
star
25

hyperdrive-trigger

Event based workflow manager.
TypeScript
7
star
26

spark-metadata-tool

Tool to fix _spark_metadata from Structured Streaming queries
Scala
6
star
27

atum-service

Scala
6
star
28

spline-openlineage

Open Lineage Integration for Spline
Scala
5
star
29

ghpages-to-tf-provider-registry

5
star
30

spot

Aggregate and analyze Spark history, export to elasticsearch, visualize and monitor with Kibana.
Python
5
star
31

fixed-width

Scala
5
star
32

gh-pages-skeleton

Serve as a starter of github pages for any project of AbsaOSS
Ruby
5
star
33

generate-release-notes

Efficiently automate your release note generation with 'generate-release-notes'. This tool scans your target GitHub repository's issues, sorting and organizing them into well-formatted release notes. Perfect for maintaining a streamlined and organized release process.
JavaScript
4
star
34

cert-manager-webhook-externaldns

A cert-manager webhook completing DNS01 challenge by using External DNS
Go
4
star
35

spark-data-standardization

A library for Spark that helps to stadardize any input data (DataFrame) to adhere to the provided schema.
Scala
4
star
36

absaoss.github.io

CSS
3
star
37

balta

Scala library to write Postgres DB code tests with
Scala
3
star
38

fa-db

Functional Access to Database
Scala
3
star
39

login-service

AbsaOSS Common Login gateway using JWT Public key signatures
Scala
3
star
40

rest-api-doc-generator

Scala
3
star
41

ultet

Database deployment tool
Scala
3
star
42

rialto

An open source data science framework for feature and model deployment
Python
2
star
43

manabu-ui

Front-end application for the Manabu Learning Portal
TypeScript
2
star
44

tf-provider-registry-generator

Go
2
star
45

inception

Java
2
star
46

CertMe

A NodeJS tool to generate and sign TLS certificates blazing fast with HashiCorp Vault and import them into AWS ACM
JavaScript
2
star
47

aries-oob-shortener

Shortener for URL-formatted Aries OOB messages.
Rust
2
star
48

cps-shared-ui

Angular shared components library
TypeScript
2
star
49

filename-inspector

The Test File Suffix Inspector GitHub Action scans test files in src/test directories to ensure naming conventions, reporting any files missing specified suffixes.
Python
2
star
50

pgdump-lambda

HCL
2
star
51

root-pom

1
star
52

springdoc-openapi-scala

Enhancement of springdoc-openapi for Scala
Scala
1
star
53

artifactory-registry-meta-generator

Builds a metadata for serving Docker registry with checksum-based storage
Go
1
star
54

pit-junit-cucumber-upstream

Java
1
star
55

manabu-backend

JavaScript
1
star
56

provider-jet-rancher

Crossplane terrajet based rancher provider
Makefile
1
star
57

hackathon-turbo

Team Turbo Hackathon Repo
Jupyter Notebook
1
star
58

reusable-workflows

A collection of AbsaOSS reusable workflows for GitHub action
1
star
59

driver-did-sov

DID resolver HTTP(s) binding for Sovrin DID method.
Rust
1
star
60

cap-infra-dns

CAPI Cluster controlplaneEndpoint DNS registrator
Go
1
star
61

simba-athena-login-service-support

Credentials provider for Simba Athena driver using Absa Login Service
Scala
1
star
62

version-tag-check

A GH action for validating version tag sequences and ensuring compliance with versioning standards in repositories.
1
star
63

EventGate

HCL
1
star
64

spline-python-agent

Python
1
star
65

datasets-similarity

Computes the similarity between tabular datasets.
HTML
1
star
66

cps-mdoc-viewer

Angular library utilized in constructing websites that host tutorials and documentation, providing reference materials to help users learn about a particular topic, tool, or technology. The content is supplied in the format of markdown documents. This repository comprises both the library itself and an example website constructed using it.
TypeScript
1
star
67

living-doc-generator

"living-doc-generator: A GitHub Action designed to data-mine GitHub repositories for issues containing project documentation (e.g., tagged with feature-related labels). This action automatically generates fresh documentation in markdown format, providing detailed feature overview pages and in-depth feature descriptions.
Python
1
star
68

sbt-git-hooks

SBT plugin to sync git hooks as part of the project
Scala
1
star