From c2ecb79adb3895502f74168612f40567f2392be0 Mon Sep 17 00:00:00 2001 From: Khwezi Date: Sun, 12 Oct 2025 13:26:24 +0200 Subject: [PATCH] Refactored test pipeline and manifest to fit new cluster --- .drone.yml | 49 +++++----- manifests/deploy-app.yml | 92 +++++++++++++++++++ .../deployment.yaml.bak | 0 3 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 manifests/deploy-app.yml rename templates/deployment.yaml => manifests/deployment.yaml.bak (100%) diff --git a/.drone.yml b/.drone.yml index 6c10c99..9bf9b72 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,6 @@ kind: pipeline type: kubernetes name: build -# disable built-in clone step clone: disable: true @@ -12,35 +11,35 @@ steps: - name: git clone image: drone/git commands: - - git clone http://gitea.main.k3s.lab.mngoma.africa/mngomalab/sampleapi.git . - - git checkout $DRONE_COMMIT + - git clone https://gitea.apps.mngoma.lab/mngomalab/sampleapi.git . + - git checkout $DRONE_COMMIT # dotnet restore - name: dotnet restore image: mcr.microsoft.com/dotnet/sdk:8.0 commands: - - dotnet restore + - dotnet restore # dotnet build - name: dotnet build image: mcr.microsoft.com/dotnet/sdk:8.0 commands: - - dotnet build --configuration Release - - ls ./SampleApi/bin/Release/net8.0/ + - dotnet build --configuration Release + - ls ./SampleApi/bin/Release/net8.0/ # dotnet test - name: dotnet test image: mcr.microsoft.com/dotnet/sdk:8.0 commands: - - dotnet test --configuration Release + - dotnet test --configuration Release + --- kind: pipeline type: kubernetes name: package depends_on: -- build + - build -# disable built-in clone step clone: disable: true @@ -49,36 +48,36 @@ steps: - name: git clone image: drone/git commands: - - git clone http://gitea.main.k3s.lab.mngoma.africa/mngomalab/sampleapi.git . - - git checkout $DRONE_COMMIT + - git clone https://gitea.apps.mngoma.lab/mngomalab/sampleapi.git . + - git checkout $DRONE_COMMIT # dotnet publish - name: dotnet publish image: mcr.microsoft.com/dotnet/sdk:8.0 commands: - - dotnet publish --configuration Release - - ls ./SampleApi/bin/Release/net8.0/publish/ + - dotnet publish --configuration Release + - 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 image: plugins/docker settings: - repo: khwezi/mngomalab + repo: registry.registry.svc.cluster.local:5000/experiments/sampleapi auto_tag: true username: - from_secret: docker_username + from_secret: registry-username password: - from_secret: docker_password + from_secret: registry-password dockerfile: Dockerfile context: ./SampleApi/bin/Release/net8.0/publish/ + --- kind: pipeline type: kubernetes name: deploy depends_on: -- package + - package -# disable built-in clone step clone: disable: true @@ -87,15 +86,15 @@ steps: - name: git clone image: drone/git commands: - - git clone http://gitea.main.k3s.lab.mngoma.africa/mngomalab/sampleapi.git . - - git checkout $DRONE_COMMIT + - git clone https://gitea.apps.mngoma.lab/mngomalab/sampleapi.git . + - git checkout $DRONE_COMMIT - name: deploy image: danielgormly/drone-plugin-kube:0.0.1 settings: - template: ./templates/deployment.yaml - ca: + template: ./manifests/deploy-app.yml + ca: from_secret: kube_ca_cert - server: https://192.168.1.161:6443 + server: https://lead:6443 token: - from_secret: k3s_token \ No newline at end of file + from_secret: k3s_token diff --git a/manifests/deploy-app.yml b/manifests/deploy-app.yml new file mode 100644 index 0000000..e4bf3a5 --- /dev/null +++ b/manifests/deploy-app.yml @@ -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: {} diff --git a/templates/deployment.yaml b/manifests/deployment.yaml.bak similarity index 100% rename from templates/deployment.yaml rename to manifests/deployment.yaml.bak