Skip to content

Commit d0f4e83

Browse files
committed
ci: publish with kustomize
1 parent 6616c1d commit d0f4e83

5 files changed

Lines changed: 25 additions & 34 deletions

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -81,41 +81,24 @@ jobs:
8181
helm chart remove ghcr.io/${{ github.repository_owner }}/betterstack-operator/helm/betterstack-operator:latest
8282
rm -rf "$TMP_DIR"
8383
84-
- name: Install publish dependencies
85-
run: python3 -m pip install --user pyyaml
84+
- name: Set up kustomize
85+
uses: imranismail/setup-kustomize@v1
86+
with:
87+
kustomize-version: '5.1.0'
8688

8789
- name: Publish manifests
8890
env:
8991
VERSION: ${{ steps.meta.outputs.version }}
9092
IMAGE: ${{ steps.meta.outputs.image }}
9193
run: |
9294
set -euo pipefail
93-
python3 - <<'PY'
94-
import os
95-
from pathlib import Path
96-
import yaml
97-
98-
image = f"{os.environ['IMAGE']}:{os.environ['VERSION']}"
99-
src = Path("config/manager/manager.yaml")
100-
docs = list(yaml.safe_load_all(src.read_text()))
101-
102-
for doc in docs:
103-
if not isinstance(doc, dict):
104-
continue
105-
if doc.get("kind") != "Deployment":
106-
continue
107-
spec = doc.get("spec", {})
108-
template = spec.get("template", {})
109-
pod_spec = template.get("spec", {})
110-
for container in pod_spec.get("containers", []):
111-
if container.get("name") == "manager":
112-
container["image"] = image
113-
114-
dist = Path("dist")
115-
dist.mkdir(parents=True, exist_ok=True)
116-
with (dist / "manager.yaml").open("w") as fh:
117-
yaml.safe_dump_all(docs, fh, sort_keys=False)
118-
PY
95+
TMP_DIR=$(mktemp -d)
96+
cp -r config/manager "$TMP_DIR/manager"
97+
pushd "$TMP_DIR/manager" >/dev/null
98+
kustomize edit set image ghcr.io/loks0n/betterstack-operator=$IMAGE:$VERSION
99+
kustomize build . > "$GITHUB_WORKSPACE/dist/manager.yaml"
100+
popd >/dev/null
101+
rm -rf "$TMP_DIR"
119102
cp config/crd/bases/monitoring.betterstack.io_betterstackmonitors.yaml dist/
120103
tar czf dist/betterstack-operator-${VERSION}.tar.gz -C dist manager.yaml monitoring.betterstack.io_betterstackmonitors.yaml
121104

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Create the `betterstack-credentials` secret before running the chart (see Quick
5252
kubectl apply -f config/rbac/service_account.yaml
5353
kubectl apply -f config/rbac/role.yaml
5454
kubectl apply -f config/rbac/role_binding.yaml
55-
kubectl apply -f config/manager/manager.yaml
55+
kubectl apply -k config/manager
5656
```
5757

5858
4. **Create a monitor resource**

config/manager/kustomization.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: system
4+
resources:
5+
- namespace.yaml
6+
- manager.yaml
7+
images:
8+
- name: ghcr.io/loks0n/betterstack-operator
9+
newTag: latest

config/manager/manager.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
apiVersion: v1
2-
kind: Namespace
3-
metadata:
4-
name: system
5-
---
61
apiVersion: apps/v1
72
kind: Deployment
83
metadata:

config/manager/namespace.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: system

0 commit comments

Comments
 (0)