Skip to content
Open
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
18 changes: 18 additions & 0 deletions .github/workflows/publish-components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:
- code-interpreter
- ingress
- egress
- controller
- task-executor
default: 'execd'
image_tag:
description: 'Docker image tag'
Expand All @@ -26,6 +28,8 @@ on:
- 'docker/code-interpreter/**'
- 'docker/ingress/**'
- 'docker/egress/**'
- 'k8s/controller/**'
- 'k8s/task-executor/**'

jobs:
publish:
Expand Down Expand Up @@ -63,6 +67,15 @@ jobs:
COMPONENT=$(echo "$TAG_PATH" | cut -d'/' -f2)
IMAGE_TAG=$(echo "$TAG_PATH" | cut -d'/' -f3)

echo "component=$COMPONENT" >> $GITHUB_OUTPUT
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == refs/tags/k8s/* ]]; then
TAG_PATH="${{ github.ref }}"
TAG_PATH="${TAG_PATH#refs/tags/}"

COMPONENT=$(echo "$TAG_PATH" | cut -d'/' -f2)
IMAGE_TAG=$(echo "$TAG_PATH" | cut -d'/' -f3)

echo "component=$COMPONENT" >> $GITHUB_OUTPUT
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
else
Expand All @@ -88,10 +101,15 @@ jobs:
cd components/ingress
elif [ "$COMPONENT" == "egress" ]; then
cd components/egress
elif [ "$COMPONENT" == "controller" ]; then
cd kubernetes
elif [ "$COMPONENT" == "task-executor" ]; then
cd kubernetes
else
cd sandboxes/$COMPONENT
fi

export TAG=$IMAGE_TAG
export COMPONENT=$COMPONENT
chmod +x build.sh
./build.sh
143 changes: 143 additions & 0 deletions .github/workflows/publish-helm-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Publish Helm Chart

on:
workflow_dispatch:
inputs:
component:
description: 'Component to release'
required: true
type: choice
options:
- opensandbox-controller
default: 'opensandbox-controller'
chart_version:
description: 'Chart version to release'
required: true
default: '0.1.0'
app_version:
description: 'App version'
required: true
default: '0.0.1'
push:
tags:
- 'helm/**'

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Install Helm
uses: azure/setup-helm@v4
with:
version: 'latest'

- name: Parse tag and set variables
id: parse_tag
run: |
if [[ "${{ github.ref }}" == refs/tags/helm/* ]]; then
TAG_PATH="${{ github.ref }}"
TAG_PATH="${TAG_PATH#refs/tags/}"

COMPONENT=$(echo "$TAG_PATH" | cut -d'/' -f2)
VERSION=$(echo "$TAG_PATH" | cut -d'/' -f3)

echo "component=$COMPONENT" >> $GITHUB_OUTPUT
echo "chart_version=$VERSION" >> $GITHUB_OUTPUT
echo "app_version=$VERSION" >> $GITHUB_OUTPUT
else
echo "component=${{ inputs.component }}" >> $GITHUB_OUTPUT
echo "chart_version=${{ inputs.chart_version }}" >> $GITHUB_OUTPUT
echo "app_version=${{ inputs.app_version }}" >> $GITHUB_OUTPUT
fi

- name: Set chart path
id: chart_path
run: |
COMPONENT="${{ steps.parse_tag.outputs.component }}"

if [ "$COMPONENT" == "opensandbox-controller" ]; then
CHART_PATH="kubernetes/charts/opensandbox-controller"
else
echo "Error: Unknown component: $COMPONENT"
exit 1
fi

echo "path=$CHART_PATH" >> $GITHUB_OUTPUT

- name: Update Chart.yaml with versions
run: |
CHART_VERSION="${{ steps.parse_tag.outputs.chart_version }}"
APP_VERSION="${{ steps.parse_tag.outputs.app_version }}"
CHART_PATH="${{ steps.chart_path.outputs.path }}"

sed -i "s/^version:.*/version: $CHART_VERSION/" $CHART_PATH/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: \"$APP_VERSION\"/" $CHART_PATH/Chart.yaml

echo "Updated Chart.yaml:"
cat $CHART_PATH/Chart.yaml

- name: Lint Helm chart
run: |
CHART_PATH="${{ steps.chart_path.outputs.path }}"
helm lint $CHART_PATH

- name: Package Helm chart
run: |
CHART_PATH="${{ steps.chart_path.outputs.path }}"
helm package $CHART_PATH

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: helm/${{ steps.parse_tag.outputs.component }}/${{ steps.parse_tag.outputs.chart_version }}
name: Helm Chart ${{ steps.parse_tag.outputs.component }} v${{ steps.parse_tag.outputs.chart_version }}
body: |
## ${{ steps.parse_tag.outputs.component }} Helm Chart v${{ steps.parse_tag.outputs.chart_version }}

**App Version:** ${{ steps.parse_tag.outputs.app_version }}

### Installation

直接从 GitHub Release 安装:

```bash
helm install opensandbox \
https://github.com/${{ github.repository }}/releases/download/helm/${{ steps.parse_tag.outputs.component }}/${{ steps.parse_tag.outputs.chart_version }}/${{ steps.parse_tag.outputs.component }}-${{ steps.parse_tag.outputs.chart_version }}.tgz \
--namespace opensandbox-system \
--create-namespace
```

或者先下载后安装:

```bash
# 下载
wget https://github.com/${{ github.repository }}/releases/download/helm/${{ steps.parse_tag.outputs.component }}/${{ steps.parse_tag.outputs.chart_version }}/${{ steps.parse_tag.outputs.component }}-${{ steps.parse_tag.outputs.chart_version }}.tgz

# 安装
helm install opensandbox ./${{ steps.parse_tag.outputs.component }}-${{ steps.parse_tag.outputs.chart_version }}.tgz \
--namespace opensandbox-system \
--create-namespace
```

### What's Changed

- Chart version: ${{ steps.parse_tag.outputs.chart_version }}
- App version: ${{ steps.parse_tag.outputs.app_version }}
files: |
${{ steps.parse_tag.outputs.component }}-*.tgz
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86 changes: 84 additions & 2 deletions kubernetes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# opensandbox.io/sandbox-k8s-bundle:$VERSION and opensandbox.io/sandbox-k8s-catalog:$VERSION.
IMAGE_TAG_BASE ?= opensandbox.io/sandbox-k8s
IMAGE_TAG_BASE ?= sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/controller

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
Expand Down Expand Up @@ -412,4 +412,86 @@ catalog-build: opm ## Build a catalog image.
# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)
$(MAKE) docker-push IMG=$(CATALOG_IMG)

##@ Helm

# Helm chart configuration
HELM_CHART_PATH ?= charts/opensandbox-controller
HELM_CHART_VERSION ?= $(VERSION)

.PHONY: helm-lint
helm-lint: ## Lint the Helm chart
@echo "Linting Helm chart..."
helm lint $(HELM_CHART_PATH)

.PHONY: helm-template
helm-template: ## Generate Kubernetes manifests from Helm chart
@echo "Generating manifests from Helm chart..."
helm template opensandbox $(HELM_CHART_PATH) \
--set controller.image.repository=$(IMAGE_TAG_BASE) \
--set controller.image.tag=$(VERSION)

.PHONY: helm-template-debug
helm-template-debug: ## Generate Kubernetes manifests with debug output
@echo "Generating manifests from Helm chart with debug..."
helm template opensandbox $(HELM_CHART_PATH) \
--set controller.image.repository=$(IMAGE_TAG_BASE) \
--set controller.image.tag=$(VERSION) \
--debug

.PHONY: helm-package
helm-package: ## Package the Helm chart
@echo "Packaging Helm chart..."
@mkdir -p dist
helm package $(HELM_CHART_PATH) -d dist/ --version $(HELM_CHART_VERSION) --app-version $(VERSION)

.PHONY: helm-install
helm-install: ## Install the Helm chart
@echo "Installing Helm chart..."
helm install opensandbox $(HELM_CHART_PATH) \
--set controller.image.repository=$(IMAGE_TAG_BASE) \
--set controller.image.tag=$(VERSION) \
--namespace opensandbox-system \
--create-namespace

.PHONY: helm-upgrade
helm-upgrade: ## Upgrade the Helm chart
@echo "Upgrading Helm chart..."
helm upgrade opensandbox $(HELM_CHART_PATH) \
--set controller.image.repository=$(IMAGE_TAG_BASE) \
--set controller.image.tag=$(VERSION) \
--namespace opensandbox-system

.PHONY: helm-uninstall
helm-uninstall: ## Uninstall the Helm chart
@echo "Uninstalling Helm chart..."
helm uninstall opensandbox --namespace opensandbox-system

.PHONY: helm-test
helm-test: ## Run Helm chart tests
@echo "Running Helm chart tests..."
helm test opensandbox --namespace opensandbox-system

.PHONY: helm-docs
helm-docs: ## Generate Helm chart documentation (requires helm-docs)
@if command -v helm-docs >/dev/null 2>&1; then \
echo "Generating Helm chart documentation..."; \
helm-docs $(HELM_CHART_PATH); \
else \
echo "helm-docs is not installed. Install it with: go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest"; \
exit 1; \
fi

.PHONY: helm-dry-run
helm-dry-run: ## Perform a dry-run install of the Helm chart
@echo "Performing dry-run installation..."
helm install opensandbox $(HELM_CHART_PATH) \
--set controller.image.repository=$(IMAGE_TAG_BASE) \
--set controller.image.tag=$(VERSION) \
--namespace opensandbox-system \
--create-namespace \
--dry-run --debug

.PHONY: helm-all
helm-all: helm-lint helm-package ## Run all Helm-related tasks (lint and package)
Loading
Loading