Skip to content

Commit 4dea88e

Browse files
authored
Merge branch 'main' into release/v0.2.1
2 parents a73651d + 9c8683e commit 4dea88e

File tree

18 files changed

+467
-50
lines changed

18 files changed

+467
-50
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Create Github Release
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
tags:
9+
- "v*.*.*"
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
- name: Release
18+
uses: softprops/action-gh-release@v2
19+
with:
20+
generate_release_notes: true

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Dockerfile.cross
1818

1919
!vendor/**/zz_generated.*
2020

21+
rendered/
22+
2123
# editor and IDE paraphernalia
2224
.idea
2325
.vscode
@@ -35,4 +37,4 @@ cover.html
3537
.design
3638
.DS_Store
3739
TODO.*
38-
# package-lock.json
40+
# package-lock.json

CONTRIBUTING.md

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ GitHub provides additional document on [forking a repository](https://help.githu
4040
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
4141

4242
## Setting Up a Local Development Environment
43+
44+
By following the steps for [externally running a controller](#running-the-controller-external-to-the-cluster) or
45+
[running the controller inside a `KinD` cluster](#running-the-controller-inside-a-kind-cluster-with-ko), you can set up
46+
a local environment to test your contributions before submitting a pull request.
47+
48+
### Running the controller external to the cluster
49+
4350
To test and run the project with your local changes, follow these steps to set up a development environment:
4451

4552
1. Install Dependencies: Ensure you have the necessary dependencies installed, including:
@@ -64,7 +71,93 @@ To test and run the project with your local changes, follow these steps to set u
6471
```
6572
This will connect to the default Kubernetes context in your local kubeconfig (`~/.kube/config`). Ensure the context is pointing to your local cluster.
6673

67-
By following these steps, you can setup a local environment to test your contributions before submitting a pull request.
74+
### Running the controller inside a [`KinD`][kind] cluster with [`ko`][ko]
75+
76+
[ko]: https://ko.build
77+
[kind]: https://kind.sigs.k8s.io/
78+
79+
1. Create a `KinD` cluster.
80+
81+
```sh
82+
kind create cluster
83+
```
84+
85+
2. Create the `kro-system` namespace.
86+
87+
```sh
88+
kubectl create namespace kro-system
89+
```
90+
91+
3. Set the `KO_DOCKER_REPO` env var.
92+
93+
```sh
94+
export KO_DOCKER_REPO=kind.local
95+
```
96+
97+
> _Note_, if not using the default kind cluster name, set KIND_CLUSTER_NAME
98+
99+
```sh
100+
export KIND_CLUSTER_NAME=my-other-cluster
101+
```
102+
4. Apply the Kro CRDs.
103+
104+
```sh
105+
make manifests
106+
kubectl apply -f ./helm/crds
107+
```
108+
109+
5. Render and apply the local helm chart.
110+
111+
```sh
112+
helm template kro ./helm \
113+
--namespace kro-system \
114+
--set image.pullPolicy=Never \
115+
--set image.ko=true | ko apply -f -
116+
```
117+
118+
### Dev Environment Hello World
119+
120+
1. Create a `NoOp` ResourceGraph using the `ResourceGraphDefinition`.
121+
122+
```sh
123+
kubectl apply -f - <<EOF
124+
apiVersion: kro.run/v1alpha1
125+
kind: ResourceGraphDefinition
126+
metadata:
127+
name: noop
128+
spec:
129+
schema:
130+
apiVersion: v1alpha1
131+
kind: NoOp
132+
spec: {}
133+
status: {}
134+
resources: []
135+
EOF
136+
```
137+
138+
Inspect that the `ResourceGraphDefinition` was created, and also the newly created CRD `NoOp`.
139+
140+
```sh
141+
kubectl get ResourceGraphDefinition noop
142+
kubectl get crds | grep noops
143+
```
144+
145+
3. Create an instance of the new `NoOp` kind.
146+
147+
```sh
148+
kubectl apply -f - <<EOF
149+
apiVersion: kro.run/v1alpha1
150+
kind: NoOp
151+
metadata:
152+
name: demo
153+
EOF
154+
```
155+
156+
And inspect the new instance,
157+
158+
```shell
159+
kubectl get noops -oyaml
160+
```
68161
69162
## Finding contributions to work on
70163
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.

examples/aws/serverless-microservice/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ kubectl describe resourcegraphdefinition.kro.run/microservice.kro.run
202202

203203
Expected result (resource definitions removed for brevity)
204204

205+
<!-- TODO: update this example output to the latest schema -->
205206
```
206207
Name: microservice.kro.run
207208
Namespace: default

helm/templates/_helpers.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ helm.sh/chart: {{ include "kro.chart" . }}
5151
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
5252
{{- end }}
5353
app.kubernetes.io/managed-by: {{ .Release.Service }}
54+
app.kubernetes.io/component: controller
55+
app.kubernetes.io/part-of: kro
56+
{{- if .Values.additionalLabels }}
57+
{{ toYaml .Values.additionalLabels }}
58+
{{- end }}
5459
{{- end }}
5560

5661
{{/*

helm/templates/cluster-role-binding.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ kind: ClusterRoleBinding
33
metadata:
44
name: {{ include "kro.fullname" . }}-role-binding
55
labels:
6-
app: kro
7-
release: {{ .Release.Name }}
6+
{{- include "kro.labels" . | nindent 4 }}
87
roleRef:
98
kind: ClusterRole
109
apiGroup: rbac.authorization.k8s.io
1110
name: {{ include "kro.fullname" . }}-cluster-role
1211
subjects:
1312
- kind: ServiceAccount
1413
name: {{ include "kro.serviceAccountName" . }}
15-
namespace: {{ .Release.Namespace }}
14+
namespace: {{ .Release.Namespace }}

helm/templates/cluster-role.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRole
33
metadata:
44
name: {{ include "kro.fullname" . }}-cluster-role
5+
labels:
6+
{{- include "kro.labels" . | nindent 4 }}
57
rules:
68
- apiGroups:
79
- "*"
810
resources:
911
- "*"
1012
verbs:
11-
- '*'
13+
- '*'

helm/templates/deployment.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
{{- toYaml . | nindent 8 }}
1818
{{- end }}
1919
labels:
20-
{{- include "kro.selectorLabels" . | nindent 8 }}
20+
{{- include "kro.labels" . | nindent 8 }}
2121
{{- with .Values.deployment.podLabels }}
2222
{{- toYaml . | nindent 8 }}
2323
{{- end }}
@@ -33,7 +33,11 @@ spec:
3333
- name: {{ .Chart.Name }}
3434
securityContext:
3535
{{- toYaml .Values.deployment.securityContext | nindent 12 }}
36+
{{- if .Values.image.ko }}
37+
image: "ko://github.com/kro-run/kro/cmd/controller"
38+
{{- else }}
3639
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
40+
{{- end }}
3741
imagePullPolicy: {{ .Values.image.pullPolicy }}
3842
ports:
3943
- name: metricsport

helm/templates/servicemonitor.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- if and .Values.metrics.service.create .Values.metrics.serviceMonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
name: {{ include "kro.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "kro.labels" . | nindent 4 }}
9+
{{- with .Values.metrics.serviceMonitor.additionalLabels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
jobLabel: {{ .Release.Name }}
14+
namespaceSelector:
15+
matchNames:
16+
- {{ .Release.Namespace }}
17+
selector:
18+
matchLabels:
19+
{{- include "kro.selectorLabels" . | nindent 6 }}
20+
endpoints:
21+
- port: metrics
22+
path: {{ .Values.metrics.serviceMonitor.telemetryPath }}
23+
{{- with .Values.metrics.serviceMonitor.interval }}
24+
interval: {{ . }}
25+
{{- end }}
26+
{{- with .Values.metrics.serviceMonitor.scrapeTimeout }}
27+
scrapeTimeout: {{ . }}
28+
{{- end }}
29+
{{- if .Values.metrics.serviceMonitor.metricRelabelings }}
30+
metricRelabelings:
31+
{{- toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 8 }}
32+
{{- end }}
33+
{{- if .Values.metrics.serviceMonitor.relabelings }}
34+
relabelings:
35+
{{- toYaml .Values.metrics.serviceMonitor.relabelings | nindent 8 }}
36+
{{- end }}
37+
{{- if .Values.metrics.serviceMonitor.targetLabels }}
38+
targetLabels:
39+
{{- range .Values.metrics.serviceMonitor.targetLabels }}
40+
- {{ . }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}

helm/values.yaml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ nameOverride: ""
33
# Override the full name of the chart
44
fullnameOverride: ""
55

6+
# Additional labels that should be applied to all resources
7+
additionalLabels: {}
8+
# app: kro
9+
610
image:
711
# The location of the container image repository
812
repository: ghcr.io/kro-run/kro/controller
9-
# Image pull policy (IfNotPresent: pull the image only if it is not present locally)
10-
pullPolicy: IfNotPresent
1113
# Overrides the image tag whose default is the chart appVersion.
1214
tag: "0.2.1"
15+
# Ignores the repository and tag settings and uses the controllers ko entrypoint.
16+
ko: false
17+
# Image pull policy (IfNotPresent: pull the image only if it is not present locally)
18+
pullPolicy: IfNotPresent
1319

1420
# List of secrets for pulling images from a private registry
1521
imagePullSecrets: []
@@ -97,3 +103,25 @@ metrics:
97103
type: "ClusterIP"
98104
# Port for the metrics service
99105
port: 8080
106+
serviceMonitor:
107+
# -- Whether to create a ServiceMonitor
108+
enabled: false
109+
# -- Set of labels to transfer from the Kubernetes Service onto the target
110+
additionalLabels: {}
111+
# -- Set how frequently Prometheus should scrape
112+
interval: 1m
113+
# -- Set timeout for scrape
114+
scrapeTimeout: 10s
115+
# -- Set path to metrics path
116+
telemetryPath: /metrics
117+
# -- Set of labels to transfer from the Kubernetes Service onto the target
118+
targetLabels: []
119+
# -- MetricRelabelConfigs to apply to samples before ingestion
120+
metricRelabelings: []
121+
# - action: replace
122+
# replacement: my-cluster
123+
# targetLabel: cluster
124+
relabelings: []
125+
# - action: replace
126+
# replacement: my-cluster
127+
# targetLabel: cluster

0 commit comments

Comments
 (0)