Skip to content

Commit 8339bd1

Browse files
authored
Merge pull request #57 from JSpon/default-timeout
Ability to specify the default issuer timeout across all issuers
2 parents bb90adf + 8d8ce73 commit 8339bd1

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

cmd/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"flag"
2323
"fmt"
2424
"os"
25+
"time"
2526

2627
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
2728
// to ensure that exec-entrypoint and run can make use of them.
@@ -64,6 +65,7 @@ func main() {
6465
var metricsAddr string
6566
var enableLeaderElection bool
6667
var probeAddr string
68+
var healthCheckInterval string
6769
var secureMetrics bool
6870
var enableHTTP2 bool
6971
var clusterResourceNamespace string
@@ -79,6 +81,8 @@ func main() {
7981
"If set the metrics endpoint is served securely")
8082
flag.BoolVar(&enableHTTP2, "enable-http2", false,
8183
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
84+
flag.StringVar(&healthCheckInterval, "default-health-check-interval", "60s",
85+
"If set, it is the default health check interval for issuers.")
8286
flag.StringVar(&clusterResourceNamespace, "cluster-resource-namespace", "", "The namespace for secrets in which cluster-scoped resources are found.")
8387
flag.BoolVar(&disableApprovedCheck, "disable-approved-check", false,
8488
"Disables waiting for CertificateRequests to have an approved condition before signing.")
@@ -168,13 +172,25 @@ func main() {
168172
os.Exit(1)
169173
}
170174

175+
defaultHealthCheckInterval, err := time.ParseDuration(healthCheckInterval)
176+
if err != nil {
177+
setupLog.Error(err, "unable to parse default health check interval")
178+
os.Exit(1)
179+
}
180+
181+
if defaultHealthCheckInterval < time.Duration(30) * time.Second {
182+
setupLog.Error(err, fmt.Sprintf("interval %s is invalid, must be greater than or equal to '30s'", healthCheckInterval))
183+
os.Exit(1)
184+
}
185+
171186
if err = (&controller.IssuerReconciler{
172187
Client: mgr.GetClient(),
173188
Kind: "Issuer",
174189
ClusterResourceNamespace: clusterResourceNamespace,
175190
SecretAccessGrantedAtClusterLevel: secretAccessGrantedAtClusterLevel,
176191
Scheme: mgr.GetScheme(),
177192
HealthCheckerBuilder: command.NewHealthChecker,
193+
DefaultHealthCheckInterval: defaultHealthCheckInterval,
178194
}).SetupWithManager(mgr); err != nil {
179195
setupLog.Error(err, "unable to create controller", "controller", "Issuer")
180196
os.Exit(1)
@@ -186,6 +202,7 @@ func main() {
186202
ClusterResourceNamespace: clusterResourceNamespace,
187203
SecretAccessGrantedAtClusterLevel: secretAccessGrantedAtClusterLevel,
188204
HealthCheckerBuilder: command.NewHealthChecker,
205+
DefaultHealthCheckInterval: defaultHealthCheckInterval,
189206
}).SetupWithManager(mgr); err != nil {
190207
setupLog.Error(err, "unable to create controller", "controller", "ClusterIssuer")
191208
os.Exit(1)

deploy/charts/command-cert-manager-issuer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ The following table lists the configurable parameters of the `command-cert-manag
8484
| `nodeSelector` | Node labels for pod assignment | `{}` |
8585
| `tolerations` | Tolerations for pod assignment | `[]` |
8686
| `secretConfig.useClusterRoleForSecretAccess` | Specifies if the ServiceAccount should be granted access to the Secret resource using a ClusterRole | `false` |
87+
| `defaultHealthCheckInterval` | Specifies the default health check interval for issuers | `""` (uses the default in the code which is 60s) |

deploy/charts/command-cert-manager-issuer/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ spec:
3636
{{- if .Values.secretConfig.useClusterRoleForSecretAccess}}
3737
- --secret-access-granted-at-cluster-level
3838
{{- end}}
39+
{{- if .Values.defaultHealthCheckInterval }}
40+
- --default-health-check-interval={{ .Values.defaultHealthCheckInterval }}
41+
{{- end }}
3942
command:
4043
- /manager
4144
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}"

deploy/charts/command-cert-manager-issuer/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,5 @@ resources: {}
7070
nodeSelector: {}
7171

7272
tolerations: []
73+
74+
defaultHealthCheckInterval: ""

internal/controller/issuer_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ import (
3636

3737
const (
3838
issuerReadyConditionReason = "command-issuer.IssuerController.Reconcile"
39-
defaultHealthCheckInterval = time.Minute
4039
)
4140

4241
var (
4342
errGetAuthSecret = errors.New("failed to get Secret containing Issuer credentials")
4443
errGetCaSecret = errors.New("caSecretName specified a name, but failed to get Secret containing CA certificate")
4544
errHealthCheckerBuilder = errors.New("failed to build the healthchecker")
4645
errHealthCheckerCheck = errors.New("healthcheck failed")
46+
defaultHealthCheckInterval = time.Minute
4747
)
4848

4949
// IssuerReconciler reconciles a Issuer object
@@ -54,6 +54,7 @@ type IssuerReconciler struct {
5454
SecretAccessGrantedAtClusterLevel bool
5555
Scheme *runtime.Scheme
5656
HealthCheckerBuilder command.HealthCheckerBuilder
57+
DefaultHealthCheckInterval time.Duration
5758
}
5859

5960
//+kubebuilder:rbac:groups=command-issuer.keyfactor.com,resources=issuers;clusterissuers,verbs=get;list;watch
@@ -67,6 +68,7 @@ func (r *IssuerReconciler) newIssuer() (commandissuer.IssuerLike, error) {
6768
if err != nil {
6869
return nil, err
6970
}
71+
defaultHealthCheckInterval = r.DefaultHealthCheckInterval
7072
return ro.(commandissuer.IssuerLike), nil
7173
}
7274

internal/controller/issuer_controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ func TestIssuerReconcile(t *testing.T) {
923923
HealthCheckerBuilder: tc.healthCheckerBuilder,
924924
ClusterResourceNamespace: tc.clusterResourceNamespace,
925925
SecretAccessGrantedAtClusterLevel: true,
926+
DefaultHealthCheckInterval: time.Minute,
926927
}
927928
result, err := controller.Reconcile(
928929
ctrl.LoggerInto(context.TODO(), logrtesting.NewTestLogger(t)),

0 commit comments

Comments
 (0)