Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 3ab4790

Browse files
author
Pablo Mercado
authored
Merge pull request #7 from triggermesh/task/ko-hook
ko hook project
2 parents 511ec59 + e22c797 commit 3ab4790

File tree

8 files changed

+406
-0
lines changed

8 files changed

+406
-0
lines changed

config/200-clusterroles.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
kind: ClusterRole
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: scoby-hook-triggermesh
5+
labels:
6+
scoby.triggermesh.io/crdregistration: "true"
7+
app.kubernetes.io/name: scoby
8+
rules:
9+
- apiGroups:
10+
- "extensions.triggermesh.io"
11+
resources:
12+
- kuards
13+
verbs:
14+
- get
15+
- list
16+
- watch
17+
18+
---
19+
20+
# ClusterRole that will be aggregated at Scoby so that it can
21+
# manage these objects.
22+
23+
kind: ClusterRole
24+
apiVersion: rbac.authorization.k8s.io/v1
25+
metadata:
26+
name: crd-registrations-scoby-kuard
27+
labels:
28+
scoby.triggermesh.io/crdregistration: "true"
29+
app.kubernetes.io/name: scoby
30+
# Do not use this role directly. These rules will be added to the "crd-registrations-scoby" role.
31+
rules:
32+
- apiGroups:
33+
- "extensions.triggermesh.io"
34+
resources:
35+
- kuards
36+
verbs:
37+
- get
38+
- list
39+
- watch
40+
- update
41+
- apiGroups:
42+
- "extensions.triggermesh.io"
43+
resources:
44+
- kuards/status
45+
verbs:
46+
- get
47+
- update
48+
- patch
49+
# If a hook is used for finalization, the finalize resource
50+
# must be added to the ClusterRole.
51+
- apiGroups:
52+
- "extensions.triggermesh.io"
53+
resources:
54+
- kuards/finalizers
55+
verbs:
56+
- list
57+
- watch
58+
- create
59+
- update
60+
- delete

config/201-serviceaccounts.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2023 TriggerMesh Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v1
5+
kind: ServiceAccount
6+
metadata:
7+
name: scoby-hook-triggermesh
8+
namespace: triggermesh
9+
labels:
10+
app.kubernetes.io/part-of: triggermesh
11+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2023 TriggerMesh Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: ClusterRoleBinding
6+
metadata:
7+
name: scoby-hook-triggermesh
8+
labels:
9+
app.kubernetes.io/part-of: triggermesh
10+
subjects:
11+
- kind: ServiceAccount
12+
name: scoby-hook-triggermesh
13+
namespace: triggermesh
14+
roleRef:
15+
apiGroup: rbac.authorization.k8s.io
16+
kind: ClusterRole
17+
name: scoby-hook-triggermesh
18+
19+
20+

config/300-kuard.yaml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: kuards.extensions.triggermesh.io
5+
spec:
6+
group: extensions.triggermesh.io
7+
scope: Namespaced
8+
names:
9+
plural: kuards
10+
singular: kuard
11+
kind: Kuard
12+
versions:
13+
- name: v1
14+
served: true
15+
storage: true
16+
subresources:
17+
status: {}
18+
schema:
19+
openAPIV3Schema:
20+
type: object
21+
properties:
22+
spec:
23+
type: object
24+
properties:
25+
# Root variables demo
26+
variable1:
27+
type: string
28+
variable2:
29+
type: string
30+
# Nested variables demo
31+
group:
32+
type: object
33+
properties:
34+
variable3:
35+
type: boolean
36+
variable4:
37+
type: integer
38+
# Simple array demo
39+
array:
40+
type: array
41+
items:
42+
type: string
43+
# Secret reference demo
44+
refToSecret:
45+
type: object
46+
properties:
47+
secretName:
48+
type: string
49+
secretKey:
50+
type: string
51+
# ConfigMap reference demo
52+
refToConfigMap:
53+
type: object
54+
properties:
55+
configName:
56+
type: string
57+
configKey:
58+
type: string
59+
# URI resolving demo
60+
refToAddress:
61+
type: object
62+
properties:
63+
ref:
64+
type: object
65+
properties:
66+
apiVersion:
67+
type: string
68+
kind:
69+
type: string
70+
name:
71+
type: string
72+
namespace:
73+
type: string
74+
required:
75+
- kind
76+
- name
77+
- apiVersion
78+
uri:
79+
type: string
80+
oneOf:
81+
- required: [ref]
82+
- required: [uri]
83+
84+
status:
85+
description: CRDRegistrationStatus defines the observed state of CRDRegistration
86+
properties:
87+
address:
88+
description: URL exposed by this workload.
89+
type: object
90+
properties:
91+
url:
92+
type: string
93+
sinkUri:
94+
description: URI this workload is pointing to.
95+
type: string
96+
format: uri
97+
annotations:
98+
additionalProperties:
99+
type: string
100+
description: Annotations is additional Status fields for the Resource
101+
to save some additional State as well as convey more information
102+
to the user. This is roughly akin to Annotations on any k8s resource,
103+
just the reconciler conveying richer information outwards.
104+
type: object
105+
conditions:
106+
description: Conditions the latest available observations of a resource's
107+
current state.
108+
items:
109+
properties:
110+
lastTransitionTime:
111+
description: lastTransitionTime is the last time the condition
112+
transitioned from one status to another. This should be when
113+
the underlying condition changed. If that is not known, then
114+
using the time when the API field changed is acceptable.
115+
format: date-time
116+
type: string
117+
message:
118+
description: message is a human readable message indicating
119+
details about the transition. This may be an empty string.
120+
maxLength: 32768
121+
type: string
122+
reason:
123+
description: reason contains a programmatic identifier indicating
124+
the reason for the condition's last transition. Producers
125+
of specific condition types may define expected values and
126+
meanings for this field, and whether the values are considered
127+
a guaranteed API. The value should be a CamelCase string.
128+
This field may not be empty.
129+
maxLength: 1024
130+
minLength: 1
131+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
132+
type: string
133+
status:
134+
description: status of the condition, one of True, False, Unknown.
135+
enum:
136+
- "True"
137+
- "False"
138+
- Unknown
139+
type: string
140+
type:
141+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
142+
--- Many .condition.type values are consistent across resources
143+
like Available, but because arbitrary conditions can be useful
144+
(see .node.status.conditions), the ability to deconflict is
145+
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
146+
maxLength: 316
147+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
148+
type: string
149+
required:
150+
- status
151+
- type
152+
type: object
153+
type: array
154+
observedGeneration:
155+
description: ObservedGeneration is the 'Generation' of the Object
156+
that was last processed by the controller.
157+
format: int64
158+
type: integer
159+
type: object
160+
161+
additionalPrinterColumns:
162+
- jsonPath: .status.address.url
163+
name: URL
164+
type: string
165+
- jsonPath: .status.conditions[?(@.type=="Ready")].status
166+
name: Ready
167+
type: string

config/400-kuar-reg.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: scoby.triggermesh.io/v1alpha1
2+
kind: CRDRegistration
3+
metadata:
4+
name: kuard
5+
spec:
6+
crd: kuards.extensions.triggermesh.io
7+
hook:
8+
address:
9+
uri: "http://:8080/v1"
10+
ref:
11+
apiVersion: v1
12+
kind: Service
13+
name: scoby-hook-triggermesh
14+
namespace: triggermesh
15+
16+
initialization:
17+
enabled: true
18+
apiVersion: "1"
19+
finalization:
20+
enabled: true
21+
apiVersion: "1"
22+
23+
workload:
24+
formFactor:
25+
deployment:
26+
replicas: 1
27+
service:
28+
port: 80
29+
targetPort: 8080
30+
fromImage:
31+
repo: gcr.io/kuar-demo/kuard-amd64:blue
32+
33+
statusConfiguration:
34+
conditionsFromHook:
35+
- type: HookReportedStatus

config/500-hook.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Copyright 2022 TriggerMesh Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: apps/v1
5+
kind: Deployment
6+
metadata:
7+
name: scoby-hook-triggermesh
8+
namespace: triggermesh
9+
labels:
10+
app.kubernetes.io/part-of: triggermesh
11+
app.kubernetes.io/version: devel
12+
app.kubernetes.io/component: scoby-hook-triggermesh
13+
app.kubernetes.io/name: triggermesh-eventing
14+
spec:
15+
replicas: 1
16+
selector:
17+
matchLabels:
18+
app: scoby-hook-triggermesh
19+
template:
20+
metadata:
21+
labels:
22+
app: scoby-hook-triggermesh
23+
app.kubernetes.io/part-of: triggermesh
24+
app.kubernetes.io/version: devel
25+
app.kubernetes.io/component: scoby-hook-triggermesh
26+
app.kubernetes.io/name: triggermesh-eventing
27+
28+
spec:
29+
30+
serviceAccountName: scoby-hook-triggermesh
31+
enableServiceLinks: false
32+
33+
affinity:
34+
podAntiAffinity:
35+
preferredDuringSchedulingIgnoredDuringExecution:
36+
- podAffinityTerm:
37+
labelSelector:
38+
matchLabels:
39+
app: eventing-controller
40+
topologyKey: kubernetes.io/hostname
41+
weight: 100
42+
43+
44+
containers:
45+
- name: scoby-hook-triggermesh
46+
terminationMessagePolicy: FallbackToLogsOnError
47+
image: ko://github.com/triggermesh/scoby-hook-triggermesh/cmd/triggermesh-hook
48+
49+
args: ["start"]
50+
51+
env:
52+
- name: PATH
53+
value: "v1"
54+
- name: ADDRESS
55+
value: ":8080"
56+
57+
resources:
58+
requests:
59+
cpu: 50m
60+
memory: 50Mi
61+
limits:
62+
cpu: 50m
63+
memory: 200Mi
64+
65+
securityContext:
66+
runAsNonRoot: true
67+
allowPrivilegeEscalation: false
68+
readOnlyRootFilesystem: true
69+
capabilities:
70+
drop: [all]
71+
72+
ports:
73+
- name: api
74+
containerPort: 8080
75+
76+
---
77+
78+
apiVersion: v1
79+
kind: Service
80+
metadata:
81+
name: scoby-hook-triggermesh
82+
namespace: triggermesh
83+
spec:
84+
selector:
85+
app.kubernetes.io/component: scoby-hook-triggermesh
86+
app.kubernetes.io/name: triggermesh-eventing
87+
ports:
88+
- protocol: TCP
89+
port: 8080
90+
targetPort: 8080

0 commit comments

Comments
 (0)