@@ -23,7 +23,6 @@ import (
23
23
appsv1 "k8s.io/api/apps/v1"
24
24
corev1 "k8s.io/api/core/v1"
25
25
v1 "k8s.io/api/core/v1"
26
- r1 "k8s.io/api/rbac/v1"
27
26
"k8s.io/apimachinery/pkg/api/errors"
28
27
"k8s.io/apimachinery/pkg/api/resource"
29
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -75,101 +74,6 @@ func GetService(config v1alpha1.K8sGPT) (*corev1.Service, error) {
75
74
return & service , nil
76
75
}
77
76
78
- // GetServiceAccount Create Service Account for K8sGPT and bind it to K8sGPT role
79
- func GetServiceAccount (config v1alpha1.K8sGPT ) (* corev1.ServiceAccount , error ) {
80
- // Create service account
81
- serviceAccount := corev1.ServiceAccount {
82
- ObjectMeta : metav1.ObjectMeta {
83
- Name : "k8sgpt" ,
84
- Namespace : config .Namespace ,
85
- OwnerReferences : []metav1.OwnerReference {
86
- {
87
- Kind : config .Kind ,
88
- Name : config .Name ,
89
- UID : config .UID ,
90
- APIVersion : config .APIVersion ,
91
- BlockOwnerDeletion : utils .PtrBool (true ),
92
- Controller : utils .PtrBool (true ),
93
- },
94
- },
95
- },
96
- }
97
-
98
- return & serviceAccount , nil
99
- }
100
-
101
- // GetClusterRoleBinding Create cluster role binding for K8sGPT
102
- func GetClusterRoleBinding (config v1alpha1.K8sGPT ) (* r1.ClusterRoleBinding , error ) {
103
-
104
- // Create cluster role binding
105
- clusterRoleBinding := r1.ClusterRoleBinding {
106
- ObjectMeta : metav1.ObjectMeta {
107
- Name : "k8sgpt" ,
108
- OwnerReferences : []metav1.OwnerReference {
109
- {
110
- Kind : config .Kind ,
111
- Name : config .Name ,
112
- UID : config .UID ,
113
- APIVersion : config .APIVersion ,
114
- BlockOwnerDeletion : utils .PtrBool (true ),
115
- Controller : utils .PtrBool (true ),
116
- },
117
- },
118
- },
119
- Subjects : []r1.Subject {
120
- {
121
- Kind : "ServiceAccount" ,
122
- Name : "k8sgpt" ,
123
- Namespace : config .Namespace ,
124
- },
125
- },
126
- RoleRef : r1.RoleRef {
127
- Kind : "ClusterRole" ,
128
- Name : "k8sgpt" ,
129
- APIGroup : "rbac.authorization.k8s.io" ,
130
- },
131
- }
132
-
133
- return & clusterRoleBinding , nil
134
- }
135
-
136
- // GetClusterRole Create ClusterRole for K8sGPT with cluster read all
137
- func GetClusterRole (config v1alpha1.K8sGPT ) (* r1.ClusterRole , error ) {
138
-
139
- // Create cluster role
140
- clusterRole := r1.ClusterRole {
141
- ObjectMeta : metav1.ObjectMeta {
142
- Name : "k8sgpt" ,
143
- OwnerReferences : []metav1.OwnerReference {
144
- {
145
- Kind : config .Kind ,
146
- Name : config .Name ,
147
- UID : config .UID ,
148
- APIVersion : config .APIVersion ,
149
- BlockOwnerDeletion : utils .PtrBool (true ),
150
- Controller : utils .PtrBool (true ),
151
- },
152
- },
153
- },
154
- Rules : []r1.PolicyRule {
155
- {
156
- APIGroups : []string {"*" },
157
- Resources : []string {"*" },
158
- // This is necessary for the creation of integrations
159
- Verbs : []string {"create" , "list" , "get" , "watch" , "delete" },
160
- },
161
- // Allow creation of custom resources
162
- {
163
- APIGroups : []string {"apiextensions.k8s.io" },
164
- Resources : []string {"*" },
165
- Verbs : []string {"*" },
166
- },
167
- },
168
- }
169
-
170
- return & clusterRole , nil
171
- }
172
-
173
77
// GetDeployment Create deployment with the latest K8sGPT image
174
78
func GetDeployment (config v1alpha1.K8sGPT ) (* appsv1.Deployment , error ) {
175
79
@@ -345,27 +249,6 @@ func Sync(ctx context.Context, c client.Client,
345
249
346
250
objs = append (objs , svc )
347
251
348
- svcAcc , er := GetServiceAccount (config )
349
- if er != nil {
350
- return er
351
- }
352
-
353
- objs = append (objs , svcAcc )
354
-
355
- clusterRole , er := GetClusterRole (config )
356
- if er != nil {
357
- return er
358
- }
359
-
360
- objs = append (objs , clusterRole )
361
-
362
- clusterRoleBinding , er := GetClusterRoleBinding (config )
363
- if er != nil {
364
- return er
365
- }
366
-
367
- objs = append (objs , clusterRoleBinding )
368
-
369
252
deployment , er := GetDeployment (config )
370
253
if er != nil {
371
254
return er
0 commit comments