chicken and egg solved

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
Andrei Kvapil
2023-12-29 20:29:15 +01:00
parent f288d9f246
commit a7f5c4aba9
39 changed files with 284 additions and 67 deletions

View File

@@ -152,5 +152,17 @@ Run [talos-bootstrap](https://github.com/aenix-io/talos-bootstrap/) to deploy cl
Install cozystack system components:
```
kubectl apply -f cozystack.yaml
kubectl apply -f cozystack-installer.yaml
```
### Dependencies chart
- **core/installer**
- core/cilium
- core/kubeovn
- core/fluxcd
- **core/fluxcd-release**
- core/cilium
- core/kubeovn
- core/fluxcd
- system/*

1
packages/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
repos/**

View File

@@ -1,3 +1,3 @@
apply show diff:
apply show diff repo:
make -C core $@
make -C system $@

View File

@@ -0,0 +1,2 @@
name: cozystack
version: 0.0.0

2
packages/config/Makefile Normal file
View File

@@ -0,0 +1,2 @@
collect:

View File

@@ -1,5 +1,16 @@
apply show diff prepare:
REPO=core
apply show diff:
make -C namespaces $@
make -C cilium $@
make -C kubeovn $@
make -C fluxcd $@
repo: fix-chartnames
rm -rf ../repos/$(REPO)
mkdir -p ../repos/$(REPO)
cd ../repos/$(REPO) && helm package $$(find ../../$(REPO) -mindepth 2 -maxdepth 2 -name Chart.yaml | awk 'sub("/Chart.yaml", "")')
cd ../repos/$(REPO) && helm repo index .
fix-chartnames:
find . -name Chart.yaml -maxdepth 2 | awk -F/ '{print $$2}' | while read i; do printf "name: cozy-%s\nversion: 1.0.0\n" "$$i" > "$$i/Chart.yaml"; done

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-cilium
version: 1.0.0

View File

@@ -0,0 +1,2 @@
name: cozy-fluxcd-releases
version: 1.0.0

View File

@@ -0,0 +1,19 @@
NAMESPACE=cozy-system
NAME=fluxcd-releases
show:
helm template -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased -n $(NAMESPACE) $(NAME) .
update:
rm -rf charts
helm repo add cilium https://helm.cilium.io/
helm repo update cilium
helm pull cilium/cilium --untar --untardir charts
sed -i -e '/Used in iptables/d' -e '/SYS_MODULE/d' charts/cilium/values.yaml
patch -p3 < patches/fix-cgroups.patch

View File

@@ -0,0 +1,76 @@
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: cilium
namespace: cozy-cilium
spec:
interval: 1m
releaseName: cilium
chart:
spec:
chart: cozy-cilium
sourceRef:
kind: HelmRepository
name: cozystack-core
namespace: cozy-system
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: kubeovn
namespace: cozy-kubeovn
spec:
interval: 1m
releaseName: kubeovn
chart:
spec:
chart: cozy-kubeovn
sourceRef:
kind: HelmRepository
name: cozystack-core
namespace: cozy-system
dependsOn:
- name: cilium
namespace: cozy-cilium
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: cozy-fluxcd
namespace: cozy-fluxcd
spec:
interval: 1m
releaseName: fluxcd
chart:
spec:
chart: cozy-fluxcd
sourceRef:
kind: HelmRepository
name: cozystack-core
namespace: cozy-system
dependsOn:
- name: cilium
namespace: cozy-cilium
- name: kubeovn
namespace: cozy-kubeovn
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: cozy-telepresence
namespace: cozy-telepresence
spec:
interval: 1m
releaseName: traffic-manager
chart:
spec:
chart: cozy-telepresence
sourceRef:
kind: HelmRepository
name: cozystack-system
namespace: cozy-system
dependsOn:
- name: cilium
namespace: cozy-cilium
- name: kubeovn
namespace: cozy-kubeovn

View File

@@ -0,0 +1,18 @@
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: cozystack-core
namespace: cozy-system
spec:
interval: 5m0s
url: http://cozystack.cozy-system.svc/core
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: cozystack-system
namespace: cozy-system
spec:
interval: 5m0s
url: http://cozystack.cozy-system.svc/system

View File

@@ -1,2 +1,2 @@
name: core
version: 0.0.0
name: cozy-fluxcd
version: 1.0.0

View File

@@ -0,0 +1,2 @@
name: cozy-installer
version: 1.0.0

View File

@@ -0,0 +1,14 @@
NAMESPACE=cozy-installer
NAME=installer
show:
helm template -n $(NAMESPACE) $(NAME) .
apply:
helm template -n $(NAMESPACE) $(NAME) . | kubectl apply -f -
diff:
helm template -n $(NAMESPACE) $(NAME) . | kubectl diff -f -
image:
docker build -f images/installer/Dockerfile ../../..

View File

@@ -0,0 +1,12 @@
FROM alpine:3.19
RUN apk add --no-cache make darkhttpd
RUN apk add helm kubectl --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
COPY packages /cozystack/packages
RUN make -C /cozystack/packages/core repo
RUN make -C /cozystack/packages/system repo
RUN ln -s /cozystack/packages/core/installer/images/installer/scripts /scripts
ENTRYPOINT [ "/scripts/run.sh" ]

View File

@@ -0,0 +1,29 @@
#!/bin/sh
set -o pipefail
set -e
run_migrations() {
return 0
}
flux_is_ok() {
kubectl wait --for=condition=available -n cozy-fluxcd deploy/source-controller deploy/helm-controller --timeout=10s
}
install_core_charts() {
make -C /cozystack/packages/core/namespaces apply
make -C /cozystack/packages/core/cilium apply
make -C /cozystack/packages/core/kubeovn apply
make -C /cozystack/packages/core/fluxcd apply
}
if ! flux_is_ok; then
install_core_charts
fi
run_migrations
make -C /cozystack/packages/core/fluxcd-releases apply
tail -f /dev/null &
wait

View File

@@ -50,14 +50,37 @@ spec:
serviceAccountName: cozystack
containers:
- name: cozystack
image: ghcr.io/kvaps/test:cozystack-10
command: [ "/cozystack-system/reconcile.sh" ]
image: ghcr.io/kvaps/test:cozystack-installer-0
env:
- name: KUBERNETES_SERVICE_HOST
value: localhost
- name: KUBERNETES_SERVICE_PORT
value: "7445"
- name: darkhttpd
image: ghcr.io/kvaps/test:cozystack-installer-0
command:
- /usr/bin/darkhttpd
- /cozystack/packages/repos
- --port
- "8123"
ports:
- name: http
containerPort: 8123
tolerations:
- key: "node.kubernetes.io/not-ready"
operator: "Exists"
effect: "NoSchedule"
---
apiVersion: v1
kind: Service
metadata:
name: cozystack
namespace: cozy-system
spec:
ports:
- name: http
port: 80
targetPort: 8123
selector:
app: cozystack
type: ClusterIP

View File

@@ -1,2 +1,2 @@
name: core
version: 0.0.0
name: cozy-kubeovn
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-namespaces
version: 1.0.0

View File

@@ -1,17 +0,0 @@
FROM alpine:3.19
ARG HELMWAVE_VERSION=0.33.0
RUN wget -c https://github.com/helmwave/helmwave/releases/download/v$HELMWAVE_VERSION/helmwave_${HELMWAVE_VERSION}_linux_amd64.tar.gz -O - | tar -xz \
&& mv helmwave /usr/local/bin/
ARG KUBECTL_VERSION=1.29.0
RUN wget https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl \
&& chmod +x kubectl \
&& mv kubectl /usr/local/bin/
COPY . /cozystack-system
WORKDIR /cozystack-system
CMD [ "reconcile.sh" ]

View File

@@ -1,4 +1,6 @@
apply show diff prepare:
REPO=system
apply show diff:
make -C cert-manager $@
make -C cert-manager-issuers $@
make -C victoria-metrics-operator $@
@@ -16,3 +18,12 @@ apply show diff prepare:
make -C telepresence $@
make -C ingress-nginx $@
make -C kubeapps $@
repo: fix-chartnames
rm -rf ../repos/$(REPO)
mkdir -p ../repos/$(REPO)
cd ../repos/$(REPO) && helm package $$(find ../../$(REPO) -mindepth 2 -maxdepth 2 -name Chart.yaml | awk 'sub("/Chart.yaml", "")')
cd ../repos/$(REPO) && helm repo index .
fix-chartnames:
find . -name Chart.yaml -maxdepth 2 | awk -F/ '{print $$2}' | while read i; do printf "name: cozy-%s\nversion: 1.0.0\n" "$$i" > "$$i/Chart.yaml"; done

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-cert-manager-issuers
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-cert-manager
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-grafana-operator
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-ingress-nginx
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-kubeapps
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-kubevirt-operator
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-kubevirt
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-linstor
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-mariadb-operator
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-metallb-addresses
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-metallb
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-monitoring
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-piraeus-operator
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-postgres-operator
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-rabbitmq-operator
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-redis-operator
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-telepresence
version: 1.0.0

View File

@@ -1,2 +1,2 @@
name: cozystack
version: 0.0.0
name: cozy-victoria-metrics-operator
version: 1.0.0