2017-12-14 21:56:19 +00:00
|
|
|
package authz
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/rancher/rke/k8s"
|
2017-12-16 03:37:45 +00:00
|
|
|
"github.com/rancher/rke/templates"
|
2017-12-14 21:56:19 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ApplyJobDeployerServiceAccount(kubeConfigPath string) error {
|
|
|
|
logrus.Infof("[authz] Creating rke-job-deployer ServiceAccount")
|
|
|
|
k8sClient, err := k8s.NewClient(kubeConfigPath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-12-16 03:37:45 +00:00
|
|
|
if err := k8s.UpdateClusterRoleBindingFromYaml(k8sClient, templates.JobDeployerClusterRoleBinding); err != nil {
|
2017-12-14 21:56:19 +00:00
|
|
|
return err
|
|
|
|
}
|
2017-12-16 03:37:45 +00:00
|
|
|
if err := k8s.UpdateServiceAccountFromYaml(k8sClient, templates.JobDeployerServiceAccount); err != nil {
|
2017-12-14 21:56:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
logrus.Infof("[authz] rke-job-deployer ServiceAccount created successfully")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func ApplySystemNodeClusterRoleBinding(kubeConfigPath string) error {
|
|
|
|
logrus.Infof("[authz] Creating system:node ClusterRoleBinding")
|
|
|
|
k8sClient, err := k8s.NewClient(kubeConfigPath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-12-16 03:37:45 +00:00
|
|
|
if err := k8s.UpdateClusterRoleBindingFromYaml(k8sClient, templates.SystemNodeClusterRoleBinding); err != nil {
|
2017-12-14 21:56:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
logrus.Infof("[authz] system:node ClusterRoleBinding created successfully")
|
|
|
|
return nil
|
|
|
|
}
|