Skip to content

Commit 86433a6

Browse files
author
Dmitriy Kalinin
committed
remove option to enable shared service account
1 parent a95f092 commit 86433a6

File tree

7 files changed

+14
-39
lines changed

7 files changed

+14
-39
lines changed

cmd/controller/app_factory.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ import (
1515
)
1616

1717
type AppFactory struct {
18-
coreClient kubernetes.Interface
19-
appClient kcclient.Interface
20-
allowSharedServiceAccount bool
18+
coreClient kubernetes.Interface
19+
appClient kcclient.Interface
2120
}
2221

2322
func (f *AppFactory) NewCRDApp(app *kcv1alpha1.App, log logr.Logger) *ctlapp.CRDApp {
2423
fetchFactory := fetch.NewFactory(f.coreClient)
2524
templateFactory := template.NewFactory(f.coreClient, fetchFactory)
26-
deployFactory := deploy.NewFactory(f.coreClient, allowSharedServiceAccount)
25+
deployFactory := deploy.NewFactory(f.coreClient)
2726
return ctlapp.NewCRDApp(app, log, f.appClient, fetchFactory, templateFactory, deployFactory)
2827
}

cmd/controller/main.go

+6-14
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ const (
3232
)
3333

3434
var (
35-
log = logf.Log.WithName("kc")
36-
ctrlConcurrency = 10
37-
ctrlNamespace = ""
38-
allowSharedServiceAccount = false
39-
enablePprof = false
35+
log = logf.Log.WithName("kc")
36+
ctrlConcurrency = 10
37+
ctrlNamespace = ""
38+
enablePprof = false
4039
)
4140

4241
const (
@@ -46,8 +45,6 @@ const (
4645
func main() {
4746
flag.IntVar(&ctrlConcurrency, "concurrency", 10, "Max concurrent reconciles")
4847
flag.StringVar(&ctrlNamespace, "namespace", "", "Namespace to watch")
49-
flag.BoolVar(&allowSharedServiceAccount, "dangerous-allow-shared-service-account",
50-
false, "If set to true, allow use of shared service account instead of per-app service accounts")
5148
flag.BoolVar(&enablePprof, "dangerous-enable-pprof", false, "If set to true, enable pprof on "+pprofListenAddr)
5249
flag.Parse()
5350

@@ -80,9 +77,8 @@ func main() {
8077
}
8178

8279
appFactory := AppFactory{
83-
coreClient: coreClient,
84-
appClient: appClient,
85-
allowSharedServiceAccount: allowSharedServiceAccount,
80+
coreClient: coreClient,
81+
appClient: appClient,
8682
}
8783

8884
{ // add controller for apps
@@ -113,10 +109,6 @@ func main() {
113109

114110
entryLog.Info("starting manager")
115111

116-
if allowSharedServiceAccount {
117-
entryLog.Info("DANGEROUS in production setting -- allow shared service account")
118-
}
119-
120112
if enablePprof {
121113
entryLog.Info("DANGEROUS in production setting -- pprof running", "listen-addr", pprofListenAddr)
122114
go func() {

config/deployment.yml

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ spec:
2121
- name: kapp-controller
2222
image: kapp-controller
2323
args:
24-
#@ if/end data.values.dangerous_allow_shared_service_account:
25-
- -dangerous-allow-shared-service-account=true
2624
#@ if/end data.values.dangerous_enable_pprof:
2725
- -dangerous-enable-pprof=true
2826
env:

config/rbac.yml

-6
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,12 @@ apiVersion: rbac.authorization.k8s.io/v1
1212
metadata:
1313
name: kapp-controller-cluster-role
1414
rules:
15-
#@ if data.values.dangerous_allow_shared_service_account:
16-
- apiGroups: ["*"]
17-
resources: ["*"]
18-
verbs: ["*"]
19-
#@ else:
2015
- apiGroups: [""]
2116
resources: ["serviceaccounts", "secrets", "configmaps"]
2217
verbs: ["get"]
2318
- apiGroups: ["kappctrl.k14s.io"]
2419
resources: ["apps", "apps/status"]
2520
verbs: ["*"]
26-
#@ end
2721
---
2822
kind: ClusterRoleBinding
2923
apiVersion: rbac.authorization.k8s.io/v1

config/values.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace: kapp-controller
44
create_namespace: true
55

6-
dangerous_allow_shared_service_account: false
76
dangerous_enable_pprof: false
87

98
push_images: false

hack/build-release.sh

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ set -e -x -u
44

55
mkdir -p tmp/
66

7-
ytt -f config/ -f config-release | kbld -f- > ./tmp/release.yml --lock-output ./tmp/images.yml
8-
9-
shared_sa_flags="--data-value-yaml dangerous_allow_shared_service_account=true"
10-
ytt -f config/ -f config-release $shared_sa_flags | kbld -f- -f ./tmp/images.yml > ./tmp/release-dangerous-allow-shared-sa.yml
7+
ytt -f config/ -f config-release | kbld -f- > ./tmp/release.yml
118

129
shasum -a 256 ./tmp/release*.yml
1310

pkg/deploy/factory.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ import (
1111
)
1212

1313
type Factory struct {
14-
coreClient kubernetes.Interface
15-
allowSharedServiceAccount bool
14+
coreClient kubernetes.Interface
1615

1716
kubeconfigSecrets *KubeconfigSecrets
1817
serviceAccounts *ServiceAccounts
1918
}
2019

21-
func NewFactory(coreClient kubernetes.Interface, allowSharedServiceAccount bool) Factory {
22-
return Factory{coreClient, allowSharedServiceAccount,
23-
NewKubeconfigSecrets(coreClient), NewServiceAccounts(coreClient)}
20+
func NewFactory(coreClient kubernetes.Interface) Factory {
21+
return Factory{coreClient, NewKubeconfigSecrets(coreClient), NewServiceAccounts(coreClient)}
2422
}
2523

2624
func (f Factory) NewKapp(opts v1alpha1.AppDeployKapp, saName string,
@@ -42,9 +40,7 @@ func (f Factory) NewKapp(opts v1alpha1.AppDeployKapp, saName string,
4240
}
4341

4442
default:
45-
if !f.allowSharedServiceAccount {
46-
return nil, fmt.Errorf("Expected service account or cluster specified (shared service account is not allowed)")
47-
}
43+
return nil, fmt.Errorf("Expected service account or cluster specified")
4844
}
4945

5046
return NewKapp(opts, genericOpts, cancelCh), nil

0 commit comments

Comments
 (0)