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

Introducing sidecarInjection to ApplicationLayer resource #3460

Merged
merged 12 commits into from
Sep 12, 2024

Conversation

radixo
Copy link
Contributor

@radixo radixo commented Aug 14, 2024

Description

Those changes are introduced to make the operator capable to install and control the new Sidecar for L7 features.

Changes:

  • Create the SidecarInjection property into the ApplicationLayer resource, which will make the operator to understand when to install or remove the sidecar injection dependencies.
  • Install the MutatingWebhookConfiguration into the cluster for sidecar injection when the property is "Enabled"
  • Install the L7AdmissionControler web server inside ApiServer pods, as a new container, to control the creation of new pods that has the label "applicationlayer.projectcalico.org/sidecar" = "true", when the sidecar injection property is "Enabled" as well.

Design doc of the new feature as follows:
https://docs.google.com/document/d/1C5VKry_HLTLZq6VmpwaznpSjwYm4aYqeEpeN54S2fas/edit?usp=sharing

P.S. The introduced feature doesn't break any of the current L7 Application Layer features (WAF, Logging and ALP).

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@radixo radixo requested a review from a team as a code owner August 14, 2024 13:12
@marvin-tigera marvin-tigera added this to the v1.36.0 milestone Aug 14, 2024
@radixo radixo force-pushed the sidecar-injection branch 8 times, most recently from dd29447 to d00989a Compare August 19, 2024 16:11
@radixo radixo changed the title [WIP] Introducing sidecarInjection to ApplicationLayer resource Introducing sidecarInjection to ApplicationLayer resource Sep 3, 2024
@radixo radixo force-pushed the sidecar-injection branch 10 times, most recently from 5dbc3d7 to b6f5a90 Compare September 4, 2024 16:43
Copy link
Member

@caseydavenport caseydavenport left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First quick pass - mostly nits, but a couple of API level questions that will help me evaluate some of the other bits of code.

pkg/render/apiserver.go Outdated Show resolved Hide resolved
pkg/render/applicationlayer/applicationlayer.go Outdated Show resolved Hide resolved
pkg/render/applicationlayer/applicationlayer.go Outdated Show resolved Hide resolved
pkg/render/applicationlayer/applicationlayer.go Outdated Show resolved Hide resolved
pkg/render/applicationlayer/applicationlayer.go Outdated Show resolved Hide resolved
pkg/render/apiserver.go Outdated Show resolved Hide resolved
pkg/render/apiserver.go Outdated Show resolved Hide resolved
pkg/render/apiserver.go Outdated Show resolved Hide resolved
api/v1/applicationlayer_types.go Show resolved Hide resolved
radixo and others added 2 commits September 10, 2024 13:37
Co-authored-by: Casey Davenport <caseydavenport@users.noreply.github.com>
Copy link
Member

@caseydavenport caseydavenport left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, second round done. Will keep looking through this.

Overall I don't see any major bugs in the code, but I want to take a few more looks as I continue to get a better feel for the feature set and desired behaviors.

@@ -65,6 +67,11 @@ const (
tigeraAPIServerTLSSecretName = "tigera-apiserver-certs"
APIServerSecretsRBACName = "tigera-extension-apiserver-secrets-access"
MultiTenantManagedClustersAccessClusterRoleName = "tigera-managed-cluster-access"
L7AdmissionControllerContainerName = "calico-l7admssctrl"
L7AdmissionControllerEnvoyImage = "envoyproxy/envoy:v1.31-latest"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to hook this image up through the "components" tooling like we do for our other images, rather than hard coding it here. i.e., it should be configurable via enterprise_versions.yml

Additionally, I suspect that using latest tagged images isn't going to fly here, as it means the version that is installed can vary over time.

@Behnam-Shobiri could you chime in on whether we need to have build ownership / registry ownership of this image from an enterprise CVE perspective?

I think we probably need to host a specific version of this in our own registry, though.

pkg/render/apiserver.go Show resolved Hide resolved
collectorImage string
dikastesImage string
dikastesEnabled bool
envoyEnabled bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume envoyEnabled means perHostEnvoyEnabled?

I think we should refactor these names to be explicit about whether they are referring to per-host, sidecar, or "any" version of the component for clarity.

api/v1/applicationlayer_types.go Outdated Show resolved Hide resolved
api/v1/applicationlayer_types.go Show resolved Hide resolved
pkg/render/apiserver.go Show resolved Hide resolved
commandArgs = append(
commandArgs,
"--waf-enabled",
"--waf-log-file", filepath.Join(CalicologsVolumePath, "waf", "waf.log"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should --waf-log-file go under the if c.config.WAFEnabled section below? What aobut --waf-ruleset-file?

At face value these both seem like arguments that are only relevant when WAF is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --waf-enabled is telling dikastes that the per-host enforcement is enabled for WAF, needed for internal decisions on requests that can come even from sidecars or TPROXY iptables rules. So the --waf-log-file and --waf-ruleset-file are the configs that are required by both.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect.

Honestly, the renaming of WAFEnabled -> PerHostWAFEnabled makes this SO much easier to read for me now - this makes sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --waf-enabled is telling dikastes that the per-host enforcement is enabled for WA

It is probably a good idea to rename this argument on Dikastes (or add a new one and deprecate this one)....

--per-host-waf-enabled

^ Would be more accurate.

Copy link
Member

@caseydavenport caseydavenport left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor comments this time - otherwise this LGTM.

Thanks much @radixo !

@@ -78,7 +78,7 @@ func init() {
type APIServerDeploymentContainer struct {
// Name is an enum which identifies the API server Deployment container by name.
// Supported values are: calico-apiserver, tigera-queryserver
// +kubebuilder:validation:Enum=calico-apiserver;tigera-queryserver
// +kubebuilder:validation:Enum=calico-apiserver;tigera-queryserver;calico-l7admssctrl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this name shows up on a user-facing API, can we change the container name to avoid abbreviations?

calico-l7-admission-controller

commandArgs = append(
commandArgs,
"--waf-enabled",
"--waf-log-file", filepath.Join(CalicologsVolumePath, "waf", "waf.log"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect.

Honestly, the renaming of WAFEnabled -> PerHostWAFEnabled makes this SO much easier to read for me now - this makes sense.

commandArgs = append(
commandArgs,
"--waf-enabled",
"--waf-log-file", filepath.Join(CalicologsVolumePath, "waf", "waf.log"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --waf-enabled is telling dikastes that the per-host enforcement is enabled for WA

It is probably a good idea to rename this argument on Dikastes (or add a new one and deprecate this one)....

--per-host-waf-enabled

^ Would be more accurate.

@radixo
Copy link
Contributor Author

radixo commented Sep 12, 2024

Thanks a million @caseydavenport

@caseydavenport caseydavenport merged commit bb1e6d8 into tigera:master Sep 12, 2024
5 checks passed
@radixo radixo deleted the sidecar-injection branch September 12, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants