Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a simple pre-uninstall check command #71

Merged
merged 13 commits into from
Feb 9, 2023
Merged

Conversation

charlieegan3
Copy link
Contributor

@charlieegan3 charlieegan3 commented Nov 22, 2022

This PR is part of working on the flow defined in https://docs.google.com/document/d/1AxUss0piE9gb_r31_jBS6mv7zWALDqI0ZIfBUiJj3p0/edit?usp=sharing

Example output in a cluster that has cert-manager-csi-driver, cert-manager-csi-driver-spiffe, cert-manager-istio-csr, a Secret with Certificate owner ref, a Certificate that will be renewed and will expire soon:

irbe@jsctl$ go run main.go x clusters uninstall verify
Running checks against cluster Secrets:
        * Checking that issued certificates are safe from garbage collection...
Running checks against cluster Certificates:
        * Checking for upcoming renewals
        * Checking for upcoming expiries
        * Checking for currently failing issuances
        * Checking for unready Certificates
Running checks against cert-manager integrations installed in cluster:
        * Checking for cert-manager-istio-csr
        * Checking for cert-manager-csi-driver
        * Checking for cert-manager-csi-driver-spiffe

Results:
Secrets with Certificate owner refs were found. These Secrets will be garbage collected when Certificate CRD is uninstalled.
You can run 'jsctl experimental clusters cleanup secrets remove-certificate-owner-refs' command to remove the owner references.
        * istio-system/ca-secret secret has certificate owner ref
        * istio-system/istiod-tls secret has certificate owner ref
        * jetstack-secure/foo secret has certificate owner ref
        * jetstack-secure/spiffe-ca secret has certificate owner ref
Some certificates will be renewed soon. You might want to ensure that uninstall is completed before any renewals kick in. Or use 'cmctl renew' command to renew the certificates now.
        * istio-system/istiod certificate will be renewed soon (2023-02-07 08:41:28 +0000 GMT)
        * jetstack-secure/foo certificate will be renewed soon (2023-02-07 08:43:12 +0000 GMT)
Some certificates will expire soon. Ensure that enough time is allocated for re-installation to prevent outages. You can use 'cmctl renew' command to manually renew certs now.
        * istio-system/istiod certificate will expire soon (2023-02-07 09:11:28 +0000 GMT)
        * jetstack-secure/foo certificate will expire soon (2023-02-07 09:33:12 +0000 GMT)
A cert-manager integration that creates certificate requests was found in cluster. You might want to ensure that uninstalling Jetstack Secure software will not cause downtime.
        * cert-manager-csi-driver-spiffe found in cluster
        * cert-manager-csi-driver found in cluster
        * cert-manager-istio-csr found in cluster

Copy link
Contributor

@irbekrm irbekrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Charlie, this looks good already!

I've not ran the command yet, but have left a bunch of comments, let me know if it makes sense.

internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
internal/command/clusters/uninstall.go Show resolved Hide resolved
internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
internal/kubernetes/clients/clients.go Outdated Show resolved Hide resolved
Base automatically changed from cluster-backup to main November 25, 2022 08:41
@irbekrm irbekrm force-pushed the uninstall-verify-cmd branch 2 times, most recently from b4eb908 to 57bd9d4 Compare February 2, 2023 15:57
@irbekrm
Copy link
Contributor

irbekrm commented Feb 2, 2023

There is probably more that could be done here- if we get someone to actualy use it we can iterate and add more checks.
For now I am in favour of doing as little as possible to avoid having to maintain lots of code that is never used.

charlieegan3 and others added 11 commits February 7, 2023 15:13
Example output:

```
$ go run main.go clusters uninstall verify
The following secrets contain certificates and are owned by a Certificate resource:
 * test-namespace/example-net-tdst7 has certificate owner ref
 * test-namespace/example-com-gpsz7 has certificate owner ref
 * test-namespace/example-com-tls has certificate owner ref
The following certificates will be renewed soon:
 * test-namespace/example-net will be renewed soon (13m50.20178s)
The following certificates are currently being re-issued:
 * test-namespace/example-com
The following certificate requests are pending approval or issuance:
 * test-namespace/example-net-dxvjx is pending approval
 * test-namespace/example-com-jggql is pending approval

Suggested next steps:
 * Run 'jsctl experimental clusters cleanup secrets remove-certificate-owner-refs' to make sure secrets containing certificates are not garbage collected
 * Use cmctl to manually renew certificates: cmctl renew --namespace=test-namespace example-net
 * Wait for 1 certificates to be issued
 * Investigate 2 pending certificate requests
```

This command has been added to help users prepare for a migration to the
operator.

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
Adds a couple more checks, removes unnecessary CertificateRequests check

Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
Signed-off-by: irbekrm <irbekrm@gmail.com>
Copy link
Contributor

@inteon inteon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, I added some remarks wrt improvements that I think can be made still.

internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
internal/command/clusters/uninstall.go Outdated Show resolved Hide resolved
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
@inteon
Copy link
Contributor

inteon commented Feb 8, 2023

@irbekrm I made some additional changes to fix some code style issues and a remaining bug.
Could you take a look at the latest version and also leave a review?

Copy link
Contributor

@irbekrm irbekrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@inteon inteon merged commit bd82802 into main Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants