forked from rook/rook
Merge pull request #6471 from cybozu-go/ceph-the-number-of-admission-controller-pods
ceph: reduce the number of admission controller pods in small cluster
This commit is contained in:
@@ -17,6 +17,8 @@ limitations under the License.
|
||||
package operator
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/csi"
|
||||
@@ -26,7 +28,6 @@ import (
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -122,7 +123,7 @@ func createWebhookDeployment(context *clusterd.Context, admissionImage string) e
|
||||
secretVolumeMount := getSecretVolumeMount()
|
||||
|
||||
antiAffinity := csi.GetPodAntiAffinity(k8sutil.AppAttr, appName)
|
||||
admissionControllerDeployment := getDeployment(secretVolume, antiAffinity, admissionImage, admission_parameters, secretVolumeMount)
|
||||
admissionControllerDeployment := getDeployment(context, secretVolume, antiAffinity, admissionImage, admission_parameters, secretVolumeMount)
|
||||
|
||||
err := k8sutil.CreateDeployment(context.Clientset, appName, namespace, &admissionControllerDeployment)
|
||||
if err != nil {
|
||||
@@ -132,8 +133,17 @@ func createWebhookDeployment(context *clusterd.Context, admissionImage string) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func getDeployment(secretVolume corev1.Volume, antiAffinity corev1.PodAntiAffinity, admissionImage string, admission_parameters []string, secretVolumeMount corev1.VolumeMount) v1.Deployment {
|
||||
func getDeployment(context *clusterd.Context, secretVolume corev1.Volume, antiAffinity corev1.PodAntiAffinity,
|
||||
admissionImage string, admission_parameters []string, secretVolumeMount corev1.VolumeMount) v1.Deployment {
|
||||
var replicas int32 = 2
|
||||
nodes, err := context.Clientset.CoreV1().Nodes().List(metav1.ListOptions{})
|
||||
if err == nil {
|
||||
if len(nodes.Items) == 1 {
|
||||
replicas = 1
|
||||
}
|
||||
} else {
|
||||
logger.Errorf("failed to get nodes. Defaulting the number of replicas of admission controller pods to 2. %v", err)
|
||||
}
|
||||
|
||||
admissionControllerDeployment := v1.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
||||
Reference in New Issue
Block a user