Migrate to generated clients
This commit is contained in:
@@ -151,6 +151,11 @@ func applyControlAgentServiceAccount(ctx context.Context, kubeClient kubernetes.
|
||||
|
||||
func applyControlAgentClusterRole(ctx context.Context, kubeClient kubernetes.Interface, labels map[string]string) error {
|
||||
wantRules := []rbacv1.PolicyRule{
|
||||
{
|
||||
APIGroups: []string{monov1alpha1.Group},
|
||||
Resources: []string{"osupgrades"},
|
||||
Verbs: []string{"get"},
|
||||
},
|
||||
{
|
||||
APIGroups: []string{monov1alpha1.Group},
|
||||
Resources: []string{"osupgradeprogresses"},
|
||||
|
||||
@@ -21,9 +21,9 @@ import (
|
||||
templates "example.com/monok8s/pkg/templates"
|
||||
)
|
||||
|
||||
func applyAdmissionControllerDeploymentResources(ctx context.Context, n *NodeContext) error {
|
||||
func applyControllerDeploymentResources(ctx context.Context, n *NodeContext) error {
|
||||
if strings.TrimSpace(n.Config.Spec.ClusterRole) != "control-plane" || !n.Config.Spec.EnableControlAgent {
|
||||
klog.InfoS("skipped admission controller deployment",
|
||||
klog.InfoS("skipped controller deployment",
|
||||
"clusterRole", n.Config.Spec.ClusterRole,
|
||||
"enableControlAgent", n.Config.Spec.EnableControlAgent,
|
||||
)
|
||||
@@ -56,23 +56,23 @@ func applyAdmissionControllerDeploymentResources(ctx context.Context, n *NodeCon
|
||||
if err := ensureNamespace(ctx, kubeClient, namespace, labels); err != nil {
|
||||
return fmt.Errorf("ensure namespace %q: %w", namespace, err)
|
||||
}
|
||||
if err := applyAdmissionControllerServiceAccount(ctx, kubeClient, namespace, labels); err != nil {
|
||||
if err := applyControllerServiceAccount(ctx, kubeClient, namespace, labels); err != nil {
|
||||
return fmt.Errorf("apply serviceaccount: %w", err)
|
||||
}
|
||||
if err := applyAdmissionControllerClusterRole(ctx, kubeClient, labels); err != nil {
|
||||
if err := applyControllerClusterRole(ctx, kubeClient, labels); err != nil {
|
||||
return fmt.Errorf("apply clusterrole: %w", err)
|
||||
}
|
||||
if err := applyAdmissionControllerClusterRoleBinding(ctx, kubeClient, namespace, labels); err != nil {
|
||||
if err := applyControllerClusterRoleBinding(ctx, kubeClient, namespace, labels); err != nil {
|
||||
return fmt.Errorf("apply clusterrolebinding: %w", err)
|
||||
}
|
||||
if err := applyAdmissionControllerDeployment(ctx, kubeClient, namespace, labels); err != nil {
|
||||
if err := applyControllerDeployment(ctx, kubeClient, namespace, labels); err != nil {
|
||||
return fmt.Errorf("apply deployment: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyAdmissionControllerServiceAccount(ctx context.Context, kubeClient kubernetes.Interface, namespace string, labels map[string]string) error {
|
||||
func applyControllerServiceAccount(ctx context.Context, kubeClient kubernetes.Interface, namespace string, labels map[string]string) error {
|
||||
automount := true
|
||||
|
||||
want := &corev1.ServiceAccount{
|
||||
@@ -111,7 +111,7 @@ func applyAdmissionControllerServiceAccount(ctx context.Context, kubeClient kube
|
||||
return err
|
||||
}
|
||||
|
||||
func applyAdmissionControllerClusterRole(ctx context.Context, kubeClient kubernetes.Interface, labels map[string]string) error {
|
||||
func applyControllerClusterRole(ctx context.Context, kubeClient kubernetes.Interface, labels map[string]string) error {
|
||||
wantRules := []rbacv1.PolicyRule{
|
||||
{
|
||||
APIGroups: []string{monov1alpha1.Group},
|
||||
@@ -126,7 +126,12 @@ func applyAdmissionControllerClusterRole(ctx context.Context, kubeClient kuberne
|
||||
{
|
||||
APIGroups: []string{monov1alpha1.Group},
|
||||
Resources: []string{"osupgradeprogresses"},
|
||||
Verbs: []string{"get", "list", "watch", "create", "patch", "update"},
|
||||
Verbs: []string{"get", "list", "create"},
|
||||
},
|
||||
{
|
||||
APIGroups: []string{monov1alpha1.Group},
|
||||
Resources: []string{"osupgradeprogresses/status"},
|
||||
Verbs: []string{"create"},
|
||||
},
|
||||
{
|
||||
APIGroups: []string{""},
|
||||
@@ -170,7 +175,7 @@ func applyAdmissionControllerClusterRole(ctx context.Context, kubeClient kuberne
|
||||
return err
|
||||
}
|
||||
|
||||
func applyAdmissionControllerClusterRoleBinding(ctx context.Context, kubeClient kubernetes.Interface, namespace string, labels map[string]string) error {
|
||||
func applyControllerClusterRoleBinding(ctx context.Context, kubeClient kubernetes.Interface, namespace string, labels map[string]string) error {
|
||||
wantSubjects := []rbacv1.Subject{
|
||||
{
|
||||
Kind: "ServiceAccount",
|
||||
@@ -225,7 +230,7 @@ func applyAdmissionControllerClusterRoleBinding(ctx context.Context, kubeClient
|
||||
return err
|
||||
}
|
||||
|
||||
func applyAdmissionControllerDeployment(ctx context.Context, kubeClient kubernetes.Interface, namespace string, labels map[string]string) error {
|
||||
func applyControllerDeployment(ctx context.Context, kubeClient kubernetes.Interface, namespace string, labels map[string]string) error {
|
||||
replicas := int32(1)
|
||||
|
||||
selectorLabels := map[string]string{
|
||||
Reference in New Issue
Block a user