Skip to content

Commit f4ba48a

Browse files
authored
Merge pull request #70 from cdapio/bugfix/securitySecret-workers
[CDAP-18079 CDAP-18004] Add Support for Worker Secrets
2 parents 2431b82 + 3d05b08 commit f4ba48a

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

controllers/cdapmaster_controller.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,20 @@ func ApplyDefaults(resource interface{}) {
133133
spec.Config[confLocalDataDirKey] = confLocalDataDirVal
134134
}
135135

136-
// Set twill.security.secret.disk.name to be consistent with securitySecret if not overwritten.
137-
if _, ok := spec.Config[confTwillSecuritySecretDiskName]; !ok {
138-
spec.Config[confTwillSecuritySecretDiskName] = spec.SecuritySecret
136+
// Set security secret disk names to be consistent with securitySecret if not overwritten.
137+
if _, ok := spec.Config[confTwillSecurityMasterSecretDiskName]; !ok && spec.SecuritySecret != "" {
138+
spec.Config[confTwillSecurityMasterSecretDiskName] = spec.SecuritySecret
139+
}
140+
if _, ok := spec.Config[confTwillSecurityMasterSecretDiskPath]; !ok && spec.SecuritySecret != "" {
141+
spec.Config[confTwillSecurityMasterSecretDiskPath] = defaultSecuritySecretPath
142+
}
143+
// This configuration makes the default securitySecret available to the workers by default.
144+
// TODO: Add support for secure-by-default configurations.
145+
if _, ok := spec.Config[confTwillSecurityWorkerSecretDiskName]; !ok && spec.SecuritySecret != "" {
146+
spec.Config[confTwillSecurityWorkerSecretDiskName] = spec.SecuritySecret
147+
}
148+
if _, ok := spec.Config[confTwillSecurityWorkerSecretDiskPath]; !ok && spec.SecuritySecret != "" {
149+
spec.Config[confTwillSecurityWorkerSecretDiskPath] = defaultSecuritySecretPath
139150
}
140151

141152
// Disable explore

controllers/constants.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,23 @@ const (
4747
fieldNameCDAPExternalServiceSpec = "CDAPExternalServiceSpec"
4848

4949
// cconf and hconf
50-
confExploreEnabled = "explore.enabled"
51-
confLocalDataDirKey = "local.data.dir"
52-
confLocalDataDirVal = "/data"
53-
confRouterServerAddress = "router.server.address"
54-
confRouterBindPort = "router.bind.port"
55-
confUserInterfaceBindPort = "dashboard.bind.port"
56-
confTwillSecuritySecretDiskName = "twill.security.secret.disk.name"
50+
confExploreEnabled = "explore.enabled"
51+
confLocalDataDirKey = "local.data.dir"
52+
confLocalDataDirVal = "/data"
53+
confRouterServerAddress = "router.server.address"
54+
confRouterBindPort = "router.bind.port"
55+
confUserInterfaceBindPort = "dashboard.bind.port"
56+
confTwillSecurityMasterSecretDiskName = "twill.security.master.secret.disk.name"
57+
confTwillSecurityMasterSecretDiskPath = "twill.security.master.secret.disk.path"
58+
confTwillSecurityWorkerSecretDiskName = "twill.security.worker.secret.disk.name"
59+
confTwillSecurityWorkerSecretDiskPath = "twill.security.worker.secret.disk.path"
5760

5861
// default values
59-
defaultImage = "gcr.io/cdapio/cdap:latest"
60-
defaultRouterPort = 11015
61-
defaultUserInterfacePort = 11011
62-
defaultStorageSize = "200Gi"
62+
defaultImage = "gcr.io/cdapio/cdap:latest"
63+
defaultRouterPort = 11015
64+
defaultUserInterfacePort = 11011
65+
defaultStorageSize = "200Gi"
66+
defaultSecuritySecretPath = "/etc/cdap/security"
6367

6468
// kubernetes labels
6569
labelInstanceKey = "cdap.instance"

controllers/spec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type BaseSpec struct {
131131
RuntimeClassName string `json:"runtimeClassName,omitempty"`
132132
PriorityClassName string `json:"priorityClassName,omitempty"`
133133
SecuritySecret string `json:"securitySecret,omitempty"`
134+
SecuritySecretPath string `json:"securitySecretPath,omitempty"`
134135
CConf string `json:"cdapConf,omitempty"`
135136
HConf string `json:"hadoopConf,omitempty"`
136137
SysAppConf string `json:"sysAppConf,omitempty"`
@@ -149,6 +150,7 @@ func newBaseSpec(master *v1alpha1.CDAPMaster, name string, labels map[string]str
149150
s.RuntimeClassName = ""
150151
s.PriorityClassName = ""
151152
s.SecuritySecret = master.Spec.SecuritySecret
153+
s.SecuritySecretPath = defaultSecuritySecretPath
152154
s.CConf = cconf
153155
s.HConf = hconf
154156
s.SysAppConf = sysappconf

templates/cdap-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ spec:
121121
readOnly: true
122122
{{if $.Base.SecuritySecret}}
123123
- name: cdap-security
124-
mountPath: /etc/cdap/security
124+
mountPath: {{$.Base.SecuritySecretPath}}
125125
readOnly: true
126126
{{end}}
127127
{{range $k,$v := $.Base.ConfigMapVolumes}}

templates/cdap-sts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ spec:
9999
mountPath: {{.DataDir}}
100100
{{if $.Base.SecuritySecret}}
101101
- name: cdap-security
102-
mountPath: /etc/cdap/security
102+
mountPath: {{$.Base.SecuritySecretPath}}
103103
readOnly: true
104104
{{end}}
105105
{{end}}

0 commit comments

Comments
 (0)