Skip to content

Commit c43db3b

Browse files
committed
[cozystack-operator] Add deployment files
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent d7931fd commit c43db3b

8 files changed

Lines changed: 215 additions & 2 deletions

File tree

‎packages/core/installer/Makefile‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,31 @@ image-cozystack:
2727
IMAGE="$(REGISTRY)/installer:$(call settag,$(TAG))@$$(yq e '."containerimage.digest"' images/installer.json -o json -r)" \
2828
yq -i '.cozystack.image = strenv(IMAGE)' values.yaml
2929
rm -f images/installer.json
30+
31+
update-version:
32+
TAG="$(call settag,$(TAG))" \
33+
yq -i '.cozystackOperator.cozystackVersion = strenv(TAG)' values.yaml
34+
35+
image-operator:
36+
docker buildx build -f images/cozystack-operator/Dockerfile ../../.. \
37+
--tag $(REGISTRY)/cozystack-operator:$(call settag,$(TAG)) \
38+
--cache-from type=registry,ref=$(REGISTRY)/cozystack-operator:latest \
39+
--cache-to type=inline \
40+
--metadata-file images/cozystack-operator.json \
41+
$(BUILDX_ARGS)
42+
IMAGE="$(REGISTRY)/cozystack-operator:$(call settag,$(TAG))@$$(yq e '."containerimage.digest"' images/cozystack-operator.json -o json -r)" \
43+
yq -i '.cozystackOperator.image = strenv(IMAGE)' values.yaml
44+
rm -f images/cozystack-operator.json
45+
46+
47+
image-packages: update-version
48+
mkdir -p ../../../_out/assets images
49+
flux push artifact \
50+
oci://$(REGISTRY)/platform-packages:$(call settag,$(TAG)) \
51+
--path=../../../packages \
52+
--source=https://github.com/cozystack/cozystack \
53+
--revision="$$(git describe --tags):$$(git rev-parse HEAD)" \
54+
2>&1 | tee images/cozystack-packages.log
55+
export REPO="oci://$(REGISTRY)/platform-packages"; \
56+
export DIGEST=$$(awk -F@ '/artifact successfully pushed/ {print $$2}' images/cozystack-packages.log; rm -f images/cozystack-packages.log); \
57+
test -n "$$DIGEST" && yq -i '.cozystackOperator.platformSource = (strenv(REPO) + "@" + strenv(DIGEST))' values.yaml
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
apiVersion: cozystack.io/v1alpha1
3+
kind: Package
4+
metadata:
5+
name: cozystack.cozystack-platform
6+
spec:
7+
variant: isp-full
8+
components:
9+
platform:
10+
values:
11+
publishing:
12+
host: "dev5.infra.aenix.org"
13+
apiServerEndpoint: "https://api.dev5.infra.aenix.org"
14+
externalIPs:
15+
- 10.4.0.94
16+
- 10.4.0.179
17+
- 10.4.0.26
18+
authentication:
19+
oidc:
20+
enabled: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM golang:1.25-alpine as builder
2+
3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
6+
RUN apk add --no-cache make git
7+
8+
COPY . /src/
9+
WORKDIR /src
10+
11+
RUN go mod download
12+
13+
# Build cozystack-operator
14+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
15+
-ldflags="-w -s" \
16+
-o /cozystack-operator \
17+
./cmd/cozystack-operator
18+
19+
FROM alpine:3.22
20+
21+
COPY --from=builder /cozystack-operator /usr/bin/cozystack-operator
22+
23+
ENTRYPOINT ["/usr/bin/cozystack-operator"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Exclude everything except src directory
2+
*
3+
!src/**
4+
!api/**
5+
!cmd/**
6+
!hack/**
7+
!internal/**
8+
!packages/**
9+
!pkg/**
10+
!scripts/**
11+
!go.mod
12+
!go.sum
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{{- if .Values.cozystackOperator.enabled }}
2+
---
3+
apiVersion: v1
4+
kind: Namespace
5+
metadata:
6+
name: cozy-system
7+
labels:
8+
cozystack.io/system: "true"
9+
pod-security.kubernetes.io/enforce: privileged
10+
---
11+
apiVersion: v1
12+
kind: ServiceAccount
13+
metadata:
14+
name: cozystack
15+
namespace: cozy-system
16+
---
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: ClusterRoleBinding
19+
metadata:
20+
name: cozystack
21+
subjects:
22+
- kind: ServiceAccount
23+
name: cozystack
24+
namespace: cozy-system
25+
roleRef:
26+
kind: ClusterRole
27+
name: cluster-admin
28+
apiGroup: rbac.authorization.k8s.io
29+
---
30+
apiVersion: apps/v1
31+
kind: Deployment
32+
metadata:
33+
name: cozystack-operator
34+
namespace: cozy-system
35+
spec:
36+
replicas: 1
37+
selector:
38+
matchLabels:
39+
app: cozystack-operator
40+
strategy:
41+
type: RollingUpdate
42+
rollingUpdate:
43+
maxSurge: 0
44+
maxUnavailable: 1
45+
template:
46+
metadata:
47+
labels:
48+
app: cozystack-operator
49+
spec:
50+
serviceAccountName: cozystack
51+
containers:
52+
- name: cozystack-operator
53+
image: "{{ .Values.cozystackOperator.image }}"
54+
args:
55+
- --leader-elect=true
56+
- --install-flux=true
57+
- --metrics-bind-address=0
58+
- --health-probe-bind-address=
59+
- --cozystack-version={{ .Values.cozystackOperator.cozystackVersion }}
60+
{{- if .Values.cozystackOperator.disableTelemetry }}
61+
- --disable-telemetry
62+
{{- end }}
63+
- --platform-source-name=cozystack-platform
64+
- --platform-source-url={{ .Values.cozystackOperator.platformSourceUrl }}
65+
{{- if .Values.cozystackOperator.platformSourceRef }}
66+
- --platform-source-ref={{ .Values.cozystackOperator.platformSourceRef }}
67+
{{- end }}
68+
env:
69+
- name: KUBERNETES_SERVICE_HOST
70+
value: localhost
71+
- name: KUBERNETES_SERVICE_PORT
72+
value: "7445"
73+
hostNetwork: true
74+
tolerations:
75+
- key: "node.kubernetes.io/not-ready"
76+
operator: "Exists"
77+
effect: "NoSchedule"
78+
- key: "node.cilium.io/agent-not-ready"
79+
operator: "Exists"
80+
effect: "NoSchedule"
81+
---
82+
apiVersion: cozystack.io/v1alpha1
83+
kind: PackageSource
84+
metadata:
85+
name: cozystack.cozystack-platform
86+
spec:
87+
sourceRef:
88+
kind: OCIRepository
89+
name: cozystack-packages
90+
namespace: cozy-system
91+
path: /
92+
variants:
93+
- name: default
94+
components:
95+
- install:
96+
namespace: cozy-system
97+
releaseName: cozystack-platform
98+
name: cozystack-platform
99+
path: core/platform
100+
valuesFiles:
101+
- values.yaml
102+
- name: isp-full
103+
components:
104+
- install:
105+
namespace: cozy-system
106+
releaseName: cozystack-platform
107+
name: cozystack-platform
108+
path: core/platform
109+
valuesFiles:
110+
- values.yaml
111+
- values-isp-full.yaml
112+
- name: isp-hosted
113+
components:
114+
- install:
115+
namespace: cozy-system
116+
releaseName: cozystack-platform
117+
name: cozystack-platform
118+
path: core/platform
119+
valuesFiles:
120+
- values.yaml
121+
- values-isp-hosted.yaml
122+
{{- end }}

‎packages/core/installer/templates/cozystack.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.cozystackOperator.enabled }}
12
---
23
apiVersion: v1
34
kind: Namespace
@@ -77,3 +78,4 @@ spec:
7778
- key: "node.cilium.io/agent-not-ready"
7879
operator: "Exists"
7980
effect: "NoSchedule"
81+
{{- end }}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{{/*
1+
{{- if .Values.cozystackOperator.enabled }}
22
{{- range $path, $_ := .Files.Glob "definitions/*.yaml" }}
33
---
44
{{ $.Files.Get $path }}
55
{{- end }}
6-
*/}}
6+
{{- end }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
cozystack:
22
image: ghcr.io/cozystack/cozystack/installer:v0.38.2@sha256:9ff92b655de6f9bea3cba4cd42dcffabd9aace6966dcfb1cc02dda2420ea4a15
3+
cozystackOperator:
4+
enabled: false
5+
image: ghcr.io/cozystack/cozystack/cozystack-operator:latest@sha256:f7f6e0fd9e896b7bfa642d0bfa4378bc14e646bc5c2e86e2e09a82770ef33181
6+
platformSourceUrl: 'oci://ghcr.io/cozystack/cozystack/platform-packages'
7+
platformSourceRef: 'digest=sha256:0576491291b33936cdf770a5c5b5692add97339c1505fc67a92df9d69dfbfdf6'
8+
cozystackVersion: latest

0 commit comments

Comments
 (0)