From 7385346105397ddf6c8ec4405cfdc3e17cadfece Mon Sep 17 00:00:00 2001 From: gitea_admin_user Date: Wed, 9 Apr 2025 16:46:13 +0000 Subject: [PATCH] Add initial files --- .gitea/workflows/ci_workflows.yml | 60 +++++++++++++++++++++++++++++++ Chart.yaml | 6 ++++ templates/configmap.yaml | 11 ++++++ templates/deployment.yaml | 47 ++++++++++++++++++++++++ templates/pvc.yaml | 17 +++++++++ templates/registrysecret.yaml | 11 ++++++ templates/secret.yaml | 12 +++++++ templates/service.yaml | 17 +++++++++ values.yaml | 36 +++++++++++++++++++ 9 files changed, 217 insertions(+) create mode 100644 .gitea/workflows/ci_workflows.yml create mode 100644 Chart.yaml create mode 100644 templates/configmap.yaml create mode 100644 templates/deployment.yaml create mode 100644 templates/pvc.yaml create mode 100644 templates/registrysecret.yaml create mode 100644 templates/secret.yaml create mode 100644 templates/service.yaml create mode 100644 values.yaml diff --git a/.gitea/workflows/ci_workflows.yml b/.gitea/workflows/ci_workflows.yml new file mode 100644 index 0000000..9cc7c3d --- /dev/null +++ b/.gitea/workflows/ci_workflows.yml @@ -0,0 +1,60 @@ +name: Helm Chart CI +on: + push: + branches: + - "*" + branches-ignore: + - main +jobs: + package-and-register: + name: Package and Register Helm Chart + runs-on: ubuntu-latest + steps: + # Step 1: Checkout Repository + - name: Checkout Repository + uses: actions/checkout@v3 + + # Step 2: Check Helm Installation + - name: Check Helm Installation + id: helm_installed + run: | + if command -v helm >/dev/null 2>&1; then + echo "helm_installed=true" >> $GITHUB_OUTPUT + else + echo "helm_installed=false" >> $GITHUB_OUTPUT + fi + + # Step 3: Install Helm + - name: Install Helm + if: steps.helm_installed.outputs.helm_installed == 'false' + run: | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + + + # Step 4: Validate Helm Chart + - name: Lint Helm Chart + run: | + helm lint ./ # Validate chart structure and syntax + + # Step 5: Package Helm Chart with Updated Version + - name: Package Helm Chart + env: + COMMIT_SHA: ${{ github.sha }} + run: | + # Package the Helm chart + helm package ./ --destination ./packages + + # Step 6: Push Helm Chart to Gitea + - name: Push Helm Chart to Gitea + env: + CI_USER: ${{ secrets.CI_USER }} + CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} + run: | + # Login to the registry + echo $CI_USER_TOKEN | helm registry login centurion-version-control.default.svc.cluster.local:3000 \ + --username $CI_USER --password-stdin --insecure + + # Push Helm chart to Gitea + helm push ./packages/*.tgz oci://centurion-version-control.default.svc.cluster.local:3000/centurion/helm --plain-http diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..8f95eeb --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: block-worker +description: A Helm chart for deploying a flow +type: application +version: 0.1.4 +appVersion: 1.0.0 diff --git a/templates/configmap.yaml b/templates/configmap.yaml new file mode 100644 index 0000000..3a11652 --- /dev/null +++ b/templates/configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }}-config + labels: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + namespace: {{ .Values.namespace }} +data: + {{- range .Values.environment.variables }} + {{ .name }}: {{ .value }} + {{- end }} diff --git a/templates/deployment.yaml b/templates/deployment.yaml new file mode 100644 index 0000000..f662117 --- /dev/null +++ b/templates/deployment.yaml @@ -0,0 +1,47 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + template: + metadata: + labels: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + spec: + containers: + - name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + image: "{{ .Values.imageRegistry.server }}/centurion/{{ .Values.name }}:{{ .Values.version }}" + insecure: true + imagePullPolicy: Always + envFrom: + - configMapRef: + name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }}-config + - secretRef: + name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }}-secret + imagePullSecrets: + - name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }}-registry-secret + resources: + limits: + cpu: {{ .Values.resources.limits.cpu | quote }} + memory: {{ .Values.resources.limits.memory | quote }} + requests: + cpu: {{ .Values.resources.requests.cpu | quote }} + memory: {{ .Values.resources.requests.memory | quote }} + {{- if .Values.persistence.enabled }} + volumeMounts: + - mountPath: /mnt/temporal-worker-data + name: worker-storage + {{- end }} + volumes: + {{- if .Values.persistence.enabled }} + - name: worker-storage + persistentVolumeClaim: + claimName: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.version }}-pvc + {{- end }} diff --git a/templates/pvc.yaml b/templates/pvc.yaml new file mode 100644 index 0000000..ddbd7d8 --- /dev/null +++ b/templates/pvc.yaml @@ -0,0 +1,17 @@ +{{- if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }}-pvc + labels: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + namespace: {{ .Values.namespace }} +spec: + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} diff --git a/templates/registrysecret.yaml b/templates/registrysecret.yaml new file mode 100644 index 0000000..b78a9be --- /dev/null +++ b/templates/registrysecret.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }}-registry-secret + labels: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + namespace: {{ .Values.namespace }} +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: > + {{ printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"dummy@example.com\"}}}" .Values.imageRegistry.server .Values.imageRegistry.username .Values.imageRegistry.password | b64enc }} diff --git a/templates/secret.yaml b/templates/secret.yaml new file mode 100644 index 0000000..0cd1549 --- /dev/null +++ b/templates/secret.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }}-secret + labels: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + namespace: {{ .Values.namespace }} +type: Opaque +data: + {{- range .Values.environment.secrets }} + {{ .name }}: {{ .value | b64enc }} + {{- end }} diff --git a/templates/service.yaml b/templates/service.yaml new file mode 100644 index 0000000..7c40317 --- /dev/null +++ b/templates/service.yaml @@ -0,0 +1,17 @@ +{{- if .Values.service.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }}-service + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} +spec: + selector: + app: {{ .Values.repoName }}-{{ .Values.branchName }}-{{ .Values.shortVersion }} + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: 8080 + type: {{ .Values.service.type }} +{{- end }} diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..04b1060 --- /dev/null +++ b/values.yaml @@ -0,0 +1,36 @@ +namespace: default +name: "name" +repoName: "default-repo-name" +branchName: "default-branch" +version: "0.0.0" +shortVersion: "0.0.0" +replicaCount: 1 +FLOWX_ENGINE_ADDRESS: "centurion-workflow-frontend.default.svc.cluster.local:7233" +imageRegistry: + server: "centurion-version-control.default.svc.cluster.local:3000" + username: "your-username" + password: "your-token" # Corrected missing closing quote here + +environment: + secrets: + - name: "default-secret" + value: "default-value" + variables: + - name: "default-variable" + value: "default-value" +resources: + limits: + cpu: "100m" + memory: "128Mi" + requests: + cpu: "100m" + memory: "128Mi" +persistence: + enabled: false + accessModes: + - ReadWriteOnce + size: "1Gi" +service: + enabled: false + port: 80 + type: ClusterIP