Skip to content

Commit 7a9b9d1

Browse files
authored
Merge pull request #998 from stackhpc/secgroups-allow-all
✨ Implement allowAllInClusterTraffic flag
2 parents e825d84 + 614ad18 commit 7a9b9d1

File tree

6 files changed

+277
-167
lines changed

6 files changed

+277
-167
lines changed

api/v1alpha4/openstackcluster_types.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,21 @@ type OpenStackClusterSpec struct {
7575
// APIServerLoadBalancerAdditionalPorts adds additional ports to the APIServerLoadBalancer
7676
APIServerLoadBalancerAdditionalPorts []int `json:"apiServerLoadBalancerAdditionalPorts,omitempty"`
7777

78-
// ManagedSecurityGroups defines that kubernetes manages the OpenStack security groups
79-
// for now, that means that we'll create security group allows traffic to/from
80-
// machines belonging to that group based on Calico CNI plugin default network
81-
// requirements: BGP and IP-in-IP for master node(s) and worker node(s) respectively.
82-
// In the future, we could make this more flexible.
78+
// ManagedSecurityGroups determines whether OpenStack security groups for the cluster
79+
// will be managed by the OpenStack provider or whether pre-existing security groups will
80+
// be specified as part of the configuration.
81+
// By default, the managed security groups have rules that allow the Kubelet, etcd, the
82+
// Kubernetes API server and the Calico CNI plugin to function correctly.
8383
// +optional
8484
ManagedSecurityGroups bool `json:"managedSecurityGroups"`
8585

86+
// AllowAllInClusterTraffic is only used when managed security groups are in use.
87+
// If set to true, the rules for the managed security groups are configured so that all
88+
// ingress and egress between cluster nodes is permitted, allowing CNIs other than
89+
// Calico to be used.
90+
// +optional
91+
AllowAllInClusterTraffic bool `json:"allowAllInClusterTraffic"`
92+
8693
// DisablePortSecurity disables the port security of the network created for the
8794
// Kubernetes cluster, which also disables SecurityGroups
8895
DisablePortSecurity bool `json:"disablePortSecurity,omitempty"`

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,12 @@ spec:
10721072
spec:
10731073
description: OpenStackClusterSpec defines the desired state of OpenStackCluster.
10741074
properties:
1075+
allowAllInClusterTraffic:
1076+
description: AllowAllInClusterTraffic is only used when managed security
1077+
groups are in use. If set to true, the rules for the managed security
1078+
groups are configured so that all ingress and egress between cluster
1079+
nodes is permitted, allowing CNIs other than Calico to be used.
1080+
type: boolean
10751081
apiServerFloatingIP:
10761082
description: APIServerFloatingIP is the floatingIP which will be associated
10771083
to the APIServer. The floatingIP will be created if it not already
@@ -1553,12 +1559,12 @@ spec:
15531559
properties are mandatory: APIServerFloatingIP, APIServerPort'
15541560
type: boolean
15551561
managedSecurityGroups:
1556-
description: 'ManagedSecurityGroups defines that kubernetes manages
1557-
the OpenStack security groups for now, that means that we''ll create
1558-
security group allows traffic to/from machines belonging to that
1559-
group based on Calico CNI plugin default network requirements: BGP
1560-
and IP-in-IP for master node(s) and worker node(s) respectively.
1561-
In the future, we could make this more flexible.'
1562+
description: ManagedSecurityGroups determines whether OpenStack security
1563+
groups for the cluster will be managed by the OpenStack provider
1564+
or whether pre-existing security groups will be specified as part
1565+
of the configuration. By default, the managed security groups have
1566+
rules that allow the Kubelet, etcd, the Kubernetes API server and
1567+
the Calico CNI plugin to function correctly.
15621568
type: boolean
15631569
network:
15641570
description: If NodeCIDR cannot be set this can be used to detect

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ spec:
5050
description: OpenStackClusterSpec defines the desired state of
5151
OpenStackCluster.
5252
properties:
53+
allowAllInClusterTraffic:
54+
description: AllowAllInClusterTraffic is only used when managed
55+
security groups are in use. If set to true, the rules for
56+
the managed security groups are configured so that all ingress
57+
and egress between cluster nodes is permitted, allowing
58+
CNIs other than Calico to be used.
59+
type: boolean
5360
apiServerFloatingIP:
5461
description: APIServerFloatingIP is the floatingIP which will
5562
be associated to the APIServer. The floatingIP will be created
@@ -544,13 +551,13 @@ spec:
544551
APIServerPort'
545552
type: boolean
546553
managedSecurityGroups:
547-
description: 'ManagedSecurityGroups defines that kubernetes
548-
manages the OpenStack security groups for now, that means
549-
that we''ll create security group allows traffic to/from
550-
machines belonging to that group based on Calico CNI plugin
551-
default network requirements: BGP and IP-in-IP for master
552-
node(s) and worker node(s) respectively. In the future,
553-
we could make this more flexible.'
554+
description: ManagedSecurityGroups determines whether OpenStack
555+
security groups for the cluster will be managed by the OpenStack
556+
provider or whether pre-existing security groups will be
557+
specified as part of the configuration. By default, the
558+
managed security groups have rules that allow the Kubelet,
559+
etcd, the Kubernetes API server and the Calico CNI plugin
560+
to function correctly.
554561
type: boolean
555562
network:
556563
description: If NodeCIDR cannot be set this can be used to

docs/book/src/clusteropenstack/configuration.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
44

55
- [Required configuration](#required-configuration)
6-
- [OpenStack Version](#openstack-version)
6+
- [OpenStack version](#openstack-version)
77
- [Operating system image](#operating-system-image)
88
- [SSH key pair](#ssh-key-pair)
99
- [OpenStack credential](#openstack-credential)
@@ -19,6 +19,7 @@
1919
- [Multiple Networks](#multiple-networks)
2020
- [Subnet Filters](#subnet-filters)
2121
- [Ports](#ports)
22+
- [Security groups](#security-groups)
2223
- [Tagging](#tagging)
2324
- [Metadata](#metadata)
2425
- [Boot From Volume](#boot-from-volume)
@@ -77,19 +78,9 @@ openstack keypair create [--public-key <file> | --private-key <file>] <name>
7778

7879
The key pair name must be exposed as an environment variable `OPENSTACK_SSH_KEY_NAME`.
7980

80-
If you want to login to each machine by ssh, you can [access nodes through the bastion host via SSH](#accessing-nodes-through-the-bastion-host-via-ssh). Otherwise you have to configure security groups. If `spec.managedSecurityGroups` of `OpenStackCluster` set to true, two security groups will be created and added to the instances. One is `k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-controlplane`, another is `k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-worker`. These security group rules include the kubeadm's [Check required ports](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#check-required-ports) so that each node can not be logged in through ssh by default. Please add pre-existing security group allowing ssh port to OpenStackMachineTemplate spec. Here is an example:
81-
82-
```yaml
83-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4
84-
kind: OpenStackMachineTemplate
85-
metadata:
86-
name: ${CLUSTER_NAME}-control-plane
87-
spec:
88-
template:
89-
spec:
90-
securityGroups:
91-
- name: allow-ssh
92-
```
81+
In order to access cluster nodes via SSH, you must either
82+
[access nodes through the bastion host](#accessing-nodes-through-the-bastion-host-via-ssh)
83+
or [configure custom security groups](#security-groups) with rules allowing ingress for port 22.
9384

9485
## OpenStack credential
9586

@@ -255,6 +246,47 @@ spec:
255246
...
256247
```
257248

249+
## Security groups
250+
251+
Security groups are used to determine which ports of the cluster nodes are accessible from where.
252+
253+
If `spec.managedSecurityGroups` of `OpenStackCluster` is set to `true`, two security groups named
254+
`k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-controlplane` and
255+
`k8s-cluster-${NAMESPACE}-${CLUSTER_NAME}-secgroup-worker` will be created and added to the control
256+
plane and worker nodes respectively.
257+
258+
By default, these groups have rules that allow the following traffic:
259+
260+
* Control plane nodes
261+
* API server traffic from anywhere
262+
* Etcd traffic from other control plane nodes
263+
* Kubelet traffic from other cluster nodes
264+
* Calico CNI traffic from other cluster nodes
265+
* Worker nodes
266+
* Node port traffic from anywhere
267+
* Kubelet traffic from other cluster nodes
268+
* Calico CNI traffic from other cluster nodes
269+
270+
To use a CNI other than Calico, the flag `OpenStackCluster.spec.allowAllInClusterTraffic` can be
271+
set to `true`. With this flag set, the rules for the managed security groups permit all traffic
272+
between cluster nodes on all ports and protocols (API server and node port traffic is still
273+
permitted from anywhere, as with the default rules).
274+
275+
If this is not flexible enough, pre-existing security groups can be added to the
276+
spec of an `OpenStackMachineTemplate`, e.g.:
277+
278+
```yaml
279+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4
280+
kind: OpenStackMachineTemplate
281+
metadata:
282+
name: ${CLUSTER_NAME}-control-plane
283+
spec:
284+
template:
285+
spec:
286+
securityGroups:
287+
- name: allow-ssh
288+
```
289+
258290
## Tagging
259291

260292
You have the ability to tag all resources created by the cluster in the `cluster.yaml` file. Here is an example how to configure tagging:

0 commit comments

Comments
 (0)