Drone build - cannot clone repo from gitea

Any advise on how to get this working?
It looks like drone sees that gitea k8s service is listening on port 3000, but to access gitea, it needs to go over port 80 to hit the ingress into the pod.

Error:

Initialized empty Git repository in /drone/src/.git/
2 + git fetch origin +refs/heads/master:
3 fatal: unable to access ‘http://gitea.example.com:3000/midacts/test.git/’: Failed to connect to gitea.example.com port 3000: Connection refused

gitea k8s deploy:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitea
  namespace: git
  labels:
    app: gitea
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitea
  template:
    metadata:
      labels:
        app: gitea
    spec:
      containers:
      - name: gitea
        image: gitea/gitea:latest
        ports:
        - containerPort: 3000
          name: gitea-http
        - containerPort: 22
          name: gitea-ssh
        volumeMounts:
        - mountPath: /data
          name: gitea-data
      volumes:
      - name: gitea-data
        hostPath:
          path: /kube-data/gitea
          type: Directory
---
kind: Service
apiVersion: v1
metadata:
  name: gitea
  namespace: git
spec:
  selector:
    app: gitea
  ports:
  - name: gitea-http
    port: 3000
    targetPort: gitea-http
  - name: gitea-ssh
    port: 2222
    targetPort: gitea-ssh
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: gitea
  namespace: git
  annotations:
    kubernetes.io/ingress.class: "traefik"
spec:
  rules:
  - host: gitea.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: gitea
          servicePort: 3000
  - host: gitea.10.2.1.204.xip.io
    http:
      paths:
      - path: /
        backend:
          serviceName: gitea
          servicePort: 3000

drone deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: drone
  namespace: git
  labels:
    app: drone
spec:
  replicas: 1
  selector:
    matchLabels:
      app: drone
  template:
    metadata:
      labels:
        app: drone
    spec:
      containers:
      - name: drone
        image: drone/drone:1
        ports:
        - containerPort: 80
          name: http
        env:
        - name: DRONE_GITEA_SERVER
          value: http://gitea.10.2.1.204.xip.io
        - name: DRONE_GITEA_CLIENT_ID
          value: xxx
        - name: DRONE_GITEA_CLIENT_SECRET
          value: xxx
        - name: DRONE_RPC_SECRET
          value: xxx
        - name: DRONE_SERVER_HOST
          value: drone.example.com
        - name: DRONE_SERVER_PROTO
          value: http
        volumeMounts:
        - mountPath: /data
          name: drone-data
      - name: runner
        image: drone/drone-runner-kube:latest
        ports:
        - containerPort: 3000
        env:
        - name: DRONE_RPC_HOST
          value: drone.git.svc.cluster.local
        - name: DRONE_RPC_PROTO
          value: http
        - name: DRONE_RPC_SECRET
          value: xxx
        - name: DRONE_NAMESPACE_DEFAULT
          value: git
      volumes:
      - name: drone-data
        hostPath:
          path: /kube-data/drone
          type: Directory
---
kind: Service
apiVersion: v1
metadata:
  name: drone
  namespace: git
spec:
  selector:
    app: drone
  ports:
  - name: http
    port: 80
    targetPort: http
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: drone
  namespace: git
  annotations:
    kubernetes.io/ingress.class: "traefik"
spec:
  rules:
  - host: drone.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: drone
          servicePort: 80
  - host: drone.10.2.1.240.xip.io
    http:
      paths:
      - path: /
        backend:
          serviceName: drone
          servicePort: 80
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  namespace: git
  name: drone
rules:
- apiGroups:
  - ""
  resources:
  - secrets
  verbs:
  - create
  - delete
- apiGroups:
  - ""
  resources:
  - pods
  - pods/log
  verbs:
  - get
  - create
  - delete
  - list
  - watch
  - update

---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: drone
  namespace: git
subjects:
- kind: ServiceAccount
  name: default
  namespace: git
roleRef:
  kind: Role
  name: drone
  apiGroup: rbac.authorization.k8s.io

Hello midacts,

Could you please confirm if gitea server is running locally on 3000 and could you please run telnet command for http://gitea.example.com:3000 and share the output so that we can suggest accordingly.

Regards,
Harness Support

Hello csgit.

Thanks for the reply and your support.

I figured out the problem.
Just like this forum post, the solution is to set the ROOT_URL env variable on your gitea container. Drone pulls that and uses it to connect to gitea - avatars, git clones, pipeline runs, etc.

but

The problem i ran into is i set the ROOT_URL and it still didn’t work.
The problem is drone “caches” or stores the ROOT_URL the first time it connects to gitea. The only real way I found to get it to work was to delete the local database that drone uses, respin the pod, and drone picks up the new ROOT_URL and everything works correctly.

Hopefully that helps someone else in the future. I spent hours over the weekend trying to get this to work.

FWIW Gitea has a helm-chart which is the recommended way to use Gitea on k8s https://gitea.com/gitea/helm-chart/

Drone also has a helm chart: GitHub - drone/charts: Helm charts for the Drone platform on Kubernetes