Skip to content

Commit 4562e8f

Browse files
pedjakPer G. da Silva
authored andcommitted
Add ability to play with startup/readines/liveness probes in test-operator
Start busybox's httpd and serves probes from created files
1 parent 9e5d754 commit 4562e8f

File tree

10 files changed

+313
-24
lines changed

10 files changed

+313
-24
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: httpd-script
5+
data:
6+
httpd.sh: |
7+
#!/bin/sh
8+
echo true > /var/www/started
9+
echo true > /var/www/ready
10+
echo true > /var/www/live
11+
exec httpd -f -h /var/www -p 80

testdata/images/bundles/test-operator/v1.0.0/manifests/testoperator.clusterserviceversion.yaml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,42 @@ spec:
5454
metadata:
5555
labels:
5656
app: olme2etest
57-
spec:
58-
terminationGracePeriodSeconds: 0
59-
containers:
60-
- name: busybox
61-
image: busybox:1.36
62-
command:
63-
- 'sleep'
64-
- '1000'
65-
securityContext:
66-
runAsUser: 1000
67-
runAsNonRoot: true
68-
serviceAccountName: simple-bundle-manager
57+
spec:
58+
terminationGracePeriodSeconds: 0
59+
volumes:
60+
- name: scripts
61+
configMap:
62+
name: httpd-script
63+
defaultMode: 0755
64+
containers:
65+
- name: busybox-httpd-container
66+
image: busybox:1.36
67+
command: ["/scripts/httpd.sh"]
68+
ports:
69+
- containerPort: 80
70+
volumeMounts:
71+
- name: scripts
72+
mountPath: /scripts
73+
readOnly: true
74+
startupProbe:
75+
httpGet:
76+
path: /started
77+
port: 80
78+
failureThreshold: 30
79+
periodSeconds: 10
80+
livenessProbe:
81+
httpGet:
82+
path: /live
83+
port: 80
84+
failureThreshold: 1
85+
periodSeconds: 2
86+
readinessProbe:
87+
httpGet:
88+
path: /ready
89+
port: 80
90+
initialDelaySeconds: 1
91+
periodSeconds: 1
92+
serviceAccountName: simple-bundle-manager
6993
clusterPermissions:
7094
- rules:
7195
- apiGroups:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: test-configmap
5+
annotations:
6+
shouldNotTemplate: >
7+
The namespace is {{ $labels.namespace }}. The templated $labels.namespace is NOT expected to be processed by OLM's rendering engine for registry+v1 bundles.
8+
9+
data:
10+
version: "v1.0.2"
11+
name: "test-configmap"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
controller-gen.kubebuilder.io/version: v0.16.1
6+
name: olme2etests.olm.operatorframework.io
7+
spec:
8+
group: olm.operatorframework.io
9+
names:
10+
kind: OLME2ETest
11+
listKind: OLME2ETestList
12+
plural: olme2etests
13+
singular: olme2etest
14+
scope: Cluster
15+
versions:
16+
- name: v1
17+
served: true
18+
storage: true
19+
schema:
20+
openAPIV3Schema:
21+
type: object
22+
properties:
23+
spec:
24+
type: object
25+
properties:
26+
testField:
27+
type: string
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
apiVersion: operators.coreos.com/v1alpha1
2+
kind: ClusterServiceVersion
3+
metadata:
4+
annotations:
5+
alm-examples: |-
6+
[
7+
{
8+
"apiVersion": "olme2etests.olm.operatorframework.io/v1",
9+
"kind": "OLME2ETests",
10+
"metadata": {
11+
"labels": {
12+
"app.kubernetes.io/managed-by": "kustomize",
13+
"app.kubernetes.io/name": "test"
14+
},
15+
"name": "test-sample"
16+
},
17+
"spec": null
18+
}
19+
]
20+
capabilities: Basic Install
21+
createdAt: "2024-10-24T19:21:40Z"
22+
operators.operatorframework.io/builder: operator-sdk-v1.34.1
23+
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
24+
name: testoperator.v1.0.2
25+
namespace: placeholder
26+
spec:
27+
apiservicedefinitions: {}
28+
customresourcedefinitions:
29+
owned:
30+
- description: Configures subsections of Alertmanager configuration specific to each namespace
31+
displayName: OLME2ETest
32+
kind: OLME2ETest
33+
name: olme2etests.olm.operatorframework.io
34+
version: v1
35+
description: OLM E2E Testing Operator with a wrong image ref
36+
displayName: test-operator
37+
icon:
38+
- base64data: ""
39+
mediatype: ""
40+
install:
41+
spec:
42+
deployments:
43+
- label:
44+
app.kubernetes.io/component: controller
45+
app.kubernetes.io/name: test-operator
46+
app.kubernetes.io/version: 1.0.2
47+
name: test-operator
48+
spec:
49+
replicas: 1
50+
selector:
51+
matchLabels:
52+
app: olme2etest
53+
template:
54+
metadata:
55+
labels:
56+
app: olme2etest
57+
spec:
58+
terminationGracePeriodSeconds: 0
59+
volumes:
60+
- name: scripts
61+
configMap:
62+
name: httpd-script
63+
defaultMode: 0755
64+
containers:
65+
- name: busybox-httpd-container
66+
# This image ref is wrong and should trigger ImagePullBackOff condition
67+
image: wrong/image
68+
serviceAccountName: simple-bundle-manager
69+
clusterPermissions:
70+
- rules:
71+
- apiGroups:
72+
- authentication.k8s.io
73+
resources:
74+
- tokenreviews
75+
verbs:
76+
- create
77+
- apiGroups:
78+
- authorization.k8s.io
79+
resources:
80+
- subjectaccessreviews
81+
verbs:
82+
- create
83+
serviceAccountName: simple-bundle-manager
84+
permissions:
85+
- rules:
86+
- apiGroups:
87+
- ""
88+
resources:
89+
- configmaps
90+
- serviceaccounts
91+
verbs:
92+
- get
93+
- list
94+
- watch
95+
- create
96+
- update
97+
- patch
98+
- delete
99+
- apiGroups:
100+
- networking.k8s.io
101+
resources:
102+
- networkpolicies
103+
verbs:
104+
- get
105+
- list
106+
- create
107+
- update
108+
- delete
109+
- apiGroups:
110+
- coordination.k8s.io
111+
resources:
112+
- leases
113+
verbs:
114+
- get
115+
- list
116+
- watch
117+
- create
118+
- update
119+
- patch
120+
- delete
121+
- apiGroups:
122+
- ""
123+
resources:
124+
- events
125+
verbs:
126+
- create
127+
- patch
128+
serviceAccountName: simple-bundle-manager
129+
strategy: deployment
130+
installModes:
131+
- supported: false
132+
type: OwnNamespace
133+
- supported: true
134+
type: SingleNamespace
135+
- supported: false
136+
type: MultiNamespace
137+
- supported: true
138+
type: AllNamespaces
139+
keywords:
140+
- registry
141+
links:
142+
- name: simple-bundle
143+
url: https://simple-bundle.domain
144+
maintainers:
145+
- email: main#simple-bundle.domain
146+
name: Simple Bundle
147+
maturity: beta
148+
provider:
149+
name: Simple Bundle
150+
url: https://simple-bundle.domain
151+
version: 1.0.2
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: test-operator-network-policy
5+
spec:
6+
podSelector: {}
7+
policyTypes:
8+
- Ingress
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
annotations:
2+
# Core bundle annotations.
3+
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
4+
operators.operatorframework.io.bundle.manifests.v1: manifests/
5+
operators.operatorframework.io.bundle.metadata.v1: metadata/
6+
operators.operatorframework.io.bundle.package.v1: test
7+
operators.operatorframework.io.bundle.channels.v1: beta
8+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.28.0
9+
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
10+
operators.operatorframework.io.metrics.project_layout: unknown
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: httpd-script
5+
data:
6+
httpd.sh: |
7+
#!/bin/sh
8+
echo "Version 1.2.0"
9+
echo true > /var/www/started
10+
echo true > /var/www/ready
11+
echo true > /var/www/live
12+
exec httpd -f -h /var/www -p 80

testdata/images/bundles/test-operator/v1.2.0/manifests/testoperator.clusterserviceversion.yaml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,42 @@ spec:
5454
metadata:
5555
labels:
5656
app: olme2etest
57-
spec:
58-
terminationGracePeriodSeconds: 0
59-
containers:
60-
- name: busybox
61-
image: busybox:1.37
62-
command:
63-
- 'sleep'
64-
- '1000'
65-
securityContext:
66-
runAsUser: 1000
67-
runAsNonRoot: true
68-
serviceAccountName: simple-bundle-manager
57+
spec:
58+
terminationGracePeriodSeconds: 0
59+
volumes:
60+
- name: scripts
61+
configMap:
62+
name: httpd-script
63+
defaultMode: 0755
64+
containers:
65+
- name: busybox-httpd-container
66+
image: busybox:1.37
67+
command: ["/scripts/httpd.sh"]
68+
ports:
69+
- containerPort: 80
70+
volumeMounts:
71+
- name: scripts
72+
mountPath: /scripts
73+
readOnly: true
74+
startupProbe:
75+
httpGet:
76+
path: /started
77+
port: 80
78+
failureThreshold: 30
79+
periodSeconds: 10
80+
livenessProbe:
81+
httpGet:
82+
path: /live
83+
port: 80
84+
failureThreshold: 1
85+
periodSeconds: 2
86+
readinessProbe:
87+
httpGet:
88+
path: /ready
89+
port: 80
90+
initialDelaySeconds: 1
91+
periodSeconds: 1
92+
serviceAccountName: simple-bundle-manager
6993
clusterPermissions:
7094
- rules:
7195
- apiGroups:

testdata/images/catalogs/test-catalog/v1/configs/catalog.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ name: alpha
77
package: test
88
entries:
99
- name: test-operator.1.0.0
10+
- name: test-operator.1.0.2
1011
---
1112
schema: olm.channel
1213
name: beta
@@ -39,6 +40,16 @@ properties:
3940
version: 1.0.1
4041
---
4142
schema: olm.bundle
43+
name: test-operator.1.0.2
44+
package: test
45+
image: docker-registry.operator-controller-e2e.svc.cluster.local:5000/bundles/registry-v1/test-operator:v1.0.2
46+
properties:
47+
- type: olm.package
48+
value:
49+
packageName: test
50+
version: 1.0.2
51+
---
52+
schema: olm.bundle
4253
name: test-operator.1.2.0
4354
package: test
4455
image: docker-registry.operator-controller-e2e.svc.cluster.local:5000/bundles/registry-v1/test-operator:v1.2.0

0 commit comments

Comments
 (0)