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

Don't create secgroup for a bastion host on openstack, if it doesn't exist #4291

Merged
merged 1 commit into from
Apr 9, 2019
Merged

Don't create secgroup for a bastion host on openstack, if it doesn't exist #4291

merged 1 commit into from
Apr 9, 2019

Conversation

trawler
Copy link
Contributor

@trawler trawler commented Feb 21, 2019

even if number_of_bastions var is set to 0, terraform creates a security group and rules for a non-existing bastion host.

This PR sets these resources as conditionals, and uses the join() hack from: hashicorp/terraform#11566 to set a dynamic value to the attached security groups on the instances themselves.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 21, 2019
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 21, 2019
description = "${var.cluster_name} - Bastion Server"
}

resource "openstack_networking_secgroup_rule_v2" "bastion" {
count = "${length(var.bastion_allowed_remote_ips)}"
count = "${var.number_of_bastions ? length(var.bastion_allowed_remote_ips) : 0}"
Copy link
Contributor

Choose a reason for hiding this comment

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

If var.number_of_bastions, isn't length(var.bastion_allowed_remote_ips) already 0 ?

Copy link
Contributor Author

@trawler trawler Feb 25, 2019

Choose a reason for hiding this comment

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

var.bastion_allowed_remote_ips is given a default value in https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/terraform/openstack/variables.tf#L142, so it's length is "1" by default. I can leave the line as is, but then the default in variables file needs to be changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. got it.

contrib/terraform/openstack/modules/compute/main.tf Outdated Show resolved Hide resolved
contrib/terraform/openstack/modules/compute/main.tf Outdated Show resolved Hide resolved
description = "${var.cluster_name} - Bastion Server"
}

resource "openstack_networking_secgroup_rule_v2" "bastion" {
count = "${length(var.bastion_allowed_remote_ips)}"
count = "${var.number_of_bastions ? length(var.bastion_allowed_remote_ips) : 0}"
Copy link
Contributor

Choose a reason for hiding this comment

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

OK. got it.

@Miouge1
Copy link
Contributor

Miouge1 commented Feb 26, 2019

ci check this

@trawler
Copy link
Contributor Author

trawler commented Mar 4, 2019

/assign @riverzhang

@Miouge1
Copy link
Contributor

Miouge1 commented Mar 6, 2019

I have tested this in an OpenStack public cloud. It works as expected.

Thank you for your contribution @trawler

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 6, 2019
@trawler
Copy link
Contributor Author

trawler commented Mar 19, 2019

@Miouge1 Thank you for reviewing and testing. Can you help with getting this PR approved and merged?

@holmsten
Copy link
Contributor

holmsten commented Apr 9, 2019

@trawler sorry for the wait. Can you run terraform fmt and also rebase on latest master? We added some new CI steps for validating terraform recipes.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 9, 2019
@trawler
Copy link
Contributor Author

trawler commented Apr 9, 2019

@holmsten thanks for looking into it. rebased and checked.

@holmsten
Copy link
Contributor

holmsten commented Apr 9, 2019

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

@holmsten: changing LGTM is restricted to assignees, and only kubernetes-sigs/kubespray repo collaborators may be assigned issues.

In response to this:

/lgtm
/approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Miouge1
Copy link
Contributor

Miouge1 commented Apr 9, 2019

@gix while you fix the kubespray-sigs membership, I can give this a try:

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 9, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: holmsten, Miouge1, trawler

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 9, 2019
@k8s-ci-robot k8s-ci-robot merged commit 20ebb49 into kubernetes-sigs:master Apr 9, 2019
LuckySB pushed a commit to southbridgeio/kubespray that referenced this pull request Apr 9, 2019
holmsten added a commit to holmsten/kubespray that referenced this pull request Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants