BUGFIX: cainjector leaderelection defaults were missing
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
This commit is contained in:
parent
fd551160b1
commit
620d6ff679
@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package v1alpha1
|
package v1alpha1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
time "time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
logsapi "k8s.io/component-base/logs/api/v1"
|
logsapi "k8s.io/component-base/logs/api/v1"
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
@ -24,6 +26,14 @@ import (
|
|||||||
"github.com/cert-manager/cert-manager/pkg/apis/config/cainjector/v1alpha1"
|
"github.com/cert-manager/cert-manager/pkg/apis/config/cainjector/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
defaultLeaderElect = true
|
||||||
|
defaultLeaderElectionNamespace = "kube-system"
|
||||||
|
defaultLeaderElectionLeaseDuration = 60 * time.Second
|
||||||
|
defaultLeaderElectionRenewDeadline = 40 * time.Second
|
||||||
|
defaultLeaderElectionRetryPeriod = 15 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||||
return RegisterDefaults(scheme)
|
return RegisterDefaults(scheme)
|
||||||
}
|
}
|
||||||
@ -36,6 +46,29 @@ func SetDefaults_CAInjectorConfiguration(obj *v1alpha1.CAInjectorConfiguration)
|
|||||||
logsapi.SetRecommendedLoggingConfiguration(&obj.Logging)
|
logsapi.SetRecommendedLoggingConfiguration(&obj.Logging)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetDefaults_LeaderElectionConfig(obj *v1alpha1.LeaderElectionConfig) {
|
||||||
|
if obj.Enabled == nil {
|
||||||
|
obj.Enabled = &defaultLeaderElect
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.Namespace == "" {
|
||||||
|
obj.Namespace = defaultLeaderElectionNamespace
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Does it make sense to have a duration of 0?
|
||||||
|
if obj.LeaseDuration == time.Duration(0) {
|
||||||
|
obj.LeaseDuration = defaultLeaderElectionLeaseDuration
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.RenewDeadline == time.Duration(0) {
|
||||||
|
obj.RenewDeadline = defaultLeaderElectionRenewDeadline
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.RetryPeriod == time.Duration(0) {
|
||||||
|
obj.RetryPeriod = defaultLeaderElectionRetryPeriod
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func SetDefaults_EnableDataSourceConfig(obj *v1alpha1.EnableDataSourceConfig) {
|
func SetDefaults_EnableDataSourceConfig(obj *v1alpha1.EnableDataSourceConfig) {
|
||||||
if obj.Certificates == nil {
|
if obj.Certificates == nil {
|
||||||
obj.Certificates = ptr.To(true)
|
obj.Certificates = ptr.To(true)
|
||||||
|
|||||||
@ -38,6 +38,7 @@ func RegisterDefaults(scheme *runtime.Scheme) error {
|
|||||||
|
|
||||||
func SetObjectDefaults_CAInjectorConfiguration(in *v1alpha1.CAInjectorConfiguration) {
|
func SetObjectDefaults_CAInjectorConfiguration(in *v1alpha1.CAInjectorConfiguration) {
|
||||||
SetDefaults_CAInjectorConfiguration(in)
|
SetDefaults_CAInjectorConfiguration(in)
|
||||||
|
SetDefaults_LeaderElectionConfig(&in.LeaderElectionConfig)
|
||||||
SetDefaults_EnableDataSourceConfig(&in.EnableDataSourceConfig)
|
SetDefaults_EnableDataSourceConfig(&in.EnableDataSourceConfig)
|
||||||
SetDefaults_EnableInjectableConfig(&in.EnableInjectableConfig)
|
SetDefaults_EnableInjectableConfig(&in.EnableInjectableConfig)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user