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

feat: Add refreshInterval to the helm chart Values #1773

Conversation

shahramk64
Copy link
Contributor

@shahramk64 shahramk64 commented Sep 2, 2024

Description

What this PR does / why we need it:

This PR adds refreshInterval to Values.yaml so that the installation of ratify can support dynamic certificate refresh.

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):

Fixes #1755

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Helm Chart Change (any edit/addition/update that is necessary for changes merged to the main branch)
  • This change requires a documentation update

How Has This Been Tested?

Two scenarios were tested:

  1. refreshInterval not set to anything. Then make sure there is no refresh happening
  2. refreshInterval set to 20s, and make sure that refresh is happening.

Scenario 1:

  1. create kmp_config.yaml:
apiVersion: config.ratify.deislabs.io/v1beta1
kind: KeyManagementProvider
metadata:
 name: kmp-akv-refresh-nill
spec:
 type: azurekeyvault
 parameters:
   vaultURI: https://skal21kv.vault.azure.net/
   certificates:
     - name: wabbit-networks-io
   tenantID: 72f988bf-86f1-41af-91ab-2d7cd011db47
   clientID: 6f77181a-6ca6-404d-accc-703b3ae18d03
  1. run
kubectl apply -f kmp_config.yaml
run kubectl get keymanagementprovider kmp-akv-refresh-nill -o jsonpath='{.status.properties.Certificates[0].Version}'

returns version: d53015bda2dc4f24923143e8535c4ed2%

  1. create a new certificate in your azure key vault after a few seconds:
az keyvault certificate get-default-policy -o json >>new-policy.json
az keyvault certificate create --vault-name skal21kv --name wabbit-networks-io --policy @new-policy.json

Make sure a new certificate is created in your Azure key vault by checking your Azure portal.

  1. wait for a few seconds, then run
    kubectl get keymanagementprovider kmp-akv-refresh-nill -o jsonpath='{.status.properties.Certificates[0].Version}'
    returns: d53015bda2dc4f24923143e8535c4ed2%
    As expected, It should return the old certificate version, because the refreshInterval was left blank in the config file.
    To make sure it was nil, run
    kubectl describe keymanagementprovider kmp-akv-refresh-nill
    shows “Refresh Interval: “

Scenario 2

  1. modify kmp_config.yaml and set refreshInterval to 20s in kmp_config.yaml:
apiVersion: config.ratify.deislabs.io/v1beta1
kind: KeyManagementProvider
metadata:
 name: kmp-akv-refresh
spec:
 type: azurekeyvault
 refreshInterval:  20s
 parameters:
   vaultURI: https://skal21kv.vault.azure.net/
   certificates:
     - name: wabbit-networks-io
   tenantID: 72f988bf-86f1-41af-91ab-2d7cd011db47
   clientID: 6f77181a-6ca6-404d-accc-703b3ae18d03
  1. Run
kubectl replace -f kmp_config.yaml 
kubectl describe keymanagementprovider kmp-akv-refresh

shows “Refresh Interval: 20s“

  1. run kubectl get keymanagementprovider kmp-akv-refresh -o jsonpath='{.status.properties.Certificates[0].Version}'
    returns version: 2f42ed3d160145aca51d78c59ba9cd57%

  2. create a new certificate in your azure key vault after a few seconds, then run
    az keyvault certificate create --vault-name skal21kv --name wabbit-networks-io --policy @new-policy.json
    Make sure a new certificate is created in your Azure key vault by checking your Azure portal.

  3. wait at least 20 seconds, then run
    kubectl get keymanagementprovider kmp-akv-refresh -o jsonpath='{.status.properties.Certificates[0].Version}'
    As expected, it fetches the new version and returns: 01a3761c92e24adb85ca9036c4e6b2bf%

Checklist:

  • Does the affected code have corresponding tests?
  • Are the changes documented, not just with inline documentation, but also with conceptual documentation such as an overview of a new feature, or task-based documentation like a tutorial? Consider if this change should be announced on your project blog.
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have appropriate license header?

Post Merge Requirements

  • MAINTAINERS: manually trigger the "Publish Package" workflow after merging any PR that indicates Helm Chart Change

Copy link

codecov bot commented Sep 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

see 19 files with indirect coverage changes

@shahramk64 shahramk64 force-pushed the skalantari/Configure-kmp-refresh-interval-in-Ratify-default-helm-chart branch 2 times, most recently from de73f00 to a2ffe16 Compare September 3, 2024 01:43
@shahramk64 shahramk64 force-pushed the skalantari/Configure-kmp-refresh-interval-in-Ratify-default-helm-chart branch from a2ffe16 to 5d08645 Compare September 3, 2024 01:44
@shahramk64 shahramk64 changed the title Add refreshInterval to the helm chart Values feat: Add refreshInterval to the helm chart Values Sep 3, 2024
@shahramk64 shahramk64 marked this pull request as ready for review September 3, 2024 01:46
charts/ratify/templates/akv-key-management-provider.yaml Outdated Show resolved Hide resolved
charts/ratify/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@binbin-li binbin-li left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for adding it!

@binbin-li binbin-li enabled auto-merge (squash) September 3, 2024 06:13
@binbin-li binbin-li merged commit 4a44d3a into ratify-project:dev Sep 3, 2024
19 checks passed
akashsinghal pushed a commit to akashsinghal/ratify that referenced this pull request Sep 13, 2024
binbin-li pushed a commit to binbin-li/ratify that referenced this pull request Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure kmp refresh interval in Ratify default helm chart
2 participants