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

msd api to return kubernetes network policy object #2396

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

abvaidya
Copy link
Collaborator

@abvaidya abvaidya commented Nov 7, 2023

Description

Contribution Checklist:

  • The pull request does not introduce any breaking changes
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Attach Screenshots (Optional)

@abvaidya abvaidya marked this pull request as draft November 7, 2023 04:25
@abvaidya abvaidya marked this pull request as ready for review November 7, 2023 05:57
include "KubernetesNetworkPolicy.tdl";

// API endpoint to get the Kubernetes network policy converted from the corresponding MSD policy
resource KubernetesNetworkPolicyResponse GET "/domain/{domainName}/service/{serviceName}/kubernetesnetworkpolicy" {
Copy link
Contributor

@rajeshal rajeshal Nov 7, 2023

Choose a reason for hiding this comment

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

It may not be feasible to call one service per request, for an environment with hundreds/thousands of services.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to have an option to make batch call, another endpoint is also fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah that could be another endpoint.

resource KubernetesNetworkPolicyResponse GET "/domain/{domainName}/service/{serviceName}/kubernetesnetworkpolicy" {
DomainName domainName; //Name of the domain
EntityName serviceName; //Name of the service
KubernetesNetworkPolicyRequest request; //Struct representing input options based on the cluster context
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this be passed for a get call ? am i missing something ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! It wont, I will update it to be POST.

String requestedApiVersion (optional); //Requested network policy apiVersion
String networkPolicyNamespace (optional); //Kubernetes namespace for the network policy target
KubernetesLabelSelector podSelector (optional); //Kubernetes pod selector for the network policy target
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think one option is missing - whether to use a combination of namespace selector and label selector to form the k8s policies OR use only the label selector.

Copy link
Collaborator Author

@abvaidya abvaidya Nov 7, 2023

Choose a reason for hiding this comment

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

I debated about that in my mind too, and added athenzDomainLabel key for that. But probably a good idea for a flag to indicate whether the athenzDomainLabel should be a namespace selector.

Copy link
Contributor

Choose a reason for hiding this comment

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

upon further review, noticed this definition uses namespace selector as well, so let me rephrase the previous question - how can user choose between combination of namespace selector and label selector and only the label selector, using athenzServiceLabel ?

}

// Kubernetes network policy port range
type KubernetesNetworkPolicyPort PolicyPort {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we reuse TransportPolicyPort here, like TransportPolicyProtocol ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would prefer to keep the objects separate for api calls even though they have similar members for now. RDL doesnt like to share Enums unlike Struct so couldn't create KubernetesNetworkPolicyProtocol

@@ -7,7 +7,7 @@

//
// NetworkPolicyChangeEffect - IMPACT indicates that a change in network policy
// will interfere with workings of one or more transport policies NO_IMAPCT
Copy link
Contributor

@rajeshal rajeshal Nov 7, 2023

Choose a reason for hiding this comment

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

😄 , took some time for me to realize what is changed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

😂 without spell check, I dont think I would have noticed it.

Copy link
Contributor

@rajeshal rajeshal left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@havetisyan havetisyan merged commit d51d336 into master Nov 7, 2023
@havetisyan havetisyan deleted the msd-k8s-policy-api branch November 7, 2023 17:01
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.

3 participants