Skip to content

Commit b049f01

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

8 files changed

Lines changed: 211 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: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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={{ .Values.cozystackOperator.platformSource }}
65+
env:
66+
- name: KUBERNETES_SERVICE_HOST
67+
value: localhost
68+
- name: KUBERNETES_SERVICE_PORT
69+
value: "7445"
70+
hostNetwork: true
71+
tolerations:
72+
- key: "node.kubernetes.io/not-ready"
73+
operator: "Exists"
74+
effect: "NoSchedule"
75+
- key: "node.cilium.io/agent-not-ready"
76+
operator: "Exists"
77+
effect: "NoSchedule"
78+
---
79+
apiVersion: cozystack.io/v1alpha1
80+
kind: PackageSource
81+
metadata:
82+
name: cozystack.cozystack-platform
83+
spec:
84+
sourceRef:
85+
kind: OCIRepository
86+
name: cozystack-packages
87+
namespace: cozy-system
88+
path: /
89+
variants:
90+
- name: default
91+
components:
92+
- install:
93+
namespace: cozy-system
94+
releaseName: cozystack-platform
95+
name: cozystack-platform
96+
path: core/platform
97+
valuesFiles:
98+
- values.yaml
99+
- name: isp-full
100+
components:
101+
- install:
102+
namespace: cozy-system
103+
releaseName: cozystack-platform
104+
name: cozystack-platform
105+
path: core/platform
106+
valuesFiles:
107+
- values.yaml
108+
- values-isp-full.yaml
109+
- name: isp-hosted
110+
components:
111+
- install:
112+
namespace: cozy-system
113+
releaseName: cozystack-platform
114+
name: cozystack-platform
115+
path: core/platform
116+
valuesFiles:
117+
- values.yaml
118+
- values-isp-hosted.yaml
119+
{{- 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
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+
platformSource: 'oci://ghcr.io/cozystack/cozystack/platform-packages@sha256:0576491291b33936cdf770a5c5b5692add97339c1505fc67a92df9d69dfbfdf6'
7+
cozystackVersion: latest

0 commit comments

Comments
 (0)