Skip to content

Gitea

This role helps in installing and configuring Gitea the Kubernetes cluster.

Requirements

Access to Kubernetes cluster,

For demo purpose you can have minikube cluster created locally as shown in the following example playbook,

e.g.

- name: "Create minikube Clusters"
  hosts: all
  vars:
    # the demo work directory
    work_dir: "{{ playbook_dir }}/work"
    # the kubeconfig directory
    kubeconfig_dir: "{{ work_dir }}/.kube"
    # the kubernetes version to use with minikube
    minikube_kubernetes_version: v1.21.6
    # the minikube home directory
    minikube_home_dir: "{{ work_dir }}/.minikube"
    # minikube profiles
    minikube_profiles:
      mgmt: # profile name and Kubernetes context name
        create: yes
        destroy: no
        addons:
          - metallb
        lbStartIP: 192.168.64.80
        lbEndIP: 192.168.64.90
  roles:
    - role: kameshsampath.minikube

  # Some extra configurations
  tasks:
    - name: "Configure metallb"
      ansible.builtin.expect:
        command: "{{ minikube_binary }} -p {{ item.key }} addons configure metallb"
        responses:
          "-- Enter Load Balancer Start IP:": "{{ item.value.lbStartIP}}"
          "-- Enter Load Balancer End IP:": "{{ item.value.lbEndIP}}"
      loop: "{{ minikube_profiles | dict2items }}"
      loop_control:
         label: "{{ item.key }}"
      register: lb_setup_result
      when: item.value.create and not item.value.destroy

    - name: "Metallb result"
      debug:
        var: lb_setup_result

    - name: "Ensure we are in mgmt context"
      ansible.builtin.command:
        argv:
          - kubectl 
          - config 
          - use-context
          - "mgmt"
      environment:
        KUBECONFIG: "{{ work_dir }}/.kube/config"

    - name: "Ensure right permissions to kubeconfig directory"
      ansible.builtin.file:
        state: directory
        recurse: yes
        path: "{{ work_dir }}/.kube"
        mode: "0700"

Variables

Name Description Default
kubernetes_spices_gitea_k8s_context The Kubernetes context where Gitea will be installed. The playbook will fail if this is not set.
kubernetes_spices_gitea_namespace The namespace to install Gitea gitea
kubernetes_spices_gitea_cli_version The gitea cli version 1.15.6

Example Playbook

- name: "Setup Gitea"
  hosts: localhost
  vars:
    kubernetes_spices_argocd_k8s_context: 'mgmt'
  roles:
    - { role: kameshsampath.kubernetes_spices.gitea }

Important

  • Based on the above example the kubernetes_spices_gitea_k8s_context should be set to mgmt, the context which is created by minikube
  • The gitea password will be generated and stored in the {{ work_dir }}/gitea.password file. The default admin username is gitea

The playbook installs a proxy in the namespace where Gitea is installed to allow the service to be accessed from the host machine. To get your gitea url run,

GITEA_URL=
gitea-$(kubectl -n gitea gateway-proxy -ojsonpath='{.status.loadBalancer.ingress[*].ip}').nip.io"