Skip to content

Commit a6fc76a

Browse files
Merge pull request #18 from bharath-b-rh/eso-49
ESO-49: Implement the functionality to ensure RBAC specific resources stay in desired state
2 parents 0dabaa6 + 57f0d0b commit a6fc76a

31 files changed

+1189
-141
lines changed

Dockerfile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,7 @@ ARG TARGETOS
44
ARG TARGETARCH
55

66
WORKDIR /workspace
7-
# Copy the Go Modules manifests
8-
COPY go.mod go.mod
9-
COPY go.sum go.sum
10-
# cache deps before building and copying source so that we don't need to re-download as much
11-
# and so that source changes don't invalidate our downloaded layer
12-
RUN go mod download
13-
14-
# Copy the go source
15-
COPY cmd/external-secrets-operator/main.go cmd/external-secrets-operator/main.go
16-
COPY api/ api/
17-
COPY pkg/controller/ pkg/controller/
7+
COPY . .
188

199
# Build
2010
# the GOARCH has not a default value to allow the binary be built according to the host where the command

api/v1alpha1/external_secrets_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ type ExternalSecretsConfig struct {
120120

121121
// ControllerConfig is for configuring the operator for setting up
122122
// defaults to install external-secrets.
123+
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.namespace) && !has(self.namespace) || has(oldSelf.namespace) && has(self.namespace)",message="namespace may only be configured during creation"
123124
type ControllerConfig struct {
124125
// namespace is for configuring the namespace to install the external-secret operand.
125126
// +kubebuilder:validation:Optional
126127
// +kubebuilder:default:="external-secrets"
128+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable once set"
127129
Namespace string `json:"namespace,omitempty"`
128130

129131
// labels to apply to all resources created for external-secrets deployment.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: external-secrets

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

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ metadata:
3333
categories: Security
3434
console.openshift.io/disable-operand-delete: "true"
3535
containerImage: ""
36-
createdAt: "2025-05-27T10:56:51Z"
36+
createdAt: "2025-06-02T08:50:05Z"
3737
features.operators.openshift.io/cnf: "false"
3838
features.operators.openshift.io/cni: "false"
3939
features.operators.openshift.io/csi: "false"
@@ -175,6 +175,7 @@ spec:
175175
- apiGroups:
176176
- ""
177177
resources:
178+
- configmaps
178179
- events
179180
- secrets
180181
- serviceaccounts
@@ -187,6 +188,22 @@ spec:
187188
- patch
188189
- update
189190
- watch
191+
- apiGroups:
192+
- ""
193+
resources:
194+
- endpoints
195+
- namespaces
196+
verbs:
197+
- create
198+
- get
199+
- list
200+
- watch
201+
- apiGroups:
202+
- ""
203+
resources:
204+
- serviceaccounts/token
205+
verbs:
206+
- create
190207
- apiGroups:
191208
- admissionregistration.k8s.io
192209
resources:
@@ -199,6 +216,18 @@ spec:
199216
- patch
200217
- update
201218
- watch
219+
- apiGroups:
220+
- apiextensions.k8s.io
221+
resources:
222+
- customresourcedefinitions
223+
verbs:
224+
- create
225+
- delete
226+
- get
227+
- list
228+
- patch
229+
- update
230+
- watch
202231
- apiGroups:
203232
- apps
204233
resources:
@@ -235,10 +264,71 @@ spec:
235264
- patch
236265
- update
237266
- watch
267+
- apiGroups:
268+
- external-secrets.io
269+
resources:
270+
- clusterexternalsecrets
271+
- clustersecretstores
272+
- externalsecrets
273+
- pushsecrets
274+
- secretstores
275+
verbs:
276+
- create
277+
- delete
278+
- deletecollection
279+
- get
280+
- list
281+
- patch
282+
- update
283+
- watch
284+
- apiGroups:
285+
- external-secrets.io
286+
resources:
287+
- clusterexternalsecrets/finalizers
288+
- clusterexternalsecrets/status
289+
- clustersecretstores/finalizers
290+
- clustersecretstores/status
291+
- externalsecrets/finalizers
292+
- externalsecrets/status
293+
- pushsecrets/finalizers
294+
- pushsecrets/status
295+
- secretstores/finalizers
296+
- secretstores/status
297+
verbs:
298+
- get
299+
- patch
300+
- update
301+
- apiGroups:
302+
- generators.external-secrets.io
303+
resources:
304+
- acraccesstokens
305+
- clustergenerators
306+
- ecrauthorizationtokens
307+
- fakes
308+
- gcraccesstokens
309+
- generatorstates
310+
- githubaccesstokens
311+
- grafanas
312+
- passwords
313+
- quayaccesstokens
314+
- stssessiontokens
315+
- uuids
316+
- vaultdynamicsecrets
317+
- webhooks
318+
verbs:
319+
- create
320+
- delete
321+
- deletecollection
322+
- get
323+
- list
324+
- patch
325+
- update
326+
- watch
238327
- apiGroups:
239328
- operator.openshift.io
240329
resources:
241330
- externalsecrets
331+
- externalsecretsmanagers
242332
verbs:
243333
- create
244334
- delete

bundle/manifests/operator.openshift.io_externalsecrets.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ spec:
6363
description: namespace is for configuring the namespace to install
6464
the external-secret operand.
6565
type: string
66+
x-kubernetes-validations:
67+
- message: namespace is immutable once set
68+
rule: self == oldSelf
6669
type: object
70+
x-kubernetes-validations:
71+
- message: namespace may only be configured during creation
72+
rule: '!has(oldSelf.namespace) && !has(self.namespace) || has(oldSelf.namespace)
73+
&& has(self.namespace)'
6774
externalSecretsConfig:
6875
description: externalSecretsConfig is for configuring the external-secrets
6976
behavior.
@@ -1278,6 +1285,10 @@ spec:
12781285
x-kubernetes-list-map-keys:
12791286
- type
12801287
x-kubernetes-list-type: map
1288+
externalSecretsImage:
1289+
description: externalSecretsImage is the name of the image and the
1290+
tag used for deploying external-secrets.
1291+
type: string
12811292
type: object
12821293
type: object
12831294
x-kubernetes-validations:

cmd/external-secrets-operator/main.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@ import (
2121
"flag"
2222
"os"
2323

24+
appsv1 "k8s.io/api/apps/v1"
25+
corev1 "k8s.io/api/core/v1"
26+
rbacv1 "k8s.io/api/rbac/v1"
2427
"k8s.io/apimachinery/pkg/runtime"
2528
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2629
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
30+
"k8s.io/klog/v2/textlogger"
2731
ctrl "sigs.k8s.io/controller-runtime"
2832
"sigs.k8s.io/controller-runtime/pkg/healthz"
29-
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3033
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
3134
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3235
"sigs.k8s.io/controller-runtime/pkg/webhook"
3336

34-
zaplog "go.uber.org/zap"
35-
"go.uber.org/zap/zapcore"
36-
3737
certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
38+
3839
operatorv1alpha1 "github.com/openshift/external-secrets-operator/api/v1alpha1"
3940
externalsecretscontroller "github.com/openshift/external-secrets-operator/pkg/controller"
4041
// +kubebuilder:scaffold:imports
@@ -47,9 +48,12 @@ var (
4748

4849
func init() {
4950
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
51+
utilruntime.Must(appsv1.AddToScheme(scheme))
52+
utilruntime.Must(corev1.AddToScheme(scheme))
53+
utilruntime.Must(rbacv1.AddToScheme(scheme))
54+
utilruntime.Must(certmanagerv1.AddToScheme(scheme))
5055

5156
utilruntime.Must(operatorv1alpha1.AddToScheme(scheme))
52-
utilruntime.Must(certmanagerv1.AddToScheme(scheme))
5357
// +kubebuilder:scaffold:scheme
5458
}
5559

@@ -73,16 +77,8 @@ func main() {
7377
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
7478
flag.IntVar(&logLevel, "v", 1, "operator log verbosity")
7579

76-
opts := zap.Options{
77-
Development: true,
78-
ZapOpts: []zaplog.Option{zaplog.AddCaller()},
79-
TimeEncoder: zapcore.ISO8601TimeEncoder,
80-
Level: zaplog.NewAtomicLevelAt(zapcore.Level(logLevel)),
81-
}
82-
opts.BindFlags(flag.CommandLine)
83-
flag.Parse()
84-
85-
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
80+
logConfig := textlogger.NewConfig(textlogger.Verbosity(logLevel))
81+
ctrl.SetLogger(textlogger.NewLogger(logConfig))
8682

8783
// if the enable-http2 flag is false (the default), http/2 should be disabled
8884
// due to its vulnerabilities. More specifically, disabling http/2 will
@@ -134,6 +130,7 @@ func main() {
134130
HealthProbeBindAddress: probeAddr,
135131
LeaderElection: enableLeaderElection,
136132
LeaderElectionID: "de6a4747.operator.openshift.io",
133+
Logger: ctrl.Log.WithName("operator-manager"),
137134
})
138135
if err != nil {
139136
setupLog.Error(err, "failed to create controller manager")

config/crd/bases/operator.openshift.io_externalsecrets.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ spec:
6363
description: namespace is for configuring the namespace to install
6464
the external-secret operand.
6565
type: string
66+
x-kubernetes-validations:
67+
- message: namespace is immutable once set
68+
rule: self == oldSelf
6669
type: object
70+
x-kubernetes-validations:
71+
- message: namespace may only be configured during creation
72+
rule: '!has(oldSelf.namespace) && !has(self.namespace) || has(oldSelf.namespace)
73+
&& has(self.namespace)'
6774
externalSecretsConfig:
6875
description: externalSecretsConfig is for configuring the external-secrets
6976
behavior.
@@ -1282,9 +1289,6 @@ spec:
12821289
description: externalSecretsImage is the name of the image and the
12831290
tag used for deploying external-secrets.
12841291
type: string
1285-
serviceAccount:
1286-
description: serviceAccount created by the controller for the external-secrets.
1287-
type: string
12881292
type: object
12891293
type: object
12901294
x-kubernetes-validations:

0 commit comments

Comments
 (0)