Skip to content

Commit 86c632a

Browse files
committed
Add security groups automatically
Currently generate security groups are not added to the instances. This commit makes it automatically.
1 parent e5037a9 commit 86c632a

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
@@ -121,8 +121,6 @@ spec:
121121
cloudsSecret:
122122
name: ${CLUSTER_NAME}-cloud-config
123123
namespace: ${NAMESPACE}
124-
securityGroups:
125-
- name: k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-controlplane
126124
---
127125
apiVersion: cluster.x-k8s.io/v1alpha3
128126
kind: MachineDeployment
@@ -161,8 +159,6 @@ spec:
161159
namespace: ${NAMESPACE}
162160
flavor: ${OPENSTACK_NODE_MACHINE_FLAVOR}
163161
image: ${OPENSTACK_IMAGE_NAME}
164-
securityGroups:
165-
- name: k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-worker
166162
---
167163
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
168164
kind: KubeadmConfigTemplate

0 commit comments

Comments
 (0)