Guhan Eswaran
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Checking expiry of Secrets in the clusters ## Introduction `airshipctl secret check-certificate-expiration` checks for all the expirable secret and certificate entities in the cluster and reports back to the operator Basically, there are three different types of entities identified 1. TLS Secrets in the cluster 2. Workload Cluster kubeconfig secret 3. Workload Cluster node certificates ## Explanation ### TLS Secrets in the cluster The tls secrets are a type of Kubernetes secrets with 'Type' set as 'kubernetes.io/tls'. This is basically the TLS CA and the resultant certificates related secrets which will be applied/used in the Management and the Workload CAPI clusters ### Workload Cluster kubeconfig secret This secret gets created while deploying the Workload cluster and is named as `cluster-name`-kubeconfig The base64 decoded content of the secret value is basically a kubeconfig which is used to connect to the Workload Cluster. The kubeconfig contains the expirable contents of cluster and the user certificate information ### Workload Cluster node certificates When a Workload Cluster is deployed, control plane nodes and worker nodes gets created. These are nothing but a normal Kubernetes cluster nodes and hence has the certificate content in /etc/kubernetes/pki directory for each node. These certificate's expiry information needs to be identified ## Implementation `airshipctl secret check-certificate-expiration` command has been introduced to manage all the above 3 conditions. > Note: The command must be flagged with kubeconfig data to connect to the corresponding cluster ``` ubuntu@airship-f1:$ ./airshipctl cluster -h This command provides capabilities for interacting with a Kubernetes cluster, such as getting status and deploying initial infrastructure. Usage: airshipctl cluster [command] Available Commands: check-certificate-expiration Check for expiring TLS certificates, secrets and kubeconfigs in the kubernetes cluster init Deploy cluster-api provider components move Move Cluster API objects, provider specific objects and all dependencies to the target cluster rotate-sa-token Rotate tokens of Service Accounts status Retrieve statuses of deployed cluster components Flags: -h, --help help for cluster Global Flags: --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --debug enable verbose output Use "airshipctl cluster [command] --help" for more information about a command. ubuntu@airship-f1:~/code-sops/airshipctl$ ./airshipctl cluster check-certificate-expiration -h Checks for the expiring entities in the both the Management and the Workload Clusters or in a self-managed cluster and reports with the intention on alerting the operator to take necessary actions. Checks for TLS Secrets, kubeconf secrets (which gets created while creating the workload cluster) and also the node certificates present inside /etc/kubernetes/pki directory for each nodes Usage: airshipctl cluster check-certificate-expiration [flags] Examples: # To display all the expirying entities in the cluster airshipctl cluster check-certificate-expiration # To display the entities whose expiry is within threshold of 30 days airshipctl cluster check-certificate-expiration -t 30 # To output the contents to json (default operation) airshipctl cluster check-certificate-expiration -o json or airshipctl cluster check-certificate-expiration # To output the contents to yaml airshipctl cluster check-certificate-expiration -o yaml # To output the contents whose expiry is within 30 days to yaml airshipctl cluster check-certificate-expiration -t 30 -o yaml Flags: -h, --help help for check-certificate-expiration --kubeconfig string Path to kubeconfig associated with cluster being managed -o, --output string convert output to yaml or json (default "json") -t, --threshold int The max expiration threshold in days before a secret is expiring. Displays all the secrets by default (default -1) Global Flags: --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") --debug enable verbose output ubuntu@airship-f1:~/code-sops/airshipctl$ ``` ## Working ### TLS Secrets in the cluster The command just runs through all the TLS secrets in the cluster and checks if any of the crt is within the duration and if so, displays it ### Workload Cluster kubeconfig secret The command fetches all the secrets suffixed with `-kubeconfig` and checks its association with a Workload cluster by looking for a kubeadmcontrolplane reference, fetches the 'value' field, base64 decodes it and checks for the certificate expiry ### Workload Cluster node certificates Communicating and fetching some contents in the Workload nodes is tricky. Hence, an Ansible Operator called HOSTCONFIG operator has been introduced as part of a different work item and the same is leveraged here. The Ansible operator runs like a cron job inside one of the control plane nodes (reconcile period can be set in days), fetches the expiry information using `kubeadm alpha certs check-expiration` command and annotates each node with its certificate-expiry information.`airshipctl secret check-certificate-expiration` just reads the annotation, parses it and displays if the limit is within the duration. ### `airshipctl secret check-certificate-expiration` ``` yaml ./airshipctl cluster check-certificate-expiration --kubeconfig ~/.airship/kubeconfig -o yaml --- kubeconfs: - cluster: - certificateName: CertificateAuthorityData expiryDate: 2030-09-29 14:17:57 +0000 UTC name: dtc secretName: dtc-kubeconfig secretNamespace: default user: - certificateName: ClientCertificateData expiryDate: 2021-10-01 14:17:58 +0000 UTC name: dtc-admin tlsSecrets: - certificate: - expiryDate: 2020-12-30 14:16:18 +0000 UTC name: tls.crt - expiryDate: 2020-12-30 14:16:18 +0000 UTC name: ca.crt name: capd-webhook-service-cert namespace: capd-system - certificate: - expiryDate: 2020-12-30 14:16:17 +0000 UTC name: tls.crt - expiryDate: 2020-12-30 14:16:17 +0000 UTC name: ca.crt name: capi-kubeadm-bootstrap-webhook-service-cert namespace: capi-webhook-system - certificate: - expiryDate: 2020-12-30 14:16:17 +0000 UTC name: tls.crt - expiryDate: 2020-12-30 14:16:17 +0000 UTC name: ca.crt name: capi-kubeadm-control-plane-webhook-service-cert namespace: capi-webhook-system - certificate: - expiryDate: 2020-12-30 14:16:16 +0000 UTC name: tls.crt - expiryDate: 2020-12-30 14:16:16 +0000 UTC name: ca.crt name: capi-webhook-service-cert namespace: capi-webhook-system - certificate: - expiryDate: 2025-09-30 14:16:05 +0000 UTC name: tls.crt - expiryDate: 2025-09-30 14:16:05 +0000 UTC name: ca.crt name: cert-manager-webhook-ca namespace: cert-manager - certificate: - expiryDate: 2021-10-01 14:16:10 +0000 UTC name: tls.crt - expiryDate: 2025-09-30 14:16:05 +0000 UTC name: ca.crt name: cert-manager-webhook-tls namespace: cert-manager - certificate: - expiryDate: 2020-10-12 09:29:21 +0000 UTC name: tls.crt name: tester namespace: default ... ``` ``` ./airshipctl cluster check-certificate-expiration --kubeconfig ~/.airship/kubeconfig { "tlsSecrets": [ { "name": "capd-webhook-service-cert", "namespace": "capd-system", "certificate": [ { "name": "tls.crt", "expiryDate": "2020-12-30 14:16:18 +0000 UTC" }, { "name": "ca.crt", "expiryDate": "2020-12-30 14:16:18 +0000 UTC" } ] }, { "name": "capi-kubeadm-bootstrap-webhook-service-cert", "namespace": "capi-webhook-system", "certificate": [ { "name": "tls.crt", "expiryDate": "2020-12-30 14:16:17 +0000 UTC" }, { "name": "ca.crt", "expiryDate": "2020-12-30 14:16:17 +0000 UTC" } ] }, { "name": "capi-kubeadm-control-plane-webhook-service-cert", "namespace": "capi-webhook-system", "certificate": [ { "name": "tls.crt", "expiryDate": "2020-12-30 14:16:17 +0000 UTC" }, { "name": "ca.crt", "expiryDate": "2020-12-30 14:16:17 +0000 UTC" } ] }, { "name": "capi-webhook-service-cert", "namespace": "capi-webhook-system", "certificate": [ { "name": "tls.crt", "expiryDate": "2020-12-30 14:16:16 +0000 UTC" }, { "name": "ca.crt", "expiryDate": "2020-12-30 14:16:16 +0000 UTC" } ] }, { "name": "cert-manager-webhook-ca", "namespace": "cert-manager", "certificate": [ { "name": "tls.crt", "expiryDate": "2025-09-30 14:16:05 +0000 UTC" }, { "name": "ca.crt", "expiryDate": "2025-09-30 14:16:05 +0000 UTC" } ] }, { "name": "cert-manager-webhook-tls", "namespace": "cert-manager", "certificate": [ { "name": "tls.crt", "expiryDate": "2021-10-01 14:16:10 +0000 UTC" }, { "name": "ca.crt", "expiryDate": "2025-09-30 14:16:05 +0000 UTC" } ] }, { "name": "tester", "namespace": "default", "certificate": [ { "name": "tls.crt", "expiryDate": "2020-10-12 09:29:21 +0000 UTC" } ] } ], "kubeconfs": [ { "secretName": "dtc-kubeconfig", "secretNamespace": "default", "cluster": [ { "name": "dtc", "certificateName": "CertificateAuthorityData", "expiryDate": "2030-09-29 14:17:57 +0000 UTC" } ], "user": [ { "name": "dtc-admin", "certificateName": "ClientCertificateData", "expiryDate": "2021-10-01 14:17:58 +0000 UTC" } ] } ] ```

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully