From bcac73a9dba2da10fcd882abb53a525c595865d8 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Tue, 8 Jul 2025 16:37:28 +0200 Subject: [PATCH] Added gitea releases. --- .gitea/workflows/release.yaml | 59 +++++++++++++++++++++++++ .gitlab-ci.yml | 50 --------------------- deploy/Dockerfile => Dockerfile | 0 deploy/helm/.helmignore | 23 ---------- deploy/helm/Chart.yaml | 24 ----------- deploy/helm/files/dockerauth.json | 8 ---- deploy/helm/templates/NOTES.txt | 22 ---------- deploy/helm/templates/_helpers.tpl | 51 ---------------------- deploy/helm/templates/deployment.yaml | 62 --------------------------- deploy/helm/templates/hpa.yaml | 28 ------------ deploy/helm/templates/ingress.yaml | 60 -------------------------- deploy/helm/templates/pull_secret.yml | 9 ---- deploy/helm/templates/service.yaml | 15 ------- deploy/helm/values.yaml | 41 ------------------ values.yaml | 27 ++++++++++++ 15 files changed, 86 insertions(+), 393 deletions(-) create mode 100644 .gitea/workflows/release.yaml delete mode 100644 .gitlab-ci.yml rename deploy/Dockerfile => Dockerfile (100%) delete mode 100644 deploy/helm/.helmignore delete mode 100644 deploy/helm/Chart.yaml delete mode 100644 deploy/helm/files/dockerauth.json delete mode 100644 deploy/helm/templates/NOTES.txt delete mode 100644 deploy/helm/templates/_helpers.tpl delete mode 100644 deploy/helm/templates/deployment.yaml delete mode 100644 deploy/helm/templates/hpa.yaml delete mode 100644 deploy/helm/templates/ingress.yaml delete mode 100644 deploy/helm/templates/pull_secret.yml delete mode 100644 deploy/helm/templates/service.yaml delete mode 100644 deploy/helm/values.yaml create mode 100644 values.yaml diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..0c30f1a --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,59 @@ +on: + push: + tags: ["*"] + +env: + DEPLOY_RELEASE_NAME: "blog" + DEPLOY_IMAGE_URL: "gitea.le-memese.com/s3rius/blog" + DEPLOY_NAMESPACE: "s3rius" + +jobs: + docker_build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + registry: gitea.le-memese.com + username: ${{ gitea.actor }} + password: ${{ secrets.PACKAGE_PAT }} + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + file: ./Dockerfile + platforms: linux/amd64 + tags: | + ${{ env.DEPLOY_IMAGE_URL }}:latest + ${{ env.DEPLOY_IMAGE_URL }}:${{ gitea.ref_name }} + deploy_helm: + runs-on: ubuntu-latest + needs: docker_build + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup helm + uses: azure/setup-helm@v4.3.0 + - name: Deploy + run: | + echo "${{secrets.KUBE_CONFIG}}" > /tmp/kubeconfig + helm upgrade \ + "${{ env.DEPLOY_RELEASE_NAME }}" \ + 'oci://gitea.le-memese.com/common/charts/py-app' \ + --install \ + --wait \ + --atomic \ + --kubeconfig "/tmp/kubeconfig" \ + --namespace="${{ env.DEPLOY_NAMESPACE }}" \ + --create-namespace \ + --values=./values.yaml \ + --version "0.1.0" \ + --set-literal "image.tag=${{ gitea.ref_name }}" \ + --set-literal "image.repository=${{ env.DEPLOY_IMAGE_URL }}" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 1fdfcc0..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,50 +0,0 @@ -variables: - APP_VERSION: $CI_COMMIT_REF_SLUG - DOCKER_AUTH_CONFIG: '{"auths":{"$DOCKER_REGISTRY":{"username":"$DOCKER_USER","password":"$DOCKER_PASSWORD"}}}' - -build: - stage: build - image: - name: gcr.io/kaniko-project/executor:v1.6.0-debug - entrypoint: [""] - tags: - - kube - only: - - master - script: - - mkdir -p /kaniko/.docker - - echo "$DOCKER_AUTH_CONFIG" > /kaniko/.docker/config.json - - /kaniko/executor - --context . - --dockerfile deploy/Dockerfile - --destination "$DOCKER_REGISTRY/s3rius/blog:latest" - --cache=true - --force - -deploy: - stage: deploy - image: - name: alpine/helm:3.7.1 - entrypoint: ["/bin/sh", "-c"] - tags: - - kube - only: - - master - environment: - name: blog-production - kubernetes: - namespace: "$NAMESPACE" - action: start - url: "https://s3rius.blog/" - script: - - helm - upgrade - "s3rius-blog" - ./deploy/helm - --install - --wait - --create-namespace - --atomic - --timeout 3m - --namespace "$NAMESPACE" - -f "$HELM_CONFIG" diff --git a/deploy/Dockerfile b/Dockerfile similarity index 100% rename from deploy/Dockerfile rename to Dockerfile diff --git a/deploy/helm/.helmignore b/deploy/helm/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/deploy/helm/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ diff --git a/deploy/helm/Chart.yaml b/deploy/helm/Chart.yaml deleted file mode 100644 index 9ea0f6a..0000000 --- a/deploy/helm/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: s3rius-blog -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.1.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" diff --git a/deploy/helm/files/dockerauth.json b/deploy/helm/files/dockerauth.json deleted file mode 100644 index cd2ce74..0000000 --- a/deploy/helm/files/dockerauth.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "auths": { - {{ .Values.image.pullSecret.registry | quote}}: { - "username": {{.Values.image.pullSecret.username | quote }}, - "password": {{.Values.image.pullSecret.password | quote }} - } - } -} diff --git a/deploy/helm/templates/NOTES.txt b/deploy/helm/templates/NOTES.txt deleted file mode 100644 index f3cf193..0000000 --- a/deploy/helm/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "s3rius-blog.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "s3rius-blog.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "s3rius-blog.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "s3rius-blog.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/deploy/helm/templates/_helpers.tpl b/deploy/helm/templates/_helpers.tpl deleted file mode 100644 index 14d7ee8..0000000 --- a/deploy/helm/templates/_helpers.tpl +++ /dev/null @@ -1,51 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "s3rius-blog.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "s3rius-blog.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "s3rius-blog.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "s3rius-blog.labels" -}} -helm.sh/chart: {{ include "s3rius-blog.chart" . }} -{{ include "s3rius-blog.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "s3rius-blog.selectorLabels" -}} -app.kubernetes.io/name: {{ include "s3rius-blog.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} diff --git a/deploy/helm/templates/deployment.yaml b/deploy/helm/templates/deployment.yaml deleted file mode 100644 index 64a686a..0000000 --- a/deploy/helm/templates/deployment.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "s3rius-blog.fullname" . }} - labels: - {{- include "s3rius-blog.labels" . | nindent 4 }} - annotations: - updated_at: {{now | quote}} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "s3rius-blog.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "s3rius-blog.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.image.pullSecret }} - imagePullSecrets: - - name: {{ .secretName | quote }} - {{- end }} - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - initialDelaySeconds: 40 - periodSeconds: 20 - readinessProbe: - httpGet: - path: / - port: http - initialDelaySeconds: 30 - periodSeconds: 15 - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/deploy/helm/templates/hpa.yaml b/deploy/helm/templates/hpa.yaml deleted file mode 100644 index d1d6062..0000000 --- a/deploy/helm/templates/hpa.yaml +++ /dev/null @@ -1,28 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "s3rius-blog.fullname" . }} - labels: - {{- include "s3rius-blog.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "s3rius-blog.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/deploy/helm/templates/ingress.yaml b/deploy/helm/templates/ingress.yaml deleted file mode 100644 index f960c69..0000000 --- a/deploy/helm/templates/ingress.yaml +++ /dev/null @@ -1,60 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "s3rius-blog.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} - {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} - {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} - {{- end }} -{{- end }} -{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "s3rius-blog.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} - ingressClassName: {{ .Values.ingress.className }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - {{- end }} - {{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - pathType: {{ .pathType }} - {{- end }} - backend: - {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} - service: - name: {{ $fullName }} - port: - number: {{ $svcPort }} - {{- else }} - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} diff --git a/deploy/helm/templates/pull_secret.yml b/deploy/helm/templates/pull_secret.yml deleted file mode 100644 index 1f3a321..0000000 --- a/deploy/helm/templates/pull_secret.yml +++ /dev/null @@ -1,9 +0,0 @@ -{{- if .Values.image.pullSecret }} -apiVersion: v1 -kind: Secret -metadata: - name: {{ .Values.image.pullSecret.secretName }} -data: - .dockerconfigjson: {{tpl (.Files.Get "files/dockerauth.json") . | b64enc | quote}} -type: kubernetes.io/dockerconfigjson -{{- end }} diff --git a/deploy/helm/templates/service.yaml b/deploy/helm/templates/service.yaml deleted file mode 100644 index b604321..0000000 --- a/deploy/helm/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "s3rius-blog.fullname" . }} - labels: - {{- include "s3rius-blog.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "s3rius-blog.selectorLabels" . | nindent 4 }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml deleted file mode 100644 index 9b1c0b6..0000000 --- a/deploy/helm/values.yaml +++ /dev/null @@ -1,41 +0,0 @@ -replicaCount: 1 - -image: - repository: $DOCKER_REGISTRY/s3rius/blog - pullPolicy: Always - tag: "latest" - pullSecret: {} - -podAnnotations: {} - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: true - className: "" - annotations: {} - hosts: - - host: "s3rius.blog" - paths: - - path: / - pathType: Prefix - tls: - - hosts: - - "s3rius.blog" - -resources: {} - # cpu: 100m - # memory: 100Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} -tolerations: [] -affinity: {} diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..c26adad --- /dev/null +++ b/values.yaml @@ -0,0 +1,27 @@ +nameOverride: "blog" + +image: + tag: "latest" + +service: + port: 80 + +resources: + limits: + cpu: 100m + memory: 120Mi + +ingress: + enabled: true + annotations: + cert-manager.io/cluster-issuer: cert-issuer + external-dns.alpha.kubernetes.io/hostname: s3rius.blog + tls: + - hosts: + - s3rius.blog + secretName: blog-tls + hosts: + - host: s3rius.blog + paths: + - path: / + pathType: Prefix