Skip to content

Commit

Permalink
Add security groups automatically
Browse files Browse the repository at this point in the history
Currently generate security groups are not added to the instances.
This commit makes it automatically.
  • Loading branch information
hidekazuna committed Jun 17, 2020
1 parent e5037a9 commit 86c632a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 8 additions & 0 deletions pkg/cloud/services/compute/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ func (s *Service) InstanceCreate(clusterName string, machine *clusterv1.Machine,
if err != nil {
return nil, err
}
if openStackCluster.Spec.ManagedSecurityGroups {
if util.IsControlPlaneMachine(machine) {
securityGroups = append(securityGroups, openStackCluster.Status.ControlPlaneSecurityGroup.ID)
} else {
securityGroups = append(securityGroups, openStackCluster.Status.WorkerSecurityGroup.ID)
}
}

// Get all network UUIDs
var nets []ServerNetwork
if len(openStackMachine.Spec.Networks) > 0 {
Expand Down
4 changes: 0 additions & 4 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ spec:
cloudsSecret:
name: ${CLUSTER_NAME}-cloud-config
namespace: ${NAMESPACE}
securityGroups:
- name: k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-controlplane
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: MachineDeployment
Expand Down Expand Up @@ -161,8 +159,6 @@ spec:
namespace: ${NAMESPACE}
flavor: ${OPENSTACK_NODE_MACHINE_FLAVOR}
image: ${OPENSTACK_IMAGE_NAME}
securityGroups:
- name: k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-worker
---
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
kind: KubeadmConfigTemplate
Expand Down

0 comments on commit 86c632a

Please sign in to comment.