Skip to content

Instantly share code, notes, and snippets.

@franzwong
Last active March 21, 2026 05:26
Show Gist options
  • Select an option

  • Save franzwong/a32b05ea021bb1c502164ad5bb50282b to your computer and use it in GitHub Desktop.

Select an option

Save franzwong/a32b05ea021bb1c502164ad5bb50282b to your computer and use it in GitHub Desktop.
Deploy Flux on a cluster connected to a Git repository with Gitea and Minikube
#!/bin/bash
minikube start
gitea_user_name=gitea_admin
repository_name=flux-main
cat <<EOF > "values.yml"
gitea:
admin:
enabled: true
username: "'${gitea_user_name}'"
password: "gitea_password"
email: "admin@example.com"
config:
server:
SSH_PORT: 2222
service:
ssh:
port: 2222
EOF
helm repo add gitea-charts https://dl.gitea.com/charts/
helm install gitea gitea-charts/gitea -f values.yml
echo "Waiting for Gitea deployment to be available..."
kubectl wait --for=condition=available deployment/gitea --timeout=300s
kubectl --namespace default port-forward svc/gitea-http 3000:3000 &
kubectl --namespace default port-forward svc/gitea-ssh 2222:2222 &
ssh-keygen -t ed25519 -C "gitea" -f $(pwd)/id_gitea_ed25519 -N '' <<< y
echo "127.0.0.1 gitea-http.default.svc.cluster.local" | sudo tee -a /etc/hosts
echo "127.0.0.1 gitea-ssh.default.svc.cluster.local" | sudo tee -a /etc/hosts
gitea_pod_name=$(kubectl get pods -l app.kubernetes.io/name=gitea,app.kubernetes.io/instance=gitea -o jsonpath='{.items[0].metadata.name}')
access_token=$(kubectl exec -it ${gitea_pod_name} \
-- /usr/local/bin/gitea admin user generate-access-token \
--username ${gitea_user_name} \
--scopes all \
--token-name "flux-token" | awk '/Access token was successfully created: / {print $NF}' | tr -d '\r')
gitea_ssh_pub_key=$(cat "$(pwd)/id_gitea_ed25519.pub")
curl -X POST "http://gitea-http.default.svc.cluster.local:3000/api/v1/user/keys" \
-H "Authorization: token ${access_token}" \
-H "Content-Type: application/json" \
-d "{
\"title\": \"flux-key\",
\"key\": \"${gitea_ssh_pub_key}\",
\"read_only\": false
}"
curl -X POST "http://gitea-http.default.svc.cluster.local:3000/api/v1/user/repos" \
-H "Authorization: token ${access_token}" \
-H "Content-Type: application/json" \
-d '{
"name": "'${repository_name}'",
"description": "Flux main repository",
"private": true,
"auto_init": true
}'
flux bootstrap git \
--url=ssh://git@gitea-ssh.default.svc.cluster.local:2222/$gitea_user_name/$repository_name.git \
--branch=main \
--private-key-file=./id_gitea_ed25519 \
--path=clusters/my-cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment