Skip to content

Commit

Permalink
Add unique ClusterRoleBinding names
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira committed Jan 23, 2024
1 parent bd4d72e commit 6b56fe3
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 115 deletions.
224 changes: 112 additions & 112 deletions config/crd/bases/trustyai.opendatahub.io_trustyaiservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,121 +2,121 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: trustyaiservices.trustyai.opendatahub.io
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: trustyaiservices.trustyai.opendatahub.io
spec:
group: trustyai.opendatahub.io
names:
kind: TrustyAIService
listKind: TrustyAIServiceList
plural: trustyaiservices
singular: trustyaiservice
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: TrustyAIService is the Schema for the trustyaiservices API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
group: trustyai.opendatahub.io
names:
kind: TrustyAIService
listKind: TrustyAIServiceList
plural: trustyaiservices
singular: trustyaiservice
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: TrustyAIService is the Schema for the trustyaiservices API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: TrustyAIServiceSpec defines the desired state of TrustyAIService
properties:
data:
properties:
filename:
type: string
format:
type: string
required:
- filename
- format
type: object
metrics:
properties:
batchSize:
type: integer
schedule:
type: string
required:
- schedule
type: object
replicas:
description: Number of replicas
format: int32
type: integer
storage:
properties:
folder:
type: string
format:
type: string
size:
type: string
required:
- folder
- format
- size
type: object
required:
- data
- metrics
- storage
type: object
status:
description: TrustyAIServiceStatus defines the observed state of TrustyAIService
properties:
conditions:
items:
description: Condition represents possible conditions of a TrustyAIServiceStatus
properties:
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
phase:
description: Define your status fields here
type: string
ready:
type: string
replicas:
format: int32
type: integer
required:
- conditions
- phase
- replicas
type: object
type: string
metadata:
type: object
spec:
description: TrustyAIServiceSpec defines the desired state of TrustyAIService
properties:
data:
properties:
filename:
type: string
format:
type: string
required:
- filename
- format
type: object
metrics:
properties:
batchSize:
type: integer
schedule:
type: string
required:
- schedule
type: object
replicas:
description: Number of replicas
format: int32
type: integer
storage:
properties:
folder:
type: string
format:
type: string
size:
type: string
required:
- folder
- format
- size
type: object
required:
- data
- metrics
- storage
type: object
status:
description: TrustyAIServiceStatus defines the observed state of TrustyAIService
properties:
conditions:
items:
description: Condition represents possible conditions of a TrustyAIServiceStatus
properties:
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
served: true
storage: true
subresources:
status: {}
type: array
phase:
description: Define your status fields here
type: string
ready:
type: string
replicas:
format: int32
type: integer
required:
- conditions
- phase
- replicas
type: object
type: object
served: true
storage: true
subresources:
status: {}
5 changes: 2 additions & 3 deletions controllers/service_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (r *TrustyAIServiceReconciler) createServiceAccount(ctx context.Context, in
func (r *TrustyAIServiceReconciler) createClusterRoleBinding(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, serviceAccountName string) error {
clusterRoleBinding := &rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: instance.Name + "-proxy-rolebinding",
Name: instance.Name + "-" + instance.Namespace + "-proxy-rolebinding",
Namespace: instance.Namespace,
},
Subjects: []rbacv1.Subject{
Expand Down Expand Up @@ -128,10 +128,9 @@ func (r *TrustyAIServiceReconciler) createClusterRoleBinding(ctx context.Context
log.FromContext(ctx).Info("Creating a new ClusterRoleBinding", "Name", clusterRoleBinding.Name)
err = r.Create(ctx, clusterRoleBinding)
if err != nil {
log.FromContext(ctx).Error(err, "Error creating a new ClusterRoleBinding")
return err
}
} else if err != nil {
return err
}

return nil
Expand Down

0 comments on commit 6b56fe3

Please sign in to comment.