Migrate gitea to k8s
This commit is contained in:
parent
b4ba3d0b4e
commit
55a6f2f3ff
5 changed files with 212 additions and 109 deletions
|
@ -1,109 +0,0 @@
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: git
|
|
||||||
namespace: external-services
|
|
||||||
spec:
|
|
||||||
type: ClusterIP
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 80
|
|
||||||
...
|
|
||||||
---
|
|
||||||
apiVersion: discovery.k8s.io/v1
|
|
||||||
kind: EndpointSlice
|
|
||||||
metadata:
|
|
||||||
name: git
|
|
||||||
namespace: external-services
|
|
||||||
labels:
|
|
||||||
kubernetes.io/service-name: git
|
|
||||||
addressType: IPv4
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
appProtocol: http
|
|
||||||
protocol: TCP
|
|
||||||
port: 27298
|
|
||||||
endpoints:
|
|
||||||
- addresses:
|
|
||||||
- "192.168.0.12"
|
|
||||||
conditions:
|
|
||||||
ready: true
|
|
||||||
...
|
|
||||||
---
|
|
||||||
apiVersion: cert-manager.io/v1
|
|
||||||
kind: Certificate
|
|
||||||
metadata:
|
|
||||||
name: git-cert
|
|
||||||
namespace: istio-system
|
|
||||||
spec:
|
|
||||||
secretName: git-cert
|
|
||||||
commonName: git.minhas.io
|
|
||||||
dnsNames:
|
|
||||||
- git.minhas.io
|
|
||||||
issuerRef:
|
|
||||||
name: letsencrypt-prod
|
|
||||||
kind: ClusterIssuer
|
|
||||||
group: cert-manager.io
|
|
||||||
...
|
|
||||||
---
|
|
||||||
apiVersion: networking.istio.io/v1beta1
|
|
||||||
kind: Gateway
|
|
||||||
metadata:
|
|
||||||
name: git-gateway
|
|
||||||
namespace: external-services
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
istio: ingressgateway
|
|
||||||
servers:
|
|
||||||
- port:
|
|
||||||
number: 443
|
|
||||||
name: https
|
|
||||||
protocol: HTTPS
|
|
||||||
tls:
|
|
||||||
mode: SIMPLE
|
|
||||||
credentialName: git-cert
|
|
||||||
hosts:
|
|
||||||
- git.minhas.io
|
|
||||||
...
|
|
||||||
---
|
|
||||||
apiVersion: networking.istio.io/v1beta1
|
|
||||||
kind: ServiceEntry
|
|
||||||
metadata:
|
|
||||||
name: git
|
|
||||||
namespace: external-services
|
|
||||||
spec:
|
|
||||||
hosts:
|
|
||||||
- git.minhas.io
|
|
||||||
addresses:
|
|
||||||
- 0.0.0.0/0
|
|
||||||
ports:
|
|
||||||
- number: 27298
|
|
||||||
name: git
|
|
||||||
protocol: HTTP
|
|
||||||
location: MESH_EXTERNAL
|
|
||||||
resolution: STATIC
|
|
||||||
endpoints:
|
|
||||||
- address: 192.168.0.12
|
|
||||||
...
|
|
||||||
---
|
|
||||||
apiVersion: networking.istio.io/v1beta1
|
|
||||||
kind: VirtualService
|
|
||||||
metadata:
|
|
||||||
name: git-gateway
|
|
||||||
namespace: external-services
|
|
||||||
spec:
|
|
||||||
hosts:
|
|
||||||
- git.minhas.io
|
|
||||||
gateways:
|
|
||||||
- git-gateway
|
|
||||||
http:
|
|
||||||
- match:
|
|
||||||
- uri:
|
|
||||||
prefix: /
|
|
||||||
route:
|
|
||||||
- destination:
|
|
||||||
port:
|
|
||||||
number: 80
|
|
||||||
host: git
|
|
||||||
...
|
|
68
helm/apps/gitea/external-secrets.yaml
Normal file
68
helm/apps/gitea/external-secrets.yaml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
type: kubernetes.io/service-account-token
|
||||||
|
metadata:
|
||||||
|
name: serviceaccounttoken
|
||||||
|
namespace: gitea
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/service-account.name: "gitea"
|
||||||
|
...
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: gitea-tokenreview-binding
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: ClusterRole
|
||||||
|
name: system:auth-delegator
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: gitea
|
||||||
|
namespace: gitea
|
||||||
|
...
|
||||||
|
---
|
||||||
|
apiVersion: external-secrets.io/v1beta1
|
||||||
|
kind: SecretStore
|
||||||
|
metadata:
|
||||||
|
name: gitea
|
||||||
|
namespace: gitea
|
||||||
|
spec:
|
||||||
|
provider:
|
||||||
|
vault:
|
||||||
|
server: "https://vault.service.masked.name:8200"
|
||||||
|
path: "kv"
|
||||||
|
version: "v2"
|
||||||
|
caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUROVENDQWgyZ0F3SUJBZ0lVWXA4eG81dDJsSkZQM1NpRDFmSmlyZ0dVUUowd0RRWUpLb1pJaHZjTkFRRUwKQlFBd0ZqRVVNQklHQTFVRUF4TUxiV0Z6YTJWa0xtNWhiV1V3SGhjTk1qQXdPREk1TVRreU16RXlXaGNOTXpBdwpPREkzTVRreU16UXlXakFXTVJRd0VnWURWUVFERXd0dFlYTnJaV1F1Ym1GdFpUQ0NBU0l3RFFZSktvWklodmNOCkFRRUJCUUFEZ2dFUEFEQ0NBUW9DZ2dFQkFNSTdvUitLSHZ2em5mbmFBWERNTzVxcFNUQ0FZQ3lmakZFb2hZSmYKbE9jbkxPTlhiM2Y2c1A1ZDFlbHRMK1VUcTBSVlU1VVAwYU5XN2hxRFRhNDFNUncwSkNEdEI2OHlLZFlxMmhaZgo5N2dBK2xqM01FSlU2UlRBS0xyZzc1R1JoL0FiTkVJZ3d2UHVIS1c2aE1idHdPeU05REZVLy9XM3hwdXNhbFh5ClJNRnpBSGZTRGo5Y2krVXlnVXQ5SElOV2QvU21NR0cvOFBnaGFSaGZFNDR3UkZNcVllemVsaUl0MkpJczQzQlYKN0hxRzBPZXY5V1BlWG1pYVpVWUtRZXRIaVFxUjE0TXhpd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zFpCmFXRXViV0Z6YTJWa0xtNWhiV1U2T0RJd01DOTJNUzl3YTJsZmNtOXZkQzlqY213d0RRWUpLb1pJaHZjTkFRRUwKQlFBRGdnRUJBSzZITWdSK2hwd2paQ21mNU5zekRTSHI3ZFlLWlhQNExyY0hQV3M5NG5MTTMzVVo1NzJ1YkdIcwpkS2pSdzhZRDBjbmNyc3lwc1ltRWdSNTdVK0RIa3lzMzk0d2tiN1VPd3kxWnZkNUlJUlhkUDBjRHlsejBRenFNCkFQblFZTitpc21rb2xqaGs5ZXkwUWJvM0NtUGpNK1VRY0F4dVpRdEE0TStyaUMxK2prdWRlMXVZTDBzekM2WTkKNEtldGZ2Yk5rZWRTYVY1eUphUktDQmhSY0M0L0dqcEJHL29kUS81QWZCUEFGalpxaGNJSldCclZZYlRRVkM3OQpoTUExaXdXSlBtVDlMc2pNU1VmeEZUUHp4Um5OWFFpS0Z6NWtUMk9pUzFucWg4YU9jeVU5WUM5Mjhwa2lmTkpWCktva3VEZXpKRk03aWUzZCtFY0JrMVY5bEh3T1dkdG89Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
||||||
|
auth:
|
||||||
|
kubernetes:
|
||||||
|
mountPath: "k8s-teapot"
|
||||||
|
role: "gitea"
|
||||||
|
secretRef:
|
||||||
|
name: "serviceaccounttoken"
|
||||||
|
...
|
||||||
|
---
|
||||||
|
apiVersion: external-secrets.io/v1beta1
|
||||||
|
kind: ExternalSecret
|
||||||
|
metadata:
|
||||||
|
name: gitea-vault
|
||||||
|
namespace: gitea
|
||||||
|
spec:
|
||||||
|
secretStoreRef:
|
||||||
|
name: gitea
|
||||||
|
kind: SecretStore
|
||||||
|
data:
|
||||||
|
- secretKey: db_pw
|
||||||
|
remoteRef:
|
||||||
|
key: git
|
||||||
|
property: db_pw
|
||||||
|
- secretKey: username
|
||||||
|
remoteRef:
|
||||||
|
key: git
|
||||||
|
property: username
|
||||||
|
- secretKey: password
|
||||||
|
remoteRef:
|
||||||
|
key: git
|
||||||
|
property: password
|
||||||
|
...
|
38
helm/apps/gitea/install.sh
Executable file
38
helm/apps/gitea/install.sh
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CHART_VERSION=6.0.5
|
||||||
|
NAMESPACE=gitea
|
||||||
|
VAULT_AUTH_NAMESPACE="k8s-teapot"
|
||||||
|
|
||||||
|
helm repo add gitea-charts https://dl.gitea.io/charts/
|
||||||
|
helm repo update
|
||||||
|
|
||||||
|
kubectl create ns gitea
|
||||||
|
kubectl create serviceaccount -n ${NAMESPACE} gitea
|
||||||
|
kubectl apply -n ${NAMESPACE} -f external-secrets.yaml
|
||||||
|
cat << EOH > gitea.hcl
|
||||||
|
path "kv/data/git" {
|
||||||
|
capabilities = ["read"]
|
||||||
|
}
|
||||||
|
EOH
|
||||||
|
vault policy write gitea gitea.hcl
|
||||||
|
rm gitea.hcl
|
||||||
|
|
||||||
|
helm upgrade --install \
|
||||||
|
gitea \
|
||||||
|
gitea-charts/gitea \
|
||||||
|
-f values.yaml \
|
||||||
|
-n ${NAMESPACE} \
|
||||||
|
--version ${CHART_VERSION} \
|
||||||
|
--cleanup-on-fail
|
||||||
|
|
||||||
|
HOST_IP=$(ip addr show eth0 | grep -Po 'inet \K[\d.]+')
|
||||||
|
TOKEN="$(kubectl get secret serviceaccounttoken -n gitea -o go-template='{{ .data.token }}' | base64 -d)"
|
||||||
|
|
||||||
|
vault write auth/${VAULT_AUTH_NAMESPACE}/role/gitea \
|
||||||
|
bound_service_account_names=gitea \
|
||||||
|
bound_service_account_namespaces=gitea \
|
||||||
|
policies=gitea \
|
||||||
|
ttl=24h
|
||||||
|
|
||||||
|
vault write auth/${VAULT_AUTH_NAMESPACE}/login role=gitea jwt=${TOKEN} iss=https://${HOST_IP}:6443
|
57
helm/apps/gitea/istio-ingress.yaml
Normal file
57
helm/apps/gitea/istio-ingress.yaml
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
---
|
||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: Certificate
|
||||||
|
metadata:
|
||||||
|
name: gitea-cert
|
||||||
|
namespace: istio-system
|
||||||
|
spec:
|
||||||
|
secretName: gitea-cert
|
||||||
|
commonName: git.minhas.io
|
||||||
|
dnsNames:
|
||||||
|
- git.minhas.io
|
||||||
|
issuerRef:
|
||||||
|
name: letsencrypt-prod
|
||||||
|
kind: ClusterIssuer
|
||||||
|
group: cert-manager.io
|
||||||
|
...
|
||||||
|
---
|
||||||
|
apiVersion: networking.istio.io/v1beta1
|
||||||
|
kind: Gateway
|
||||||
|
metadata:
|
||||||
|
name: gitea-gateway
|
||||||
|
namespace: gitea
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
istio: ingressgateway
|
||||||
|
servers:
|
||||||
|
- port:
|
||||||
|
number: 443
|
||||||
|
name: https
|
||||||
|
protocol: HTTPS
|
||||||
|
tls:
|
||||||
|
mode: SIMPLE
|
||||||
|
credentialName: gitea-cert
|
||||||
|
hosts:
|
||||||
|
- git.minhas.io
|
||||||
|
...
|
||||||
|
---
|
||||||
|
apiVersion: networking.istio.io/v1beta1
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: gitea-gateway
|
||||||
|
namespace: gitea
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- git.minhas.io
|
||||||
|
gateways:
|
||||||
|
- gitea-gateway
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
prefix: /
|
||||||
|
route:
|
||||||
|
- destination:
|
||||||
|
port:
|
||||||
|
number: 80
|
||||||
|
host: gitea-http
|
||||||
|
...
|
49
helm/apps/gitea/values.yaml
Normal file
49
helm/apps/gitea/values.yaml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
---
|
||||||
|
service:
|
||||||
|
http:
|
||||||
|
port: 80
|
||||||
|
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
existingClaim: data-gitea-0
|
||||||
|
storageClass: longhorn-retain
|
||||||
|
|
||||||
|
signing:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
gitea:
|
||||||
|
config:
|
||||||
|
server:
|
||||||
|
ROOT_URL: https://git.minhas.io
|
||||||
|
DOMAIN: git.minhas.io
|
||||||
|
database:
|
||||||
|
DB_TYPE: postgres
|
||||||
|
HOST: sedan.minhas.io
|
||||||
|
NAME: git
|
||||||
|
USER: git
|
||||||
|
additionalConfigFromEnvs:
|
||||||
|
- name: ENV_TO_INI__DATABASE__PASSWD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: gitea-vault
|
||||||
|
key: db_pw
|
||||||
|
|
||||||
|
admin:
|
||||||
|
existingSecret: gitea-vault
|
||||||
|
username: gitea-admin
|
||||||
|
|
||||||
|
metrics:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
APP_NAME: "git.minhas.io"
|
||||||
|
RUN_MODE: prod
|
||||||
|
|
||||||
|
additionalConfigSources: []
|
||||||
|
# - secret:
|
||||||
|
# secretName: gitea-app-ini-oauth
|
||||||
|
|
||||||
|
memcached:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
postgresql:
|
||||||
|
enabled: false
|
Loading…
Reference in a new issue