-
-
Notifications
You must be signed in to change notification settings - Fork 55
Initial access config support #115
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Did you have a chance to test this out in your cluster to make sure it works? Had a couple questions/comments.
| return ids, nil | ||
| } | ||
|
|
||
| func (c *CloudflareAPI) CreateAccessConfig(name string, config networkingv1alpha1.AccessConfig) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove the dependency of networkingv1alpha1 from this file by calling this function with the newApp already created and accepting an AccessApp instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that I need to call CF api, to have it translated into AccessApp - basically to translate Access Group Names into ids.
That means I would need to include CloudflareAPI from cloudflare_api.go into tunnelbinding_types.go
Or I could move (c *AccessConfig) NewAccessApplication() into controllers package as a function.
I did this, since I originally wanted to have it as a method of AccessConfig. That way it is near the definition of the CRD and it makes a bit easier to map the fields.
Which way you would prefer more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to include/import the CloudflareAPI in the tunnelbinding_types.go, or write a simple translation layer if we do not need all the fields. The cloudflare_api.go should not include any k8s CRDs to prevent circular deps.
| c.Log.Error(err, "failed retrieving existing access policies for application", "applicationId", applicationId) | ||
| } | ||
|
|
||
| if len(existingPolicies) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if condition is not necessary.
| } | ||
|
|
||
| // Check if the policy is still required | ||
| required := false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems convoluted. Let me phrase what I understand this function should be doing and you can correct me.
Given the set of existing access policies on the application, and the set of access policies defined in the CRD, you are trying to reconcile them. But there are a couple of problems. Does having the same name of the policy guarantee that the policy wasn't changed? Do we also create access groups here or just refer to them by name?
If possible, I'd like to see this split up into smaller functions and sync all the rules regardless of what was present, unless there was a way you could verify what is set online matches the local config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was a bit tricky.
What I am doing here is checking by name if there are any policies in the application, which are not defined in crd.
If yes, we delete them.
Later on we loop trough policies defined in crd and update them.
Cases I tested:
- Policy by same name is changed manually, it should be updated to be matching crd configuration - works
- Policy manually added to the ui, should be deleted - works
- Policy should be deleted once gone from crd - works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Policy manually added to the ui, should be deleted - works
This is approaching the terraform provider territory. All the operator needs to do is create what was defined in config, and clean it up when removed. If config is updated, create/update all of the configured ones. Looking for others might not be in the scope of this operator.
Yes, seem to work fine.
|
|
@adyanth can we resolve some of the comments? |
|
Thanks for taking the time of implementing this! I tried testing this on my cluster but I couldn't get it to create access applications, is anything else missing? I don't see any errors in the log. I also added access permission for applications to the token |
Have you installed the updated CRDs inside your cluster? Could you provide operator log? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase to latest main as well. Any further logic changes can be done iteratively once this is merged!
| type AccessConfig struct { | ||
| // Enable handling of access configuration | ||
| //+kubebuilder:validation:Optional | ||
| //+kubebuilder:default:=false | ||
| Enabled bool `json:"enabled"` | ||
| // Application type self_hosted,saas | ||
| //+kubebuilder:validation:Optional | ||
| //+kubebuilder:validation:Enum:="";"self_hosted";"saas" | ||
| //+kubebuilder:default:="self_hosted" | ||
| Type string `json:"type"` | ||
| // List of access policies | ||
| //+kubebuilder:validation:Optional | ||
| AccessPolicies []AccessPolicy `json:"accessPolicies"` | ||
| // Application settings | ||
| //+kubebuilder:validation:Optional | ||
| Settings AccessConfigSettings `json:"settings"` | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is being used as part of the tunnelBinding, can we use only the configs that makes sense?
For example, the type would always need to be self_hosted, saas would never work. Do we need the enabled flag? If the config isn't specified, it is disabled.
| type AccessConfigAdditional struct { | ||
| // Cloudflare will render an SSH terminal or VNC session for this application in a web browser. [ssh,vnc] | ||
| //+kubebuilder:validation:Optional | ||
| //+kubebuilder:validation:Enum:="";"vnc";"ssh" | ||
| BrowserRendering string `json:"browserRendering"` | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might need to be validated against the tunnelBinding subject's protocol, or rather use that to determine instead of being a config.
|
Will come back to it soon |
Initial AccessConfig version.
To do:
TunnelBindingCurrently tested with the following CRD:
#67