Skip to content

Commit

Permalink
Add service account selector support
Browse files Browse the repository at this point in the history
Fixes #2927

This PR added `serviceAccount` field support to ACNP. It uses
Namespace and Name to specify a ServiceAccount and all Pods with this
ServiceAccount will be selected as workloads. It could be used in
egress `to`, ingress `from` and `appliedTo` of both policy and single
rule. To implement this feature, this PR also added a custom label to
all Pods internally, which looks like:
`internal.antrea.io/service-account:[ServiceAccountName]`. And when
process ACNP, `serviceAccount` will be translate to a `GroupSelector`
with `Namespace` and `PodSelector` to select Pods we need.

Signed-off-by: wgrayson <wgrayson@vmware.com>
  • Loading branch information
GraysonWu committed Feb 16, 2022
1 parent 15de4cf commit 42088ae
Show file tree
Hide file tree
Showing 21 changed files with 994 additions and 84 deletions.
50 changes: 50 additions & 0 deletions build/yamls/antrea-aks.yml
Expand Up @@ -468,6 +468,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
egress:
Expand Down Expand Up @@ -533,6 +543,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
enableLogging:
Expand Down Expand Up @@ -616,6 +636,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
toServices:
Expand Down Expand Up @@ -697,6 +727,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
enableLogging:
Expand Down Expand Up @@ -767,6 +807,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
name:
Expand Down
50 changes: 50 additions & 0 deletions build/yamls/antrea-eks.yml
Expand Up @@ -468,6 +468,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
egress:
Expand Down Expand Up @@ -533,6 +543,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
enableLogging:
Expand Down Expand Up @@ -616,6 +636,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
toServices:
Expand Down Expand Up @@ -697,6 +727,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
enableLogging:
Expand Down Expand Up @@ -767,6 +807,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
name:
Expand Down
50 changes: 50 additions & 0 deletions build/yamls/antrea-gke.yml
Expand Up @@ -468,6 +468,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
egress:
Expand Down Expand Up @@ -533,6 +543,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
enableLogging:
Expand Down Expand Up @@ -616,6 +636,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
toServices:
Expand Down Expand Up @@ -697,6 +727,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
enableLogging:
Expand Down Expand Up @@ -767,6 +807,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
name:
Expand Down
50 changes: 50 additions & 0 deletions build/yamls/antrea-ipsec.yml
Expand Up @@ -468,6 +468,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
egress:
Expand Down Expand Up @@ -533,6 +543,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
enableLogging:
Expand Down Expand Up @@ -616,6 +636,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
toServices:
Expand Down Expand Up @@ -697,6 +727,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
enableLogging:
Expand Down Expand Up @@ -767,6 +807,16 @@ spec:
matchLabels:
x-kubernetes-preserve-unknown-fields: true
type: object
serviceAccount:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: object
type: array
name:
Expand Down

0 comments on commit 42088ae

Please sign in to comment.