Skip to content

OCPEDGE-2998: Add certificate status command - #7397

Open
eggfoobar wants to merge 2 commits into
openshift:mainfrom
eggfoobar:ocpstrat-2899-certs-status
Open

eggfoobar wants to merge 2 commits into
openshift:mainfrom
eggfoobar:ocpstrat-2899-certs-status

Conversation

@eggfoobar

@eggfoobar eggfoobar commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Add read-only certificate inventory loading with service ownership and rotation policy metadata. Report deterministic human-readable and JSON certificate status using the enhancement's zone thresholds.

Example Output:

$ sudo ./_output/bin/microshift certs status
SERVICE                    CERTIFICATE                             STATUS  EXPIRY                REASON       MESSAGE
authentication             admin-kubeconfig-client                 Green   2036-09-15T00:00:01Z  NotExpiring  Valid for 3651 days
authentication             admin-kubeconfig-signer                 Green   2036-09-15T00:00:00Z  NotExpiring  Valid for 3651 days
cluster-policy-controller  cluster-policy-controller               Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
control-plane              kube-control-plane-signer               Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
etcd                       etcd-peer                               Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
etcd                       etcd-serving                            Green   2036-09-15T00:00:03Z  NotExpiring  Valid for 3651 days
etcd                       etcd-signer                             Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
ingress                    ingress-ca                              Green   2036-09-15T00:00:01Z  NotExpiring  Valid for 3651 days
ingress                    router-default-serving                  Green   2027-09-18T00:00:02Z  NotExpiring  Valid for 366 days
kube-apiserver             aggregator-client                       Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kube-apiserver             aggregator-signer                       Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kube-apiserver             apiserver-etcd-client                   Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
kube-apiserver             kube-apiserver-external-signer          Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
kube-apiserver             kube-apiserver-localhost-serving        Green   2027-09-18T00:00:02Z  NotExpiring  Valid for 366 days
kube-apiserver             kube-apiserver-localhost-signer         Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
kube-apiserver             kube-apiserver-service-network-serving  Green   2027-09-18T00:00:02Z  NotExpiring  Valid for 366 days
kube-apiserver             kube-apiserver-service-network-signer   Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
kube-apiserver             kube-apiserver-to-kubelet-client        Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
kube-apiserver             kube-apiserver-to-kubelet-signer        Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
kube-apiserver             kube-external-serving                   Green   2027-09-18T00:00:02Z  NotExpiring  Valid for 366 days
kube-controller-manager    kube-controller-manager                 Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
kube-scheduler             kube-scheduler                          Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
kubelet                    kube-csr-signer                         Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kubelet                    kubelet-client                          Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kubelet                    kubelet-server                          Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kubelet                    kubelet-signer                          Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
metrics-server             metrics-server-kubelet-client           Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
observability              openshift-observability-client          Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
route-controller-manager   route-controller-manager                Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
route-controller-manager   route-controller-manager-serving        Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
service-ca                 service-ca                              Green   2036-09-15T00:00:01Z  NotExpiring  Valid for 3651 days

Example Output JSON:

$ sudo ./_output/bin/microshift certs status -ojson
{
  "apiVersion": "microshift.openshift.io/v1alpha1",
  "kind": "CertificateStatusList",
  "generatedAt": "2026-09-17T18:43:13Z",
  "config": {
    "forceRestartOnRedZone": true,
    "servingValidity": "8760h",
    "caValidity": "87600h"
  },
  "items": [
    {
      "service": "authentication",
      "name": "admin-kubeconfig-client",
      "role": "client",
      "rotationPolicy": "extended",
      "zone": "green",
      "notBefore": "2026-09-17T18:33:20Z",
      "notAfter": "2036-09-15T00:00:01Z",
      "remainingSeconds": 315379008
    },
    {
      "service": "authentication",
      "name": "admin-kubeconfig-signer",
      "role": "ca",
      "rotationPolicy": "extended",
      "zone": "green",
      "notBefore": "2026-09-17T18:33:20Z",
      "notAfter": "2036-09-15T00:00:00Z",
      "remainingSeconds": 315379007
    },
    {
      "service": "cluster-policy-controller",
      "name": "cluster-policy-controller",
      "role": "client",
      "rotationPolicy": "standard",
      "zone": "green",
      "notBefore": "2026-09-17T18:33:20Z",
      "notAfter": "2027-09-18T00:00:00Z",
      "remainingSeconds": 31555007
    },
....

Example Output YAML:

$ sudo ./_output/bin/microshift certs status -oyaml
apiVersion: microshift.openshift.io/v1alpha1
config:
  caValidity: 87600h
  forceRestartOnRedZone: true
  servingValidity: 8760h
generatedAt: "2026-09-22T18:55:14Z"
items:
- name: admin-kubeconfig-client
  notAfter: "2036-09-15T00:00:01Z"
  notBefore: "2026-09-17T18:33:20Z"
  remainingSeconds: 314946287
  role: client
  rotationPolicy: extended
  service: authentication
  zone: green
- name: admin-kubeconfig-signer
  notAfter: "2036-09-15T00:00:00Z"
  notBefore: "2026-09-17T18:33:20Z"
  remainingSeconds: 314946286
  role: ca
  rotationPolicy: extended
  service: authentication
  zone: green
...

Summary by CodeRabbit

  • New Features

    • Added a certificate status command with JSON, YAML, and table output formats.
    • Certificate reports now include certificate names, services, issuing authorities, rotation policies, validity status, and renewal urgency.
    • Added standardized certificate status and renewal result formats for consistent CLI output.
  • Bug Fixes

    • Certificate entries are displayed in a consistent, deterministic order.
    • Unsupported output formats now fail with a clear error message.

Add read-only certificate inventory loading with service ownership and rotation policy metadata. Report deterministic human-readable and JSON certificate status using the enhancement's zone thresholds.

Co-Authored-By: GPT-5 <noreply@openai.com>
Signed-off-by: ehila <ehila@redhat.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 17, 2026
@openshift-ci-robot

openshift-ci-robot commented Sep 17, 2026

Copy link
Copy Markdown

@eggfoobar: This pull request references OCPEDGE-2998 which is a valid jira issue.

Details

In response to this:

Add read-only certificate inventory loading with service ownership and rotation policy metadata. Report deterministic human-readable and JSON certificate status using the enhancement's zone thresholds.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 955ead0f-61ff-4070-bd15-3e753f483edc

📥 Commits

Reviewing files that changed from the base of the PR and between aa31215 and 240cdf9.

📒 Files selected for processing (6)
  • pkg/apis/certificates/v1alpha1/doc.go
  • pkg/apis/certificates/v1alpha1/types.go
  • pkg/apis/certificates/v1alpha1/types_test.go
  • pkg/cmd/certs.go
  • pkg/cmd/certs_test.go
  • test/suites/standard2/cert-status.robot

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

The change adds certificate service and rotation metadata, disk-backed inventory loading, shared certificate status API types, and a privileged certs status command with JSON, YAML, and table output.

Changes

Certificate status administration

Layer / File(s) Summary
Status API contract
pkg/apis/certificates/v1alpha1/*
The v1alpha1 package defines certificate status, renewal, configuration, and error documents. Tests cover JSON and YAML round trips.
Signer metadata and chain setup
pkg/cmd/init.go, pkg/util/cryptomaterial/certchains/signerbuilder.go, pkg/util/cryptomaterial/certchains/signers.go
Signers preserve service and rotation-policy metadata. Certificate initialization assigns metadata across control-plane, kubelet, serving, aggregator, and etcd certificates.
Inventory metadata and loading
pkg/util/cryptomaterial/certchains/chainsbuilder.go, pkg/util/cryptomaterial/certchains/inventory.go, pkg/util/cryptomaterial/certchains/inventory_test.go
Inventory entries include names, services, parent CAs, and rotation policies. Disk loading sorts certificates and ZoneAt classifies validity periods.
Certificate status command and validation
cmd/microshift/main.go, pkg/cmd/certs.go, pkg/cmd/certs_test.go, test/suites/standard2/cert-status.robot
The command loads inventory data and writes JSON, YAML, or table output. Tests cover ordering, warnings, formats, privileges, flags, writer errors, and validity reporting.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant CertsStatus
  participant CertificateInventory
  participant Output
  Operator->>CertsStatus: Run certs status
  CertsStatus->>CertificateInventory: Load inventory
  CertificateInventory-->>CertsStatus: Return certificate entries and zones
  CertsStatus->>Output: Render JSON, YAML, or table output
  Output-->>Operator: Display status and warnings
Loading

Merge Risk: ⚪ Minimal · up to 240cd

The JSON and YAML status output uses the intended versioned list format, with certificate details represented as nested records. No actionable merge-blocking issue remains.

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 12 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The pull request adds standard Go tests and Robot Framework test cases, not Ginkgo tests. The added test names are static: Go Test... identifiers and Robot cases such as `JSON And YAML Report The Sa…
Test Structure And Quality ✅ Passed PASS — the pull request adds no Ginkgo tests. The changed Go tests use the standard testing package with testify/require, and the integration test is a Robot Framework suite. Therefore, the Ginkgo…
Microshift Test Compatibility ✅ Passed The PR adds a Robot Framework certificate-status suite and Go unit tests. It adds no Ginkgo e2e tests such as It, Describe, Context, or When. The Robot suite does not reference unavailable Ope…
Single Node Openshift (Sno) Test Compatibility ✅ Passed PASS — The pull request adds no Ginkgo e2e tests. The changed Go tests use standard func Test...(t *testing.T) declarations, and the added integration suite is Robot Framework (cert-status.robot).…
Topology-Aware Scheduling Compatibility ✅ Passed PASS: The pull request adds a certificate status command, certificate inventory/API types, and certificate setup metadata. The authoritative diff contains no deployment manifests, operator/controller …
Ote Binary Stdout Contract ✅ Passed The pull request does not add stdout writes in the checked process-level contexts. cmd/microshift/main.go only registers NewCertsCommand(ioStreams); main() still only constructs the command, cal…
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo test was added. The new Robot suite runs microshift certs status on the configured MicroShift host through existing SSH resources and does not use IPv4 literals, IP parsing, IPv4-only …
No-Weak-Crypto ✅ Passed No weak-crypto usage was introduced. The authoritative diff contains no MD5, SHA1, DES, 3DES, RC4, Blowfish, or ECB implementation or reference. New certificate loading only parses PEM data through `c…
Container-Privileges ✅ Passed The PR changes no container or Kubernetes manifests. The diff contains no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, allowPrivilegeEscalation, or security-context settings. The …
No-Sensitive-Data-In-Logs ✅ Passed No sensitive-data logging was introduced. The new command outputs only certificate service/name, role, rotation status, validity timestamps, expiry status, and configuration warnings. It does not seri…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding the certificate status command.
Full details: Docstring Coverage

Explanation

Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 12 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@openshift-ci

openshift-ci Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: eggfoobar
Once this PR has been reviewed and has the lgtm label, please assign ggiguash for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@eggfoobar

Copy link
Copy Markdown
Contributor Author

/retest

moved to add certificates as full k8s objects to make ingestion by other tooling better
updated wording for status from planned to validated

Signed-off-by: ehila <ehila@redhat.com>
@openshift-ci

openshift-ci Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@eggfoobar: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants