Skip to content

Commit 2e7ed44

Browse files
authored
Merge pull request #563 from hidekazuna/secgroup_auto
Add generated security groups automatically
2 parents 576be6a + 86c632a commit 2e7ed44

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pkg/cloud/services/compute/instance.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ func (s *Service) InstanceCreate(clusterName string, machine *clusterv1.Machine,
9898
if err != nil {
9999
return nil, err
100100
}
101+
if openStackCluster.Spec.ManagedSecurityGroups {
102+
if util.IsControlPlaneMachine(machine) {
103+
securityGroups = append(securityGroups, openStackCluster.Status.ControlPlaneSecurityGroup.ID)
104+
} else {
105+
securityGroups = append(securityGroups, openStackCluster.Status.WorkerSecurityGroup.ID)
106+
}
107+
}
108+
101109
// Get all network UUIDs
102110
var nets []ServerNetwork
103111
if len(openStackMachine.Spec.Networks) > 0 {

templates/cluster-template.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ spec:
119119
cloudsSecret:
120120
name: ${CLUSTER_NAME}-cloud-config
121121
namespace: ${NAMESPACE}
122-
securityGroups:
123-
- name: k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-controlplane
124122
---
125123
apiVersion: cluster.x-k8s.io/v1alpha3
126124
kind: MachineDeployment
@@ -159,8 +157,6 @@ spec:
159157
namespace: ${NAMESPACE}
160158
flavor: ${OPENSTACK_NODE_MACHINE_FLAVOR}
161159
image: ${OPENSTACK_IMAGE_NAME}
162-
securityGroups:
163-
- name: k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-worker
164160
---
165161
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
166162
kind: KubeadmConfigTemplate

0 commit comments

Comments
 (0)