1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-01 23:16:22 +00:00

Add kubeapi proxy cluster role and role binding

This commit is contained in:
galal-hussein
2019-07-25 22:07:38 +02:00
committed by Alena Prokharchyk
parent e923730388
commit 2bc960a01c
3 changed files with 45 additions and 1 deletions

View File

@@ -36,3 +36,19 @@ func ApplySystemNodeClusterRoleBinding(ctx context.Context, kubeConfigPath strin
log.Infof(ctx, "[authz] system:node ClusterRoleBinding created successfully")
return nil
}
func ApplyKubeAPIClusterRole(ctx context.Context, kubeConfigPath string, k8sWrapTransport k8s.WrapTransport) error {
log.Infof(ctx, "[authz] Creating kube-apiserver proxy ClusterRole and ClusterRoleBinding")
k8sClient, err := k8s.NewClient(kubeConfigPath, k8sWrapTransport)
if err != nil {
return err
}
if err := k8s.UpdateClusterRoleFromYaml(k8sClient, templates.KubeAPIClusterRole); err != nil {
return err
}
if err := k8s.UpdateClusterRoleBindingFromYaml(k8sClient, templates.KubeAPIClusterRoleBinding); err != nil {
return err
}
log.Infof(ctx, "[authz] kube-apiserver proxy ClusterRole and ClusterRoleBinding created successfully")
return nil
}