Skip to content

Commit

Permalink
wip: enable gke autopilot support
Browse files Browse the repository at this point in the history
  • Loading branch information
redhatrises committed Sep 25, 2023
1 parent aa59e91 commit b06a723
Show file tree
Hide file tree
Showing 15 changed files with 467 additions and 83 deletions.
39 changes: 38 additions & 1 deletion api/falcon/v1alpha1/falconnodesensor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,53 @@ type FalconNodeSensorConfig struct {
// +kubebuilder:default=false
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=8
NodeCleanup *bool `json:"disableCleanup,omitempty"`

// Configure resource requests and limits for the DaemonSet Sensor. Only applies when using the eBPF backend.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Falcon eBPF Sensor Resources",order=9
SensorResources Resources `json:"resources,omitempty"`

// Sets the backend to be used by the DaemonSet Sensor.
// +kubebuilder:default=kernel
// +kubebuilder:validation:Enum=kernel;bpf
// +operator-sdk-csv:customresourcedefinitions:type=spec,order=9
// +operator-sdk-csv:customresourcedefinitions:type=spec,order=10
Backend string `json:"backend,omitempty"`

// Enables the use of GKE Autopilot.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="GKE Autopilot Settings",order=11
GKE AutoPilot `json:"gke,omitempty"`

// Enable priority class for the DaemonSet. This is useful for GKE Autopilot clusters, but can be set for any cluster.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Priority Class",order=12
PriorityClassName string `json:"priorityClassName,omitempty"`

// Version of the sensor to be installed. The latest version will be selected when this version specifier is missing.
Version *string `json:"version,omitempty"`
}

type Resources struct {
// Sets the resource limits for the DaemonSet Sensor. Only applies when using the eBPF backend.
// +operator-sdk:csv:customresourcedefinitions:type=spec
Limits ResourceList `json:"limits,omitempty"`
// Sets the resource requests for the DaemonSet Sensor. Only applies when using the eBPF backend.
// +operator-sdk:csv:customresourcedefinitions:type=spec
Requests ResourceList `json:"requests,omitempty"`
}

type ResourceList struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +kubebuilder:validation:Pattern="^([0-9]{4,}m)|[0-9]*$"
CPU string `json:"cpu,omitempty"`
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +kubebuilder:validation:Pattern="^([0-9.]+[iEGTP]+)|[0-9]{10,}$"
Memory string `json:"memory,omitempty"`
}

type AutoPilot struct {
// Enables the use of GKE Autopilot.
// +operator-sdk:csv:customresourcedefinitions:type=spec
Enabled *bool `json:"autopilot,omitempty"`
}

type FalconNodeUpdateStrategy struct {
// +kubebuilder:default=RollingUpdate
// +kubebuilder:validation:Enum=RollingUpdate;OnDelete
Expand Down
54 changes: 54 additions & 0 deletions api/falcon/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,26 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
)

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AutoPilot) DeepCopyInto(out *AutoPilot) {
*out = *in
if in.Enabled != nil {
in, out := &in.Enabled, &out.Enabled
*out = new(bool)
**out = **in
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoPilot.
func (in *AutoPilot) DeepCopy() *AutoPilot {
if in == nil {
return nil
}
out := new(AutoPilot)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FalconAPI) DeepCopyInto(out *FalconAPI) {
*out = *in
Expand Down Expand Up @@ -589,6 +609,8 @@ func (in *FalconNodeSensorConfig) DeepCopyInto(out *FalconNodeSensorConfig) {
*out = new(bool)
**out = **in
}
out.SensorResources = in.SensorResources
in.GKE.DeepCopyInto(&out.GKE)
if in.Version != nil {
in, out := &in.Version, &out.Version
*out = new(string)
Expand Down Expand Up @@ -795,3 +817,35 @@ func (in *RegistryTLSSpec) DeepCopy() *RegistryTLSSpec {
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceList) DeepCopyInto(out *ResourceList) {
*out = *in
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceList.
func (in *ResourceList) DeepCopy() *ResourceList {
if in == nil {
return nil
}
out := new(ResourceList)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Resources) DeepCopyInto(out *Resources) {
*out = *in
out.Limits = in.Limits
out.Requests = in.Requests
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Resources.
func (in *Resources) DeepCopy() *Resources {
if in == nil {
return nil
}
out := new(Resources)
in.DeepCopyInto(out)
return out
}
38 changes: 38 additions & 0 deletions config/crd/bases/falcon.crowdstrike.com_falconnodesensors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ spec:
on the nodes. Disabling might have unintended consequences for
certain operations such as sensor downgrading.
type: boolean
gke:
description: Enables the use of GKE Autopilot.
properties:
autopilot:
description: Enables the use of GKE Autopilot.
type: boolean
type: object
image:
description: Location of the Falcon Sensor image. Use only in
cases when you mirror the original image to your repository/name:tag
Expand Down Expand Up @@ -379,6 +386,37 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: object
priorityClassName:
description: Enable priority class for the DaemonSet. This is
useful for GKE Autopilot clusters, but can be set for any cluster.
type: string
resources:
description: Configure resource requests and limits for the DaemonSet
Sensor. Only applies when using the eBPF backend.
properties:
limits:
description: Sets the resource limits for the DaemonSet Sensor.
Only applies when using the eBPF backend.
properties:
cpu:
pattern: ^([0-9]{4,}m)|[0-9]*$
type: string
memory:
pattern: ^([0-9.]+[iEGTP]+)|[0-9]{10,}$
type: string
type: object
requests:
description: Sets the resource requests for the DaemonSet
Sensor. Only applies when using the eBPF backend.
properties:
cpu:
pattern: ^([0-9]{4,}m)|[0-9]*$
type: string
memory:
pattern: ^([0-9.]+[iEGTP]+)|[0-9]{10,}$
type: string
type: object
type: object
serviceAccount:
description: Add metadata to the DaemonSet Service Account for
IAM roles.
Expand Down
2 changes: 2 additions & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ bases:
- ../crd
- ../rbac
- ../manager
- ../resources

# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- ../webhook
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ kind: Kustomization
images:
- name: controller
newName: quay.io/crowdstrike/falcon-operator
newTag: latest
newTag: autopilot
1 change: 1 addition & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ spec:
args:
- --leader-elect
image: controller:latest
imagePullPolicy: Always
name: manager
env:
- name: WATCH_NAMESPACE
Expand Down
1 change: 1 addition & 0 deletions config/non-olm/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bases:
#- ../prometheus

patchesStrategicMerge:
- patches/manager_config_patch.yaml
- patches/auth_proxy_client_clusterrole.yaml
- patches/auth_proxy_role.yaml
- patches/auth_proxy_role_binding.yaml
Expand Down
20 changes: 20 additions & 0 deletions config/non-olm/patches/manager_config_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- name: manager
args:
- "--config=controller_manager_config.yaml"
volumeMounts:
- name: manager-config
mountPath: /controller_manager_config.yaml
subPath: controller_manager_config.yaml
volumes:
- name: manager-config
configMap:
name: manager-config
5 changes: 5 additions & 0 deletions controllers/falcon_node/falconnodesensor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ func (r *FalconNodeSensorReconciler) Reconcile(ctx context.Context, req ctrl.Req
volumeUpdates := updateDaemonSetVolumes(dsUpdate, dsTarget, logger)
updated = updateDaemonSetContainerProxy(dsUpdate, nodesensor, logger)

if !reflect.DeepEqual(dsUpdate.Spec.Template.Spec.PriorityClassName, dsTarget.Spec.Template.Spec.PriorityClassName) {
dsUpdate.Spec.Template.Spec.PriorityClassName = dsTarget.Spec.Template.Spec.PriorityClassName
updated = true
}

// Update the daemonset and re-spin pods with changes
if imgUpdate || tolsUpdate || affUpdate || containerVolUpdate || volumeUpdates || updated {
err = r.Update(ctx, dsUpdate)
Expand Down
17 changes: 16 additions & 1 deletion deploy/falcon-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,13 @@ spec:
on the nodes. Disabling might have unintended consequences for
certain operations such as sensor downgrading.
type: boolean
gke:
description: Enables the use of GKE Autopilot.
properties:
autopilot:
default: false
type: boolean
type: object
image:
description: Location of the Falcon Sensor image. Use only in
cases when you mirror the original image to your repository/name:tag
Expand Down Expand Up @@ -3124,7 +3131,7 @@ spec:
- linux
containers:
- args:
- --leader-elect
- --config=controller_manager_config.yaml
command:
- /manager
env:
Expand Down Expand Up @@ -3160,8 +3167,16 @@ spec:
drop:
- ALL
privileged: false
volumeMounts:
- mountPath: /controller_manager_config.yaml
name: manager-config
subPath: controller_manager_config.yaml
securityContext:
fsGroup: 65534
runAsNonRoot: true
serviceAccountName: falcon-operator-controller-manager
terminationGracePeriodSeconds: 10
volumes:
- configMap:
name: falcon-operator-manager-config
name: manager-config
Loading

0 comments on commit b06a723

Please sign in to comment.