Skip to content

Commit

Permalink
feat: wip CI + vcluster deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
banshee86vr committed Feb 13, 2024
1 parent 8fdcc9d commit cbcc632
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 25 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ permissions:
pages: write
id-token: write

env:
REGISTRY: ghcr.io

jobs:
build:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout your repository using git
uses: actions/checkout@v4
Expand All @@ -27,3 +31,30 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release

build-docker-image:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Res
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get short SHA
id: slug
# run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
run: echo "SHA8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> "$GITHUB_ENV"
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:hello-world-app"
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/heads/main' && true || false }}
tags: |
${{ env.REGISTRY }}/${{ github.repository }}:${{ env.SHA8 }}
${{ env.REGISTRY }}/${{ github.repository }}:latest
33 changes: 32 additions & 1 deletion argo/workflow/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
# Configuration of Argo Workflow

## Installation

```bash
helm repo add argo https://argoproj.github.io/argo-helm
kubectl create namespace argo
kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/v3.5.4/quick-start-minimal.yaml

```

```bash
kubectl create clusterrolebinding argo-admin-server --clusterrole=cluster-admin --serviceaccount=argo:argo-server -n argo
kubectl create clusterrolebinding argo-admin-default --clusterrole=cluster-admin --serviceaccount=argo:default -n argo
```

```bash
kubectl create rolebinding default-admin --clusterrole=admin --serviceaccount=argo:default -n argo
kubectl patch deployment \
argo-server \
--namespace argo \
--type='json' \
-p='[{"op": "replace", "path": "/spec/template/spec/containers/0/args", "value": [
"server",
"--auth-mode=server"
]}]'

```

```bash
kubectl create secret generic github-token -n argo --from-literal=token=.........

export DOCKER_USERNAME=******
export DOCKER_TOKEN=******
kubectl create secret generic docker-config --from-literal="config.json={\"auths\": {\"https://ghcr.io/\": {\"auth\": \"$(echo -n $DOCKER_USERNAME:$DOCKER_TOKEN|base64)\"}}}"

```

But: <https://argoproj.github.io/argo-workflows/workflow-rbac/>
20 changes: 10 additions & 10 deletions argo/workflow/buildkit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,33 @@ spec:
- name: main
dag:
tasks:
- name: clone
template: clone
- name: clone-repo
template: tmpl-clone
arguments:
parameters:
- name: repo
value: "{{workflow.parameters.repo}}"
- name: branch
value: "{{workflow.parameters.branch}}"
- name: build
- name: build-code
templateRef:
name: go
template: go-ci
template: tmpl-go
arguments:
parameters:
- name: path
value: "{{workflow.parameters.path}}"
depends: "clone"
- name: image
template: image
depends: "clone-repo"
- name: build-push-image
template: tmpl-image
arguments:
parameters:
- name: path
value: "{{workflow.parameters.path}}"
- name: image
value: "{{workflow.parameters.image}}"
depends: "build"
- name: clone
depends: "build-code"
- name: tmpl-clone
inputs:
parameters:
- name: repo
Expand Down Expand Up @@ -110,7 +110,7 @@ spec:
- --single-branch
- "https://workflow:$(GH_TOKEN)@github.com/{{inputs.parameters.repo}}"
- .
- name: image
- name: tmpl-image
inputs:
parameters:
- name: path
Expand Down
51 changes: 39 additions & 12 deletions argo/workflow/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,29 @@ spec:
- name: main
dag:
tasks:
- name: clone
- name: clone-repo
template: tmpl-clone
arguments:
parameters:
- name: repo
value: "{{workflow.parameters.repo}}"
- name: branch
value: "{{workflow.parameters.branch}}"
- name: path
value: "{{workflow.parameters.path-chart}}"
- name: vcluster
- name: create-vcluster
template: tmpl-vcluster
arguments:
parameters:
- name: name
value: "{{workflow.parameters.vcluster-name}}"
# - name: Install the helm chart
# template: deploy
# arguments:
# parameters:
# - name: image
# value: "{{workflow.parameters.image}}"
# depends: "clone"
- name: install-helm-chart
template: tmpl-deploy
arguments:
parameters:
- name: path-chart
value: "{{workflow.parameters.path-chart}}"
- name: image
value: "{{workflow.parameters.image}}"
depends: "clone"
- name: tmpl-clone
inputs:
parameters:
Expand All @@ -95,6 +95,7 @@ spec:
valueFrom:
secretKeyRef:
name: github-token # name of an existing k8s secret
namespace: argo
key: token
image: alpine/git:v2.26.2
workingDir: /work
Expand All @@ -114,11 +115,37 @@ spec:
parameters:
- name: name
container:
image: ghcr.io/loft-sh/vcluster-cli:0.18.1
image: ghcr.io/loft-sh/vcluster-cli:0.19
command:
- vcluster
args:
- create
- "{{inputs.parameters.name}}"
- --namespace
- demo-pr-request
- --isolate
- --connect=false
- name: tmpl-deploy
inputs:
parameters:
- name: path-chart
- name: image
container:
image: ghcr.io/loft-sh/vcluster-cli:0.19
workingDir: /work/"{{inputs.parameters.path-chart}}"
command:
- vcluster
args:
- connect
- "{{inputs.parameters.name}}"
- --namespace
- demo-pr-request
- --
- helm
- upgrade
- --install
- "{{inputs.parameters.name}}"
- .
- --namespace
- "{{inputs.parameters.name}}"
- --create-namespace
2 changes: 1 addition & 1 deletion argo/workflow/lang/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
requests:
storage: 64Mi
templates:
- name: go-ci
- name: tmpl-go
inputs:
parameters:
- name: path
Expand Down
2 changes: 1 addition & 1 deletion hello-world-app/hello-world/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
replicaCount: 1

image:
repository: ghcr.io/banshee86vr/ephemeral-test-environment
repository: ghcr.io/banshee86vr/hello-world
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: latest
Expand Down

0 comments on commit cbcc632

Please sign in to comment.