1
0
Fork 0

gitea dev config

This commit is contained in:
Massaki Archambault 2021-08-26 12:42:21 -04:00
parent 0678bbd56d
commit 89c09df7bf
27 changed files with 280 additions and 234 deletions

View File

@ -4,58 +4,74 @@ KUSTOMIZEFLAGS = --enable_alpha_plugins
KUBECTL = kubectl KUBECTL = kubectl
KUBECTLFLAGS = KUBECTLFLAGS =
KUBECTLDIFFFLAGS = KUBECTLDIFFFLAGS =
KUBECTLAPPLYFLAGS = -l managed-by=kustomize --prune KUBECTLAPPLYFLAGS = --prune
SRC := $(shell find kustomize/ -type f) SRC := $(shell find kustomize/ -type f)
OUTDIR = build OUTDIR = build
DEVOUT = $(OUTDIR)/dev
DEVMANIFESTSRC = kustomize/overlays/dev
DEVMANIFESTOUT = $(DEVOUT)/manifest.yaml
DEVCLUSTERSRC = kustomize/overlays/dev-cluster
DEVCLUSTEROUT = $(DEVOUT)/cluster.yaml
PRODOUT = $(OUTDIR)/prod
PRODMANIFESTOUT = $(PRODOUT)/manifest.yaml
PRODMANIFESTSRC = kustomize/overlays/prod
PRODCLUSTERTOUT = $(PRODOUT)/cluster.yaml
PRODCLUSTERTSRC = kustomize/overlays/prod-cluster
ifeq ($(environment),prod) ifeq ($(environment),prod)
environment = prod environment = prod
# prod ENVOUTDIR = $(PRODOUT)
KUSTOMIZEDIR = kustomize/overlays/prod ENVOUTFILE = $(PRODMANIFESTOUT) $(PRODCLUSTERTOUT)
KUSTOMIZEOUT = $(OUTDIR)/$(environment)/manifest.yaml
# auto-deploy
KUSTOMIZEDIRALL = kustomize/overlays/prod-auto-deploy
KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/auto-deploy.yaml
else else
environment = dev environment = dev
# dev ENVOUTDIR = $(DEVOUT)
#KUBECTLFLAGS += --kubeconfig kubectl/kubeconfig.yaml ENVOUTFILE = $(DEVMANIFESTOUT) $(DEVCLUSTERTOUT)
KUSTOMIZEDIR = kustomize/overlays/dev
KUSTOMIZEOUT = $(OUTDIR)/$(environment)/manifest.yaml
# auto-deploy
KUSTOMIZEDIRALL = kustomize/overlays/dev-auto-deploy
KUSTOMIZEOUTALL = $(OUTDIR)/$(environment)/auto-deploy.yaml
endif endif
.PHONY: all info auto-deploy clean diff apply .PHONY: diff
diff: $(environment)
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(ENVOUTDIR) | highlight --out-format xterm256 --syntax diff
all: info $(KUSTOMIZEOUTALL) $(KUSTOMIZEOUT) .PHONY: apply
apply: $(environment)
$(KUBECTL) $(KUBECTLFLAGS) apply -l managed-by=kustomize-cluster -f $(ENVOUTDIR)
$(KUBECTL) $(KUBECTLFLAGS) apply -l managed-by=kustomize -f $(ENVOUTDIR)
info: .PHONY: all dev prod
@echo "Building for" $(environment) all: dev prod
$(KUSTOMIZE) version dev: $(DEVMANIFESTOUT) $(DEVCLUSTEROUT)
prod: $(PRODMANIFESTOUT) $(PRODCLUSTEROUT)
$(DEVMANIFESTOUT): $(SRC)
mkdir -p $(DEVOUT)
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(DEVMANIFESTSRC) >$(DEVMANIFESTOUT) || (rm $(DEVMANIFESTOUT); exit 1)
$(DEVCLUSTEROUT): $(SRC)
mkdir -p $(DEVOUT)
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(DEVCLUSTERSRC) >$(DEVCLUSTEROUT) || (rm $(DEVCLUSTEROUT); exit 1)
$(PRODMANIFESTOUT): $(SRC)
mkdir -p $(PRODOUT)
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(PRODMANIFESTSRC) >$(PRODMANIFESTOUT) || (rm $(PRODMANIFESTOUT); exit 1)
$(PRODCLUSTEROUT): $(SRC)
mkdir -p $(PRODOUT)
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(PRODCLUSTERSRC) >$(PRODCLUSTEROUT) || (rm $(PRODCLUSTEROUT); exit 1)
.PHONY: clean
clean: clean:
rm -r $(OUTDIR) rm -r $(OUTDIR)
auto-deploy: $(KUSTOMIZEOUTALL) # $(KUSTOMIZEOUTALL): $(SRC)
# @mkdir -p $(dir $(KUSTOMIZEOUTALL))
# $(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIRALL) >$(KUSTOMIZEOUTALL) || (rm $(KUSTOMIZEOUTALL); exit 1)
$(KUSTOMIZEOUTALL): $(SRC) # $(KUSTOMIZEOUT): $(SRC)
@mkdir -p $(dir $(KUSTOMIZEOUTALL)) # @mkdir -p $(dir $(KUSTOMIZEOUT))
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIRALL) >$(KUSTOMIZEOUTALL) || (rm $(KUSTOMIZEOUTALL); exit 1) # $(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIR) >$(KUSTOMIZEOUT) || (rm $(KUSTOMIZEOUT); exit 1)
$(KUSTOMIZEOUT): $(SRC)
@mkdir -p $(dir $(KUSTOMIZEOUT))
$(KUSTOMIZE) build $(KUSTOMIZEFLAGS) $(KUSTOMIZEDIR) >$(KUSTOMIZEOUT) || (rm $(KUSTOMIZEOUT); exit 1)
diff: $(KUSTOMIZEOUT)
$(KUBECTL) $(KUBECTLFLAGS) diff $(KUBECTLDIFFFLAGS) -f $(KUSTOMIZEOUT)
apply: $(KUSTOMIZEOUT)
$(KUBECTL) $(KUBECTLFLAGS) apply $(KUBECTLAPPLYFLAGS) -f $(KUSTOMIZEOUT)

View File

@ -18,7 +18,7 @@ spec:
spec: spec:
containers: containers:
- name: drone - name: drone
image: drone/drone-runner-kube:1.0.0-beta.3 image: drone/drone-runner-kube
env: env:
- name: DRONE_RPC_HOST - name: DRONE_RPC_HOST
value: drone.gitea.svc value: drone.gitea.svc

View File

@ -18,10 +18,12 @@ spec:
spec: spec:
containers: containers:
- name: drone - name: drone
image: drone/drone:1.7.0 image: drone/drone
env: env:
- name: DRONE_SERVER_HOST - name: DRONE_SERVER_HOST
value: ${DRONE_EXTERNAL_HOST} value: ${DRONE_EXTERNAL_HOST}
- name: DRONE_SERVER_PROTO
value: https
- name: DRONE_GITEA_SERVER - name: DRONE_GITEA_SERVER
value: https://${GITEA_EXTERNAL_HOST} value: https://${GITEA_EXTERNAL_HOST}
- name: DRONE_GITEA_CLIENT_ID - name: DRONE_GITEA_CLIENT_ID
@ -58,26 +60,3 @@ spec:
protocol: TCP protocol: TCP
port: 80 port: 80
targetPort: http targetPort: http
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: drone
labels:
app: drone
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/cluster-issuer: letsencrypt
spec:
tls:
- hosts:
- drone.127.0.0.1.nip.io
secretName: letsencrypt-cert
rules:
- host: drone.127.0.0.1.nip.io
http:
paths:
- path: /
backend:
serviceName: drone
servicePort: http

View File

@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: drone
labels:
app: drone
annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /
# cert-manager.io/cluster-issuer: letsencrypt
spec:
# tls:
# - hosts:
# - ${GITEA_EXTERNAL_HOST}
# secretName: letsencrypt-cert
rules:
- host: ${DRONE_EXTERNAL_HOST}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: drone
port:
name: http

View File

@ -1,3 +1,15 @@
resources: resources:
- drone-server-deployment.yaml
- drone-runner-deployment.yaml - drone-runner-deployment.yaml
- drone-server-deployment.yaml
- drone-server-ingress.yaml
secretGenerator:
- name: drone-secret
type: Opaque
literals:
- rpc_secret=changeme
- name: drone-gitea-oauth-secret
type: Opaque
literals:
- client_id=changeme
- client_secret=changeme

View File

@ -5,6 +5,7 @@ metadata:
labels: labels:
app: gitea app: gitea
spec: spec:
replicas: 1 # replica count must be set to 1 in database is sqlite
selector: selector:
matchLabels: matchLabels:
app: gitea app: gitea
@ -15,10 +16,10 @@ spec:
spec: spec:
containers: containers:
- name: gitea - name: gitea
image: gitea/gitea:1.11.4 image: gitea/gitea
env: env:
- name: INSTALL_LOCK # - name: INSTALL_LOCK
value: "yes" # value: "yes"
- name: DISABLE_REGISTRATION - name: DISABLE_REGISTRATION
value: "yes" value: "yes"
- name: APP_NAME - name: APP_NAME
@ -29,28 +30,28 @@ spec:
value: https://${GITEA_EXTERNAL_HOST} value: https://${GITEA_EXTERNAL_HOST}
- name: SSH_DOMAIN - name: SSH_DOMAIN
value: ${GITEA_EXTERNAL_HOST} value: ${GITEA_EXTERNAL_HOST}
- name: DB_TYPE # - name: DB_TYPE
value: postgres # value: postgres
- name: DB_HOST # - name: DB_HOST
valueFrom: # valueFrom:
secretKeyRef: # secretKeyRef:
name: postgres-credentials-secret # name: postgres-credentials-secret
key: host # key: host
- name: DB_NAME # - name: DB_NAME
valueFrom: # valueFrom:
secretKeyRef: # secretKeyRef:
name: postgres-credentials-secret # name: postgres-credentials-secret
key: database # key: database
- name: DB_USER # - name: DB_USER
valueFrom: # valueFrom:
secretKeyRef: # secretKeyRef:
name: postgres-credentials-secret # name: postgres-credentials-secret
key: username # key: username
- name: DB_PASSWD # - name: DB_PASSWD
valueFrom: # valueFrom:
secretKeyRef: # secretKeyRef:
name: postgres-credentials-secret # name: postgres-credentials-secret
key: password # key: password
ports: ports:
- name: http - name: http
containerPort: 3000 containerPort: 3000
@ -63,22 +64,22 @@ spec:
- name: gitea-data - name: gitea-data
persistentVolumeClaim: persistentVolumeClaim:
claimName: gitea-data claimName: gitea-data
--- # ---
apiVersion: v1 # apiVersion: v1
kind: PersistentVolume # kind: PersistentVolume
metadata: # metadata:
name: gitea-data-nfs # name: gitea-data-nfs
labels: # labels:
app: gitea # app: gitea
spec: # spec:
accessModes: # accessModes:
- ReadWriteMany # - ReadWriteMany
capacity: # capacity:
storage: 100Mi # storage: 100Mi
nfs: # nfs:
server: nfs-localhost # server: nfs-localhost
path: /gitea # path: /gitea
mountOptions: ["vers=4"] # mountOptions: ["vers=4"]
--- ---
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
@ -87,20 +88,20 @@ metadata:
labels: labels:
app: gitea app: gitea
spec: spec:
storageClassName: "" # storageClassName: ""
accessModes: accessModes:
- ReadWriteMany - ReadWriteOnce
resources: resources:
requests: requests:
storage: 100Mi storage: 100Mi
selector: # selector:
matchLabels: # matchLabels:
app: gitea # app: gitea
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: gitea-http name: gitea
labels: labels:
app: gitea app: gitea
spec: spec:
@ -111,17 +112,6 @@ spec:
protocol: TCP protocol: TCP
port: 80 port: 80
targetPort: http targetPort: http
---
apiVersion: v1
kind: Service
metadata:
name: gitea-ssh
labels:
app: gitea
spec:
selector:
app: gitea
ports:
- name: ssh - name: ssh
protocol: TCP protocol: TCP
port: 22 port: 22

View File

@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gitea
labels:
app: gitea
annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /
# cert-manager.io/cluster-issuer: letsencrypt
spec:
# tls:
# - hosts:
# - ${GITEA_EXTERNAL_HOST}
# secretName: letsencrypt-cert
rules:
- host: ${GITEA_EXTERNAL_HOST}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: gitea
port:
name: http

View File

@ -1,22 +0,0 @@
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: gitea
labels:
app: gitea
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/cluster-issuer: letsencrypt
spec:
tls:
- hosts:
- ${GITEA_EXTERNAL_HOST}
secretName: letsencrypt-cert
rules:
- host: ${GITEA_EXTERNAL_HOST}
http:
paths:
- path: /
backend:
serviceName: gitea-http
servicePort: http

View File

@ -1,22 +1,13 @@
resources: resources:
- gitea-deployment.yaml - gitea-deployment.yaml
- ingress.yaml - gitea-ingress.yaml
secretGenerator: # secretGenerator:
- name: postgres-credentials-secret # - name: postgres-credentials-secret
type: Opaque # type: Opaque
behavior: create # behavior: create
literals: # literals:
- host=172.18.1.2:5432 # - host=172.18.1.2:5432
- database=gitea # - database=gitea
- username=gitea # - username=gitea
- password=changeme # - password=changeme
- name: drone-secret
type: Opaque
literals:
- rpc_secret=changeme
- name: drone-gitea-oauth-secret
type: Opaque
literals:
- client_id=changeme
- client_secret=changeme

View File

@ -0,0 +1,27 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kubernetes-dashboard
labels:
app: kubernetes-dashboard
annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /
# nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
# ingress.kubernetes.io/protocol: https
# cert-manager.io/cluster-issuer: letsencrypt
spec:
# tls:
# - hosts:
# - ${GITEA_EXTERNAL_HOST}
# secretName: letsencrypt-cert
rules:
- host: ${KUBERNETES_DASHBOARD_EXTERNAL_HOST}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 443

View File

@ -1,23 +0,0 @@
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: kubernetes-dashboard
labels:
app: kubernetes-dashboard
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
cert-manager.io/cluster-issuer: letsencrypt
spec:
tls:
- hosts:
- ${KUBERNETES_DASHBOARD_EXTERNAL_HOST}
secretName: letsencrypt-cert
rules:
- host: ${KUBERNETES_DASHBOARD_EXTERNAL_HOST}
http:
paths:
- path: /
backend:
serviceName: kubernetes-dashboard
servicePort: 443

View File

@ -1,7 +0,0 @@
apiVersion: badjware/v1
kind: RemoteResources
metadata:
name: kubernetes-dashboard
resources:
- url: https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
sha256: d8b96dfa27da511d5116fc3583281dd1da709c3c6e07b033e4f3424bc2ab64c8

View File

@ -1,8 +1,6 @@
resources: resources:
- kubernetes-dashboard-admin-user.yaml - https://raw.githubusercontent.com/kubernetes/dashboard/v2.3.1/aio/deploy/recommended.yaml
- ingress.yaml - dashboard-admin-user.yaml
- dashboard-ingress.yaml
generators:
- kubernetes-dashboard.yaml
namespace: kubernetes-dashboard namespace: kubernetes-dashboard

View File

@ -0,0 +1,2 @@
resources:
- traefik-helmchartconfig.yaml

View File

@ -0,0 +1,11 @@
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: traefik
spec:
valuesContent: |-
additionalArguments:
- '--serversTransport.insecureSkipVerify=true'
ports:
web:
redirectTo: websecure

View File

@ -1,4 +1,4 @@
bases: bases:
- ../../bases/cert-manager - ../../bases/cert-manager
# namespace: cert-manager namespace: cert-manager

View File

@ -1,5 +1,6 @@
bases: bases:
- ../../bases/gitea - ../../bases/gitea
- ../../bases/drone
# - ../../base/postgres # - ../../base/postgres
resources: resources:

View File

@ -1,4 +1,5 @@
bases: bases:
- ../../bases/ingress-nginx - ../../bases/traefik
# - ../../bases/ingress-nginx
namespace: kube-system namespace: kube-system

View File

@ -0,0 +1,4 @@
bases:
- ../../bases/kubernetes-dashboard
namespace: kubernetes-dashboard

View File

@ -1,7 +0,0 @@
bases:
- ../../namespaces/kube-system
- ../../namespaces/cert-manager
# allow "kubectl apply -l managed-by=auto-deploy --prune ..."
commonlabels:
managed-by: auto-deploy

View File

@ -0,0 +1,7 @@
bases:
- ../../namespaces/kube-system
# - ../../namespaces/cert-manager
# allow "kubectl apply -l managed-by=cluster --prune ..."
commonlabels:
managed-by: kustomize-cluster

View File

@ -1,33 +1,49 @@
bases: bases:
- ../../namespaces/kubernetes-dashboard
- ../../namespaces/gitea - ../../namespaces/gitea
# - ../../namespaces/grafana # - ../../namespaces/grafana
- ../../namespaces/nextcloud # - ../../namespaces/nextcloud
# resources:
# - cert-manager/clusterissuer.yaml
images:
- name: gitea/gitea
newtag: 1.15.0
- name: drone/drone
newtag: 2.0.6
- name: drone/drone-runner-kube
newtag: 1.0.0-beta.9
resources:
- cert-manager/clusterissuer.yaml
secretGenerator: secretGenerator:
- name: digitalocean-api-key # - name: digitalocean-api-key
type: Opaque
namespace: cert-manager
literals:
- access-token=${ssm:/prod/digitalocean/api_token}
# - name: drone-gitea-oauth-secret
# type: Opaque # type: Opaque
# namespace: gitea # namespace: cert-manager
# behavior: replace
# literals: # literals:
# - client_id=749cde98-9b3b-4e19-8933-2937e12625f2 # - access-token=${ssm:/prod/digitalocean/api_token}
# - client_secret=12wTErChjQQW3CGEzbDMiSxEt08i-abeB0pbRbXEKKg= - name: drone-secret
type: Opaque
namespace: gitea
behavior: replace
literals:
- rpc_secret=9128146e66f104873df80dad3ef12cf0
# https://docs.drone.io/server/provider/gitea/
- name: drone-gitea-oauth-secret
type: Opaque
namespace: gitea
behavior: replace
literals:
- client_id=6c0c6878-baf1-4648-b0cf-69eeae69e692
- client_secret=Q78VsgyfgTzKrvQEmokEMj84g7epKrlBpmDjcbhKXCIh
# allow "kubectl apply -l managed-by=kustomize --prune ..." # allow "kubectl apply -l managed-by=kustomize --prune ..."
commonlabels: commonlabels:
managed-by: kustomize managed-by: kustomize
transformers: transformers:
- placeholders.yaml - transformers/placeholders.yaml
- ssm-secrets.yaml - transformers/ssm-secrets.yaml
configurations: # configurations:
- cert-manager/kustomizeconfig.yaml # - cert-manager/kustomizeconfig.yaml

View File

@ -1,5 +1,5 @@
DRONE_EXTERNAL_HOST=drone.local.badjware.dev DRONE_EXTERNAL_HOST=drone.localhost
GITEA_EXTERNAL_HOST=gitea.local.badjware.dev GITEA_EXTERNAL_HOST=gitea.localhost
GRAFANA_EXTERNAL_HOST=grafana.local.badjware.dev GRAFANA_EXTERNAL_HOST=grafana.localhost
KUBERNETES_DASHBOARD_EXTERNAL_HOST=kubernetes-dashboard.local.badjware.dev KUBERNETES_DASHBOARD_EXTERNAL_HOST=kubernetes-dashboard.localhost
NEXTCLOUD_EXTERNAL_HOST=nextcloud.local.badjware.dev NEXTCLOUD_EXTERNAL_HOST=nextcloud.localhost

View File

@ -4,8 +4,8 @@ cluster_name='local'
k3s_registry_config="$HOME/.config/k3d/registries.yaml" k3s_registry_config="$HOME/.config/k3d/registries.yaml"
# generate manifest to be deployed on boot # generate manifest to be deployed on boot
make auto-deploy # make cluster
auto_deploy_manifest="$(dirname "$(readlink -f "$0")")/build/dev/auto-deploy.yaml" # auto_deploy_manifest="$(dirname "$(readlink -f "$0")")/build/dev/cluster.yaml"
# cluster registry configuration # cluster registry configuration
if [[ ! -f "$k3s_registry_cofing" ]]; then if [[ ! -f "$k3s_registry_cofing" ]]; then
@ -25,13 +25,12 @@ if ! k3d cluster list "$cluster_name" &>/dev/null; then
k3d cluster create "$cluster_name" \ k3d cluster create "$cluster_name" \
--servers 1 \ --servers 1 \
--agents 3 \ --agents 3 \
--k3s-server-arg '--no-deploy=traefik' \
--volume "$k3s_registry_config:/etc/rancher/k3s/registries.yaml" \ --volume "$k3s_registry_config:/etc/rancher/k3s/registries.yaml" \
-p 80:80@loadbalancer \ -p 80:80@loadbalancer \
-p 443:443@loadbalancer -p 443:443@loadbalancer
sleep 10 sleep 10
fi fi
# --volume ":/var/lib/rancher/k3s/server/manifests/auto-deploy.yaml" \ # --volume ":/var/lib/rancher/k3s/server/manifests/cluster.yaml" \
# local docker registry # local docker registry
if ! docker ps -a | grep registry-localhost &>/dev/null; then if ! docker ps -a | grep registry-localhost &>/dev/null; then
@ -82,6 +81,7 @@ if ! docker ps -a | grep nfs-localhost &>/dev/null; then
sleep 10 sleep 10
fi fi
k3d kubeconfig merge "$cluster_name" --switch-context >/dev/null # k3d kubeconfig merge "$cluster_name" --switch-context >/dev/null
kubectl apply -f "$auto_deploy_manifest" # kubectl apply -f "$auto_deploy_manifest"
kubectl config use-context "k3d-$cluster_name"
kubectl get nodes kubectl get nodes