diff --git a/.github/workflows/publish-charts.yml b/.github/workflows/publish-charts.yml index 59d9fb2..659f2ff 100644 --- a/.github/workflows/publish-charts.yml +++ b/.github/workflows/publish-charts.yml @@ -9,29 +9,85 @@ name: Publish charts on: push: tags: ["*"] + branches: + - main + pull_request: workflow_dispatch: defaults: run: shell: bash +env: + CHARTPRESS_ARGS: > + --builder docker-buildx + --platform linux/amd64 + --platform linux/arm64 + jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + with: + # chartpress requires git history to set chart version and image tags + # correctly + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Decide to publish or not + id: publishing + shell: python + run: | + import os + repo = "${{ github.repository }}" + event = "${{ github.event_name }}" + ref = "${{ github.event.ref }}" + publishing = "" + if ( + event == "push" + and ( + ref.startswith("refs/tags/") + or ref == "refs/heads/main" + ) + ): + publishing = "true" + print("Publishing chart") + with open(os.environ["GITHUB_OUTPUT"], "a") as f: + f.write(f"publishing={publishing}\n") + + - name: Set up QEMU (for docker buildx) + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx (for chartpress multi-arch builds) + uses: docker/setup-buildx-action@v3 + + - name: Install chart publishing dependencies (chartpress) + run: | + pip install -r requirements.txt + pip list + + helm version + + - name: Enable chartpress publishing + if: steps.publishing.outputs.publishing + run: + echo CHARTPRESS_ARGS="${CHARTPRESS_ARGS} --push" >> $GITHUB_ENV + - - name: Get the version - id: get_version + - name: build chart with chartpress run: | - echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + chartpress $CHARTPRESS_ARGS - name: Publish Helm charts + if: steps.publishing.outputs.publishing uses: stefanprodan/helm-gh-pages@master with: token: ${{ secrets.GITHUB_TOKEN }} charts_dir: "." charts_url: https://kbatch-dev.github.io/helm-chart linting: "off" - chart_version: ${{ env.VERSION }} diff --git a/.github/workflows/test-kbatch-chart.yaml b/.github/workflows/test-kbatch-chart.yaml index 4ed1300..398fc35 100644 --- a/.github/workflows/test-kbatch-chart.yaml +++ b/.github/workflows/test-kbatch-chart.yaml @@ -20,7 +20,7 @@ defaults: jobs: test-install-chart: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: # Keep running even if one variation of the job fail @@ -33,32 +33,44 @@ jobs: # k3s-version: https://github.com/rancher/k3s/tags # k3s-channel: https://update.k3s.io/v1-release/channels include: - - k3s-channel: v1.19 - - k3s-channel: v1.16 + - k3s-channel: v1.28 + - k3s-channel: v1.31 steps: - - uses: actions/checkout@v2 - - name: Install helm - run: | - curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash + - uses: actions/checkout@v4 + with: + # chartpress requires git history to set chart version and image tags + # correctly + fetch-depth: 0 - - name: Lint chart's templates + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + cache: pip + + - name: Install dependencies run: | - helm lint ./kbatch --strict --values kbatch/values.yaml + pip install -r requirements.txt + pip freeze - - name: Validate chart's templates can render + - name: Render chartpress run: | - helm template ./kbatch --values kbatch/values.yaml 1>/dev/null + chartpress # Starts a k8s cluster with NetworkPolicy enforcement and installs kubectl # # ref: https://github.com/jupyterhub/action-k3s-helm/ - - uses: jupyterhub/action-k3s-helm@v1 + - uses: jupyterhub/action-k3s-helm@v4 with: k3s-channel: ${{ matrix.k3s-channel }} metrics-enabled: false traefik-enabled: false - docker-enabled: false + # docker-enabled required to access images built in chartpress stage + docker-enabled: true + + - name: Lint chart's templates + run: | + helm lint ./kbatch --strict --values kbatch/values.yaml - name: Validate charts' rendered templates are valid k8s resources run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6f03eec..b70c444 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,14 @@ repos: - repo: https://github.com/rapidsai/frigate/ - rev: v0.4.0 # pre-commit autoupdate - to keep the version up to date + # need a release after https://github.com/rapidsai/frigate/pull/74 + rev: 0aca194f9011a656fd7211dbe2210511c94a36a5 hooks: - id: frigate - repo: https://github.com/gruntwork-io/pre-commit - rev: v0.1.12 # pre-commit autoupdate - to keep the version up to date + rev: v0.1.23 # pre-commit autoupdate - to keep the version up to date hooks: - id: helmlint + - repo: https://github.com/jupyterhub/chartpress + rev: 2.2.0 + hooks: + - id: chartpress diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md new file mode 120000 index 0000000..1ffef23 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +kbatch/README.md \ No newline at end of file diff --git a/chartpress.yaml b/chartpress.yaml new file mode 100644 index 0000000..c4009f5 --- /dev/null +++ b/chartpress.yaml @@ -0,0 +1,14 @@ +charts: + - name: kbatch + baseVersion: "0.5.0" + imagePrefix: ghcr.io/kbatch-dev/k8s- + repo: + git: kbatch-dev/helm-chart + published: https://kbatch-dev.github.io/helm-chart + images: + kbatch-proxy: + valuesPath: image + buildArgs: + # keep in sync with appVersion in Chart.yaml + kbatch_version: "0.4.2" + diff --git a/images/kbatch-proxy/Dockerfile b/images/kbatch-proxy/Dockerfile new file mode 100644 index 0000000..8c497b7 --- /dev/null +++ b/images/kbatch-proxy/Dockerfile @@ -0,0 +1,4 @@ +ARG kbatch_version=set-by-chartress +# for now, just retagging the image to match the chart +# but this could be where we translate config from helm +FROM ghcr.io/kbatch-dev/kbatch-proxy:${kbatch_version} diff --git a/kbatch/README.md b/kbatch/README.md index e69de29..ab554d4 100644 --- a/kbatch/README.md +++ b/kbatch/README.md @@ -0,0 +1,52 @@ + +Kbatch-proxy +=========== + +A Helm chart for kbatch-proxy + + +## Configuration + +The following table lists the configurable parameters of the Kbatch-proxy chart and their default values. + +| Parameter | Description | Default | +| ------------------------ | ----------------------- | -------------- | +| `replicaCount` | | `1` | +| `app.jupyterhub_api_url` | | `""` | +| `app.jupyterhub_api_token` | | `""` | +| `app.jupyterhub_service_prefix` | | `""` | +| `app.extra_env` | | `{}` | +| `app.extraFiles` | | `{}` | +| `image.repository` | | `"ghcr.io/kbatch-dev/k8s-kbatch-proxy"` | +| `image.pullPolicy` | | `"IfNotPresent"` | +| `image.tag` | | `"set-by-chartpress"` | +| `imagePullSecrets` | | `[]` | +| `nameOverride` | | `""` | +| `fullnameOverride` | | `""` | +| `serviceAccount.create` | | `true` | +| `serviceAccount.annotations` | | `{}` | +| `serviceAccount.name` | | `""` | +| `podAnnotations` | | `{}` | +| `extraPodLabels` | | `{}` | +| `podSecurityContext` | | `{}` | +| `securityContext` | | `{}` | +| `service.type` | | `"ClusterIP"` | +| `service.port` | | `80` | +| `ingress.enabled` | | `false` | +| `ingress.className` | | `""` | +| `ingress.annotations` | | `{}` | +| `ingress.hosts` | | `[{"host": "chart-example.local", "paths": [{"path": "/", "pathType": "ImplementationSpecific"}]}]` | +| `ingress.tls` | | `[]` | +| `resources` | | `{}` | +| `autoscaling.enabled` | | `false` | +| `autoscaling.minReplicas` | | `1` | +| `autoscaling.maxReplicas` | | `100` | +| `autoscaling.targetCPUUtilizationPercentage` | | `80` | +| `nodeSelector` | | `{}` | +| `tolerations` | | `[]` | +| `affinity` | | `{}` | + + + +--- +_Documentation generated by [Frigate](https://frigate.readthedocs.io)._ diff --git a/kbatch/values.yaml b/kbatch/values.yaml index 25a7404..298e081 100644 --- a/kbatch/values.yaml +++ b/kbatch/values.yaml @@ -8,9 +8,9 @@ app: extraFiles: {} image: - repository: ghcr.io/kbatch-dev/kbatch-proxy + repository: ghcr.io/kbatch-dev/k8s-kbatch-proxy pullPolicy: IfNotPresent - tag: "" + tag: "set-by-chartpress" imagePullSecrets: [] nameOverride: "" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f76e616 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +chartpress