Skip to content

Commit

Permalink
Add github actions to create downloadable manifest on release
Browse files Browse the repository at this point in the history
Also reorganizes the `manifests` directory to have a different overlay for releases.
  • Loading branch information
sibucan committed Dec 11, 2024
1 parent 17a1b4f commit db6aac1
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-container-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
fail-fast: false
matrix:
platform:
- 'linux/amd64'
- 'linux/arm64'
- 'linux/amd64'
- 'linux/arm64'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/generate-manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release assets

on:
release:
types:
- published

permissions:
contents: read

jobs:
build:
name: build
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true

- name: Build manifests
run: hack/release-manifests.sh ${{ github.event.release.tag_name }}

- name: Release manifests
uses: softprops/action-gh-release@v2
with:
files: |
_output/install.yaml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.kubeconfig
bin/*
cover.out
_output
2 changes: 1 addition & 1 deletion hack/install-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cluster_name="${1:-kind}"
kind get kubeconfig --name "${cluster_name}" > "${kubeconfig_file}"

# Deploy capargo
kubectl --kubeconfig "${kubeconfig_file}" apply -k manifests/kustomize
kubectl --kubeconfig "${kubeconfig_file}" apply -k manifests/overlays/local
kubectl --kubeconfig "${kubeconfig_file}" rollout --namespace capargo status deployment capargo

# Install vcluster binary
Expand Down
19 changes: 19 additions & 0 deletions hack/release-manifests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eou pipefail

OUTPUT_DIR="${OUTPUT_DIR:-_output}"
IMAGE_VERSION=${1}

mkdir -p "${OUTPUT_DIR}"


SED="sed"
# Requires gsed to be installed via brew if on MacOS
if [[ $(uname -s | tr '[:upper:]' '[:lower:]') == "darwin" ]]; then
SED="gsed"
fi

# Create install manifest
echo "# This is an auto-generated file. DO NOT EDIT." > "${OUTPUT_DIR}"/install.yaml
kubectl kustomize manifests/overlays/default >> "${OUTPUT_DIR}"/install.yaml
"${SED}" -i -e "s|image: superorbital/capargo:latest|image: superorbital/capargo:${IMAGE_VERSION}|g" "${OUTPUT_DIR}"/install.yaml
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions manifests/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: capargo
spec:
replicas: 1
selector: {}
template:
spec:
containers:
- name: capargo
resources:
limits:
cpu: 500m
memory: 1G
serviceAccount: capargo
securityContext:
runAsUser: 1001
13 changes: 13 additions & 0 deletions manifests/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
labels:
- includeSelectors: true
pairs:
app.kubernetes.io/name: capargo
namespace: capargo
resources:
- namespace.yaml
- deployment.yaml
- clusterrole.yaml
- clusterrolebinding.yaml
- serviceaccount.yaml
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions manifests/kustomize/kustomization.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions manifests/overlays/default/deployment-default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: capargo
spec:
selector: {}
template:
spec:
containers:
- name: capargo
args:
- --argo-namespace=argocd
image: superorbital/capargo:latest
resources:
limits:
cpu: 500m
memory: 1G
6 changes: 6 additions & 0 deletions manifests/overlays/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
patches:
- path: deployment-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kind: Deployment
metadata:
name: capargo
spec:
replicas: 1
selector: {}
template:
spec:
Expand All @@ -17,8 +16,5 @@ spec:
imagePullPolicy: Always
resources:
limits:
cpu: 500m
memory: 1G
serviceAccount: capargo
securityContext:
runAsUser: 1001
cpu: 250m
memory: 500M
6 changes: 6 additions & 0 deletions manifests/overlays/local/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
patches:
- path: deployment-local.yaml

0 comments on commit db6aac1

Please sign in to comment.