Merge pull request 'develop' (#1) from develop into main

Reviewed-on: https://gitea.apps.mngoma.lab/mngomalab/sampleapi/pulls/1
This commit is contained in:
khwezi
2025-10-12 11:29:01 +00:00
3 changed files with 116 additions and 25 deletions

View File

@@ -3,7 +3,6 @@ kind: pipeline
type: kubernetes type: kubernetes
name: build name: build
# disable built-in clone step
clone: clone:
disable: true disable: true
@@ -12,35 +11,35 @@ steps:
- name: git clone - name: git clone
image: drone/git image: drone/git
commands: commands:
- git clone http://gitea.main.k3s.lab.mngoma.africa/mngomalab/sampleapi.git . - git clone https://gitea.apps.mngoma.lab/mngomalab/sampleapi.git .
- git checkout $DRONE_COMMIT - git checkout $DRONE_COMMIT
# dotnet restore # dotnet restore
- name: dotnet restore - name: dotnet restore
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
- dotnet restore - dotnet restore
# dotnet build # dotnet build
- name: dotnet build - name: dotnet build
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
- dotnet build --configuration Release - dotnet build --configuration Release
- ls ./SampleApi/bin/Release/net8.0/ - ls ./SampleApi/bin/Release/net8.0/
# dotnet test # dotnet test
- name: dotnet test - name: dotnet test
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
- dotnet test --configuration Release - dotnet test --configuration Release
--- ---
kind: pipeline kind: pipeline
type: kubernetes type: kubernetes
name: package name: package
depends_on: depends_on:
- build - build
# disable built-in clone step
clone: clone:
disable: true disable: true
@@ -49,36 +48,36 @@ steps:
- name: git clone - name: git clone
image: drone/git image: drone/git
commands: commands:
- git clone http://gitea.main.k3s.lab.mngoma.africa/mngomalab/sampleapi.git . - git clone https://gitea.apps.mngoma.lab/mngomalab/sampleapi.git .
- git checkout $DRONE_COMMIT - git checkout $DRONE_COMMIT
# dotnet publish # dotnet publish
- name: dotnet publish - name: dotnet publish
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
- dotnet publish --configuration Release - dotnet publish --configuration Release
- ls ./SampleApi/bin/Release/net8.0/publish/ - ls ./SampleApi/bin/Release/net8.0/publish/
# build and push docker image # build and push docker image to in-cluster registry
- name: docker build and push - name: docker build and push
image: plugins/docker image: plugins/docker
settings: settings:
repo: khwezi/mngomalab repo: registry.registry.svc.cluster.local:5000/experiments/sampleapi
auto_tag: true auto_tag: true
username: username:
from_secret: docker_username from_secret: registry-username
password: password:
from_secret: docker_password from_secret: registry-password
dockerfile: Dockerfile dockerfile: Dockerfile
context: ./SampleApi/bin/Release/net8.0/publish/ context: ./SampleApi/bin/Release/net8.0/publish/
--- ---
kind: pipeline kind: pipeline
type: kubernetes type: kubernetes
name: deploy name: deploy
depends_on: depends_on:
- package - package
# disable built-in clone step
clone: clone:
disable: true disable: true
@@ -87,15 +86,15 @@ steps:
- name: git clone - name: git clone
image: drone/git image: drone/git
commands: commands:
- git clone http://gitea.main.k3s.lab.mngoma.africa/mngomalab/sampleapi.git . - git clone https://gitea.apps.mngoma.lab/mngomalab/sampleapi.git .
- git checkout $DRONE_COMMIT - git checkout $DRONE_COMMIT
- name: deploy - name: deploy
image: danielgormly/drone-plugin-kube:0.0.1 image: danielgormly/drone-plugin-kube:0.0.1
settings: settings:
template: ./templates/deployment.yaml template: ./manifests/deploy-app.yml
ca: ca:
from_secret: kube_ca_cert from_secret: kube_ca_cert
server: https://192.168.1.161:6443 server: https://lead:6443
token: token:
from_secret: k3s_token from_secret: k3s_token

92
manifests/deploy-app.yml Normal file
View File

@@ -0,0 +1,92 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: experiments
labels:
name: experiments
---
apiVersion: v1
kind: ConfigMap
metadata:
name: sampleapi-config
namespace: experiments
data:
appname: "SampleApi"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sampleapi
namespace: experiments
labels:
app: sampleapi
spec:
replicas: 1
selector:
matchLabels:
app: sampleapi
template:
metadata:
labels:
app: sampleapi
spec:
containers:
- name: sampleapi
image: registry.registry.svc.cluster.local:5000/experiments/sampleapi:latest
imagePullPolicy: Always
ports:
- name: http
containerPort: 8080
- name: https
containerPort: 8081
---
apiVersion: v1
kind: Service
metadata:
name: sampleapi
namespace: experiments
spec:
type: ClusterIP
selector:
app: sampleapi
ports:
- name: http
port: 80
targetPort: 8080
- name: https
port: 443
targetPort: 8081
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: sampleapi-http
namespace: experiments
spec:
entryPoints:
- web
routes:
- match: Host(`sampleapi.apps.mngoma.lab`)
kind: Rule
services:
- name: sampleapi
port: 80
scheme: http
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: sampleapi-https
namespace: experiments
spec:
entryPoints:
- websecure
routes:
- match: Host(`sampleapi.apps.mngoma.lab`)
kind: Rule
services:
- name: sampleapi
port: 443
scheme: http
tls: {}