Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth: feature flag for authentication #26208

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/cmdref/cilium-agent.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Documentation/cmdref/cilium-agent_hive.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Documentation/cmdref/cilium-agent_hive_dot-graph.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Documentation/helm-values.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions install/kubernetes/cilium/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,7 @@ data:
agent-not-ready-taint-key: {{ .Values.agentNotReadyTaintKey | quote }}
{{- end }}

mesh-auth-enabled: {{ .Values.authentication.enabled | quote }}
mesh-auth-queue-size: {{ .Values.authentication.queueSize | quote }}
mesh-auth-rotated-identities-queue-size: {{ .Values.authentication.rotatedIdentitiesQueueSize | quote }}
mesh-auth-expired-gc-interval: {{ include "validateDuration" .Values.authentication.expiredGCInterval | quote }}
Expand Down
6 changes: 6 additions & 0 deletions install/kubernetes/cilium/templates/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
{{- end }}
{{- end }}

{{- if .Values.authentication.mutual.spire.enabled }}
{{- if not .Values.authentication.enabled }}
{{ fail "SPIRE integration requires .Values.authentication.enabled=true and .Values.authentication.mutual.spire.enabled=true" }}
{{- end }}
{{- end }}

{{- if .Values.authentication.mutual.spire.install.enabled }}
{{- if not .Values.authentication.mutual.spire.enabled }}
{{ fail "SPIRE installation requires .Values.auth.mTLS.enabled=true and .Values.auth.mTLS.spire.enabled=true" }}
Expand Down
4 changes: 4 additions & 0 deletions install/kubernetes/cilium/values.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions install/kubernetes/cilium/values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2970,6 +2970,10 @@ sctp:

# Configuration for types of authentication for Cilium
authentication:
# -- Enable authentication processing and garbage collection.
# Note that if disabled, policy enforcement will still block requests that require authentication.
# But the resulting authentication requests for these requests will not be processed, therefore the requests not be allowed.
enabled: true
# -- Buffer size of the channel Cilium uses to receive authentication events from the signal map.
queueSize: 1024
# -- Buffer size of the channel Cilium uses to receive certificate expiration events from auth handlers.
Expand Down
8 changes: 8 additions & 0 deletions pkg/auth/cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ var Cell = cell.Module(
k8s.CiliumIdentityResource,
),
cell.Config(config{
MeshAuthEnabled: true,
MeshAuthQueueSize: 1024,
MeshAuthExpiredGCInterval: 15 * time.Minute,
}),
cell.Config(MutualAuthConfig{}),
)

type config struct {
MeshAuthEnabled bool
MeshAuthQueueSize int
MeshAuthExpiredGCInterval time.Duration
}

func (r config) Flags(flags *pflag.FlagSet) {
flags.Bool("mesh-auth-enabled", r.MeshAuthEnabled, "Enable authentication processing & garbage collection")
flags.Int("mesh-auth-queue-size", r.MeshAuthQueueSize, "Queue size for the auth manager")
flags.Duration("mesh-auth-expired-gc-interval", r.MeshAuthExpiredGCInterval, "Interval in which expired auth entries are attempted to be garbage collected")
}
Expand All @@ -85,6 +88,11 @@ type authManagerParams struct {
}

func newManager(params authManagerParams) error {
if !params.Config.MeshAuthEnabled {
params.Logger.Info("Authentication processing is disabled")
return nil
}

mapWriter := newAuthMapWriter(params.Logger, params.AuthMap)
mapCache := newAuthMapCache(params.Logger, mapWriter)

Expand Down