-
Notifications
You must be signed in to change notification settings - Fork 240
add support for stateless rules #1044
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
Open
robo-cap
wants to merge
3
commits into
oracle-terraform-modules:main
Choose a base branch
from
robo-cap:stateless-rules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,9 @@ locals { | |
| ]) | ||
| # Return provided NSG when configured with an existing ID or created resource ID | ||
| control_plane_nsg_id = one(compact([try(var.nsgs.cp.id, null), one(oci_core_network_security_group.cp[*].id)])) | ||
| control_plane_rules = local.control_plane_nsg_enabled ? merge( | ||
| control_plane_rules = local.control_plane_nsg_enabled ? ( var.use_stateless_rules ? local.control_plane_stateless_rules: local.control_plane_stateful_rules ) : {} | ||
|
|
||
| control_plane_stateful_rules= merge( | ||
| { | ||
| "Allow TCP egress from OKE control plane to OCI services" : { | ||
| protocol = local.tcp_protocol, port = local.all_ports, destination = local.osn, destination_type = local.rule_type_service, | ||
|
|
@@ -83,7 +85,83 @@ locals { | |
| } | ||
| }, | ||
| var.allow_rules_cp | ||
| ) : {} | ||
| ) | ||
|
|
||
| control_plane_stateless_rules= merge( | ||
| { | ||
| "Allow TCP egress from OKE control plane to OCI services" : { | ||
| protocol = local.all_protocols, port = local.all_ports, destination = local.osn, destination_type = local.rule_type_service, stateless = true | ||
| }, | ||
| "Allow TCP ingress to OKE control plane from OCI services" : { | ||
| protocol = local.all_protocols, port = local.all_ports, source = local.osn, source_type = local.rule_type_service, stateless = true | ||
| }, | ||
|
|
||
| "Allow TCP ingress to OKE control plane from worker nodes" : { | ||
| protocol = local.tcp_protocol, port = local.all_ports, source = local.worker_nsg_id, source_type = local.rule_type_nsg, stateless = true | ||
| }, | ||
| "Allow TCP egress from OKE control plane to Kubelet on worker nodes" : { | ||
| protocol = local.tcp_protocol, port = local.all_ports, destination = local.worker_nsg_id, destination_type = local.rule_type_nsg, stateless = true | ||
| }, | ||
|
|
||
| "Allow TCP ingress for Kubernetes control plane inter-communication" : { | ||
| protocol = local.tcp_protocol, destination_port_min = local.apiserver_port, destination_port_max = local.apiserver_port, source = local.control_plane_nsg_id, source_type = local.rule_type_nsg, stateless = true | ||
| }, | ||
| "Allow TCP egress for Kubernetes control plane inter-communication" : { | ||
| protocol = local.tcp_protocol, source_port_min = local.apiserver_port, source_port_max = local.apiserver_port, destination = local.control_plane_nsg_id, destination_type = local.rule_type_nsg, stateless = true | ||
| }, | ||
|
|
||
| "Allow ICMP egress for path discovery to worker nodes" : { | ||
| protocol = local.icmp_protocol, destination = local.worker_nsg_id, destination_type = local.rule_type_nsg, | ||
| }, | ||
| "Allow ICMP ingress for path discovery from worker nodes" : { | ||
| protocol = local.icmp_protocol, source = local.worker_nsg_id, source_type = local.rule_type_nsg, | ||
| }, | ||
| }, | ||
| var.enable_ipv6 ? { | ||
| "Allow ICMPv6 egress for path discovery to worker nodes" : { | ||
| protocol = local.icmpv6_protocol, destination = local.worker_nsg_id, destination_type = local.rule_type_nsg, | ||
| }, | ||
| "Allow ICMPv6 ingress for path discovery from worker nodes" : { | ||
| protocol = local.icmpv6_protocol, source = local.worker_nsg_id, source_type = local.rule_type_nsg, | ||
| }, | ||
| } : {}, | ||
| local.operator_nsg_enabled ? { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above, operator is for troubleshooting. do we really need this rule to be stateless? maybe for the bastion and operator, just create them separately? |
||
| "Allow TCP ingress to kube-apiserver from operator instance" : { | ||
| protocol = local.tcp_protocol, destination_port_min = local.apiserver_port, destination_port_max = local.apiserver_port, source = local.operator_nsg_id, source_type = local.rule_type_nsg, stateless = true | ||
| }, | ||
| "Allow TCP egress from kube-apiserver to operator instance" : { | ||
| protocol = local.tcp_protocol, source_port_min = local.apiserver_port, source_port_max = local.apiserver_port, source = local.operator_nsg_id, source_type = local.rule_type_nsg, stateless = true | ||
| }, | ||
| } : {}, | ||
| local.pod_nsg_enabled ? { | ||
| "Allow TCP ingress to OKE control plane from pods" : { | ||
| protocol = local.tcp_protocol, port = local.all_ports, source = local.pod_nsg_id, source_type = local.rule_type_nsg, stateless = true | ||
| } | ||
| "Allow TCP egress from OKE control plane to pods" : { | ||
| protocol = local.tcp_protocol, port = local.all_ports, destination = local.pod_nsg_id, destination_type = local.rule_type_nsg, stateless = true | ||
| } | ||
| } : {}, | ||
| (var.allow_bastion_cluster_access && local.bastion_nsg_enabled) ? { | ||
| "Allow TCP ingress to kube-apiserver from bastion host" = { | ||
| protocol = local.tcp_protocol, destination_port_min = local.apiserver_port, destination_port_max = local.apiserver_port, source = local.bastion_nsg_id, source_type = local.rule_type_nsg, stateless = true | ||
| }, | ||
| "Allow TCP egress from kube-apiserver to bastion host" = { | ||
| protocol = local.tcp_protocol, source_port_min = local.apiserver_port, source_port_max = local.apiserver_port, destination = local.bastion_nsg_id, destination_type = local.rule_type_nsg, stateless = true | ||
| }, | ||
| } : {}, | ||
|
|
||
| { for allowed_cidr in var.control_plane_allowed_cidrs : | ||
| "Allow TCP ingress to kube-apiserver from ${allowed_cidr}" => { | ||
| protocol = local.tcp_protocol, destination_port_min = local.apiserver_port, destination_port_max = local.apiserver_port, source = allowed_cidr, source_type = local.rule_type_cidr, stateless = true | ||
| } | ||
| }, | ||
| { for allowed_cidr in var.control_plane_allowed_cidrs : | ||
| "Allow TCP egress from kube-apiserver to ${allowed_cidr}" => { | ||
| protocol = local.tcp_protocol, source_port_min = local.apiserver_port, source_port_max = local.apiserver_port, destination = allowed_cidr, destination_type = local.rule_type_cidr, stateless = true | ||
| } | ||
| }, | ||
| var.allow_rules_cp | ||
| ) | ||
| } | ||
|
|
||
| resource "oci_core_network_security_group" "cp" { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Bastion and operator are used for admin/troubleshooting purposes. I don't see the need to make their rules stateless.