Skip to content

Commit bac9a0a

Browse files
committed
Publish static kro manifests on release
The industry tends to have different descriptions for helm and plain k8s manifests with kustomize. We can notice it in argoCD where they maintain the [manifests](https://github.com/argoproj/argo-cd/blob/master/manifests/core-install.yaml) as well as the helm [chart](https://github.com/argoproj/argo-helm/tree/main/charts/argo-cd) (even in a different repository). When we first tried to generate static manifests using this technique, during the review, a concern was raised about the additional cognitive load and maintenance burden having 2 different deployment methods would introduce. This commit aims at providing static bundles to benefit from static manifests without the additional maintenance burden. It keeps Helm as the source of truth for deployment description and picks a list of well-known values combination to generate static manifests out of it.
1 parent 64da0cb commit bac9a0a

File tree

7 files changed

+172
-26
lines changed

7 files changed

+172
-26
lines changed

.github/workflows/github-release.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
16+
- name: Build static manifests
17+
env:
18+
TAG: ${{ github.ref_name}}
19+
run: |
20+
make render-static-manifests RELEASE_VERSION=${TAG}
21+
1622
- uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # 2.4.1
1723
with:
1824
generate_release_notes: true
25+
files: |
26+
./manifests/rendered/kro-*.yaml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ TODO.*
4444
node_modules/
4545

4646
tools/lsp/client/out/
47+
manifests/rendered

Makefile

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ LDFLAGS="-buildid= -X sigs.k8s.io/release-utils/version.gitVersion=$(GIT_VERSION
4444

4545
WITH_GOFLAGS = GOFLAGS="$(GOFLAGS)"
4646

47+
HELM_STATIC_MANIFESTS_FLAGS ?= --set metadata.includeHelmChart=false --set metadata.includeManagedBy=false --include-crds --namespace kro
48+
49+
ifeq ($(shell uname -s),Darwin)
50+
SED_INPLACE_FLAGS ?= -i ''
51+
else
52+
SED_INPLACE_FLAGS ?= -i
53+
endif
54+
4755
HELM_DIR = ./helm
4856
WHAT ?= unit
4957

@@ -224,17 +232,33 @@ publish-image: ko ## Publish the kro controller images
224232
$(KO) publish --bare github.com/kubernetes-sigs/kro/cmd/controller \
225233
--tags ${RELEASE_VERSION} --sbom=none
226234

235+
.PHONY: inject-helm-version
236+
inject-helm-version:
237+
sed $(SED_INPLACE_FLAGS) 's/tag: .*/tag: "$(RELEASE_VERSION)"/' helm/values.yaml
238+
sed $(SED_INPLACE_FLAGS) 's/version: .*/version: $(RELEASE_VERSION)/' helm/Chart.yaml
239+
sed $(SED_INPLACE_FLAGS) 's/appVersion: .*/appVersion: "$(RELEASE_VERSION)"/' helm/Chart.yaml
240+
227241
.PHONY: package-helm
228-
package-helm: ## Package Helm chart
229-
sed -i 's/tag: .*/tag: "$(RELEASE_VERSION)"/' helm/values.yaml
230-
sed -i 's/version: .*/version: $(RELEASE_VERSION)/' helm/Chart.yaml
231-
sed -i 's/appVersion: .*/appVersion: "$(RELEASE_VERSION)"/' helm/Chart.yaml
242+
package-helm: inject-helm-version ## Package Helm chart
232243
${HELM} package helm
233244

234245
.PHONY: publish-helm
235246
publish-helm: ## Helm publish
236247
${HELM} push ./kro-${RELEASE_VERSION}.tgz oci://${HELM_IMAGE}
237248

249+
.PHONY: render-static-manifests
250+
render-static-manifests: inject-helm-version
251+
mkdir -p manifests/rendered
252+
@command -v yq >/dev/null 2>&1 || { echo >&2 "yq is required but not installed. Please install yq v4+"; exit 1; }
253+
@variants=$$(yq -r '.variants[].name' manifests/variants.yaml); \
254+
for v in $$variants; do \
255+
echo "Rendering variant: $$v"; \
256+
tmpfile=$$(mktemp); \
257+
yq -r ".variants[] | select(.name==\"$${v}\") | .values" manifests/variants.yaml > $$tmpfile; \
258+
${HELM} template ${HELM_STATIC_MANIFESTS_FLAGS} --set image.tag=${RELEASE_VERSION} -f $$tmpfile kro ./helm > manifests/rendered/$${v}.yaml; \
259+
rm -f $$tmpfile; \
260+
done
261+
238262
.PHONY:
239263
release: build-image publish-image package-helm publish-helm
240264

helm/templates/_helpers.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ Create the name of the service account to use
4545
Common labels
4646
*/}}
4747
{{- define "kro.labels" -}}
48+
{{- if .Values.metadata.includeHelmChart }}
4849
helm.sh/chart: {{ include "kro.chart" . }}
50+
{{- end }}
4951
{{ include "kro.selectorLabels" . }}
5052
{{- if .Chart.AppVersion }}
5153
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
5254
{{- end }}
55+
{{- if .Values.metadata.includeManagedBy }}
5356
app.kubernetes.io/managed-by: {{ .Release.Service }}
57+
{{- end }}
5458
app.kubernetes.io/component: controller
5559
app.kubernetes.io/part-of: kro
5660
{{- if .Values.additionalLabels }}

helm/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ fullnameOverride: ""
77
additionalLabels: {}
88
# app: kro
99

10+
metadata:
11+
includeHelmChart: true
12+
includeManagedBy: true
13+
1014
image:
1115
# The location of the container image repository
1216
repository: registry.k8s.io/kro/kro

manifests/variants.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
variants:
2+
- name: kro-core-install-manifests
3+
values:
4+
rbac:
5+
mode: aggregation
6+
- name: kro-unrestricted-manifests
7+
values:
8+
rbac:
9+
mode: unrestricted
10+
legacy: true
11+
- name: kro-core-install-manifests-with-prometheus
12+
values:
13+
rbac:
14+
mode: aggregation
15+
metrics:
16+
service:
17+
create: true
18+
serviceMonitor:
19+
enabled: true
20+
- name: kro-unrestricted-manifests-with-prometheus
21+
values:
22+
rbac:
23+
mode: unrestricted
24+
legacy: true
25+
metrics:
26+
service:
27+
create: true
28+
serviceMonitor:
29+
enabled: true

website/docs/docs/getting-started/01-Installation.md

Lines changed: 98 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,45 @@ cluster using Helm.
99

1010
## Prerequisites
1111

12-
Before you begin, ensure you have the following:
13-
14-
1. `Helm` 3.x installed
15-
2. `kubectl` installed and configured to interact with your Kubernetes cluster
16-
17-
## Installation Steps
18-
1912
:::info[**Alpha Stage**]
2013

2114
kro is currently in alpha stage. While the images are publicly available, please
2215
note that the software is still under active development and APIs may change.
2316

2417
:::
2518

26-
### Install kro using Helm
19+
Before you begin, ensure you have the following:
20+
21+
1. `Helm` 3.x installed (for helm based installation)
22+
2. `kubectl` installed and configured to interact with your Kubernetes cluster
23+
3. chose the version you want to install or fetch the latest release from GitHub
24+
Fetch the latest release version from GitHub
25+
```sh
26+
export KRO_VERSION=$(curl -sL \
27+
https://api.github.com/repos/kubernetes-sigs/kro/releases/latest | \
28+
jq -r '.tag_name | ltrimstr("v")'
29+
)
30+
```
31+
Validate `KRO_VERSION` populated with a version
32+
```
33+
echo $KRO_VERSION
34+
```
35+
4. For kubectl installation, select the variant you want to install
36+
| variant | Prometheus scrape config | Kro permissions |
37+
| ------------------------------------------ | ------------------------ | --------------- |
38+
| kro-core-install-manifests | Not installed | least privilege |
39+
| kro-core-install-manifests-with-prometheus | Installed | least privilege |
40+
| kro-unrestricted-manifests | Not installed | cluster admin |
41+
| kro-unrestricted-manifests-with-prometheus | Installed | cluster admin |
42+
43+
## Installation with helm
44+
45+
### Installation Steps
46+
47+
#### Install kro using Helm
2748

2849
Once authenticated, install kro using the Helm chart:
2950

30-
Fetch the latest release version from GitHub
31-
```sh
32-
export KRO_VERSION=$(curl -sL \
33-
https://api.github.com/repos/kubernetes-sigs/kro/releases/latest | \
34-
jq -r '.tag_name | ltrimstr("v")'
35-
)
36-
```
37-
Validate `KRO_VERSION` populated with a version
38-
```
39-
echo $KRO_VERSION
40-
```
4151
Install kro using Helm
4252
```
4353
helm install kro oci://registry.k8s.io/kro/charts/kro \
@@ -46,7 +56,7 @@ helm install kro oci://registry.k8s.io/kro/charts/kro \
4656
--version=${KRO_VERSION}
4757
```
4858

49-
## Verifying the Installation
59+
### Verifying the Installation
5060

5161
After running the installation command, verify that Kro has been installed
5262
correctly:
@@ -73,7 +83,7 @@ correctly:
7383
kro-7d98bc6f46-jvjl5 1/1 Running 0 1s
7484
```
7585

76-
## Upgrading kro
86+
### Upgrading kro
7787

7888
To upgrade to a newer version of kro, use the Helm upgrade command:
7989

@@ -97,7 +107,7 @@ documentation.
97107

98108
:::
99109

100-
## Uninstalling kro
110+
### Uninstalling kro
101111

102112
To uninstall kro, use the following command:
103113

@@ -108,3 +118,69 @@ helm uninstall kro -n kro
108118
Keep in mind that this command will remove all kro resources from your cluster,
109119
except for the ResourceGraphDefinition CRD and any other custom resources you may have
110120
created.
121+
122+
## Installation with kubectl
123+
124+
### Installation Steps
125+
126+
#### Install kro using Kubectl
127+
128+
Select the variant you want (see available variants in [prerequisites](#prerequisites))
129+
```
130+
export KRO_VARIANT=kro-core-install-manifests
131+
```
132+
133+
Install kro using Kubectl
134+
```
135+
kubectl create namespace kro
136+
kubectl apply -f https://github.com/kubernetes-sigs/kro/releases/download/$KRO_VERSION/$KRO_VARIANT.yaml
137+
```
138+
139+
### Verifying the Installation
140+
141+
After running the installation command, verify that Kro has been installed
142+
correctly:
143+
144+
Check the kro pods:
145+
```sh
146+
kubectl get pods -n kro
147+
```
148+
Expected result: You should see kro-related pods running.
149+
```
150+
NAME READY STATUS RESTARTS AGE
151+
kro-7d98bc6f46-jvjl5 1/1 Running 0 1s
152+
```
153+
154+
### Upgrading kro
155+
156+
To upgrade to a newer version of kro, use the Helm upgrade command:
157+
158+
Replace `<new-version>` with the version you want to upgrade to.
159+
```bash
160+
export KRO_VERSION=<new-version>
161+
```
162+
163+
Upgrade the controller
164+
```
165+
kubectl apply -f https://github.com/kubernetes-sigs/kro/releases/download/$KRO_VERSION/$KRO_VARIANT.yaml
166+
```
167+
168+
:::info[**Removal of dangling objects**]
169+
170+
Kubectl installation does remove old objects. You may need to manually remove any
171+
object that was removed in the new version of Kro.
172+
173+
:::
174+
175+
### Uninstalling kro
176+
177+
To uninstall kro, use the following command:
178+
179+
```bash
180+
kubectl delete -f https://github.com/kubernetes-sigs/kro/releases/download/$KRO_VERSION/$KRO_VARIANT.yaml
181+
```
182+
183+
Keep in mind that this command will remove all kro resources from your cluster,
184+
including the ResourceGraphDefinition CRD. This means all RGD instances will also be deleted.
185+
Resources deployed by RGD instances may though be kept in the cluster depending whether the kro controller
186+
is deleted before of after the ResourceGraphDefinition CRD.

0 commit comments

Comments
 (0)