Skip to content

Commit c1b78d2

Browse files
authored
feat: kstatus for Pepr (#1288)
## Description This Pull Request introduces [kstatus](https://github.com/kubernetes-sigs/cli-utils/blob/master/pkg/kstatus/README.md) to the Pepr Operator. At the moment it supports setting only one condition: ```yaml status: phase: Ready conditions: - lastTransitionTime: "2025-02-17T09:33:00.748Z" message: The package is ready for use. reason: ReconciliationComplete status: "True" type: Ready ``` ## Related Issue Fixes #991 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Steps to Validate Run UDS Core with this patch on and observe `kubectl get packages -o yaml --all-namespaces`. ## Checklist before merging - [ ] Test, docs, adr added or updated as needed - [ ] [Contributor Guide](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md) followed
1 parent 94cee8d commit c1b78d2

17 files changed

Lines changed: 206 additions & 91 deletions

File tree

schemas/package-v1alpha1.schema.json

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"$ref": "#/definitions/Spec"
1111
},
1212
"status": {
13-
"$ref": "#/definitions/Status"
13+
"$ref": "#/definitions/StatusObject"
1414
}
1515
},
1616
"required": [],
@@ -954,7 +954,7 @@
954954
],
955955
"title": "ProtocolMapper"
956956
},
957-
"Status": {
957+
"StatusObject": {
958958
"type": "object",
959959
"additionalProperties": false,
960960
"properties": {
@@ -964,6 +964,13 @@
964964
"type": "string"
965965
}
966966
},
967+
"conditions": {
968+
"type": "array",
969+
"items": {
970+
"$ref": "#/definitions/Condition"
971+
},
972+
"description": "Status conditions following Kubernetes-style conventions"
973+
},
967974
"endpoints": {
968975
"type": "array",
969976
"items": {
@@ -996,7 +1003,46 @@
9961003
}
9971004
},
9981005
"required": [],
999-
"title": "Status"
1006+
"title": "StatusObject"
1007+
},
1008+
"Condition": {
1009+
"type": "object",
1010+
"additionalProperties": false,
1011+
"properties": {
1012+
"lastTransitionTime": {
1013+
"type": "string",
1014+
"format": "date-time",
1015+
"description": "The last time the condition transitioned from one status to another"
1016+
},
1017+
"message": {
1018+
"type": "string",
1019+
"description": "A human-readable message indicating details about the transition"
1020+
},
1021+
"observedGeneration": {
1022+
"type": "integer",
1023+
"description": "Represents the .metadata.generation that the condition was set based upon"
1024+
},
1025+
"reason": {
1026+
"type": "string",
1027+
"description": "A programmatic identifier indicating the reason for the condition's last transition"
1028+
},
1029+
"status": {
1030+
"$ref": "#/definitions/StatusEnum",
1031+
"description": "Status of the condition, one of True, False, Unknown"
1032+
},
1033+
"type": {
1034+
"type": "string",
1035+
"description": "Type of condition in CamelCase or in foo.example.com/CamelCase format"
1036+
}
1037+
},
1038+
"required": [
1039+
"lastTransitionTime",
1040+
"message",
1041+
"reason",
1042+
"status",
1043+
"type"
1044+
],
1045+
"title": "Condition"
10001046
},
10011047
"FallbackScrapeProtocol": {
10021048
"type": "string",
@@ -1077,6 +1123,16 @@
10771123
"title": "Protocol",
10781124
"description": "Specifies the protocol of the client, either 'openid-connect' or 'saml'\nProtocol of the mapper"
10791125
},
1126+
"StatusEnum": {
1127+
"type": "string",
1128+
"enum": [
1129+
"True",
1130+
"False",
1131+
"Unknown"
1132+
],
1133+
"title": "StatusEnum",
1134+
"description": "Status of the condition, one of True, False, Unknown"
1135+
},
10801136
"Phase": {
10811137
"type": "string",
10821138
"enum": [

src/authservice/common/zarf.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,3 @@ components:
1515
localPath: ../chart
1616
version: 1.0.1
1717
namespace: authservice
18-
actions:
19-
onDeploy:
20-
after:
21-
- description: Validate Authservice Package
22-
maxTotalSeconds: 300
23-
wait:
24-
cluster:
25-
kind: packages.uds.dev
26-
name: authservice
27-
namespace: authservice
28-
condition: "'{.status.phase}'=Ready"

src/grafana/common/zarf.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,3 @@ components:
2323
namespace: grafana
2424
valuesFiles:
2525
- ../values/values.yaml
26-
actions:
27-
onDeploy:
28-
after:
29-
- description: Validate Grafana Package
30-
maxTotalSeconds: 300
31-
wait:
32-
cluster:
33-
kind: packages.uds.dev
34-
name: grafana
35-
namespace: grafana
36-
condition: "'{.status.phase}'=Ready"

src/keycloak/common/zarf.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,3 @@ components:
5858
name: app.kubernetes.io/name=keycloak
5959
condition: Ready
6060
namespace: keycloak
61-
- description: Validate Keycloak Package
62-
maxTotalSeconds: 300
63-
wait:
64-
cluster:
65-
kind: packages.uds.dev
66-
name: keycloak
67-
namespace: keycloak
68-
condition: "'{.status.phase}'=Ready"

src/loki/common/zarf.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,3 @@ components:
2020
namespace: loki
2121
valuesFiles:
2222
- ../values/values.yaml
23-
actions:
24-
onDeploy:
25-
after:
26-
- description: Validate Loki Package
27-
maxTotalSeconds: 300
28-
wait:
29-
cluster:
30-
kind: packages.uds.dev
31-
name: loki
32-
namespace: loki
33-
condition: "'{.status.phase}'=Ready"

src/metrics-server/common/zarf.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,3 @@ components:
2121
version: 3.12.2
2222
valuesFiles:
2323
- "../values/values.yaml"
24-
actions:
25-
onDeploy:
26-
after:
27-
- description: Validate Metrics-Server Package
28-
maxTotalSeconds: 300
29-
wait:
30-
cluster:
31-
kind: packages.uds.dev
32-
name: metrics-server
33-
namespace: metrics-server
34-
condition: "'{.status.phase}'=Ready"

src/neuvector/common/zarf.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ components:
4040
actions:
4141
onDeploy:
4242
after:
43-
- description: Validate Neuvector Package
44-
maxTotalSeconds: 300
45-
wait:
46-
cluster:
47-
kind: packages.uds.dev
48-
name: neuvector
49-
namespace: neuvector
50-
condition: "'{.status.phase}'=Ready"
5143
- description: Annotate Controller deployment for Neuvector SSO secret
5244
cmd: |
5345
SSO_CHECKSUM=$(./zarf tools kubectl get secret neuvector-secret -o json -n neuvector | sha256sum | cut -d' ' -f1)

src/pepr/operator/crd/generated/package-v1alpha1.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { GenericKind, RegisterKind } from "kubernetes-fluent-client";
88
export class Package extends GenericKind {
99
spec?: Spec;
10-
status?: Status;
10+
status?: StatusObject;
1111
}
1212

1313
export interface Spec {
@@ -721,8 +721,12 @@ export interface ProtocolMapper {
721721
protocolMapper: string;
722722
}
723723

724-
export interface Status {
724+
export interface StatusObject {
725725
authserviceClients?: string[];
726+
/**
727+
* Status conditions following Kubernetes-style conventions
728+
*/
729+
conditions?: Condition[];
726730
endpoints?: string[];
727731
monitors?: string[];
728732
networkPolicyCount?: number;
@@ -732,6 +736,42 @@ export interface Status {
732736
ssoClients?: string[];
733737
}
734738

739+
export interface Condition {
740+
/**
741+
* The last time the condition transitioned from one status to another
742+
*/
743+
lastTransitionTime: Date;
744+
/**
745+
* A human-readable message indicating details about the transition
746+
*/
747+
message: string;
748+
/**
749+
* Represents the .metadata.generation that the condition was set based upon
750+
*/
751+
observedGeneration?: number;
752+
/**
753+
* A programmatic identifier indicating the reason for the condition's last transition
754+
*/
755+
reason: string;
756+
/**
757+
* Status of the condition, one of True, False, Unknown
758+
*/
759+
status: StatusEnum;
760+
/**
761+
* Type of condition in CamelCase or in foo.example.com/CamelCase format
762+
*/
763+
type: string;
764+
}
765+
766+
/**
767+
* Status of the condition, one of True, False, Unknown
768+
*/
769+
export enum StatusEnum {
770+
False = "False",
771+
True = "True",
772+
Unknown = "Unknown",
773+
}
774+
735775
export enum Phase {
736776
Failed = "Failed",
737777
Pending = "Pending",

src/pepr/operator/crd/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export {
1010
Gateway,
1111
Monitor,
1212
Phase,
13-
Status as PkgStatus,
13+
StatusObject as PkgStatus,
1414
Protocol,
1515
RemoteGenerated,
1616
Sso,

src/pepr/operator/crd/sources/package/v1alpha1.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,46 @@ export const v1alpha1: V1CustomResourceDefinitionVersion = {
499499
observedGeneration: {
500500
type: "integer",
501501
},
502+
conditions: {
503+
description: "Status conditions following Kubernetes-style conventions",
504+
type: "array",
505+
items: {
506+
type: "object",
507+
required: ["type", "status", "lastTransitionTime", "reason", "message"],
508+
properties: {
509+
type: {
510+
description:
511+
"Type of condition in CamelCase or in foo.example.com/CamelCase format",
512+
type: "string",
513+
},
514+
status: {
515+
description: "Status of the condition, one of True, False, Unknown",
516+
type: "string",
517+
enum: ["True", "False", "Unknown"],
518+
},
519+
observedGeneration: {
520+
description:
521+
"Represents the .metadata.generation that the condition was set based upon",
522+
type: "integer",
523+
},
524+
lastTransitionTime: {
525+
description:
526+
"The last time the condition transitioned from one status to another",
527+
type: "string",
528+
format: "date-time",
529+
},
530+
reason: {
531+
description:
532+
"A programmatic identifier indicating the reason for the condition's last transition",
533+
type: "string",
534+
},
535+
message: {
536+
description: "A human-readable message indicating details about the transition",
537+
type: "string",
538+
},
539+
},
540+
},
541+
},
502542
phase: {
503543
enum: ["Pending", "Ready", "Failed", "Retrying", "Removing"],
504544
type: "string",

0 commit comments

Comments
 (0)