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

Custom policies added to the CRD #126

Merged
merged 5 commits into from
Jun 21, 2021
Merged

Custom policies added to the CRD #126

merged 5 commits into from
Jun 21, 2021

Conversation

eguzki
Copy link
Member

@eguzki eguzki commented Jun 15, 2021

https://issues.redhat.com/browse/THREESCALE-7031

Custom policies exposed in the CRD:

apiVersion: apps.3scale.net/v1alpha1       
kind: APIcast                              
metadata:                                  
  name: apicast1                           
spec:                                      
  customPolicies:                          
    - secretRef:
        name: cp-1                     
      name: Example                        
      version: "0.1"                       
    - secretRef:
        name: cp-1    
      name: Example                        
      version: "0.2"            
   - secretRef:
        name: cp-3                 
     name: OtherExample                        
     version: "0.1"                     

Each policy is defined by:

  • Name
  • Version
  • Secret containing at least: "init.lua" and "apicast-policy.json" keys. Other lua files can also be included.
apiVersion: v1
data:
  apicast-policy.json:   CONTENT OF THE POLICY METADATA (required)
  init.lua: CODE OF THE POLICY (required)
  example.lua: CODE OF THE POLICY (optional)
  other.lua: CODE OF THE POLICY (optional)
kind: Secret
type: Opaque

All fields are mandatory.

Related liniks:

@eguzki
Copy link
Member Author

eguzki commented Jun 17, 2021

When the mounted secret is updated externally, the container can automatically see the changes. However, apicast has the policy already loaded and does not change behavior. When redeployed, updating the replica field, the policy update is applied.

@@ -122,6 +122,15 @@ func (a *APIcastOptionsProvider) GetApicastOptions() (*APIcastOptions, error) {
a.APIcastOptions.Workers = a.APIcastCR.Spec.Workers
a.APIcastOptions.Timezone = a.APIcastCR.Spec.Timezone

for _, customPolicySpec := range a.APIcastCR.Spec.CustomPolicies {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering whether we should validate each secret first, when processing the options?
In the case of HTTPsCertificate we check that it exists beforehand(see getHTTPSCertificateSecret method). Maybe check that the specific required fields in the secret are there too?

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes! additional check would be good

Copy link
Member Author

Choose a reason for hiding this comment

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

implemented

@eguzki eguzki force-pushed the injection-custom-policies branch from 251762d to a40caa3 Compare June 18, 2021 12:16
@eguzki eguzki marked this pull request as ready for review June 18, 2021 12:16
Copy link
Contributor

@miguelsorianod miguelsorianod left a comment

Choose a reason for hiding this comment

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

Looks good to me. Great work 👍

@eguzki eguzki merged commit a787307 into master Jun 21, 2021
@eguzki eguzki deleted the injection-custom-policies branch June 21, 2021 11:12
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.

2 participants