4.3 部署代码仓库 gitea
gitea
相对于 gitlab
来说比较轻量级,资源占用少,而且 Go
语言开发的,升级维护方便.
gitea
安装方式有 yum
二进制包安装、docker
安装、helm
安装等方式,这里主要介绍 helm
安装
helm
安装 gitea
具体的安装方式可以参考官方文档
添加 gitea
仓库
helm repo add gitea-charts https://dl.gitea.io/charts/
"gitea-charts" has been added to your repositories
更新 chart
仓库
helm repo update
部署 gitea
手动创建 secret
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: gitea-admin-secret
namespace: devops
type: Opaque
stringData:
username: jerry # 自定义用户名
password: ufkw2m6lA4 # 自定义密码
EOF
设置 hosts
有问题
helm install gitea gitea-charts/gitea \
--set image.pullPolicy=IfNotPresent \
--set ingress.enabled=true \
--set ingress.className=nginx \
--set ingress.hosts[0].host=git.hzde.com \
--set gitea.admin.existingSecret=gitea-admin-secret \
-n devops
改为修改 values.yaml
中的 host
helm fetch gitea-charts/gitea --untar
cd gitea
vim values.yaml
...
ingress:
enabled: false
# className: nginx
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: git.hzde.com
...
helm install gitea gitea-charts/gitea \
--set image.pullPolicy=IfNotPresent \
--set ingress.enabled=true \
--set ingress.className=nginx \
--set gitea.admin.existingSecret=gitea-admin-secret \
-f values.yaml -n devops
输出如下
NAME: gitea
LAST DEPLOYED: Sat Jan 29 20:59:06 2022
NAMESPACE: devops
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
http://git.hzde.com/
检查部署状态
需要下载的镜像比较多,需要等待久一些
kubectl get po -l app.kubernetes.io/instance=gitea -n devops
NAME READY STATUS RESTARTS AGE
gitea-0 1/1 Running 0 13m
gitea-memcached-584956987c-s97jl 1/1 Running 0 13m
gitea-postgresql-0 1/1 Running 0 13m
kubectl get svc -l app.kubernetes.io/instance=gitea -n devops
输出如下
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
gitea-http ClusterIP None <none> 3000/TCP 13m
gitea-memcached ClusterIP 10.96.174.116 <none> 11211/TCP 13m
gitea-postgresql ClusterIP 10.97.241.191 <none> 5432/TCP 13m
gitea-postgresql-headless ClusterIP None <none> 5432/TCP 13m
gitea-ssh ClusterIP None <none> 22/TCP 13m
访问 gitea
kubectl get service -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller LoadBalancer 10.102.200.139 192.168.122.191 80:31974/TCP,443:31677/TCP 2d1h
ingress-nginx-controller-admission ClusterIP 10.96.128.251 <none> 443/TCP 2d1h
修改本地hosts文件,增加一条:192.168.122.191 git.hzde.com
打开浏览器,输入:http://git.hzde.com访问 gitea
默认登录名和密码在 gitea-admin-secret
secret
中指定的