Skip to content

Commit 2f5917c

Browse files
authored
Merge 8339bd1 into 9b2182b
2 parents 9b2182b + 8339bd1 commit 2f5917c

File tree

19 files changed

+894
-88
lines changed

19 files changed

+894
-88
lines changed

.github/workflows/keyfactor-bootstrap-workflow.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313

1414
build:
15-
name: Build and Lint
15+
name: Build and Check CRDs
1616
runs-on: ubuntu-latest
1717
timeout-minutes: 8
1818
steps:
@@ -23,11 +23,17 @@ jobs:
2323
cache: true
2424
- run: go mod download
2525
- run: go build -v ./cmd/main.go
26+
- name: Regenerate CRDs
27+
run: make generate manifests
28+
- name: Check for CRD drift
29+
run: |
30+
git diff --compact-summary --exit-code || \
31+
(echo; echo "Unexpected difference in directories after code generation. Run 'make generate manifests' and commit."; exit 1)
2632
# - name: Run linters
2733
# uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0
2834
# with:
2935
# version: latest
30-
36+
3137
test:
3238
name: Go Test
3339
needs: build

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v2.4.0
2+
## Features
3+
- Add a `healthcheck` specification to Issuer / ClusterIssuer resources, allowing flexibility in the health check interval.
4+
15
# v2.3.1
26
## Fixes
37
- Add a manual dispatch of Helm chart release.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ For example, ClusterIssuer resources can be used to issue certificates for resou
251251
| ownerRoleName | The name of the security role assigned as the certificate owner. The security role must be assigned to the identity context of the issuer. If `ownerRoleId` and `ownerRoleName` are both specified, `ownerRoleId` will take precedence. This field is **required** if the enrollment pattern, certificate template, or system-wide setting requires it. |
252252
| scopes | (Optional) Required if using ambient credentials with Azure AKS. If using ambient credentials, these scopes will be put on the access token generated by the ambient credentials' token provider, if applicable. |
253253
| audience | (Optional) If using ambient credentials, this audience will be put on the access token generated by the ambient credentials' token provider, if applicable. Google's ambient credential token provider generates an OIDC ID Token. If this value is not provided, it will default to `command`. |
254+
| healthcheck | (Optional) Defines the health check configuration for the issuer. If ommitted, health checks will be enabled and default to 60 seconds. If left disabled, the issuer will not perform a health check when the issuer is healthy and may cause CertificateRequest resources to silently fail. |
255+
| healthcheck.enabled | (Required if health check block provided) Boolean to enable / disable health checks. By default, health checks are enabled. |
256+
| healthcheck.interval | (Optional) Defines the interval between health checks. Example values: `30s`, `1m`, `5.5m`. To prevent overloading the Command instance, this interval must not be less than `30s`. Default value: `60s`. |
254257
255258
> If a different combination of hostname/certificate authority/certificate template is required, a new Issuer or ClusterIssuer resource must be created. Each resource instantiation represents a single configuration.
256259
@@ -282,6 +285,9 @@ For example, ClusterIssuer resources can be used to issue certificates for resou
282285
# ownerRoleName: "$OWNER_ROLE_NAME" # Uncomment if required
283286
# scopes: "openid email https://example.com/.default" # Uncomment if required
284287
# audience: "https://your-command-url.com" # Uncomment if desired
288+
# healthcheck: # Optional health check configuration
289+
# enabled: true
290+
# interval: 30s
285291
EOF
286292
287293
kubectl -n default apply -f issuer.yaml
@@ -312,6 +318,9 @@ For example, ClusterIssuer resources can be used to issue certificates for resou
312318
# ownerRoleName: "$OWNER_ROLE_NAME" # Uncomment if required
313319
# scopes: "openid email https://example.com/.default" # Uncomment if required
314320
# audience: "https://your-command-url.com" # Uncomment if desired
321+
# healthcheck: # Optional health check configuration
322+
# enabled: true
323+
# interval: 30s
315324
EOF
316325
317326
kubectl apply -f clusterissuer.yaml

api/v1alpha1/issuer_types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ type IssuerSpec struct {
4646
// +kubebuilder:default:=KeyfactorAPI
4747
APIPath string `json:"apiPath,omitempty"`
4848

49+
// The healthcheck configuration for the issuer. This configures the frequency at which the issuer will perform
50+
// a health check to determine issuer's connectivity to Command instance.
51+
// +kubebuilder:validation:Optional
52+
HealthCheck *HealthCheckConfig `json:"healthcheck,omitempty"`
53+
4954
// EnrollmentPatternId is the ID of the enrollment pattern to use. Supported in Keyfactor Command 25.1 and later.
5055
// If both enrollment pattern and certificate template are specified, enrollment pattern will take precedence.
5156
// If EnrollmentPatternId and EnrollmentPatternName are both specified, EnrollmentPatternId will take precedence.
@@ -279,6 +284,15 @@ const (
279284
ConditionUnknown ConditionStatus = "Unknown"
280285
)
281286

287+
type HealthCheckConfig struct {
288+
// Determines whether to the health check when the issuer is healthy. Default: true
289+
Enabled bool `json:"enabled"`
290+
291+
// The interval at which to health check the issuer when healthy. Defaults to 1 minute. Must not be less than "30s".
292+
// +kubebuilder:validation:Optional
293+
Interval *metav1.Duration `json:"interval"`
294+
}
295+
282296
func init() {
283297
SchemeBuilder.Register(&Issuer{}, &IssuerList{})
284298
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 28 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)

config/crd/bases/command-issuer.keyfactor.com_clusterissuers.yaml

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,58 +68,74 @@ spec:
6868
CertificateAuthorityLogicalName is the logical name of the certificate authority to use
6969
E.g. "Keyfactor Root CA" or "Intermediate CA"
7070
type: string
71+
certificateTemplate:
72+
description: |-
73+
Deprecated. CertificateTemplate is the name of the certificate template to use. If using Keyfactor Command 25.1 or later, use EnrollmentPatternName or EnrollmentPatternId instead.
74+
If both enrollment pattern and certificate template are specified, enrollment pattern will take precedence.
75+
Enrollment will fail if the specified template is not compatible with the enrollment pattern.
76+
Refer to the Keyfactor Command documentation for more information.
77+
type: string
78+
commandSecretName:
79+
description: |-
80+
A reference to a K8s kubernetes.io/basic-auth Secret containing basic auth
81+
credentials for the Command instance configured in Hostname. The secret must
82+
be in the same namespace as the referent. If the
83+
referent is a ClusterIssuer, the reference instead refers to the resource
84+
with the given name in the configured 'cluster resource namespace', which
85+
is set as a flag on the controller component (and defaults to the
86+
namespace that the controller runs in).
87+
type: string
7188
enrollmentPatternId:
7289
description: |-
7390
EnrollmentPatternId is the ID of the enrollment pattern to use. Supported in Keyfactor Command 25.1 and later.
7491
If both enrollment pattern and certificate template are specified, enrollment pattern will take precedence.
75-
If both enrollmentPatternId and enrollmentPatternName are specified, enrollmentPatternId will take precedence.
92+
If EnrollmentPatternId and EnrollmentPatternName are both specified, EnrollmentPatternId will take precedence.
7693
Enrollment will fail if the specified template is not compatible with the enrollment pattern.
7794
Refer to the Keyfactor Command documentation for more information.
78-
type: integer
7995
format: int32
96+
type: integer
8097
enrollmentPatternName:
8198
description: |-
8299
EnrollmentPatternName is the name of the enrollment pattern to use. Supported in Keyfactor Command 25.1 and later.
83100
If both enrollment pattern and certificate template are specified, enrollment pattern will take precedence.
84-
If both enrollmentPatternId and enrollmentPatternName are specified, enrollmentPatternId will take precedence.
101+
If EnrollmentPatternId and EnrollmentPatternName are both specified, EnrollmentPatternId will take precedence.
85102
Enrollment will fail if the specified template is not compatible with the enrollment pattern.
86103
Refer to the Keyfactor Command documentation for more information.
87104
type: string
105+
healthcheck:
106+
description: |-
107+
The healthcheck configuration for the issuer. This configures the frequency at which the issuer will perform
108+
a health check to determine issuer's connectivity to Command instance.
109+
properties:
110+
enabled:
111+
description: 'Determines whether to the health check when the
112+
issuer is healthy. Default: true'
113+
type: boolean
114+
interval:
115+
description: The interval at which to health check the issuer
116+
when healthy. Defaults to 1 minute. Must not be less than "30s".
117+
type: string
118+
required:
119+
- enabled
120+
type: object
121+
hostname:
122+
description: Hostname is the hostname of a Keyfactor Command instance.
123+
type: string
88124
ownerRoleId:
89125
description: |-
90126
OwnerRoleId is the ID of the security role assigned as the certificate owner.
91127
The specified security role must be assigned to the authorized identity context.
92128
If OwnerRoleId and OwnerRoleName are both specified, OwnerRoleId will take precedence.
93129
This field is required if the enrollment pattern, certificate template, or system-wide settings has been configured as Required.
94-
type: integer
95130
format: int32
131+
type: integer
96132
ownerRoleName:
97133
description: |-
98134
OwnerRoleName is the name of the security role assigned as the certificate owner. This name must match the existing name of the security role.
99135
The specified security role must be assigned to the authorized identity context.
100136
If OwnerRoleId and OwnerRoleName are both specified, OwnerRoleId will take precedence.
101137
This field is required if the enrollment pattern, certificate template, or system-wide settings has been configured as Required.
102138
type: string
103-
certificateTemplate:
104-
description: |-
105-
CertificateTemplate is the name of the certificate template to use. Deprecated in favor of EnrollmentPattern as of Keyfactor Command 25.1.
106-
If both enrollment pattern and certificate template are specified, enrollment pattern will take precedence.
107-
Enrollment will fail if the specified template is not compatible with the enrollment pattern.
108-
Refer to the Keyfactor Command documentation for more information.
109-
type: string
110-
commandSecretName:
111-
description: |-
112-
A reference to a K8s kubernetes.io/basic-auth Secret containing basic auth
113-
credentials for the Command instance configured in Hostname. The secret must
114-
be in the same namespace as the referent. If the
115-
referent is a ClusterIssuer, the reference instead refers to the resource
116-
with the given name in the configured 'cluster resource namespace', which
117-
is set as a flag on the controller component (and defaults to the
118-
namespace that the controller runs in).
119-
type: string
120-
hostname:
121-
description: Hostname is the hostname of a Keyfactor Command instance.
122-
type: string
123139
scopes:
124140
description: |-
125141
A list of comma separated scopes used when requesting a Bearer token from an ambient token provider implied

0 commit comments

Comments
 (0)