enable privileged

This commit is contained in:
GLYASAI 2020-01-19 10:39:35 +08:00
parent 8331327922
commit 1a6cb25530
2 changed files with 5 additions and 1 deletions

View File

@ -1454,7 +1454,7 @@ func (t *ServiceLabelDaoImpl) GetTenantServiceTypeLabel(serviceID string) (*mode
// GetPrivilegedLabel -
func (t *ServiceLabelDaoImpl) GetPrivilegedLabel(serviceID string) (*model.TenantServiceLable, error) {
var label model.TenantServiceLable
if err := t.DB.Where("service_id=? and label_key = ?", serviceID, model.LabelKeyServicePrivileged).Find(&label).Error; err != nil {
if err := t.DB.Where("service_id=? and label_value=?", serviceID, model.LabelKeyServicePrivileged).Find(&label).Error; err != nil {
return nil, err
}
return &label, nil

View File

@ -138,6 +138,7 @@ func getMainContainer(as *v1.AppService, version *dbmodel.VersionInfo, dv *volum
return nil, fmt.Errorf("get privileged label: %v", err)
}
if label != nil {
logrus.Infof("service id: %s; enable privileged.", as.ServiceID)
c.SecurityContext = &corev1.SecurityContext{Privileged: util.Bool(true)}
}
@ -653,6 +654,9 @@ func createNodeSelector(as *v1.AppService, dbmanager db.Manager) map[string]stri
selector[client.LabelOS] = l.LabelValue
continue
}
if l.LabelValue == model.LabelKeyServicePrivileged {
continue
}
if strings.Contains(l.LabelValue, "=") {
kv := strings.SplitN(l.LabelValue, "=", 1)
selector[kv[0]] = kv[1]