En-mass spruce-up of cluster resources

This commit is contained in:
GeorgeRaven
2023-08-10 20:19:44 +01:00
parent 8faba73beb
commit cce290bddc
28 changed files with 228 additions and 374 deletions

100
Makefile
View File

@@ -1,61 +1,93 @@
CHART_DIR_PATH_ARGO=charts/init
ARGO_NAMESPACE=argocd
CHART_DIR_PATH_ARGO="charts/init"
ARGO_NAMESPACE="argocd"
ACD=argo-cd
FORWARD_PORT="8080"
ACD_VERSION=5.43.3
REGISTRY="registry.gitlab.com"
FORWARD_PORT="8021"
MINIKUBE_KUBE_VERSION=1.27.4
REGCRED_NAME="regcred"
DEEPCYOHER_NAMESPACE=deepcypher
# additional args for setting podman auth.json config
# https://docs.podman.io/en/latest/markdown/podman-login.1.html
DOCKER_AUTH_FILE="${HOME}/.docker/config.json"
REGISTRY_AUTH_FILE="${HOME}/.podman/auth.json"
# this will override the charts values.yaml to let the chart know it should either run in "cloud" or "metal" mode.
# The only difference should be storage and loadbalancing since on bare-metal we have to do it ourselves.
KUBE_TYPE=metal
# Cloudflared settings
CLUSTER_NAME=arbiter
CLOUDFLARED_TUNNEL_CRED_FILE="${HOME}/.cloudflared/${CLUSTER_NAME}.yaml"
.PHONY: help
help: ## display this auto generated help message
@echo "Please provide a make target:"
@grep -F -h "##" $(MAKEFILE_LIST) | grep -F -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
.PHONY: all
all: minikube install
all: minikube install forward ## create a basic minikube cluster to launch the stack onto
.PHONY: install
install:
# pre-installing argocd-workflows chart to get necessary argocd CRDs
# https://github.com/argoproj/argo-helm/issues/1447
install: #login.lock ## bootstrap cluster into default kubeconfig location
helm repo add argocd https://argoproj.github.io/argo-helm/
helm install --create-namespace --namespace ${ARGO_NAMESPACE} --set="dex.enabled=false" ${ACD} argocd/argo-cd
helm dependency update ${CHART_DIR_PATH_ARGO}
helm install --create-namespace --namespace ${ARGO_NAMESPACE} init ${CHART_DIR_PATH_ARGO}
#kubectl create namespace ${DEEPCYOHER_NAMESPACE} && kubectl apply -f login.creds
helm upgrade --install --create-namespace --namespace ${ARGO_NAMESPACE} -f argocd-values.yaml ${ACD} argocd/argo-cd --version ${ACD_VERSION}
helm upgrade --install --create-namespace --namespace ${ARGO_NAMESPACE} --set="type=${KUBE_TYPE}" init ${CHART_DIR_PATH_ARGO}
.PHONY: forward
forward:
forward: ## forward local port to argocd server deployment for secure preview
kubectl wait --timeout=600s --for=condition=Available=True -n ${ARGO_NAMESPACE} deployment ${ACD}-argocd-server
kubectl -n ${ARGO_NAMESPACE} get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d && echo
xdg-open "https://localhost:${FORWARD_PORT}?username=admin?password=" &
kubectl port-forward svc/${ACD}-argocd-server -n ${ARGO_NAMESPACE} ${FORWARD_PORT}:443
.PHONY: proxy
proxy: ## creare some minikube proxy and a socat forward to proxy traffic over 443
minikube -n ingress service ingress-ingress-nginx-controller --url
# please set auth.deepcypher.me, deepcypher.me, docs.deepcypher.me api.deepcypher.me to the TCP ip redirected after this message
sudo socat TCP-LISTEN:443,fork TCP:192.168.49.2:30443
.PHONY: uninstall
uninstall:
uninstall: ## uninstall this bootstrap but this will not remove argocd as it needs to reconcile
helm uninstall --namespace ${ARGO_NAMESPACE} init
helm uninstall --namespace ${ARGO_NAMESPACE} ${ACD}
.PHONY: upgrade
upgrade:
helm upgrade --namespace ${ARGO_NAMESPACE} init ${CHART_DIR_PATH_ARGO}
upgrade: ## upgrade both argocd and the bootstrap
helm upgrade --namespace ${ARGO_NAMESPACE} -f argo-values.yaml ${ACD} argocd/argo-cd --version ${ACD_VERSION}
helm upgrade --namespace ${ARGO_NAMESPACE} --set="type=${KUBE_TYPE}" init ${CHART_DIR_PATH_ARGO}
.PHONY: template
template:
helm template --set namespace.name=${ARGO_NAMESPACE} --set namespace.create=true ${CHART_DIR_PATH_ARGO}/. > spec.yaml
less spec.yaml
.PHONY: login
login: login.lock
login.lock:
podman login ${REGISTRY}
kubectl create -n ${DEEPCYOHER_NAMESPACE} secret generic ${REGCRED_NAME} --from-file=.dockerconfigjson=${REGISTRY_AUTH_FILE} --type=kubernetes.io/dockerconfigjson --dry-run=client -o yaml > login.creds
touch login.lock
.PHONY: patch-regcred
patch-regcred: login.lock
kubectl apply -f login.creds
.PHONY: minikube
minikube:
minikube: ## create a minikube cluster by first deleting minikube then creating a new one with calico etc
minikube delete
minikube start --kubernetes-version=v1.25.2
minikube start --cni calico --driver=podman --kubernetes-version=${MINIKUBE_KUBE_VERSION}
# minikube addons enable ingress
# OR forward URL and edit /etc/hosts to point to 127.0.0.1
# minikube -n ingress service ingress-ingress-nginx-controller --url
# sudo socat TCP-LISTEN:443,fork TCP:<URL>:30443
.PHONY: perm
perm:
sudo usermod -aG docker ${USER}
.PHONY: unperm
unperm:
sudo gpasswd -d ${USER} docker
.PHONY: clean
clean:
rm -f login.lock login.creds
docker logout ${REGISTRY}
minikube delete
# THIS IS VERY IMPORTANT PLEASE FOR THE LOVE OF GOD BACK THIS UP
# You need this master key to be able to decrypt your secrets in the cluster in future
master.key:
kubectl -n sealed-secrets get secret -l sealedsecrets.bitnami.com/sealed-secrets-key -o yaml > master.key
.PHONY: stuck
stuck:
stuck: ## find stuck resources in argocd namespace
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n ${ARGO_NAMESPACE}
.PHONY: argotunnel
argotunnel: master.key ## Generate encrypted cloudflared argo tunnel for this cluster
cloudflared tunnel create metal --output yaml --credentials-file ${CLOUDFLARED_TUNNEL_CRED_FILE}
kubectl create secret generic tunnel-credentials --from-file=credentials.json=${CLOUDFLARED_TUNNEL_CRED_FILE} --dry-run=client -o yaml > ${CLUSTER_NAME}.cloudflared.yaml

21
argocd-values.yaml Normal file
View File

@@ -0,0 +1,21 @@
redis-ha:
enabled: true
controller:
replicas: 3
server:
autoscaling:
enabled: true
minReplicas: 2
repoServer:
autoscaling:
enabled: true
minReplicas: 2
applicationSet:
replicaCount: 2
dex:
enabled: false

View File

@@ -1,7 +1,3 @@
# @Author: George Onoufriou <archer>
# @Date: 2021-11-26T16:13:56+00:00
# @Last modified by: archer
# @Last modified time: 2021-11-26T16:33:43+00:00
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:

View File

@@ -1,35 +1,30 @@
# @Author: George Onoufriou <archer>
# @Date: 2021-11-26T16:56:36+00:00
# @Last modified by: archer
# @Last modified time: 2021-12-10T13:00:50+00:00
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: exp-mongodb-app
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
name: ''
namespace: exp-mongodb
server: 'https://kubernetes.default.svc'
source:
path: charts/experimental-mongodb
repoURL: 'https://gitlab.com/deepcypher/dc-kc.git'
targetRevision: HEAD
helm:
values: |-
exmongo:
persistence:
size: {{ .Values.exmongo.persistence.size }}
tls:
mode: preferTLS
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
#apiVersion: argoproj.io/v1alpha1
#kind: Application
#metadata:
# name: exp-mongodb-app
# namespace: argocd
# finalizers:
# - resources-finalizer.argocd.argoproj.io
#spec:
# destination:
# name: ''
# namespace: exp-mongodb
# server: 'https://kubernetes.default.svc'
# source:
# path: charts/experimental-mongodb
# repoURL: 'https://gitlab.com/deepcypher/dc-kc.git'
# targetRevision: HEAD
# helm:
# values: |-
# exmongo:
# persistence:
# size: {{ .Values.exmongo.persistence.size }}
# tls:
# mode: preferTLS
# project: default
# syncPolicy:
# automated:
# prune: true
# selfHeal: true
# syncOptions:
# - CreateNamespace=true

View File

@@ -1,46 +1,46 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: jellyfin-app
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
name: ''
namespace: jellyfin
server: 'https://kubernetes.default.svc'
source:
path: jellyfin
repoURL: 'https://gitlab.com/deepcypher/jellyfin-helm.git'
targetRevision: {{ .Values.jellyfinHelm.branch | default .Values.global.branch | quote}}
helm:
values: |-
persist: {{ .Values.jellyfinHelm.persist }}
ingress:
enable: {{ .Values.jellyfinHelm.ingress.enable }}
pvc:
- name: jellyfin-media-pvc
mount: /data/media
storageClassName: {{ .Values.jellyfinHelm.mediaClass }}
volumeName: jellyfin-media-pv
readOnly: True
size: {{ .Values.jellyfinHelm.mediaSize }}
accessModes:
- ReadOnlyMany
- name: jellyfin-config-pvc
mount: /config
storageClassName: {{ .Values.jellyfinHelm.configClass }}
volumeName: jellyfin-config-pv
readOnly: False
size: {{ .Values.jellyfinHelm.configSize }}
accessModes:
- ReadWriteOnce
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
#apiVersion: argoproj.io/v1alpha1
#kind: Application
#metadata:
# name: jellyfin-app
# namespace: argocd
# finalizers:
# - resources-finalizer.argocd.argoproj.io
#spec:
# destination:
# name: ''
# namespace: jellyfin
# server: 'https://kubernetes.default.svc'
# source:
# path: jellyfin
# repoURL: 'https://gitlab.com/deepcypher/jellyfin-helm.git'
# targetRevision: {{ .Values.jellyfinHelm.branch | default .Values.global.branch | quote}}
# helm:
# values: |-
# persist: {{ .Values.jellyfinHelm.persist }}
# ingress:
# enable: {{ .Values.jellyfinHelm.ingress.enable }}
# pvc:
# - name: jellyfin-media-pvc
# mount: /data/media
# storageClassName: {{ .Values.jellyfinHelm.mediaClass }}
# volumeName: jellyfin-media-pv
# readOnly: True
# size: {{ .Values.jellyfinHelm.mediaSize }}
# accessModes:
# - ReadOnlyMany
# - name: jellyfin-config-pvc
# mount: /config
# storageClassName: {{ .Values.jellyfinHelm.configClass }}
# volumeName: jellyfin-config-pv
# readOnly: False
# size: {{ .Values.jellyfinHelm.configSize }}
# accessModes:
# - ReadWriteOnce
# project: default
# syncPolicy:
# automated:
# prune: true
# selfHeal: true
# syncOptions:
# - CreateNamespace=true
#

View File

@@ -1,28 +1,23 @@
# @Author: George Onoufriou <archer>
# @Date: 2021-11-26T16:56:36+00:00
# @Last modified by: archer
# @Last modified time: 2021-11-26T17:25:47+00:00
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: nextcloud-app
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
name: ''
namespace: nextcloud
server: 'https://kubernetes.default.svc'
source:
path: charts/dc-nextcloud
repoURL: 'https://gitlab.com/deepcypher/dc-kc.git'
targetRevision: HEAD
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
#apiVersion: argoproj.io/v1alpha1
#kind: Application
#metadata:
# name: nextcloud-app
# namespace: argocd
# finalizers:
# - resources-finalizer.argocd.argoproj.io
#spec:
# destination:
# name: ''
# namespace: nextcloud
# server: 'https://kubernetes.default.svc'
# source:
# path: charts/dc-nextcloud
# repoURL: 'https://gitlab.com/deepcypher/dc-kc.git'
# targetRevision: HEAD
# project: default
# syncPolicy:
# automated:
# prune: true
# selfHeal: true
# syncOptions:
# - CreateNamespace=true

View File

@@ -30,7 +30,7 @@ version: 0.1.0
# It is recommended to use it with quotes.
appVersion: "0.1.0"
# dependencies:
# - name: cert-manager
# version: "v1.7.2"
# repository: "https://charts.jetstack.io"
dependencies:
- name: cert-manager
version: "v1.12.2"
repository: "https://charts.jetstack.io"

View File

@@ -1,24 +0,0 @@
apiVersion: v2
name: dc-template
description: DeepCypher AoA template cluster decleration
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.0"

View File

@@ -1,23 +0,0 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -1,22 +0,0 @@
{{- /*
# Metallb IP Address Pool Custom Resource
# https://metallb.universe.tf/concepts/layer2/
# https://metallb.universe.tf/configuration/
# Purpose:
# - Tell metallb what pool of IPs it can use in L2 Mode
# - Allow for easy reconfiguration with helm variables
# - Optional; does not force user into using anything in particular
*/}}
{{- if and .Values.metallb.enable .Values.metallb.l2.enable }}
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: {{ .Values.metallb.l2.pool.name }}
namespace: {{ .Values.metallb.namespace }}
spec:
addresses:
{{- range .Values.metallb.l2.pool.addresses }}
- {{ . }}
{{- end }}
{{- end }}

View File

@@ -1,20 +0,0 @@
{{- /*
# Metallb L2 Advertisement Custom Resource
# https://metallb.universe.tf/concepts/layer2/
# https://metallb.universe.tf/configuration/
# Purpose:
# - Tell metallb what pool of IPs it can use in L2 Mode
# - Allow for easy reconfiguration with helm variables
# - Optional; does not force user into using anything in particular
*/}}
{{- if and .Values.metallb.enable .Values.metallb.l2.enable }}
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: {{ .Values.metallb.l2.config.name }}
namespace: {{ .Values.metallb.namespace }}
spec:
ipAddressPools:
- {{ .Values.metallb.l2.pool.name }}
{{- end }}

View File

@@ -1,17 +0,0 @@
global:
metallb:
namespace: metallb-system
enable: true
l2:
config:
name: metallb-l2-config
# whether to enable level 2 mode in metallb
enable: false
pool:
name: metallb-default-pool
# what addresses pr address ranges to use for the ARP requests
# this is a list so put in as many as desired
# please also eliminate the square brackets when you do as placeholding
addresses: []
# - 192.168.4.240-192.168.4.250

View File

@@ -1,7 +1,7 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: aoa
name: apps
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io

View File

@@ -12,13 +12,11 @@ spec:
server: 'https://kubernetes.default.svc'
source:
path: ''
repoURL: 'https://charts.jetstack.io'
targetRevision: v1.9.1
repoURL: 'https://kubernetes.github.io/ingress-nginx'
targetRevision: 4.3.0
chart: cert-manager
helm:
parameters:
- name: installCRDs
value: 'true'
#helm:
# values: |
project: default
syncPolicy:
automated:

View File

@@ -1,23 +0,0 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: cert-pki
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
name: ''
namespace: certs
server: 'https://kubernetes.default.svc'
source:
path: charts/cert-pki
repoURL: 'https://gitlab.com/deepcypher/dc-kc.git'
targetRevision: {{ .Values.certPKI.branch | default .Values.global.branch | quote}}
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true

View File

@@ -20,7 +20,8 @@ spec:
values: |
controller:
service:
type: NodePort
externalTrafficPolicy: "Local"
#type: NodePort
nodePorts:
http: 30080
https: 30443
@@ -28,16 +29,6 @@ spec:
enabled: true
minReplicas: 3
maxReplicas: 5
# # These are the old values from bitnami ingress-nginx
# service:
# type: NodePort
# nodePorts:
# http: 30080
# https: 30443
# autoscaling:
# enabled: true
# minReplicas: 3
# maxReplicas: 5
project: default
syncPolicy:
automated:

View File

@@ -1,40 +0,0 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: metallb-config
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
name: ''
namespace: metallb-system
server: 'https://kubernetes.default.svc'
source:
path: charts/infra-metallb
repoURL: 'https://gitlab.com/deepcypher/dc-kc.git'
targetRevision: {{ .Values.metallb.branch | default .Values.global.branch | quote}}
helm:
values: |-
metallb:
namespace: metallb-system
enable: true
l2:
config:
name: metallb-l2-config
# whether to enable level 2 mode in metallb
enable: true
pool:
name: metallb-default-pool
# what addresses pr address ranges to use for the ARP requests
# this is a list so put in as many as desired
# please also eliminate the square brackets when you do as placeholding
addresses:
- 192.168.4.240-192.168.4.250
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true

View File

@@ -1,7 +1,7 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: metallb
name: apps
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
@@ -11,10 +11,13 @@ spec:
namespace: metallb-system
server: 'https://kubernetes.default.svc'
source:
path: ''
repoURL: 'https://metallb.github.io/metallb'
targetRevision: 0.13.5
chart: metallb
path: charts/metallb
repoURL: 'https://gitlab.com/deepcypher/dc-kc.git'
targetRevision: HEAD
helm:
values: |-
global:
branch: HEAD
project: default
syncPolicy:
automated:

View File

@@ -1,30 +0,0 @@
#apiVersion: argoproj.io/v1alpha1
#kind: Application
#metadata:
# # name: argo-cd-argocd
# name: argocd
# namespace: argocd
# finalizers:
# - resources-finalizer.argocd.argoproj.io
#spec:
# destination:
# name: ''
# namespace: argocd
# server: 'https://kubernetes.default.svc'
# source:
# path: ''
# repoURL: 'https://argoproj.github.io/argo-helm/'
# targetRevision: 5.5.6
# chart: argo-cd
# helm:
# values: |-
# installCRDs: true
# dex:
# enabled: false
# project: default
# syncPolicy:
# automated:
# prune: true
# selfHeal: true
# syncOptions:
# - CreateNamespace=true

View File

@@ -1,5 +1,5 @@
apiVersion: v2
name: infra-metallb
name: metallb
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
@@ -22,3 +22,9 @@ version: 0.1.0
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
dependencies:
- name: metallb
version: 0.13.10
repository: "https://metallb.github.io/metallb"

View File

@@ -0,0 +1,8 @@
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: service-pool
namespace: metallb-system
spec:
addresses:
- 192.168.10.250/32

View File

@@ -0,0 +1,8 @@
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: arp
namespace: metallb-system
spec:
ipAddressPools:
- service-pool