Skip to content

Commit 05a312b

Browse files
Merge pull request #75 from bharath-b-rh/eso-155-3
ESO-182: Updates to use different TLS Secret name and disables cluster resource reconcile based on user config
2 parents cf0967f + d82cfc0 commit 05a312b

File tree

8 files changed

+98
-61
lines changed

8 files changed

+98
-61
lines changed

Makefile

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,15 @@ run: manifests generate fmt vet ## Run a controller from your host.
179179
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
180180
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
181181
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
182-
.PHONY: docker-build
183-
docker-build: ## Build docker image with the manager.
182+
.PHONY: image-build
183+
image-build: ## Build operator image.
184184
$(CONTAINER_TOOL) build -t ${IMG} .
185185

186-
.PHONY: docker-push
187-
docker-push: ## Push docker image with the manager.
186+
.PHONY: image-push
187+
image-push: ## Push operator image.
188188
$(CONTAINER_TOOL) push ${IMG}
189189

190-
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
190+
# PLATFORMS defines the target platforms for the operator image be built to provide support to multiple
191191
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
192192
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
193193
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
@@ -198,10 +198,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
198198
docker-buildx: ## Build and push docker image for the manager for cross-platform support
199199
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
200200
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
201-
- $(CONTAINER_TOOL) buildx create --name external-secrets-operator-builder
202-
$(CONTAINER_TOOL) buildx use external-secrets-operator-builder
203-
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
204-
- $(CONTAINER_TOOL) buildx rm external-secrets-operator-builder
201+
- docker buildx create --name external-secrets-operator-builder
202+
docker buildx use external-secrets-operator-builder
203+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
204+
- docker buildx rm external-secrets-operator-builder
205205
rm Dockerfile.cross
206206

207207
.PHONY: build-installer
@@ -240,7 +240,7 @@ LOCALBIN ?= $(shell pwd)/bin
240240
$(LOCALBIN):
241241
mkdir -p $(LOCALBIN)
242242

243-
## Location to story temp outputs
243+
## Location to store temp outputs
244244
OUTPUTS_PATH ?= $(shell pwd)/_output
245245
$(OUTPUTS_PATH):
246246
mkdir -p $(OUTPUTS_PATH)
@@ -293,16 +293,16 @@ govulncheck: $(LOCALBIN) ## Download govulncheck locally if necessary.
293293
ginkgo: $(LOCALBIN) ## Download ginkgo locally if necessary.
294294
$(call go-install-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo)
295295

296-
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
296+
# go-install-tool will 'go install' any package with custom target and name of the binary.
297297
# $1 - target path with name of binary
298298
# $2 - package url which can be installed
299299
define go-install-tool
300300
@{ \
301301
set -e; \
302302
package=$(2) ;\
303-
echo "Downloading $${package}" ;\
303+
echo "Installing $${package}" ;\
304304
rm -f $(1) || true ;\
305-
GOBIN=$(LOCALBIN) go install $${package} ;\
305+
GOBIN=$(LOCALBIN) GOFLAGS="-mod=vendor" go install $${package} ;\
306306
}
307307
endef
308308

@@ -352,11 +352,11 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada
352352

353353
.PHONY: bundle-build
354354
bundle-build: ## Build the bundle image.
355-
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
355+
$(CONTAINER_TOOL) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
356356

357357
.PHONY: bundle-push
358358
bundle-push: ## Push the bundle image.
359-
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
359+
$(CONTAINER_TOOL) push $(BUNDLE_IMG)
360360

361361
.PHONY: opm
362362
OPM = $(LOCALBIN)/opm
@@ -392,12 +392,12 @@ endif
392392
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
393393
.PHONY: catalog-build
394394
catalog-build: opm ## Build a catalog image.
395-
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
395+
$(OPM) index add --container-tool $(CONTAINER_TOOL) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
396396

397397
# Push the catalog image.
398398
.PHONY: catalog-push
399399
catalog-push: ## Push a catalog image.
400-
$(MAKE) docker-push IMG=$(CATALOG_IMG)
400+
$(CONTAINER_TOOL) push $(CATALOG_IMG)
401401

402402
## verify the changes are working as expected.
403403
.PHONY: verify
@@ -419,15 +419,30 @@ docs: crd-ref-docs
419419

420420
## perform vulnerabilities scan using govulncheck.
421421
.PHONY: govulnscan
422-
#The ignored vulnerabilities are not in the operator code, but in the vendored packages.
422+
# The ignored vulnerabilities are not in the operator code, but in the vendored packages.
423+
# Each vulnerability ID corresponds to a specific issue that has been reviewed and deemed
424+
# acceptable for the current vendored dependencies.
423425
# - https://pkg.go.dev/vuln/GO-2025-3956
424426
# - https://pkg.go.dev/vuln/GO-2025-3547
425427
# - https://pkg.go.dev/vuln/GO-2025-3521
426-
KNOWN_VULNERABILITIES:="GO-2025-3547|GO-2025-3521|GO-2025-3956|GO-2025-3915"
428+
KNOWN_VULNERABILITIES=GO-2025-3956|GO-2025-3547|GO-2025-3521
427429
govulnscan: govulncheck $(OUTPUTS_PATH) ## Run govulncheck
428-
- $(GOVULNCHECK) ./... > $(OUTPUTS_PATH)/govulcheck.results 2>&1
429-
$(eval reported_vulnerabilities = $(strip $(shell grep "pkg.go.dev" $(OUTPUTS_PATH)/govulcheck.results | ([ -n $KNOWN_VULNERABILITIES ] && grep -Ev $(KNOWN_VULNERABILITIES) || cat) | wc -l)))
430-
@(if [ $(reported_vulnerabilities) -ne 0 ]; then echo -e "\n-- ERROR -- $(reported_vulnerabilities) new vulnerabilities reported, please check\n"; exit 1; fi)
430+
@echo "Running govulncheck vulnerability scan..."
431+
@$(GOVULNCHECK) ./... > $(OUTPUTS_PATH)/govulcheck.results 2>&1 || true
432+
@grep -q "pkg.go.dev" $(OUTPUTS_PATH)/govulcheck.results || { \
433+
echo "-- ERROR -- govulncheck may have failed to run; see $(OUTPUTS_PATH)/govulcheck.results"; exit 1; }
434+
@echo "Filtering known vulnerabilities and counting new ones..."
435+
$(eval reported_vulnerabilities = $(strip $(shell grep "pkg.go.dev" $(OUTPUTS_PATH)/govulcheck.results | grep -Ev "$(KNOWN_VULNERABILITIES)" | wc -l)))
436+
@echo "Found $(reported_vulnerabilities) new vulnerabilities (excluding known issues)"
437+
@(if [ $(reported_vulnerabilities) -ne 0 ]; then \
438+
echo ""; \
439+
echo "-- ERROR -- $(reported_vulnerabilities) new vulnerabilities reported"; \
440+
echo "Please review $(OUTPUTS_PATH)/govulcheck.results for details"; \
441+
echo ""; \
442+
exit 1; \
443+
else \
444+
echo "✓ Vulnerability scan passed - no new issues found"; \
445+
fi)
431446

432447
# Utilize controller-runtime provided envtest for API integration test
433448
.PHONY: test-apis ## Run only the api integration tests.

bundle/manifests/external-secrets-operator.clusterserviceversion.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ metadata:
220220
categories: Security
221221
console.openshift.io/disable-operand-delete: "true"
222222
containerImage: openshift.io/external-secrets-operator:latest
223-
createdAt: "2025-10-09T11:13:16Z"
223+
createdAt: "2025-10-09T14:41:51Z"
224224
features.operators.openshift.io/cnf: "false"
225225
features.operators.openshift.io/cni: "false"
226226
features.operators.openshift.io/csi: "false"
@@ -756,12 +756,9 @@ spec:
756756
initialDelaySeconds: 5
757757
periodSeconds: 10
758758
resources:
759-
limits:
760-
cpu: 500m
761-
memory: 128Mi
762759
requests:
763-
cpu: 10m
764-
memory: 64Mi
760+
cpu: 100m
761+
memory: 1Gi
765762
securityContext:
766763
allowPrivilegeEscalation: false
767764
capabilities:

cmd/external-secrets-operator/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ func main() {
156156
metricsServerOptions.KeyName = metricsKeyFileName
157157
}
158158
metricsTLSOpts = append(metricsTLSOpts, func(c *tls.Config) {
159-
certPool := x509.NewCertPool()
159+
certPool, err := x509.SystemCertPool()
160+
if err != nil {
161+
setupLog.Info("unable to load system certificate pool", "error", err)
162+
certPool = x509.NewCertPool()
163+
}
160164
openshiftCACert, err := os.ReadFile(openshiftCACertificateFile)
161165
if err != nil {
162166
setupLog.Error(err, "failed to read OpenShift CA certificate")

config/manager/manager.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,8 @@ spec:
119119
initialDelaySeconds: 5
120120
periodSeconds: 10
121121
resources:
122-
limits:
123-
cpu: 500m
124-
memory: 128Mi
125122
requests:
126-
cpu: 10m
127-
memory: 64Mi
123+
cpu: 100m
124+
memory: 1Gi
128125
serviceAccountName: controller-manager
129126
terminationGracePeriodSeconds: 10

pkg/controller/common/utils.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,17 @@ func deploymentSpecModified(desired, fetched *appsv1.Deployment) bool {
224224
return true
225225
}
226226
for _, desiredVolume := range desired.Spec.Template.Spec.Volumes {
227-
if desiredVolume.Secret != nil && desiredVolume.Secret.Items != nil {
227+
if desiredVolume.Secret != nil {
228228
for _, fetchedVolume := range fetched.Spec.Template.Spec.Volumes {
229-
if !reflect.DeepEqual(desiredVolume.Secret.Items, fetchedVolume.Secret.Items) {
230-
return true
231-
}
232-
if desiredVolume.Secret.SecretName != fetchedVolume.Secret.SecretName {
233-
return true
229+
if desiredVolume.Name == fetchedVolume.Name {
230+
if !reflect.DeepEqual(desiredVolume.Secret.Items, fetchedVolume.Secret.Items) {
231+
return true
232+
}
233+
if !reflect.DeepEqual(desiredVolume.Secret.SecretName, fetchedVolume.Secret.SecretName) {
234+
return true
235+
}
234236
}
235237
}
236-
237238
}
238239
}
239240

pkg/controller/external_secrets/certificate.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ func (r *Reconciler) createOrApplyCertificate(esc *operatorv1alpha1.ExternalSecr
8282
func (r *Reconciler) getCertificateObject(esc *operatorv1alpha1.ExternalSecretsConfig, resourceLabels map[string]string, fileName string) (*certmanagerv1.Certificate, error) {
8383
certificate := common.DecodeCertificateObjBytes(assets.MustAsset(fileName))
8484

85+
// update the secret name in the Certificate resource of the webhook component.
86+
if fileName == webhookCertificateAssetName {
87+
certificate.Spec.SecretName = certmanagerTLSSecretWebhook
88+
}
89+
8590
updateNamespace(certificate, esc)
8691
common.UpdateResourceLabels(certificate, resourceLabels)
8792

pkg/controller/external_secrets/constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ const (
4848
// externalsecretsDefaultNamespace is the namespace where the `external-secrets` operand required resources
4949
// will be created, when ExternalSecretsConfig.Spec.Namespace is not set.
5050
externalsecretsDefaultNamespace = "external-secrets"
51+
52+
// certmanagerTLSSecretWebhook is the TLS secret created by cert-manager for the webhook component. A different
53+
// name is used to avoiding clash with the secret created by the inbuilt cert-controller component.
54+
certmanagerTLSSecretWebhook = "external-secrets-webhook-cm"
5155
)
5256

5357
var (

pkg/controller/external_secrets/deployments.go

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ func (r *Reconciler) getDeploymentObject(assetName string, esc *operatorv1alpha1
123123
checkInterval = esc.Spec.ApplicationConfig.WebhookConfig.CertificateCheckInterval.Duration.String()
124124
}
125125
updateWebhookContainerSpec(deployment, image, logLevel, checkInterval)
126+
updateWebhookVolumeConfig(deployment, esc)
126127
case certControllerDeploymentAssetName:
127128
updateCertControllerContainerSpec(deployment, image, logLevel)
128129
case bitwardenDeploymentAssetName:
@@ -302,20 +303,31 @@ func (r *Reconciler) updateImageInStatus(esc *operatorv1alpha1.ExternalSecretsCo
302303

303304
// argument list for external-secrets deployment resource
304305
func updateContainerSpec(deployment *appsv1.Deployment, esc *operatorv1alpha1.ExternalSecretsConfig, image, logLevel string) {
305-
namespace := getOperatingNamespace(esc)
306+
var (
307+
enableClusterStoreArgFmt = "--enable-cluster-store-reconciler=%s"
308+
enableClusterExternalSecretsArgFmt = "--enable-cluster-external-secret-reconciler=%s"
309+
)
310+
306311
args := []string{
307312
"--concurrent=1",
308313
"--metrics-addr=:8080",
309314
fmt.Sprintf("--loglevel=%s", logLevel),
310315
"--zap-time-encoding=epoch",
311316
"--enable-leader-election=true",
312-
"--enable-cluster-store-reconciler=true",
313-
"--enable-cluster-external-secret-reconciler=true",
314317
"--enable-push-secret-reconciler=true",
315318
}
316319

320+
// when spec.appConfig.operatingNamespace is configured, which is for restricting the
321+
// external-secrets custom resource reconcile scope to specified namespace, the reconciliation
322+
// of cluster scoped custom resources must also be disabled.
323+
namespace := getOperatingNamespace(esc)
317324
if namespace != "" {
318-
args = append(args, fmt.Sprintf("--namespace=%s", namespace))
325+
args = append(args, fmt.Sprintf("--namespace=%s", namespace),
326+
fmt.Sprintf(enableClusterStoreArgFmt, "false"),
327+
fmt.Sprintf(enableClusterExternalSecretsArgFmt, "false"))
328+
} else {
329+
args = append(args, fmt.Sprintf(enableClusterStoreArgFmt, "true"),
330+
fmt.Sprintf(enableClusterExternalSecretsArgFmt, "true"))
319331
}
320332

321333
for i, container := range deployment.Spec.Template.Spec.Containers {
@@ -399,27 +411,29 @@ func updateBitwardenVolumeConfig(deployment *appsv1.Deployment, esc *operatorv1a
399411
}
400412
}
401413

414+
func updateWebhookVolumeConfig(deployment *appsv1.Deployment, esc *operatorv1alpha1.ExternalSecretsConfig) {
415+
if isCertManagerConfigEnabled(esc) {
416+
updateSecretVolumeConfig(deployment, "certs", certmanagerTLSSecretWebhook)
417+
}
418+
}
419+
402420
func updateSecretVolumeConfig(deployment *appsv1.Deployment, volumeName, secretName string) {
403-
volumeExists := false
404421
for i := range deployment.Spec.Template.Spec.Volumes {
405422
if deployment.Spec.Template.Spec.Volumes[i].Name == volumeName {
406-
volumeExists = true
407-
}
408-
if deployment.Spec.Template.Spec.Volumes[i].Secret == nil {
409-
deployment.Spec.Template.Spec.Volumes[i].Secret = &corev1.SecretVolumeSource{}
423+
if deployment.Spec.Template.Spec.Volumes[i].Secret == nil {
424+
deployment.Spec.Template.Spec.Volumes[i].Secret = &corev1.SecretVolumeSource{}
425+
}
426+
deployment.Spec.Template.Spec.Volumes[i].Secret.SecretName = secretName
427+
return
410428
}
411-
deployment.Spec.Template.Spec.Volumes[i].Secret.SecretName = secretName
412-
break
413429
}
414430

415-
if !volumeExists {
416-
deployment.Spec.Template.Spec.Volumes = append(deployment.Spec.Template.Spec.Volumes, corev1.Volume{
417-
Name: volumeName,
418-
VolumeSource: corev1.VolumeSource{
419-
Secret: &corev1.SecretVolumeSource{
420-
SecretName: secretName,
421-
},
431+
deployment.Spec.Template.Spec.Volumes = append(deployment.Spec.Template.Spec.Volumes, corev1.Volume{
432+
Name: volumeName,
433+
VolumeSource: corev1.VolumeSource{
434+
Secret: &corev1.SecretVolumeSource{
435+
SecretName: secretName,
422436
},
423-
})
424-
}
437+
},
438+
})
425439
}

0 commit comments

Comments
 (0)