Skip to content

Commit a347ab0

Browse files
committed
Create new namespace pull secret based on namespace pull robot account
which is granted read permisssions for all ImageRepositories in the namespace, namespace pull secret is also linked to component build SA and integration SA, new annotation 'image-controller.appstudio.redhat.com/namespace-pull-secret-ensured' is introduced as well, which is set to 'false' after namespace pull secret is created, when missing it will force to create namespace pull robot account and namespace secret, component linking check is based now only on component label, as new model won't have anymore application STONEBLD-4018 Signed-off-by: Robert Cerven <rcerven@redhat.com>
1 parent 3f8501f commit a347ab0

24 files changed

+1624
-357
lines changed

api/v1alpha1/imagerepository_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ type ImageCredentials struct {
6464
// Refreshes both, push and pull tokens.
6565
// The field gets cleared after the refresh.
6666
RegenerateToken *bool `json:"regenerate-token,omitempty"`
67+
// RegenerateNamespacePullToken defines a request to refresh namespace pull robot credentials.
68+
// The field gets cleared after the refresh.
69+
RegenerateNamespacePullToken *bool `json:"regenerate-namespace-pull-token,omitempty"`
6770
// VerifyLinking defines a request to verify and fix
6871
// secret linking in pipeline service account.
6972
// The field gets cleared after fixing.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/coverage_init.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ package main
77
// from the running binary during E2E tests.
88

99
import _ "github.com/konflux-ci/coverport/instrumentation/go" // starts coverage server via init()
10-

cmd/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ import (
4747
"sigs.k8s.io/controller-runtime/pkg/webhook"
4848

4949
"github.com/go-logr/logr"
50+
applicationapiv1alpha1 "github.com/konflux-ci/application-api/api/v1alpha1"
5051
imagerepositoryv1alpha1 "github.com/konflux-ci/image-controller/api/v1alpha1"
5152
controllers "github.com/konflux-ci/image-controller/internal/controller"
5253
controllermetrics "github.com/konflux-ci/image-controller/pkg/metrics"
5354
"github.com/konflux-ci/image-controller/pkg/quay"
54-
appstudioredhatcomv1alpha1 "github.com/redhat-appstudio/application-api/api/v1alpha1"
55+
routev1 "github.com/openshift/api/route/v1"
5556
// +kubebuilder:scaffold:imports
5657
)
5758

@@ -69,7 +70,8 @@ var (
6970
func init() {
7071
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
7172

72-
utilruntime.Must(appstudioredhatcomv1alpha1.AddToScheme(scheme))
73+
utilruntime.Must(routev1.AddToScheme(scheme))
74+
utilruntime.Must(applicationapiv1alpha1.AddToScheme(scheme))
7375
utilruntime.Must(imagerepositoryv1alpha1.AddToScheme(scheme))
7476
// +kubebuilder:scaffold:scheme
7577
}

config/crd/bases/appstudio.redhat.com_imagerepositories.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ spec:
4949
credentials:
5050
description: Credentials management.
5151
properties:
52+
regenerate-namespace-pull-token:
53+
description: |-
54+
RegenerateNamespacePullToken defines a request to refresh namespace pull robot credentials.
55+
The field gets cleared after the refresh.
56+
type: boolean
5257
regenerate-token:
5358
description: |-
5459
RegenerateToken defines a request to refresh image accessing credentials.

config/rbac/role.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,11 @@ rules:
8282
- get
8383
- patch
8484
- update
85+
- apiGroups:
86+
- route.openshift.io
87+
resources:
88+
- routes
89+
verbs:
90+
- get
91+
- list
92+
- watch

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ toolchain go1.24.6
77
require (
88
github.com/go-logr/logr v1.4.3
99
github.com/h2non/gock v1.2.0
10+
github.com/konflux-ci/application-api v0.0.0-20251126155256-d24742e8b026
11+
github.com/konflux-ci/coverport/instrumentation/go v0.0.0-20251127103713-95b5b5e04a62
1012
github.com/onsi/ginkgo/v2 v2.26.0
1113
github.com/onsi/gomega v1.38.2
14+
github.com/openshift/api v0.0.0-20221013123534-96eec44e1979
1215
github.com/prometheus/client_golang v1.19.1
13-
github.com/redhat-appstudio/application-api v0.0.0-20231026192857-89515ad2504f
1416
go.uber.org/zap v1.27.0
1517
gotest.tools/v3 v3.5.2
1618
k8s.io/api v0.31.0
@@ -30,7 +32,6 @@ require (
3032
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3133
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3234
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
33-
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
3435
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
3536
github.com/felixge/httpsnoop v1.0.4 // indirect
3637
github.com/fsnotify/fsnotify v1.7.0 // indirect
@@ -56,7 +57,6 @@ require (
5657
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5758
github.com/josharian/intern v1.0.0 // indirect
5859
github.com/json-iterator/go v1.1.12 // indirect
59-
github.com/konflux-ci/coverport/instrumentation/go v0.0.0-20251127103713-95b5b5e04a62 // indirect
6060
github.com/mailru/easyjson v0.7.7 // indirect
6161
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6262
github.com/modern-go/reflect2 v1.0.2 // indirect

go.sum

Lines changed: 194 additions & 4 deletions
Large diffs are not rendered by default.

hack/routecrd/route.yaml

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.6.1
8+
creationTimestamp: null
9+
name: routes.route.openshift.io
10+
spec:
11+
group: route.openshift.io
12+
names:
13+
kind: Route
14+
listKind: RouteList
15+
plural: routes
16+
singular: route
17+
scope: Namespaced
18+
versions:
19+
- name: v1
20+
schema:
21+
openAPIV3Schema:
22+
description: "A route allows developers to expose services through an HTTP(S)
23+
aware load balancing and proxy layer via a public DNS entry. The route may
24+
further specify TLS options and a certificate, or specify a public CNAME
25+
that the router should also accept for HTTP and HTTPS traffic. An administrator
26+
typically configures their router to be visible outside the cluster firewall,
27+
and may also add additional security, caching, or traffic controls on the
28+
service content. Routers usually talk directly to the service endpoints.
29+
\n Once a route is created, the `host` field may not be changed. Generally,
30+
routers use the oldest route with a given host when resolving conflicts.
31+
\n Routers are subject to additional customization and may support additional
32+
controls via the annotations field. \n Because administrators may configure
33+
multiple routers, the route status field is used to return information to
34+
clients about the names and states of the route under each router. If a
35+
client chooses a duplicate name, for instance, the route status conditions
36+
are used to indicate the route cannot be chosen. \n To enable HTTP/2 ALPN
37+
on a route it requires a custom (non-wildcard) certificate. This prevents
38+
connection coalescing by clients, notably web browsers. We do not support
39+
HTTP/2 ALPN on routes that use the default certificate because of the risk
40+
of connection re-use/coalescing. Routes that do not have their own custom
41+
certificate will not be HTTP/2 ALPN-enabled on either the frontend or the
42+
backend. \n Compatibility level 1: Stable within a major release for a minimum
43+
of 12 months or 3 minor releases (whichever is longer)."
44+
properties:
45+
apiVersion:
46+
description: 'APIVersion defines the versioned schema of this representation
47+
of an object. Servers should convert recognized schemas to the latest
48+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
49+
type: string
50+
kind:
51+
description: 'Kind is a string value representing the REST resource this
52+
object represents. Servers may infer this from the endpoint the client
53+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
54+
type: string
55+
metadata:
56+
type: object
57+
spec:
58+
description: spec is the desired state of the route
59+
properties:
60+
alternateBackends:
61+
description: alternateBackends allows up to 3 additional backends
62+
to be assigned to the route. Only the Service kind is allowed, and
63+
it will be defaulted to Service. Use the weight field in RouteTargetReference
64+
object to specify relative preference.
65+
items:
66+
description: RouteTargetReference specifies the target that resolve
67+
into endpoints. Only the 'Service' kind is allowed. Use 'weight'
68+
field to emphasize one over others.
69+
properties:
70+
kind:
71+
description: The kind of target that the route is referring
72+
to. Currently, only 'Service' is allowed
73+
type: string
74+
name:
75+
description: name of the service/target that is being referred
76+
to. e.g. name of the service
77+
type: string
78+
weight:
79+
description: weight as an integer between 0 and 256, default
80+
100, that specifies the target's relative weight against other
81+
target reference objects. 0 suppresses requests to this backend.
82+
format: int32
83+
type: integer
84+
required:
85+
- kind
86+
- name
87+
type: object
88+
type: array
89+
host:
90+
description: host is an alias/DNS that points to the service. Optional.
91+
If not specified a route name will typically be automatically chosen.
92+
Must follow DNS952 subdomain conventions.
93+
type: string
94+
path:
95+
description: path that the router watches for, to route traffic for
96+
to the service. Optional
97+
type: string
98+
port:
99+
description: If specified, the port to be used by the router. Most
100+
routers will use all endpoints exposed by the service by default
101+
- set this value to instruct routers which port to use.
102+
properties:
103+
targetPort:
104+
anyOf:
105+
- type: integer
106+
- type: string
107+
description: The target port on pods selected by the service this
108+
route points to. If this is a string, it will be looked up as
109+
a named port in the target endpoints port list. Required
110+
x-kubernetes-int-or-string: true
111+
required:
112+
- targetPort
113+
type: object
114+
subdomain:
115+
description: "subdomain is a DNS subdomain that is requested within
116+
the ingress controller's domain (as a subdomain). If host is set
117+
this field is ignored. An ingress controller may choose to ignore
118+
this suggested name, in which case the controller will report the
119+
assigned name in the status.ingress array or refuse to admit the
120+
route. If this value is set and the server does not support this
121+
field host will be populated automatically. Otherwise host is left
122+
empty. The field may have multiple parts separated by a dot, but
123+
not all ingress controllers may honor the request. This field may
124+
not be changed after creation except by a user with the update routes/custom-host
125+
permission. \n Example: subdomain `frontend` automatically receives
126+
the router subdomain `apps.mycluster.com` to have a full hostname
127+
`frontend.apps.mycluster.com`."
128+
type: string
129+
tls:
130+
description: The tls field provides the ability to configure certificates
131+
and termination for the route.
132+
properties:
133+
caCertificate:
134+
description: caCertificate provides the cert authority certificate
135+
contents
136+
type: string
137+
certificate:
138+
description: certificate provides certificate contents. This should
139+
be a single serving certificate, not a certificate chain. Do
140+
not include a CA certificate.
141+
type: string
142+
destinationCACertificate:
143+
description: destinationCACertificate provides the contents of
144+
the ca certificate of the final destination. When using reencrypt
145+
termination this file should be provided in order to have routers
146+
use it for health checks on the secure connection. If this field
147+
is not specified, the router may provide its own destination
148+
CA and perform hostname validation using the short service name
149+
(service.namespace.svc), which allows infrastructure generated
150+
certificates to automatically verify.
151+
type: string
152+
insecureEdgeTerminationPolicy:
153+
description: "insecureEdgeTerminationPolicy indicates the desired
154+
behavior for insecure connections to a route. While each router
155+
may make its own decisions on which ports to expose, this is
156+
normally port 80. \n * Allow - traffic is sent to the server
157+
on the insecure port (default) * Disable - no traffic is allowed
158+
on the insecure port. * Redirect - clients are redirected to
159+
the secure port."
160+
type: string
161+
key:
162+
description: key provides key file contents
163+
type: string
164+
termination:
165+
description: "termination indicates termination type. \n * edge
166+
- TLS termination is done by the router and http is used to
167+
communicate with the backend (default) * passthrough - Traffic
168+
is sent straight to the destination without the router providing
169+
TLS termination * reencrypt - TLS termination is done by the
170+
router and https is used to communicate with the backend"
171+
type: string
172+
required:
173+
- termination
174+
type: object
175+
to:
176+
description: to is an object the route should use as the primary backend.
177+
Only the Service kind is allowed, and it will be defaulted to Service.
178+
If the weight field (0-256 default 100) is set to zero, no traffic
179+
will be sent to this backend.
180+
properties:
181+
kind:
182+
description: The kind of target that the route is referring to.
183+
Currently, only 'Service' is allowed
184+
type: string
185+
name:
186+
description: name of the service/target that is being referred
187+
to. e.g. name of the service
188+
type: string
189+
weight:
190+
description: weight as an integer between 0 and 256, default 100,
191+
that specifies the target's relative weight against other target
192+
reference objects. 0 suppresses requests to this backend.
193+
format: int32
194+
type: integer
195+
required:
196+
- kind
197+
- name
198+
type: object
199+
wildcardPolicy:
200+
description: Wildcard policy if any for the route. Currently only
201+
'Subdomain' or 'None' is allowed.
202+
type: string
203+
required:
204+
- to
205+
type: object
206+
status:
207+
description: status is the current state of the route
208+
properties:
209+
ingress:
210+
description: ingress describes the places where the route may be exposed.
211+
The list of ingress points may contain duplicate Host or RouterName
212+
values. Routes are considered live once they are `Ready`
213+
items:
214+
description: RouteIngress holds information about the places where
215+
a route is exposed.
216+
properties:
217+
conditions:
218+
description: Conditions is the state of the route, may be empty.
219+
items:
220+
description: RouteIngressCondition contains details for the
221+
current condition of this route on a particular router.
222+
properties:
223+
lastTransitionTime:
224+
description: RFC 3339 date and time when this condition
225+
last transitioned
226+
format: date-time
227+
type: string
228+
message:
229+
description: Human readable message indicating details
230+
about last transition.
231+
type: string
232+
reason:
233+
description: (brief) reason for the condition's last transition,
234+
and is usually a machine and human readable constant
235+
type: string
236+
status:
237+
description: Status is the status of the condition. Can
238+
be True, False, Unknown.
239+
type: string
240+
type:
241+
description: Type is the type of the condition. Currently
242+
only Ready.
243+
type: string
244+
required:
245+
- status
246+
- type
247+
type: object
248+
type: array
249+
host:
250+
description: Host is the host string under which the route is
251+
exposed; this value is required
252+
type: string
253+
routerCanonicalHostname:
254+
description: CanonicalHostname is the external host name for
255+
the router that can be used as a CNAME for the host requested
256+
for this route. This value is optional and may not be set
257+
in all cases.
258+
type: string
259+
routerName:
260+
description: Name is a name chosen by the router to identify
261+
itself; this value is required
262+
type: string
263+
wildcardPolicy:
264+
description: Wildcard policy is the wildcard policy that was
265+
allowed where this route is exposed.
266+
type: string
267+
type: object
268+
type: array
269+
type: object
270+
required:
271+
- spec
272+
type: object
273+
served: true
274+
storage: true
275+
subresources:
276+
status: {}
277+
status:
278+
acceptedNames:
279+
kind: ""
280+
plural: ""
281+
conditions: []
282+
storedVersions: []

0 commit comments

Comments
 (0)