mirror of
https://github.com/rancher/rke.git
synced 2025-08-12 04:03:01 +00:00
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
|
package authz
|
||
|
|
||
|
import (
|
||
|
"github.com/rancher/rke/k8s"
|
||
|
"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
|
||
|
}
|
||
|
if err := k8s.UpdateClusterRoleBindingFromYaml(k8sClient, jobDeployerClusterRoleBinding); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if err := k8s.UpdateServiceAccountFromYaml(k8sClient, jobDeployerServiceAccount); err != nil {
|
||
|
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
|
||
|
}
|
||
|
if err := k8s.UpdateClusterRoleBindingFromYaml(k8sClient, systemNodeClusterRoleBinding); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
logrus.Infof("[authz] system:node ClusterRoleBinding created successfully")
|
||
|
return nil
|
||
|
}
|