Skip to content

Commit 9bbbd14

Browse files
committed
feat: Remove API Dependency on Tekton and cert-manager
Signed-off-by: Hasan Awad <hasan.m.awad94@gmail.com>
1 parent 4336047 commit 9bbbd14

File tree

5 files changed

+122
-28
lines changed

5 files changed

+122
-28
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ Once OLM has been deployed, use the following command to install the latest oper
1313
$ kubectl apply -f https://operatorhub.io/install/shipwright-operator.yaml
1414
```
1515

16-
## OLM Dependencies
17-
When installed via OLM using the provided Shipwright Operator Bundle, the Shipwright operator will ask OLM to deploy the following operators:
18-
- The [Tekton operator](https://tekton.dev/docs/operator/) to deploy and manage Tekton Pipelines.
19-
- The [Cert-Manager operator](https://cert-manager.io/docs/installation/operator-lifecycle-manager/) to provision certificates for admission/conversion webhooks.
20-
For this to work, the Shipwright operator must be included in a catalog that includes these other operators.
16+
## Prerequisites
17+
18+
Before installing the Shipwright operator, you must have the following components installed in your cluster:
19+
20+
- **Tekton**: The Shipwright operator requires Tekton Pipelines to be installed. Follow the [Tekton installation instructions](https://tekton.dev/docs/setup/) to install Tekton in your cluster.
21+
- **cert-manager**: The Shipwright operator uses cert-manager to provision certificates for admission/conversion webhooks. Follow the [cert-manager installation instructions](https://cert-manager.io/docs/installation/) to install cert-manager in your cluster.
22+
23+
**Note**: The cert-manager operator has been deprecated. Please install cert-manager directly using the recommended installation method from the [cert-manager documentation](https://cert-manager.io/docs/installation/).
2124

2225
## Usage
2326

bundle/manifests/shipwright-operator.clusterserviceversion.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,17 @@ spec:
3636
kind: ShipwrightBuild
3737
name: shipwrightbuilds.operator.shipwright.io
3838
version: v1alpha1
39-
required:
40-
- kind: TektonConfig
41-
name: tektonconfigs.operator.tekton.dev
42-
version: v1alpha1
43-
- kind: Certificate
44-
name: certificates.cert-manager.io
45-
version: v1
4639
description: |
4740
Shipwright is a framework for building container images on Kubernetes.
4841
4942
Read more: [https://shipwright.io](https://shipwright.io)
5043
44+
## Prerequisites
45+
46+
Before installing the Shipwright operator, ensure the following components are installed:
47+
- **Tekton**: Follow the [Tekton installation instructions](https://tekton.dev/docs/setup/) to install Tekton Pipelines.
48+
- **cert-manager**: Follow the [cert-manager installation instructions](https://cert-manager.io/docs/installation/) to install cert-manager for webhook certificate provisioning.
49+
5150
## Usage
5251
5352
To deploy and manage [Shipwright Builds](https://github.com/shipwright-io/build) in your cluster,

config/manifests/bases/shipwright-operator.clusterserviceversion.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@ spec:
2222
kind: ShipwrightBuild
2323
name: shipwrightbuilds.operator.shipwright.io
2424
version: v1alpha1
25-
required:
26-
- kind: TektonConfig
27-
name: tektonconfigs.operator.tekton.dev
28-
version: v1alpha1
29-
- kind: Certificate
30-
name: certificates.cert-manager.io
31-
version: v1
3225
description: |
3326
Shipwright is a framework for building container images on Kubernetes.
3427
3528
Read more: [https://shipwright.io](https://shipwright.io)
3629
30+
## Prerequisites
31+
32+
Before installing the Shipwright operator, ensure the following components are installed:
33+
- **Tekton**: Follow the [Tekton installation instructions](https://tekton.dev/docs/setup/) to install Tekton Pipelines.
34+
- **cert-manager**: Follow the [cert-manager installation instructions](https://cert-manager.io/docs/installation/) to install cert-manager for webhook certificate provisioning.
35+
3736
## Usage
3837
3938
To deploy and manage [Shipwright Builds](https://github.com/shipwright-io/build) in your cluster,

controllers/suite_test.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ func setupTektonCRDs(ctx context.Context) {
126126
tektonOpCRD.Status.StoredVersions = []string{"v1alpha1"}
127127
err = k8sClient.Create(ctx, tektonOpCRD, &client.CreateOptions{})
128128
Expect(err).NotTo(HaveOccurred())
129+
130+
// Wait for the CRD to be established before proceeding
131+
Eventually(func() bool {
132+
crd := &crdv1.CustomResourceDefinition{}
133+
if err := k8sClient.Get(ctx, types.NamespacedName{Name: "tektonconfigs.operator.tekton.dev"}, crd); err != nil {
134+
return false
135+
}
136+
for _, condition := range crd.Status.Conditions {
137+
if condition.Type == crdv1.Established && condition.Status == crdv1.ConditionTrue {
138+
return true
139+
}
140+
}
141+
return false
142+
}).Should(BeTrue(), "TektonConfig CRD should be established")
129143
}
130144
Expect(err).NotTo(HaveOccurred())
131145
}
@@ -191,31 +205,39 @@ func createTektonConfig(ctx context.Context) *tektonoperatorv1alpha1.TektonConfi
191205
},
192206
},
193207
}
194-
_, err := tektonOpClient.TektonConfigs().Create(ctx, tektonConfig, metav1.CreateOptions{})
208+
// Use controller-runtime client instead of REST client for better compatibility with envtest
209+
err := k8sClient.Create(ctx, tektonConfig, &client.CreateOptions{})
195210
if errors.IsAlreadyExists(err) {
196-
// If it already exists, that's fine
197-
err = nil
211+
// If it already exists, fetch it
212+
err = k8sClient.Get(ctx, types.NamespacedName{Name: "config"}, tektonConfig)
213+
Expect(err).NotTo(HaveOccurred())
214+
} else {
215+
Expect(err).NotTo(HaveOccurred())
198216
}
199-
Expect(err).To(BeNil())
200217

201218
return tektonConfig
202219
}
203220

204221
// deleteTektonConfig tears down the given TektonConfig instance.
205222
func deleteTektonConfig(ctx context.Context) {
206223
By("deleting the TektonConfig instance")
207-
err := tektonOpClient.TektonConfigs().Delete(ctx, "config", metav1.DeleteOptions{})
224+
tektonConfig := &tektonoperatorv1alpha1.TektonConfig{
225+
ObjectMeta: metav1.ObjectMeta{
226+
Name: "config",
227+
},
228+
}
229+
err := k8sClient.Delete(ctx, tektonConfig, &client.DeleteOptions{})
208230
// the delete e2e's can delete this object before this AfterEach runs
209231
if errors.IsNotFound(err) {
210232
return
211233
}
212234
Expect(err).NotTo(HaveOccurred())
213235

214236
By("waiting for TektonConfig instance to be completely removed")
215-
Eventually(func() error {
216-
_, err := tektonOpClient.TektonConfigs().Get(ctx, "config", metav1.GetOptions{})
217-
return err
218-
}, "30s", "5s").Should(WithTransform(errors.IsNotFound, BeTrue()))
237+
Eventually(func() bool {
238+
err := k8sClient.Get(ctx, types.NamespacedName{Name: "config"}, tektonConfig)
239+
return errors.IsNotFound(err)
240+
}, "30s", "5s").Should(BeTrue(), "TektonConfig should be deleted")
219241
}
220242

221243
var _ = BeforeSuite(func() {

hack/run-operator-catalog.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,73 @@ function wait_for_pod() {
8181
${KUBECTL_BIN} wait --for=condition=Ready pod -l "${label}" -n "${namespace}" --timeout "${timeout}"
8282
}
8383

84+
function install_tekton() {
85+
echo "Installing Tekton Operator"
86+
# Install Tekton Operator using the official installation method
87+
# Using a specific version for stability in CI
88+
TEKTON_OPERATOR_VERSION=${TEKTON_OPERATOR_VERSION:-v0.87.0}
89+
${KUBECTL_BIN} apply -f "https://storage.googleapis.com/tekton-releases/operator/previous/${TEKTON_OPERATOR_VERSION}/release.yaml" || \
90+
${KUBECTL_BIN} apply -f "https://storage.googleapis.com/tekton-releases/operator/latest/release.yaml"
91+
92+
echo "Waiting for Tekton Operator to be ready"
93+
# Wait for the operator namespace to exist first
94+
for i in {1..30}; do
95+
if ${KUBECTL_BIN} get namespace tekton-operator &>/dev/null; then
96+
break
97+
fi
98+
sleep 2
99+
done
100+
101+
if ! wait_for_pod "app=tekton-operator" "tekton-operator" 5m; then
102+
echo "Failed to deploy Tekton Operator"
103+
${KUBECTL_BIN} get pods -n tekton-operator
104+
exit 1
105+
fi
106+
107+
echo "Creating TektonConfig instance"
108+
${KUBECTL_BIN} apply -f - <<EOF
109+
apiVersion: operator.tekton.dev/v1alpha1
110+
kind: TektonConfig
111+
metadata:
112+
name: config
113+
spec:
114+
profile: lite
115+
targetNamespace: tekton-pipelines
116+
EOF
117+
118+
echo "Waiting for TektonConfig to be ready"
119+
if ! ${KUBECTL_BIN} wait --for=condition=Ready tektonconfigs.operator.tekton.dev/config --timeout=5m; then
120+
echo "Failed to deploy TektonConfig"
121+
${KUBECTL_BIN} get tektonconfigs -o yaml
122+
${KUBECTL_BIN} get tektonconfigs config -o yaml
123+
exit 1
124+
fi
125+
}
126+
127+
function install_cert_manager() {
128+
echo "Installing cert-manager"
129+
# Install cert-manager using the official installation method
130+
${KUBECTL_BIN} apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.0/cert-manager.yaml
131+
132+
echo "Waiting for cert-manager pods to be ready"
133+
if ! wait_for_pod "app.kubernetes.io/instance=cert-manager" "cert-manager" 5m; then
134+
echo "Failed to deploy cert-manager"
135+
${KUBECTL_BIN} get pods -n cert-manager
136+
exit 1
137+
fi
138+
139+
echo "Waiting for cert-manager webhook to be ready"
140+
# Wait for the webhook to be ready by checking if it can validate certificates
141+
for i in {1..30}; do
142+
if ${KUBECTL_BIN} get validatingwebhookconfigurations cert-manager-webhook &>/dev/null; then
143+
echo "cert-manager webhook is ready"
144+
return 0
145+
fi
146+
sleep 2
147+
done
148+
echo "Warning: cert-manager webhook may not be fully ready, continuing anyway"
149+
}
150+
84151
add_kustomizations
85152

86153
echo "Deploying catalog source"
@@ -108,6 +175,10 @@ if ! wait_for_pod "app=shipwright-operator" "${SUBSCRIPTION_NAMESPACE}" 5m; then
108175
exit 1
109176
fi
110177

178+
echo "Installing prerequisites"
179+
install_cert_manager
180+
install_tekton
181+
111182
echo "Deploying Shipwright build controller"
112183

113184
${KUBECTL_BIN} apply -f - <<EOF

0 commit comments

Comments
 (0)