Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: replicated-release-unstable

on:
workflow_dispatch:
push:
branches:
- main

jobs:
push-to-replicated:
runs-on: ubuntu-22.04
outputs:
channel-slug: ${{ steps.create-release.outputs.channel-slug }}
release-sequence: ${{ steps.create-release.outputs.release-sequence }}
app-version: ${{ steps.set-release-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get latest tag
id: get-latest-tag
run: |
# Get the latest tag, defaulting to 0.1.0 if none exists
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.1.0")
echo "LATEST_TAG=${latest_tag}" >> $GITHUB_ENV

- name: Set release version
id: set-release-version
run: |
VERSION=${{ env.LATEST_TAG }}-$(git rev-parse --short HEAD)
echo "VERSION=${VERSION}" >> $GITHUB_ENV

- name: Package Helm chart
id: package-helm-chart
run: |
helm package ./app --debug -u -d ./replicated \
--version ${{ env.VERSION }} \
--app-version ${{ env.VERSION }}

- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq &&\
chmod +x /usr/local/bin/yq

- name: Update HelmChart kind
run: |
yq -i '.spec.chart.chartVersion = "${{ env.VERSION }}"' replicated/kots-chart.yaml

- name: Create Replicated release
id: create-release
uses: replicatedhq/compatibility-actions/create-release@v1
with:
app-slug: ${{ secrets.REPLICATED_APP }}
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
yaml-dir: ./replicated
promote-channel: unstable
version: ${{ env.VERSION }}
173 changes: 173 additions & 0 deletions applications/fake-services/.github/workflows/replicated-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: replicated-release

on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Version tag (e.g. v1.0.0)'
required: true
type: string

jobs:
push-to-replicated:
runs-on: ubuntu-22.04
outputs:
channel-slug: ${{ steps.create-release.outputs.channel-slug }}
release-sequence: ${{ steps.create-release.outputs.release-sequence }}
app-version: ${{ steps.set-release-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v3

- name: Set release version
id: set-release-version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi

- name: Package Helm chart
id: package-helm-chart
run: |
helm package ./app --debug -u -d ./replicated \
--version ${{ env.VERSION }} \
--app-version ${{ env.VERSION }}

- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq &&\
chmod +x /usr/local/bin/yq

- name: Update HelmChart kind
run: |
yq -i '.spec.chart.chartVersion = "${{ env.VERSION }}"' replicated/kots-chart.yaml

- name: Define Channel name
run: echo "CHANNEL_NAME=${{ env.VERSION }}-${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV

- name: Create Replicated release
id: create-release
uses: replicatedhq/compatibility-actions/create-release@v1
with:
app-slug: ${{ secrets.REPLICATED_APP }}
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
yaml-dir: ./replicated
promote-channel: ${{ env.CHANNEL_NAME }}
version: ${{ env.VERSION }}

compatibility-matrix:
needs: push-to-replicated
strategy:
fail-fast: false
matrix:
cluster: [{distribution: kind, version: v1.31.2}]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set release version
id: set-release-version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- name: Create Customer
id: create-customer
uses: replicatedhq/replicated-actions/create-customer@v1
with:
app-slug: ${{ secrets.REPLICATED_APP }}
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
customer-name: ${{ env.VERSION }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
channel-slug: ${{ needs.push-to-replicated.outputs.channel-slug }}
customer-email: ${{ env.VERSION }}@example.com
expires-in: 14
license-type: dev

- name: Create Cluster
id: create-cluster
uses: replicatedhq/replicated-actions/create-cluster@v1
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
kubernetes-distribution: ${{ matrix.cluster.distribution }}
kubernetes-version: ${{ matrix.cluster.version }}
cluster-name: ${{ env.VERSION }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
timeout-minutes: 5
ttl: 10m

- name: Deploy the app
uses: replicatedhq/replicated-actions/kots-install@v1
with:
kubeconfig: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
app-slug: ${{ secrets.REPLICATED_APP }}/${{ needs.push-to-replicated.outputs.channel-slug }}
license-file: ${{ steps.create-customer.outputs.license-file }}
app-version-label: ${{ env.VERSION }}
config-values: ./replicated/kots-sample-config-values.yaml

- name: Run a test
# mask the kubeconfig so it doesn't show up in the logs
run: |
echo "Running connectivity test..."
echo "${{ steps.create-cluster.outputs.cluster-kubeconfig }}" > kubeconfig.yaml
sleep 60
kubectl wait --for=condition=ready pods -l app.kubernetes.io/name=fake-service-frontend --timeout=60s --kubeconfig='./kubeconfig.yaml'
kubectl port-forward svc/frontend-service --pod-running-timeout=2m --kubeconfig='./kubeconfig.yaml' 8080:80 &
sleep 60
curl -f http://localhost:8080
echo "Test complete"

- name: Remove Cluster
id: remove-cluster
uses: replicatedhq/replicated-actions/remove-cluster@v1
continue-on-error: true # It could be that the cluster is already removed
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}

- name: Archive Customer
id: archive-customer
if: always()
uses: replicatedhq/replicated-actions/archive-customer@v1
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
customer-id: ${{ steps.create-customer.outputs.customer-id }}

promote-to-stable:
needs:
- compatibility-matrix
- push-to-replicated
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Promote to Stable channel
uses: replicatedhq/replicated-actions/promote-release@v1
with:
app-slug: ${{ secrets.REPLICATED_APP }}
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
channel-to: stable
release-sequence: ${{ needs.push-to-replicated.outputs.release-sequence }}
release-version: ${{ needs.push-to-replicated.outputs.app-version }}

cleanup-channel:
needs:
- compatibility-matrix
- push-to-replicated
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Archive Replicated Channel
uses: replicatedhq/replicated-actions/archive-channel@v1
with:
app-slug: ${{ secrets.REPLICATED_APP }}
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
channel-slug: ${{ needs.push-to-replicated.outputs.channel-slug }}
50 changes: 50 additions & 0 deletions applications/fake-services/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
REPLICATED_APP=gerard-helm-fake-service
REPLICATED_DIR=$(shell pwd)/replicated
CHART_DIR=$(shell pwd)/app
CHART_VERSION=0.8.0
CHANNELS=Stable Unstable Beta

clean-charts:
rm -rf $(REPLICATED_DIR)/*.tgz

bump-chart-version:
yq -i '.version = "$(CHART_VERSION)"' $(CHART_DIR)/Chart.yaml
yq -i '.spec.chart.chartVersion = "$(CHART_VERSION)"' $(REPLICATED_DIR)/kots-chart.yaml

helm-dep-up:
helm dep up $(CHART_DIR)

helm-dep-list:
helm dep list $(CHART_DIR)

helm-install-dry-run:
helm install $(REPLICATED_APP) --dry-run --debug $(CHART_DIR)

helm-template:
helm template $(REPLICATED_APP) $(CHART_DIR)

helm-install:
helm install $(REPLICATED_APP) --debug --wait $(CHART_DIR)

helm-uninstall:
helm uninstall $(REPLICATED_APP)

prepare-release: clean-charts helm-dep-up bump-chart-version
helm package --destination $(REPLICATED_DIR) --debug ./app
echo "Packaged Helm chart to $(REPLICATED_DIR)"

replicated-lint:
replicated release lint --yaml-dir $(REPLICATED_DIR)

replicated-release: prepare-release replicated-lint
replicated release create --yaml-dir $(REPLICATED_DIR)

replicated-promote:
$(eval SEQUENCE := $(shell replicated release ls --output json | jq '.[0].sequence'))
@for channel in $(CHANNELS); do \
echo "Promoting release sequence $(SEQUENCE) to $$channel channel..."; \
replicated release promote $(SEQUENCE) $$channel; \
done

sync-platform-examples:
rsync -av --exclude '.git' --exclude '.gitignore' . /Users/gerard/dev/platform-examples/applications/fake-services/
8 changes: 8 additions & 0 deletions applications/fake-services/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# helm-fake-service

This repository contains an example Helm chart that distributed with Replicated Embedded Cluster.

## Components

- A Helm chart using [fake-service](https://github.com/nicholasjackson/fake-service)
- Replicated [manifests](https://docs.replicated.com/reference/custom-resource-about) to deploy the chart with Replicated
23 changes: 23 additions & 0 deletions applications/fake-services/app/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions applications/fake-services/app/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: ingress-nginx
repository: https://kubernetes.github.io/ingress-nginx
version: 4.11.3
- name: replicated
repository: oci://registry.replicated.com/library
version: 1.0.0-beta.31
digest: sha256:c349fc2fe99276ed430877ef2a0cf0e05150cd27f6e4eae2d7bfe47733f64846
generated: "2024-11-27T11:01:55.491515+11:00"
29 changes: 29 additions & 0 deletions applications/fake-services/app/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v2
name: fake-service
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.8.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
dependencies:
- name: ingress-nginx
version: 4.11.3
repository: https://kubernetes.github.io/ingress-nginx
condition: ingress-nginx.enabled
- name: replicated
repository: oci://registry.replicated.com/library
version: 1.0.0-beta.31
10 changes: 10 additions & 0 deletions applications/fake-services/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# fake-service

This Helm chart will install:

- A fake-service frontend
- A fake-service backend

The `frontend` service will be exposed with an `Ingress`.

We will not install `ingress-nginx` as part of the Helm chart but install `ingress-nginx` controller separately. E.g. with `k0s` Helm chart (extension)[https://docs.k0sproject.io/head/helm-charts/?h=helm+extension#example]
Empty file.
Loading